|
@@ -1,8 +1,6 @@
|
|
package com.abi.qms.platform.service.impl;
|
|
package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
|
-import cn.hutool.core.io.IoUtil;
|
|
|
|
import com.abi.base.foundation.util.JsonUtil;
|
|
import com.abi.base.foundation.util.JsonUtil;
|
|
import com.abi.base.foundation.util.RedisClient;
|
|
import com.abi.base.foundation.util.RedisClient;
|
|
import com.abi.qms.platform.constant.RedisKeysConstant;
|
|
import com.abi.qms.platform.constant.RedisKeysConstant;
|
|
@@ -13,15 +11,8 @@ import com.abi.qms.platform.dao.mapper.QrPackageBatchMapper;
|
|
import com.abi.qms.platform.dao.mapper.QrPackageDownloadRecordMapper;
|
|
import com.abi.qms.platform.dao.mapper.QrPackageDownloadRecordMapper;
|
|
import com.abi.qms.platform.dao.mapper.QrPackageMapper;
|
|
import com.abi.qms.platform.dao.mapper.QrPackageMapper;
|
|
import com.abi.qms.platform.dao.vo.result.QrPackageVO;
|
|
import com.abi.qms.platform.dao.vo.result.QrPackageVO;
|
|
-import com.abi.qms.platform.dto.req.DeleteQrPackageReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.DownloadQrPackageReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.GetQrPackageDetailReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.ListQrPackageReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.PassQrPackageReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.RefuseQrPackageReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.SaveQrPackageReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.SendMobileMsgReq;
|
|
|
|
-import com.abi.qms.platform.dto.req.ValidSAPOrderNoAndMaterialReq;
|
|
|
|
|
|
+import com.abi.qms.platform.dto.req.*;
|
|
|
|
+import com.abi.qms.platform.dto.res.CheckQrPackageRepetitiveRes;
|
|
import com.abi.qms.platform.dto.res.GetQrPackageDetailRes;
|
|
import com.abi.qms.platform.dto.res.GetQrPackageDetailRes;
|
|
import com.abi.qms.platform.dto.res.ListQrPackageRes;
|
|
import com.abi.qms.platform.dto.res.ListQrPackageRes;
|
|
import com.abi.qms.platform.dto.res.ValidSAPOrderNoAndMaterialRes;
|
|
import com.abi.qms.platform.dto.res.ValidSAPOrderNoAndMaterialRes;
|
|
@@ -44,18 +35,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
|
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
-import java.io.BufferedInputStream;
|
|
|
|
-import java.io.BufferedOutputStream;
|
|
|
|
-import java.io.File;
|
|
|
|
-import java.io.FileInputStream;
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.net.URLEncoder;
|
|
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -171,7 +152,8 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
req.setPackageBatchBeanList(batchBeanList);
|
|
req.setPackageBatchBeanList(batchBeanList);
|
|
}
|
|
}
|
|
|
|
|
|
- //
|
|
|
|
|
|
+ //3-如果是盖码,那么查询盖码得默认箱码幅面,并放入入参
|
|
|
|
+ //TODO
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -258,8 +240,9 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
* @return QrPackage 如果是修改码包就把码包查出来
|
|
* @return QrPackage 如果是修改码包就把码包查出来
|
|
*/
|
|
*/
|
|
private QrPackage checkRequestWhenSaveQrPackage(SaveQrPackageReq req){
|
|
private QrPackage checkRequestWhenSaveQrPackage(SaveQrPackageReq req){
|
|
- Long qrPackageId = req.getId();
|
|
|
|
QrPackage qrPackage = null;
|
|
QrPackage qrPackage = null;
|
|
|
|
+ Long qrPackageId = req.getId();
|
|
|
|
+ boolean isAdd = (req.getId() == null);
|
|
|
|
|
|
// 修改码包时的条件限制
|
|
// 修改码包时的条件限制
|
|
if (qrPackageId != null) {
|
|
if (qrPackageId != null) {
|
|
@@ -318,6 +301,18 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(!isAdd && wholeUser.getFactoryId()!=null){
|
|
|
|
+ //一级包材厂不允许修改码包
|
|
|
|
+ if(FactoryLevelEnum.ONE.is(factoryCover.getFactoryLevel())){
|
|
|
|
+ throw new BusinessException("一级包材厂不允许修改码包");
|
|
|
|
+ }
|
|
|
|
+ //二级包材厂or无级包材厂,只能改自己得码包
|
|
|
|
+ if(!FactoryLevelEnum.ONE.is(factoryCover.getFactoryLevel())
|
|
|
|
+ && !wholeUser.getFactoryId().equals(qrPackage.getFactoryCoverLevelTwoId())){
|
|
|
|
+ throw new BusinessException("包材厂只允许修改自己的码包");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//校验批次号
|
|
//校验批次号
|
|
if (CollectionUtil.isNotEmpty(req.getPackageBatchBeanList())) {
|
|
if (CollectionUtil.isNotEmpty(req.getPackageBatchBeanList())) {
|
|
//同一个码包内,不同批次的批次号不一样
|
|
//同一个码包内,不同批次的批次号不一样
|
|
@@ -461,31 +456,15 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
}
|
|
}
|
|
|
|
|
|
//开始下载
|
|
//开始下载
|
|
- BufferedInputStream in = null;
|
|
|
|
- BufferedOutputStream out = null;
|
|
|
|
|
|
+ String url = qrPackage.getDownloadPath();
|
|
try {
|
|
try {
|
|
- // TODO 从阿里云OSS读取文件,替换下面的测试代码
|
|
|
|
- // TODO in = new BufferedInputStream(ossObject.getObjectContent());
|
|
|
|
- in = new BufferedInputStream(new FileInputStream(new File("E:\\firefox_download\\202104161027287567357.zip")));
|
|
|
|
- out = new BufferedOutputStream(response.getOutputStream());
|
|
|
|
-
|
|
|
|
- String fileName = qrPackage.getSapOrderNo() + ".zip";
|
|
|
|
- response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8"));
|
|
|
|
-
|
|
|
|
- byte[] b = new byte[1024];
|
|
|
|
- int len = 0;
|
|
|
|
- while (-1 != (len = in.read(b))) {
|
|
|
|
- out.write(b, 0, len);
|
|
|
|
- }
|
|
|
|
- out.flush();
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- log.error("IOException", e);
|
|
|
|
- } finally {
|
|
|
|
- IoUtil.close(in);
|
|
|
|
- IoUtil.close(out);
|
|
|
|
|
|
+ new OssFileDownloadUtil().downloadFile(url, response);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("下载失败", e);
|
|
|
|
+ throw new BusinessException("下载失败");
|
|
}
|
|
}
|
|
|
|
|
|
- // 插入码包下载记录
|
|
|
|
|
|
+ //插入码包下载记录
|
|
Long userId = userUtil.getUser().getId();
|
|
Long userId = userUtil.getUser().getId();
|
|
QrPackageDownloadRecord downloadRecord = new QrPackageDownloadRecord()
|
|
QrPackageDownloadRecord downloadRecord = new QrPackageDownloadRecord()
|
|
.setCreateBy(userId)
|
|
.setCreateBy(userId)
|
|
@@ -494,24 +473,6 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 删除生成的临时文件,并更新码包的下载路径
|
|
|
|
- *
|
|
|
|
- * @param txtFile txt文件
|
|
|
|
- * @param zipFile 压缩文件
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public void delFileAndUpdatePath(File txtFile, File zipFile, Long qrPackageId) {
|
|
|
|
- // TODO 上传zip包到阿里云OSS后,删除本次生成的txt和zip文件
|
|
|
|
- FileUtil.del(txtFile);
|
|
|
|
- FileUtil.del(zipFile);
|
|
|
|
-
|
|
|
|
- // TODO 更新下载路径
|
|
|
|
- String downloadPath = "";
|
|
|
|
- QrPackage update = new QrPackage().setId(qrPackageId).setDownloadPath(downloadPath);
|
|
|
|
- qrPackageMapper.updateById(update);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 码生成失败回滚
|
|
* 码生成失败回滚
|
|
*/
|
|
*/
|
|
@@ -522,17 +483,26 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
qrPackageMapper.updateById(qrPackageUpdate);
|
|
qrPackageMapper.updateById(qrPackageUpdate);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 校验是否存在SAP订单号和物料重复数据
|
|
|
|
+ * @param req
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public ValidSAPOrderNoAndMaterialRes validSAPOrderNoAndMaterial(ValidSAPOrderNoAndMaterialReq req) {
|
|
public ValidSAPOrderNoAndMaterialRes validSAPOrderNoAndMaterial(ValidSAPOrderNoAndMaterialReq req) {
|
|
|
|
+ //查询存在的列表
|
|
QueryWrapper<QrPackage> qrPackageQuery = new QueryWrapper<>();
|
|
QueryWrapper<QrPackage> qrPackageQuery = new QueryWrapper<>();
|
|
qrPackageQuery.eq("material_id", req.getMaterialId());
|
|
qrPackageQuery.eq("material_id", req.getMaterialId());
|
|
qrPackageQuery.eq("sap_order_no", req.getSapOrderNo());
|
|
qrPackageQuery.eq("sap_order_no", req.getSapOrderNo());
|
|
qrPackageQuery.eq("is_delete", 0);
|
|
qrPackageQuery.eq("is_delete", 0);
|
|
List<QrPackage> qrPackages = qrPackageMapper.selectList(qrPackageQuery);
|
|
List<QrPackage> qrPackages = qrPackageMapper.selectList(qrPackageQuery);
|
|
- ValidSAPOrderNoAndMaterialRes validSAPOrderNoAndMaterialRes = new ValidSAPOrderNoAndMaterialRes();
|
|
|
|
- List<ValidSAPOrderNoAndMaterialRes.PackageBean> packageBeans = PojoConverterUtils.copyList(qrPackages, ValidSAPOrderNoAndMaterialRes.PackageBean.class);
|
|
|
|
- validSAPOrderNoAndMaterialRes.setPackageBeanList(packageBeans);
|
|
|
|
- return validSAPOrderNoAndMaterialRes;
|
|
|
|
|
|
+
|
|
|
|
+ //构造出参
|
|
|
|
+ ValidSAPOrderNoAndMaterialRes res = new ValidSAPOrderNoAndMaterialRes();
|
|
|
|
+ List<ValidSAPOrderNoAndMaterialRes.PackageBean> packageBeanList = PojoConverterUtils.copyList(qrPackages, ValidSAPOrderNoAndMaterialRes.PackageBean.class);
|
|
|
|
+ res.setPackageBeanList(packageBeanList);
|
|
|
|
+
|
|
|
|
+ return res;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|