Commit 922bab91 by zhanglt

盘盈入库生成删掉二维码接口

parent 22ebfc25
......@@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.List;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.utils.io.FileUtil;
import com.jeeplus.modules.warehouse.code.util.CodeUtil;
import com.jeeplus.modules.warehouse.code.util.StaticNumSeq;
import com.jeeplus.modules.warehouse.goods.entity.GoodsInfo;
......@@ -92,7 +93,7 @@ public class ProfitWarehousingService extends CrudService<ProfitWarehousingMappe
qrCode.setState("0");
qrCode.preInsert();
try {
BuildQcUtil.buildQr(qrCode, qrImgPath + "/" + numSeq + ".png", qrImgPath + "/" + numSeq + ".png"); // 生成图片
BuildQcUtil.buildQrOne(qrCode, qrImgPath + "/" + numSeq + ".png", qrImgPath + "/" + numSeq + ".png"); // 生成图片
} catch (IOException e) {
e.printStackTrace();
}
......@@ -103,6 +104,37 @@ public class ProfitWarehousingService extends CrudService<ProfitWarehousingMappe
profitWarehousingInfoMapper.insert(profitWarehousingInfo);
return profitWarehousingInfo;
}
/**
* 清除二维码
* @param infoId
*/
@Transactional(readOnly = false)
public void cleanQr(String infoId) {
ProfitWarehousingInfo profitWarehousingInfo = profitWarehousingInfoMapper.get(infoId);
QrCode qrCode = qrCodeMapper.get(profitWarehousingInfo.getQrCode().getId());
if (StringUtils.isNotBlank(qrCode.getUrl())) {
try {
String url = qrCode.getUrl();
if (null != url && url.contains("image")) {
String photo = url.split("image/")[1];
File file = new File(Global.getAttachmentDir() + "image/" + photo);
if (file.exists()) {
FileUtil.deleteFile(new File(Global.getAttachmentDir() + "image/" + photo));
} else {
logger.info("二维码路径不存在,执行删除");
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
qrCodeMapper.delete(qrCode); // 删除二维码
profitWarehousingInfo.setQrCode(new QrCode());
profitWarehousingInfo.preUpdate();
profitWarehousingInfoMapper.update(profitWarehousingInfo);
}
@Transactional(readOnly = false)
public void save(ProfitWarehousing profitWarehousing) {
super.save(profitWarehousing);
......
......@@ -269,6 +269,29 @@ public class ProfitWarehousingController extends BaseController {
j.setMsg("生成二维码成功");
return j;
}
/**
* 清除二维码
* @param goodsInfoId
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping(value = "cleanQr")
public AjaxJson cleanQr(String profitWarehousingInfoId) throws Exception{
AjaxJson j = new AjaxJson();
//新增或编辑表单保存
ProfitWarehousingInfo profitWarehousingInfo1 = profitWarehousingInfoMapper.get(profitWarehousingInfoId);
if(profitWarehousingInfo1.getQrCode() == null){
j.setSuccess(false);
j.setMsg("二维码不存在");
return j;
}
profitWarehousingService.cleanQr(profitWarehousingInfoId);//保存
j.setSuccess(true);
j.setMsg("清除二维码成功");
return j;
}
/**
* 盘盈入库明细,入台账
*/
......
......@@ -35,4 +35,19 @@ public class BuildQcUtil {
}
FileUtil.deleteFile(file);
}
public static void buildQrOne(QrCode qrCode, String qrImgPath, String imgPath) throws IOException {
Map<String, String> map = new HashMap<>();
map.put("code", qrCode.getId());
TwoDimensionCode.encoderQRCode(JSON.toJSONString(map), qrImgPath, "png", 6);
File file = new File(qrImgPath);
try {
BufferedImage image = DrawQrcodeUtil.createAssetImageNew(file, qrCode);
DrawQrcodeUtil drawQrcodeUtil = new DrawQrcodeUtil();
drawQrcodeUtil.writeImage(image, imgPath);
} catch (IOException e) {
e.printStackTrace();
}
FileUtil.deleteFile(file);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment