|
@@ -2,72 +2,16 @@ 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.constant.RedisKeysConstant;
|
|
|
-import com.abi.qms.platform.dao.entity.BaseBrand;
|
|
|
-import com.abi.qms.platform.dao.entity.BaseFactory;
|
|
|
-import com.abi.qms.platform.dao.entity.BaseMaterial;
|
|
|
-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.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.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.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.entity.*;
|
|
|
+import com.abi.qms.platform.dao.enums.*;
|
|
|
+import com.abi.qms.platform.dao.mapper.*;
|
|
|
import com.abi.qms.platform.dao.tablestore.entity.QrCode;
|
|
|
-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.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.SaveQrPackageReq;
|
|
|
-import com.abi.qms.platform.dto.req.SendMobileMsgReq;
|
|
|
-import com.abi.qms.platform.dto.req.ValidSAPOrderNoAndMaterialReq;
|
|
|
-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.dao.vo.result.*;
|
|
|
+import com.abi.qms.platform.dto.req.*;
|
|
|
+import com.abi.qms.platform.dto.res.*;
|
|
|
+import com.abi.qms.platform.infrastructure.constant.RedisKey;
|
|
|
import com.abi.qms.platform.infrastructure.mq.GenerateCodeConsumer;
|
|
|
-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.infrastructure.util.*;
|
|
|
import com.abi.qms.platform.service.FactoryService;
|
|
|
import com.abi.qms.platform.service.MaterialService;
|
|
|
import com.abi.qms.platform.service.QrPackageService;
|
|
@@ -92,11 +36,7 @@ import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.text.MessageFormat;
|
|
|
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.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -167,6 +107,9 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
@Autowired
|
|
|
private FactoryService factoryService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private QrBoxCodeFormatMapper qrBoxCodeFormatMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 保存码包
|
|
|
*/
|
|
@@ -243,7 +186,17 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
}
|
|
|
|
|
|
//3-如果是盖码,那么查询盖码得默认箱码幅面,并放入入参
|
|
|
- //TODO
|
|
|
+ QueryWrapper<QrBoxCodeFormat> formatQw = new QueryWrapper<>();
|
|
|
+ formatQw.eq("is_sys",1);
|
|
|
+ //1-盖码默认幅面
|
|
|
+ formatQw.eq("sys_type",1);
|
|
|
+ formatQw.eq("is_delete",0);
|
|
|
+ List<QrBoxCodeFormat> beerFormatList = qrBoxCodeFormatMapper.selectList(formatQw);
|
|
|
+ if(CollectionUtil.isEmpty(beerFormatList)){
|
|
|
+ throw new BusinessException("盖码默认幅面与码格式不存在,请检查初始数据");
|
|
|
+ }
|
|
|
+ QrBoxCodeFormat beerFormat = beerFormatList.get(0);
|
|
|
+ req.setBoxCodeFormatId(beerFormat.getId());
|
|
|
|
|
|
//4-根据物料ID查询物料类型,判断码类型,保存至码包表中
|
|
|
BaseMaterial material = baseMaterialMapper.selectById(req.getMaterialId());
|
|
@@ -355,37 +308,26 @@ 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("预订单号不能为空");
|
|
|
}
|
|
|
|
|
|
//如果SAP订单号和物料有重复数据,需提交额外申请原因
|
|
|
- if (StringUtils.isNotBlank(req.getSapOrderNo())) {
|
|
|
+ if(StringUtils.isNotBlank(req.getSapOrderNo()) && req.getReasonApply()==null){
|
|
|
ValidSAPOrderNoAndMaterialReq reqValid = new ValidSAPOrderNoAndMaterialReq();
|
|
|
reqValid.setMaterialId(req.getMaterialId());
|
|
|
reqValid.setSapOrderNo(req.getSapOrderNo());
|
|
|
ValidSAPOrderNoAndMaterialRes validSAPOrderNoAndMaterialRes = validSAPOrderNoAndMaterial(reqValid);
|
|
|
if (Objects.nonNull(validSAPOrderNoAndMaterialRes) && CollectionUtil.isNotEmpty(validSAPOrderNoAndMaterialRes.getPackageBeanList())) {
|
|
|
- Long id = validSAPOrderNoAndMaterialRes.getPackageBeanList().get(0).getId();
|
|
|
- if (validSAPOrderNoAndMaterialRes.getPackageBeanList().size() > 1) {
|
|
|
- if (Objects.isNull(req.getReasonApply())) {
|
|
|
- throw new BusinessException("该SAP订单号和物料与码包" + id + "重复,若仍需申请需要提交额外码包申请原因");
|
|
|
- }
|
|
|
- }
|
|
|
- if (validSAPOrderNoAndMaterialRes.getPackageBeanList().size() == 1) {
|
|
|
- if (req.getId() == null) {
|
|
|
- if (Objects.isNull(req.getReasonApply())) {
|
|
|
- throw new BusinessException("该SAP订单号和物料与码包" + id + "重复,若仍需申请需要提交额外码包申请原因");
|
|
|
- }
|
|
|
- }
|
|
|
- if (!id.equals(req.getId())) {
|
|
|
- if (Objects.isNull(req.getReasonApply())) {
|
|
|
- throw new BusinessException("该SAP订单号和物料与码包" + id + "重复,若仍需申请需要提交额外码包申请原因");
|
|
|
- }
|
|
|
- }
|
|
|
+ Set<Long> validQrPackageIdSet = validSAPOrderNoAndMaterialRes.getPackageBeanList().stream().map(bean -> bean.getId()).collect(Collectors.toSet());
|
|
|
+ if(validQrPackageIdSet.size()>1
|
|
|
+ ||(isAdd && validQrPackageIdSet.size()==1)
|
|
|
+ ||(!isAdd && !validQrPackageIdSet.contains(req.getId()))){
|
|
|
+ Long id = validSAPOrderNoAndMaterialRes.getPackageBeanList().get(0).getId();
|
|
|
+ throw new BusinessException("该SAP订单号和物料与码包" + id + "重复,若仍需申请需要提交额外码包申请原因");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -393,8 +335,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("箱码幅面为空");
|
|
|
}
|
|
|
|
|
@@ -492,18 +434,17 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
|
|
|
//存在活动数据
|
|
|
if (ObjectUtils.isNotEmpty(packageActive)) {
|
|
|
- getBrandCodeName(res, packageActive);
|
|
|
+ getBrandCodeName(res,packageActive);
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 活动详情封装出参,显示品牌名称
|
|
|
- *
|
|
|
* @param res
|
|
|
* @param packageActive
|
|
|
*/
|
|
|
- private void getBrandCodeName(GetQrPackageDetailRes res, PackageActiveVO packageActive) {
|
|
|
+ private void getBrandCodeName(GetQrPackageDetailRes res,PackageActiveVO packageActive){
|
|
|
|
|
|
res.setActiveCode(packageActive.getActiveCode());
|
|
|
res.setActiveName(packageActive.getActiveName());
|
|
@@ -515,7 +456,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
StringBuffer brandNames = new StringBuffer();
|
|
|
//查询品牌一级列表
|
|
|
QueryWrapper<BaseBrand> baseBrandQW = new QueryWrapper<>();
|
|
|
- baseBrandQW.eq("brand_level", 1);
|
|
|
+ baseBrandQW.eq("brand_level",1);
|
|
|
List<BaseBrand> baseBrands = baseBrandMapper.selectList(baseBrandQW);
|
|
|
Map<String, String> brandCodeMap = baseBrands.stream().collect(Collectors.toMap(BaseBrand::getBrandCode, BaseBrand::getBrandName));
|
|
|
|
|
@@ -528,8 +469,8 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (brandNames.length() > 0) {
|
|
|
- brandNames.deleteCharAt(brandNames.length() - 1);
|
|
|
+ if (brandNames.length()>0){
|
|
|
+ brandNames.deleteCharAt(brandNames.length()-1);
|
|
|
res.setBrandNames(brandNames.toString());
|
|
|
}
|
|
|
}
|
|
@@ -644,7 +585,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);
|
|
|
}
|
|
@@ -733,7 +674,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
//key:packId:mobile
|
|
|
Long packId = qrPackage.getId();
|
|
|
String mobile = factory.getKeymanMobile();
|
|
|
- String key = MessageFormat.format("{0}{1}:{2}", RedisKeysConstant.DOWNLOAD_MOBILE_MSG, packId, mobile);
|
|
|
+ String key = MessageFormat.format("{0}{1}:{2}", RedisKey.DOWNLOAD_MOBILE_MSG, packId, mobile);
|
|
|
|
|
|
//获取随机验证码
|
|
|
String captcha = RandomCodeUtils.getCaptcha(6);
|
|
@@ -754,7 +695,7 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean verifyCaptcha(String mobile, String inputCaptcha, Long packId) {
|
|
|
- String key = MessageFormat.format("{0}{1}:{2}", RedisKeysConstant.DOWNLOAD_MOBILE_MSG, packId, mobile);
|
|
|
+ String key = MessageFormat.format("{0}{1}:{2}", RedisKey.DOWNLOAD_MOBILE_MSG, packId, mobile);
|
|
|
log.info("验证下载key:{}", key);
|
|
|
String captcha = redisClient.get(key);
|
|
|
log.info(inputCaptcha + "--------------------" + captcha);
|
|
@@ -864,22 +805,22 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public GetPackageCodeRes getPackageCodeType(GetPackageCodeReq req) {
|
|
|
+ public GetPackageCodeRes getPackageCodeType(GetPackageCodeReq req){
|
|
|
//1-查询sap订单明细
|
|
|
QrPackageSapOrderItem orderItem = qrPackageSapOrderItemMapper.selectById(req.getOrderItemId());
|
|
|
- AssertUtil.isNull(orderItem, "订单明细不存在");
|
|
|
+ AssertUtil.isNull(orderItem,"订单明细不存在");
|
|
|
|
|
|
//2-查询对应物料
|
|
|
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()));
|
|
|
|
|
|
//3-查询包材厂
|
|
|
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()));
|
|
|
|
|
|
//4-查询啤酒厂
|
|
|
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());
|
|
@@ -896,23 +837,30 @@ public class QrPackageServiceImpl implements QrPackageService {
|
|
|
|
|
|
@Override
|
|
|
public ListQrPackageWxRes listWxQrPackage(ListQrPackageWxReq listQrPackageWxReq) {
|
|
|
- return null;
|
|
|
+
|
|
|
+ ListQrPackageWxRes res = new ListQrPackageWxRes();
|
|
|
+
|
|
|
+ List<QrPackageWxVO> qrPackageWxVOList = qrPackageMapper.listWxQrPackage(listQrPackageWxReq);
|
|
|
+
|
|
|
+ List<ListQrPackageWxRes.QrPackageWxBean> beanList = PojoConverterUtils.copyList(qrPackageWxVOList, ListQrPackageWxRes.QrPackageWxBean.class);
|
|
|
+ res.setQrPackageWxBeanList(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("物料类型和对应的箱码类型不匹配!");
|
|
|
}
|
|
|
|