|
@@ -2,16 +2,84 @@ package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.abi.base.foundation.util.RedisClient;
|
|
|
-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.BaseMaterial;
|
|
|
+import com.abi.qms.platform.dao.entity.QrBoxCodeFormat;
|
|
|
+import com.abi.qms.platform.dao.entity.QrBoxMapping;
|
|
|
+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.QrPackageSapOrderItem;
|
|
|
+import com.abi.qms.platform.dao.entity.QrRepertoryColumn;
|
|
|
+import com.abi.qms.platform.dao.entity.UserInfo;
|
|
|
+import com.abi.qms.platform.dao.enums.BoxMappingActiveStatusEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.CodePackageOrderTypeEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.FactoryTypeEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.FirstFactoryEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.InvalidEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.MaterialTypeEnum;
|
|
|
+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.enums.QrTypeEnum;
|
|
|
+import com.abi.qms.platform.dao.enums.TrueFalseEnum;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseActiveMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseBrandMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseFactoryMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseMaterialMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.QrBoxCodeFormatMapper;
|
|
|
+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.QrPackageSapOrderItemMapper;
|
|
|
+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.ActivationRecordVO;
|
|
|
+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.QrPackageWxVO;
|
|
|
+import com.abi.qms.platform.dao.vo.result.QrSingleCheckVO;
|
|
|
+import com.abi.qms.platform.dao.vo.result.WxQrPackageDetailVO;
|
|
|
+import com.abi.qms.platform.dto.req.ActivationRecordReq;
|
|
|
+import com.abi.qms.platform.dto.req.DeleteQrPackageReq;
|
|
|
+import com.abi.qms.platform.dto.req.DownloadQrPackageReq;
|
|
|
+import com.abi.qms.platform.dto.req.GetPackageCodeReq;
|
|
|
+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.ListQrPackageWxReq;
|
|
|
+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.ReplenishActivationReq;
|
|
|
+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.WxQrPackageDetailReq;
|
|
|
+import com.abi.qms.platform.dto.res.ActivationRecordRes;
|
|
|
+import com.abi.qms.platform.dto.res.GetPackageCodeRes;
|
|
|
+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.ListQrPackageWxRes;
|
|
|
+import com.abi.qms.platform.dto.res.ValidSAPOrderNoAndMaterialRes;
|
|
|
+import com.abi.qms.platform.dto.res.WxQrPackageDetailRes;
|
|
|
import com.abi.qms.platform.infrastructure.constant.RedisKey;
|
|
|
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.FactoryService;
|
|
|
import com.abi.qms.platform.service.MaterialService;
|
|
|
import com.abi.qms.platform.service.QrPackageService;
|
|
@@ -36,7 +104,11 @@ import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.text.MessageFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
+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;
|
|
|
|
|
@@ -187,12 +259,12 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
|
|
|
|
|
|
QueryWrapper<QrBoxCodeFormat> formatQw = new QueryWrapper<>();
|
|
|
- formatQw.eq("is_sys",1);
|
|
|
+ formatQw.eq("is_sys", 1);
|
|
|
|
|
|
- formatQw.eq("sys_type",1);
|
|
|
- formatQw.eq("is_delete",0);
|
|
|
+ formatQw.eq("sys_type", 1);
|
|
|
+ formatQw.eq("is_delete", 0);
|
|
|
List<QrBoxCodeFormat> beerFormatList = qrBoxCodeFormatMapper.selectList(formatQw);
|
|
|
- if(CollectionUtil.isEmpty(beerFormatList)){
|
|
|
+ if (CollectionUtil.isEmpty(beerFormatList)) {
|
|
|
throw new BusinessException("盖码默认幅面与码格式不存在,请检查初始数据");
|
|
|
}
|
|
|
QrBoxCodeFormat beerFormat = beerFormatList.get(0);
|
|
@@ -309,21 +381,21 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if(CodePackageOrderTypeEnum.SAP_ORDER.is(req.getOrderType()) && StringUtils.isBlank(req.getSapOrderNo())){
|
|
|
+ if (CodePackageOrderTypeEnum.SAP_ORDER.is(req.getOrderType()) && StringUtils.isBlank(req.getSapOrderNo())) {
|
|
|
throw new BusinessException("SAP订单号不能为空");
|
|
|
}
|
|
|
- if(CodePackageOrderTypeEnum.BOOKING_ORDER.is(req.getOrderType()) && StringUtils.isBlank(req.getBookingOrder())){
|
|
|
+ if (CodePackageOrderTypeEnum.BOOKING_ORDER.is(req.getOrderType()) && StringUtils.isBlank(req.getBookingOrder())) {
|
|
|
throw new BusinessException("预订单号不能为空");
|
|
|
}
|
|
|
|
|
|
|
|
|
- if(StringUtils.isNotBlank(req.getSapOrderNo()) && req.getReasonApply()==null){
|
|
|
+ if (StringUtils.isNotBlank(req.getSapOrderNo()) && req.getReasonApply() == null) {
|
|
|
ValidSAPOrderNoAndMaterialReq reqValid = new ValidSAPOrderNoAndMaterialReq();
|
|
|
reqValid.setMaterialId(req.getMaterialId());
|
|
|
reqValid.setSapOrderNo(req.getSapOrderNo());
|
|
|
reqValid.setApplyNumber(req.getQrNumber());
|
|
|
ValidSAPOrderNoAndMaterialRes validSAPOrderNoAndMaterialRes = validSAPOrderNoAndMaterial(reqValid);
|
|
|
- if(TrueFalseEnum.TRUE.is(validSAPOrderNoAndMaterialRes.getIsOverstepNum())){
|
|
|
+ if (TrueFalseEnum.TRUE.is(validSAPOrderNoAndMaterialRes.getIsOverstepNum())) {
|
|
|
throw new BusinessException("该SAP订单号和物料已超额申请码包,若仍需申请需要提交额外码包申请原因");
|
|
|
}
|
|
|
|
|
@@ -341,8 +413,8 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
|
|
|
BaseMaterial material = baseMaterialMapper.selectById(req.getMaterialId());
|
|
|
AssertUtil.isNull(material, "物料信息不存在");
|
|
|
- if(QrTypeEnum.CARTON.is(getPackageCode(material.getMaterialType()))
|
|
|
- && req.getBoxCodeFormatId()==null){
|
|
|
+ if (QrTypeEnum.CARTON.is(getPackageCode(material.getMaterialType()))
|
|
|
+ && req.getBoxCodeFormatId() == null) {
|
|
|
throw new BusinessException("箱码幅面为空");
|
|
|
}
|
|
|
|
|
@@ -447,11 +519,12 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
|
|
|
|
|
|
* 活动详情封装出参,显示品牌名称
|
|
|
+ *
|
|
|
* @param res
|
|
|
* @param packageActive
|
|
|
*/
|
|
|
|
|
|
- private void getBrandCodeName(GetQrPackageDetailRes res,PackageActiveVO packageActive){
|
|
|
+ private void getBrandCodeName(GetQrPackageDetailRes res, PackageActiveVO packageActive) {
|
|
|
|
|
|
|
|
|
|
|
@@ -592,7 +665,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
.setQrPackageId(qrPackage.getId());
|
|
|
qrPackageDownloadRecordMapper.insert(downloadRecord);
|
|
|
|
|
|
- QrPackage qrPackages=new QrPackage()
|
|
|
+ QrPackage qrPackages = new QrPackage()
|
|
|
.setDownloadTime(LocalDateTime.now());
|
|
|
qrPackageMapper.updateById(qrPackages);
|
|
|
}
|
|
@@ -830,22 +903,22 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public GetPackageCodeRes getPackageCodeType(GetPackageCodeReq req){
|
|
|
+ public GetPackageCodeRes getPackageCodeType(GetPackageCodeReq req) {
|
|
|
|
|
|
QrPackageSapOrderItem orderItem = qrPackageSapOrderItemMapper.selectById(req.getOrderItemId());
|
|
|
- AssertUtil.isNull(orderItem,"订单明细不存在");
|
|
|
+ AssertUtil.isNull(orderItem, "订单明细不存在");
|
|
|
|
|
|
|
|
|
BaseMaterial material = materialService.getMaterialByCode(orderItem.getSapMaterialId());
|
|
|
- AssertUtil.isNull(material,String.format("SAP物料%s未创建对应的QMS系统内物料!",orderItem.getSapMaterialId()));
|
|
|
+ AssertUtil.isNull(material, String.format("SAP物料%s未创建对应的QMS系统内物料!", orderItem.getSapMaterialId()));
|
|
|
|
|
|
|
|
|
BaseFactory coverFactory = factoryService.getFactoryByCode(orderItem.getSapCoverFactoryId(), FactoryTypeEnum.COVER.getCode());
|
|
|
- AssertUtil.isNull(coverFactory,String.format("SAP包材厂%s未创建对应的QMS系统内包材厂!",orderItem.getSapCoverFactoryId()));
|
|
|
+ AssertUtil.isNull(coverFactory, String.format("SAP包材厂%s未创建对应的QMS系统内包材厂!", orderItem.getSapCoverFactoryId()));
|
|
|
|
|
|
|
|
|
BaseFactory beerFactory = factoryService.getFactoryByCode(orderItem.getSapBeerFactoryId(), FactoryTypeEnum.BEER.getCode());
|
|
|
- AssertUtil.isNull(beerFactory,String.format("SAP啤酒厂%s未创建对应的QMS系统内啤酒厂!",orderItem.getSapBeerFactoryId()));
|
|
|
+ AssertUtil.isNull(beerFactory, String.format("SAP啤酒厂%s未创建对应的QMS系统内啤酒厂!", orderItem.getSapBeerFactoryId()));
|
|
|
|
|
|
GetPackageCodeRes res = new GetPackageCodeRes();
|
|
|
res.setFactoryCoverId(coverFactory.getId());
|
|
@@ -873,19 +946,65 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public WxQrPackageDetailRes getWxQrPackageDetail(WxQrPackageDetailReq req) {
|
|
|
+
|
|
|
+
|
|
|
+ WxQrPackageDetailVO detail = qrPackageMapper.getWxQrPackageDetail(req);
|
|
|
+ WxQrPackageDetailRes res = PojoConverterUtils.copy(detail, WxQrPackageDetailRes.class);
|
|
|
+
|
|
|
+
|
|
|
+ QueryWrapper<QrBoxMapping> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("package_id", req.getPackageId());
|
|
|
+ qw.eq("is_delete", 0);
|
|
|
+ List<QrBoxMapping> boxMappingList = qrBoxMappingMapper.selectList(qw);
|
|
|
+ List<WxQrPackageDetailRes.QrBoxMappingBean> beanList = PojoConverterUtils.copyList(boxMappingList, WxQrPackageDetailRes.QrBoxMappingBean.class);
|
|
|
+ res.setQrBoxMappingBeanList(beanList);
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void replenishActivation(ReplenishActivationReq req) {
|
|
|
+
|
|
|
+ QueryWrapper<QrBoxMapping> qw = new QueryWrapper<>();
|
|
|
+ qw.eq("box_code", req.getBoxCode());
|
|
|
+ qw.eq("is_delete", 0);
|
|
|
+ QrBoxMapping qrBoxMapping = qrBoxMappingMapper.selectOne(qw);
|
|
|
+ qrBoxMapping.setActiveTime(LocalDateTime.now());
|
|
|
+ qrBoxMapping.setActiveStatus(BoxMappingActiveStatusEnum.ACTIVATED.getCode());
|
|
|
+ qrBoxMapping.setActiveUserId(userUtil.getUser().getId());
|
|
|
+ qrBoxMapping.setActiveUserName(userUtil.getUser().getUserName());
|
|
|
+ qrBoxMapping.setRemark(req.getReason());
|
|
|
+
|
|
|
+ qrBoxMappingMapper.updateById(qrBoxMapping);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ActivationRecordRes getActivationRecord(ActivationRecordReq req) {
|
|
|
+ ActivationRecordRes res = new ActivationRecordRes();
|
|
|
+
|
|
|
+ List<ActivationRecordVO> recordVOList = qrBoxMappingMapper.getActivationRecord(req);
|
|
|
+ List<ActivationRecordRes.ActivationRecordBean> beanList = PojoConverterUtils.copyList(recordVOList, ActivationRecordRes.ActivationRecordBean.class);
|
|
|
+ res.setActivationRecordBeanList(beanList);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 根据物料类型转换码类型
|
|
|
* 物料类型: 3-罐子 4-瓶盖 5-纸板箱
|
|
|
* 码类型:1-箱码 2-盖码
|
|
|
+ *
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
- public Integer getPackageCode(Integer type){
|
|
|
+ public Integer getPackageCode(Integer type) {
|
|
|
if (MaterialTypeEnum.CARTON.is(type)) {
|
|
|
- return QrTypeEnum.CARTON.getCode();
|
|
|
- }else if(MaterialTypeEnum.BOTTLE_CAP.is(type) || MaterialTypeEnum.JAR.is(type)){
|
|
|
+ return QrTypeEnum.CARTON.getCode();
|
|
|
+ } else if (MaterialTypeEnum.BOTTLE_CAP.is(type) || MaterialTypeEnum.JAR.is(type)) {
|
|
|
return QrTypeEnum.CAP.getCode();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
throw new BusinessException("物料类型和对应的箱码类型不匹配!");
|
|
|
}
|
|
|
|