|
@@ -1,22 +1,65 @@
|
|
|
package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import com.abi.base.foundation.util.JsonUtil;
|
|
|
import com.abi.base.foundation.util.RedisClient;
|
|
|
import com.abi.qms.platform.constant.RedisKeysConstant;
|
|
|
-import com.abi.qms.platform.dao.entity.*;
|
|
|
-import com.abi.qms.platform.dao.enums.*;
|
|
|
-import com.abi.qms.platform.dao.mapper.*;
|
|
|
+import com.abi.qms.platform.dao.entity.BaseFactory;
|
|
|
+import com.abi.qms.platform.dao.entity.QrPackage;
|
|
|
+import com.abi.qms.platform.dao.entity.QrPackageBatch;
|
|
|
+import com.abi.qms.platform.dao.entity.QrPackageDownloadRecord;
|
|
|
+import com.abi.qms.platform.dao.entity.QrRepertoryColumn;
|
|
|
+import com.abi.qms.platform.dao.entity.UserInfo;
|
|
|
+import com.abi.qms.platform.dao.enums.FactoryLevelEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.FactoryTypeEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.InvalidEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.QrPackageApplyStatusEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.QrPackageGenerateStatusEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.QrRepertoryTypeEnum;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseActiveMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseFactoryMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.QrBoxMappingMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.QrPackageBatchMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.QrPackageDownloadRecordMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.QrPackageMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.QrRepertoryColumnMapper;
|
|
|
import com.abi.qms.platform.dao.tablestore.entity.QrCode;
|
|
|
-import com.abi.qms.platform.dao.vo.result.*;
|
|
|
-import com.abi.qms.platform.dto.req.*;
|
|
|
-import com.abi.qms.platform.dto.res.*;
|
|
|
+import com.abi.qms.platform.dao.vo.result.PackageActiveVO;
|
|
|
+import com.abi.qms.platform.dao.vo.result.QrBoxMappingVO;
|
|
|
+import com.abi.qms.platform.dao.vo.result.QrPackageBatchVO;
|
|
|
+import com.abi.qms.platform.dao.vo.result.QrPackageVO;
|
|
|
+import com.abi.qms.platform.dao.vo.result.QrSingleCheckVO;
|
|
|
+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.GetQrSingleCheckDetailCodeReq;
|
|
|
+import com.abi.qms.platform.dto.req.InvalidQrPackageReq;
|
|
|
+import com.abi.qms.platform.dto.req.InvalidQrSingleReq;
|
|
|
+import com.abi.qms.platform.dto.req.ListQrPackageReq;
|
|
|
+import com.abi.qms.platform.dto.req.PassQrPackageReq;
|
|
|
+import com.abi.qms.platform.dto.req.QrOneBoxCodeMappingReq;
|
|
|
+import com.abi.qms.platform.dto.req.QrOnePackageBatchReq;
|
|
|
+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.res.GetQrPackageDetailRes;
|
|
|
+import com.abi.qms.platform.dto.res.GetQrSingleCheckDetailRes;
|
|
|
+import com.abi.qms.platform.dto.res.ListQrPackageRes;
|
|
|
+import com.abi.qms.platform.dto.res.ValidSAPOrderNoAndMaterialRes;
|
|
|
import com.abi.qms.platform.infrastructure.mq.GenerateCodeConsumer;
|
|
|
-import com.abi.qms.platform.infrastructure.util.*;
|
|
|
+import com.abi.qms.platform.infrastructure.util.AssertUtil;
|
|
|
+import com.abi.qms.platform.infrastructure.util.FreeMarkerUtils;
|
|
|
+import com.abi.qms.platform.infrastructure.util.OssFileDownloadUtil;
|
|
|
+import com.abi.qms.platform.infrastructure.util.PageUtil;
|
|
|
+import com.abi.qms.platform.infrastructure.util.RandomCodeUtils;
|
|
|
+import com.abi.qms.platform.infrastructure.util.SendmailUtil;
|
|
|
+import com.abi.qms.platform.infrastructure.util.SmsUtil;
|
|
|
+import com.abi.qms.platform.infrastructure.util.UserUtil;
|
|
|
import com.abi.qms.platform.service.QrPackageService;
|
|
|
import com.abi.task.common.api.exception.BusinessException;
|
|
|
import com.abi.task.common.api.exception.ErrorCodeEnum;
|
|
|
import com.abi.task.common.tablestore.TableStorePlusUtils;
|
|
|
+import com.abi.task.common.tablestore.TableStoreUtils;
|
|
|
import com.abi.task.common.utils.PojoConverterUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -33,7 +76,12 @@ import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.text.MessageFormat;
|
|
|
-import java.util.*;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -86,6 +134,9 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
@Autowired
|
|
|
private QrBoxMappingMapper qrBoxMappingMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TableStoreUtils tableStoreUtils;
|
|
|
+
|
|
|
/**
|
|
|
* 保存码包
|
|
|
*/
|
|
@@ -101,31 +152,31 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
fullParam(req);
|
|
|
|
|
|
//2-构造码包主表对象
|
|
|
- qrPackage = buildQrPackage(req,qrPackage);
|
|
|
+ qrPackage = buildQrPackage(req, qrPackage);
|
|
|
|
|
|
//3-新增or修改 码包主表
|
|
|
if (!isAdd) {
|
|
|
qrPackageMapper.updateById(qrPackage);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
qrPackageMapper.insert(qrPackage);
|
|
|
}
|
|
|
|
|
|
//4-保存码包批次子表信息
|
|
|
- saveQrPackageBatch(qrPackage,isAdd,req);
|
|
|
+ saveQrPackageBatch(qrPackage, isAdd, req);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 自动补全or处理入参数据
|
|
|
*/
|
|
|
- private void fullParam(SaveQrPackageReq req){
|
|
|
+ private void fullParam(SaveQrPackageReq req) {
|
|
|
//1-如果没有传入二级供应商,则表示选的是无等级(即自己做自己)的包材厂,那么就把自己放入二级供应商内
|
|
|
- if(req.getFactoryCoverLevelTwoId()==null){
|
|
|
+ if (req.getFactoryCoverLevelTwoId() == null) {
|
|
|
req.setFactoryCoverLevelTwoId(req.getFactoryCoverId());
|
|
|
}
|
|
|
|
|
|
//2-如果批次信息为空(盖码 or 真实业务没有批次的箱码包材厂),则补充批次信息
|
|
|
- if(CollectionUtil.isEmpty(req.getPackageBatchBeanList())){
|
|
|
+ if (CollectionUtil.isEmpty(req.getPackageBatchBeanList())) {
|
|
|
//列表
|
|
|
List<SaveQrPackageReq.PackageBatchBean> batchBeanList = new ArrayList<>();
|
|
|
|
|
@@ -136,22 +187,22 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
BaseFactory factory = baseFactoryMapper.selectById(req.getFactoryCoverLevelTwoId());
|
|
|
Long maxFileCount = factory.getMaxFileCount();
|
|
|
//如果二级包材厂的最大数为空,则认为和总数一致
|
|
|
- if(maxFileCount==null || maxFileCount<=0){
|
|
|
+ if (maxFileCount == null || maxFileCount <= 0) {
|
|
|
maxFileCount = qrNumber;
|
|
|
}
|
|
|
|
|
|
//计算需要生成多少批次,不是整除则+1
|
|
|
- int batchCount = qrNumber.intValue()/maxFileCount.intValue();
|
|
|
- if(batchCount*maxFileCount<qrNumber){
|
|
|
- batchCount = batchCount+1;
|
|
|
+ int batchCount = qrNumber.intValue() / maxFileCount.intValue();
|
|
|
+ if (batchCount * maxFileCount < qrNumber) {
|
|
|
+ batchCount = batchCount + 1;
|
|
|
}
|
|
|
|
|
|
//循环添加批次
|
|
|
- for(int i=0;i<batchCount;i++){
|
|
|
+ for (int i = 0; i < batchCount; i++) {
|
|
|
//每个批次多少条
|
|
|
Long batchQrNumber = maxFileCount;
|
|
|
- if(i==batchCount-1){
|
|
|
- batchQrNumber = qrNumber-(batchCount-1)*maxFileCount;
|
|
|
+ if (i == batchCount - 1) {
|
|
|
+ batchQrNumber = qrNumber - (batchCount - 1) * maxFileCount;
|
|
|
}
|
|
|
SaveQrPackageReq.PackageBatchBean batchBean = new SaveQrPackageReq.PackageBatchBean();
|
|
|
batchBean.setBatchNumber("000001");
|
|
@@ -169,13 +220,14 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
|
|
|
/**
|
|
|
* 保存码包批次子表信息
|
|
|
+ *
|
|
|
* @param qrPackage
|
|
|
* @param isAdd
|
|
|
* @param req
|
|
|
*/
|
|
|
- private void saveQrPackageBatch(QrPackage qrPackage,boolean isAdd,SaveQrPackageReq req){
|
|
|
+ private void saveQrPackageBatch(QrPackage qrPackage, boolean isAdd, SaveQrPackageReq req) {
|
|
|
//删除批次号(仅更新码包可能删除)
|
|
|
- if(!isAdd){
|
|
|
+ if (!isAdd) {
|
|
|
//查询原有批次号
|
|
|
QueryWrapper<QrPackageBatch> qrPackageBatchQuery = new QueryWrapper<>();
|
|
|
qrPackageBatchQuery.eq("package_id", qrPackage.getId());
|
|
@@ -221,12 +273,13 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
|
|
|
/**
|
|
|
* build数据库的码包对象
|
|
|
+ *
|
|
|
* @param req
|
|
|
* @param qrPackage
|
|
|
* @return
|
|
|
*/
|
|
|
- private QrPackage buildQrPackage(SaveQrPackageReq req,QrPackage qrPackage){
|
|
|
- if(qrPackage==null){
|
|
|
+ private QrPackage buildQrPackage(SaveQrPackageReq req, QrPackage qrPackage) {
|
|
|
+ if (qrPackage == null) {
|
|
|
qrPackage = new QrPackage();
|
|
|
}
|
|
|
|
|
@@ -239,16 +292,18 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
qrPackage.setQrNumber(req.getQrNumber());
|
|
|
qrPackage.setStandbyRatio(req.getStandbyRatio());
|
|
|
qrPackage.setReasonApply(req.getReasonApply());
|
|
|
+ qrPackage.setInvalid(InvalidEnum.NOT_INVALID.getCode());
|
|
|
|
|
|
return qrPackage;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 校验保存码包的入参
|
|
|
+ *
|
|
|
* @param req
|
|
|
* @return QrPackage 如果是修改码包就把码包查出来
|
|
|
*/
|
|
|
- private QrPackage checkRequestWhenSaveQrPackage(SaveQrPackageReq req){
|
|
|
+ private QrPackage checkRequestWhenSaveQrPackage(SaveQrPackageReq req) {
|
|
|
QrPackage qrPackage = null;
|
|
|
Long qrPackageId = req.getId();
|
|
|
boolean isAdd = (req.getId() == null);
|
|
@@ -293,31 +348,31 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
UserInfo wholeUser = userUtil.getWholeUser();
|
|
|
BaseFactory factoryCover = baseFactoryMapper.selectById(req.getFactoryCoverId());
|
|
|
//如果选择的是一级包材厂(而不是无等级包材厂),那么二级包材厂必填
|
|
|
- if(FactoryLevelEnum.ONE.is(factoryCover.getFactoryLevel())
|
|
|
- &&req.getFactoryCoverLevelTwoId()==null){
|
|
|
+ if (FactoryLevelEnum.ONE.is(factoryCover.getFactoryLevel())
|
|
|
+ && req.getFactoryCoverLevelTwoId() == null) {
|
|
|
throw new BusinessException("选择了一级包材厂,则二级包材厂必填");
|
|
|
}
|
|
|
- if(wholeUser.getFactoryId() != null&& FactoryTypeEnum.COVER.is(wholeUser.getFactoryType())){
|
|
|
+ if (wholeUser.getFactoryId() != null && FactoryTypeEnum.COVER.is(wholeUser.getFactoryType())) {
|
|
|
//1.他不是二级包材厂,包材厂必须为该用户所在的包材厂,不可修改
|
|
|
- if(!FactoryLevelEnum.TWO.is(factoryCover.getFactoryLevel())
|
|
|
- &&!req.getFactoryCoverId().equals(wholeUser.getFactoryId())){
|
|
|
+ if (!FactoryLevelEnum.TWO.is(factoryCover.getFactoryLevel())
|
|
|
+ && !req.getFactoryCoverId().equals(wholeUser.getFactoryId())) {
|
|
|
throw new BusinessException("包材厂只能选择登录用户的包材厂");
|
|
|
}
|
|
|
//2.他是二级包材厂,二级包菜场必须为用户所在的包材厂,不可修改
|
|
|
- if(FactoryLevelEnum.TWO.is(factoryCover.getFactoryLevel())
|
|
|
- &&!req.getFactoryCoverLevelTwoId().equals(wholeUser.getFactoryId())){
|
|
|
+ if (FactoryLevelEnum.TWO.is(factoryCover.getFactoryLevel())
|
|
|
+ && !req.getFactoryCoverLevelTwoId().equals(wholeUser.getFactoryId())) {
|
|
|
throw new BusinessException("二级包材厂只能选择登录用户的包材厂");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(!isAdd && wholeUser.getFactoryId()!=null){
|
|
|
+ if (!isAdd && wholeUser.getFactoryId() != null) {
|
|
|
//一级包材厂不允许修改码包
|
|
|
- if(FactoryLevelEnum.ONE.is(factoryCover.getFactoryLevel())){
|
|
|
+ if (FactoryLevelEnum.ONE.is(factoryCover.getFactoryLevel())) {
|
|
|
throw new BusinessException("一级包材厂不允许修改码包");
|
|
|
}
|
|
|
//二级包材厂or无级包材厂,只能改自己得码包
|
|
|
- if(!FactoryLevelEnum.ONE.is(factoryCover.getFactoryLevel())
|
|
|
- && !wholeUser.getFactoryId().equals(qrPackage.getFactoryCoverLevelTwoId())){
|
|
|
+ if (!FactoryLevelEnum.ONE.is(factoryCover.getFactoryLevel())
|
|
|
+ && !wholeUser.getFactoryId().equals(qrPackage.getFactoryCoverLevelTwoId())) {
|
|
|
throw new BusinessException("包材厂只允许修改自己的码包");
|
|
|
}
|
|
|
}
|
|
@@ -349,7 +404,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
@Override
|
|
|
public ListQrPackageRes listQrPackage(ListQrPackageReq req) {
|
|
|
//数据权限隔离,如果登录账号是包材厂,只能看账号包材厂的数据。否则看全部
|
|
|
- if (userUtil.getWholeUser().getFactoryId() != null && userUtil.getWholeUser().getFactoryType() != null && FactoryTypeEnum.COVER.is(userUtil.getWholeUser().getFactoryType()) ) {
|
|
|
+ if (userUtil.getWholeUser().getFactoryId() != null && userUtil.getWholeUser().getFactoryType() != null && FactoryTypeEnum.COVER.is(userUtil.getWholeUser().getFactoryType())) {
|
|
|
req.setFactoryCoverId(userUtil.getWholeUser().getFactoryId());
|
|
|
}
|
|
|
|
|
@@ -494,6 +549,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
|
|
|
/**
|
|
|
* 校验是否存在SAP订单号和物料重复数据
|
|
|
+ *
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
@@ -617,7 +673,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
QrRepertoryColumn qrRepertoryColumn = repertoryColumnMapper.selectById(qrCode.getQrRepertoryColumnId());
|
|
|
|
|
|
//存在别名(隐形码)
|
|
|
- if (ObjectUtils.isNotEmpty(qrRepertoryColumn)){
|
|
|
+ if (ObjectUtils.isNotEmpty(qrRepertoryColumn)) {
|
|
|
qrSingleCheckVO.setAlias(qrRepertoryColumn.getAlias());//隐形码
|
|
|
}
|
|
|
|
|
@@ -625,7 +681,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
PackageActiveVO packageActive = baseActiveMapper.getPackageActive(qrCode.getPackageId());
|
|
|
|
|
|
//存在活动数据
|
|
|
- if (ObjectUtils.isNotEmpty(packageActive)){
|
|
|
+ if (ObjectUtils.isNotEmpty(packageActive)) {
|
|
|
qrSingleCheckVO.setActiveName(packageActive.getActiveName());
|
|
|
qrSingleCheckVO.setActiveUrl(packageActive.getActiveUrl());
|
|
|
}
|
|
@@ -637,7 +693,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
QrPackageBatchVO qrPackageBatchOne = qrPackageBatchMapper.getQrPackageBatchOne(qrOnePackageBatchReq);
|
|
|
|
|
|
//存批次号
|
|
|
- if (ObjectUtils.isNotEmpty(qrPackageBatchOne)){
|
|
|
+ if (ObjectUtils.isNotEmpty(qrPackageBatchOne)) {
|
|
|
qrSingleCheckVO.setBatchNumber(qrPackageBatchOne.getBatchNumber());
|
|
|
}
|
|
|
|
|
@@ -648,7 +704,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
QrBoxMappingVO qrBoxMappingVO = qrBoxMappingMapper.getIndexQrBoxCodeMappingOne(qrOneBoxCodeMappingReq);
|
|
|
|
|
|
//存在激活关联信息
|
|
|
- if (ObjectUtils.isNotEmpty(qrBoxMappingVO)){
|
|
|
+ if (ObjectUtils.isNotEmpty(qrBoxMappingVO)) {
|
|
|
qrSingleCheckVO.setBoxCode(qrBoxMappingVO.getBoxCode());//条码序号
|
|
|
qrSingleCheckVO.setActiveTime(qrBoxMappingVO.getActiveTime());//激活时间
|
|
|
qrSingleCheckVO.setActiveUserName(qrBoxMappingVO.getActiveUserName());//激活时间
|
|
@@ -660,5 +716,39 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void invalidQrPackage(InvalidQrPackageReq req) {
|
|
|
+
|
|
|
+ //获取登录用户信息
|
|
|
+ UserInfo user = userUtil.getUser();
|
|
|
+
|
|
|
+ QrPackage qrPackage = qrPackageMapper.selectById(req.getId());
|
|
|
+ AssertUtil.isNull(qrPackage, "该码包不存在!");
|
|
|
+
|
|
|
+ qrPackage.setInvalid(InvalidEnum.INVALID.getCode());
|
|
|
+ qrPackage.setUpdateBy(user.getId());
|
|
|
+ qrPackage.setUpdateTime(LocalDateTime.now());
|
|
|
+
|
|
|
+ qrPackageMapper.updateById(qrPackage);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void invalidQrSingle(InvalidQrSingleReq req) {
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ //设置主键code 表名 列名称
|
|
|
+ String code = "code", tableName = "qr_code", columnName = "invalid";
|
|
|
+
|
|
|
+ //根据主键code更新列字段
|
|
|
+ tableStoreUtils.updateRow(code, req.getCode(), tableName, columnName, InvalidEnum.INVALID.getCode().toString());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("更新tableStore异常", e);
|
|
|
+ throw new BusinessException("更新tableStore异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|