Merge remote-tracking branch 'origin/dev' into dev

master
jun 6 months ago
commit 8edddb1bc0

@ -0,0 +1,8 @@
package cn.estsh.i3plus.ext.mes.pcn.api.busi.offlineprint;
import java.util.Map;
public interface IMesOfflinePrintService {
Map<String,Object> getCustSnOfflineInfo(String custSn,String templateCode,String organizeCode);
}

@ -7,7 +7,9 @@ import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
import cn.estsh.i3plus.pojo.mes.bean.MesPullingOrderInfo;
import cn.estsh.i3plus.pojo.mes.bean.MesPullingOrderPartInfo;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
@ -35,6 +37,7 @@ public class MesPullingOrderInfoController {
@Autowired
private IMesTemplateService mesTemplateService;
@GetMapping(value = "/query-pager")
@ApiOperation(value = "查询拉动单")
public ResultBean queryMesPullingOrderInfoByPager(MesPullingOrderInfo mesPullingOrderInfo, Pager pager) {
@ -49,6 +52,7 @@ public class MesPullingOrderInfoController {
return ResultBean.fail(e);
}
}
@PostMapping(value = "/doScan")
@ApiOperation(value = "拉动单扫描")
public ResultBean doMesPullingOrderInfoScan(@RequestBody MesPullingOrderInfo mesPullingOrderInfo) {
@ -97,6 +101,7 @@ public class MesPullingOrderInfoController {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping(value = "/jis-part-info/query-pager")
@ApiOperation(value = "查询JIS拉动单明细")
public ResultBean queryMesPullingOrderPartInfoByPager(MesPullingOrderInfo mesPullingOrderInfo, Pager pager) {
@ -114,6 +119,7 @@ public class MesPullingOrderInfoController {
return ResultBean.fail(e);
}
}
@PostMapping(value = "/doJisScan")
@ApiOperation(value = "JIS物料拉动-校验条码")
public ResultBean doMesPullingOrderInfoJisScan(@RequestBody MesPullingOrderPartInfo info) {

@ -0,0 +1,33 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi.offlinesn;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.model.MesCustSnOfflineModel;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.offlineprint.MesOfflinePrintServiceImpl;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@Api(tags = "离线条码打印")
@RequestMapping(MesCommonConstant.MES_YANFEN + "/offline/print")
@Slf4j
public class MesWuhanOfflinePrintController {
@Autowired
private MesOfflinePrintServiceImpl mesOfflinePrintService;
@PostMapping("/cust-sn")
public ResultBean custSn(@RequestBody MesCustSnOfflineModel model) {
Map<String, Object> custSnOfflineInfo = null;
try {
custSnOfflineInfo = mesOfflinePrintService.getCustSnOfflineInfo(model.getCustSn(), model.getTemplateCode(), model.getOrganizeCode());
} catch (Exception e) {
ResultBean.fail().setErrorMsg(e.getMessage());
}
return ResultBean.success("查询成功").setResultMap(custSnOfflineInfo);
}
}

@ -0,0 +1,12 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.model;
import lombok.Data;
@Data
public class MesCustSnOfflineModel {
private String custSn;
private String templateCode;
private String organizeCode;
}

@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
@ -247,25 +248,64 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService {
List<MesPullingOrderPartInfo> resultList = mesPullingOrderPartInfoRepository.findByHqlWherePage(packBean, pager);
if (!CollectionUtils.isEmpty(resultList)) {
Map<String, List<MesPartPullDetail>> pullCodePartMap = null;
List<MesPullingOrderInfo> pullingOrderInfoList = null;
Map<String, List<MesPullingOrderInfo>> pullingOrderInfoMap = null;
Map<String, List<MesCustomerCarModel>> customerCarModelMap = null;
//查拉动单明细对应的拉动组规则
DdlPackBean packBeanDetail = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
DdlPreparedPack.getInPackList(resultList.stream().map(MesPullingOrderPartInfo::getPullCode).collect(Collectors.toList()), "pullCode", packBeanDetail);
List<MesPartPullDetail> mesPartPullDetails = mesPartPullDetailRDao.findByHqlWhere(packBeanDetail);
if (!CollectionUtils.isEmpty(mesPartPullDetails)) {
Map<String, List<MesPartPullDetail>> pullCodePartMap = mesPartPullDetails.stream().collect(Collectors.groupingBy(a -> a.getPullCode() + "=" + a.getPartNo()));
for (MesPullingOrderPartInfo partInfo : resultList) {
if (!CollectionUtils.isEmpty(pullCodePartMap.get(partInfo.getPullCode() + "=" + partInfo.getPartNo()))) {
MesPartPullDetail mesPartPullDetail = pullCodePartMap.get(partInfo.getPullCode() + "=" + partInfo.getPartNo()).get(0);
partInfo.setScanValidationType(StringUtil.isEmpty(mesPartPullDetail.getScanValidationType()) ? 10 : mesPartPullDetail.getScanValidationType());
partInfo.setRuleValidation(StringUtil.isEmpty(mesPartPullDetail.getRuleValidation()) ? "" : mesPartPullDetail.getRuleValidation());
if (Objects.isNull(mesPartPullDetail.getScanValidationType()) || mesPartPullDetail.getScanValidationType() == MesExtEnumUtil.PART_PULL_DETAIL_SCAN_VALIDATION_TYPE.UN_VALIDATE.getValue()) {
partInfo.setColor(MesExtEnumUtil.PART_PULL_DETAIL_COLOR.WHITE.getCode());
} else if (partInfo.getColor() == MesExtEnumUtil.PART_PULL_DETAIL_COLOR.WHITE.getCode()) {
partInfo.setColor(MesExtEnumUtil.PART_PULL_DETAIL_COLOR.RED.getCode());
}
List list = (resultList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPullCode()))).map(MesPullingOrderPartInfo::getPullCode).collect(Collectors.toList())).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(list)) {
DdlPackBean packBeanDetail = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
DdlPreparedPack.getInPackList(list, "pullCode", packBeanDetail);
List<MesPartPullDetail> mesPartPullDetails = mesPartPullDetailRDao.findByHqlWhere(packBeanDetail);
pullCodePartMap = CollectionUtils.isEmpty(mesPartPullDetails) ? null :
mesPartPullDetails.stream().filter(o -> null != o).collect(Collectors.groupingBy(o -> new StringJoiner(MesPcnExtConstWords.AND).add(o.getPullCode()).add(o.getPartNo()).toString()));
}
list = resultList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPullingOrderNo()))).map(MesPullingOrderPartInfo::getPullingOrderNo).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(list)) {
packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
DdlPreparedPack.getInPackList(list, "pullingOrderNo", packBean);
pullingOrderInfoList = mesPullingOrderInfoRepository.findByHqlWhere(packBean);
pullingOrderInfoMap = CollectionUtils.isEmpty(pullingOrderInfoList) ? null :
pullingOrderInfoList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesPullingOrderInfo::getPullingOrderNo));
}
if (!CollectionUtils.isEmpty(pullingOrderInfoList)) {
list = (pullingOrderInfoList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getCarModelCode()))).map(MesPullingOrderInfo::getCarModelCode).collect(Collectors.toList())).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(list)) {
packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
DdlPreparedPack.getInPackList(list, MesPcnExtConstWords.CAR_MODEL_CODE, packBean);
List<MesCustomerCarModel> customerCarModelList = carModelRepository.findByHqlWhere(packBean);
customerCarModelMap = CollectionUtils.isEmpty(customerCarModelList) ? null :
customerCarModelList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesCustomerCarModel::getCarModelCode));
}
}
String key;
for (MesPullingOrderPartInfo partInfo : resultList) {
key = new StringJoiner(MesPcnExtConstWords.AND).add(partInfo.getPullCode()).add(partInfo.getPartNo()).toString();
if (!CollectionUtils.isEmpty(pullCodePartMap) && pullCodePartMap.containsKey(key)) {
MesPartPullDetail mesPartPullDetail = pullCodePartMap.get(key).get(0);
partInfo.setScanValidationType(StringUtil.isEmpty(mesPartPullDetail.getScanValidationType()) ? 10 : mesPartPullDetail.getScanValidationType());
partInfo.setRuleValidation(StringUtil.isEmpty(mesPartPullDetail.getRuleValidation()) ? MesPcnExtConstWords.EMPTY : mesPartPullDetail.getRuleValidation());
if (Objects.isNull(mesPartPullDetail.getScanValidationType()) || mesPartPullDetail.getScanValidationType().compareTo(MesExtEnumUtil.PART_PULL_DETAIL_SCAN_VALIDATION_TYPE.UN_VALIDATE.getValue()) == 0) {
partInfo.setColor(MesExtEnumUtil.PART_PULL_DETAIL_COLOR.WHITE.getCode());
} else if (partInfo.getColor() == MesExtEnumUtil.PART_PULL_DETAIL_COLOR.WHITE.getCode()) {
partInfo.setColor(MesExtEnumUtil.PART_PULL_DETAIL_COLOR.RED.getCode());
}
if (!CollectionUtils.isEmpty(pullingOrderInfoMap) && pullingOrderInfoMap.containsKey(partInfo.getPullingOrderNo())) {
partInfo.setCarModelCode(pullingOrderInfoMap.get(partInfo.getPullingOrderNo()).get(0).getCarModelCode());
}
if (!StringUtils.isEmpty(partInfo.getCarModelCode()) && !CollectionUtils.isEmpty(customerCarModelMap) && customerCarModelMap.containsKey(partInfo.getCarModelCode())) {
partInfo.setCarModelName(customerCarModelMap.get(partInfo.getCarModelCode()).get(0).getCarModelName());
}
}
}
}
return new ListPager<>(resultList, pager);
}

@ -0,0 +1,99 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.offlineprint;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.offlineprint.IMesOfflinePrintService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.BarCodeUtils;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateParam;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateParamRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.ByteArrayOutputStream;
import java.util.*;
@Service
@Slf4j
public class MesOfflinePrintServiceImpl implements IMesOfflinePrintService {
@Autowired
private MesWorkOrderRepository workOrderRepository;
@Autowired
private MesLabelTemplateRepository labelTemplateRepository;
@Autowired
private MesLabelTemplateParamRepository labelTemplateParamRepository;
@Override
public Map<String, Object> getCustSnOfflineInfo(String custSn,String templateCode,String organizeCode) {
List<Map<String, Object>> printDate = new ArrayList<>();
Map<String, Object> data = new HashMap<>();
if (custSn.length() != MesPcnExtConstWords.CUSTOMER_SN_LENGTH_GM) {
String a = custSn.substring(0, 3);
String b = custSn.substring(3, 5);
String c = custSn.substring(5, 20);
String d = custSn.substring(20, 29);
String e = custSn.substring(29, 41);
String f = custSn.substring(41, 58);
custSn= a + (char)30 + b + (char)29 + c + (char)29 + d + (char)29 + e + (char)29 + f + (char)30 + (char)04;
}
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(custSn,"custSn",ddlPackBean);
List<MesWorkOrder> workOrderList = workOrderRepository.findByHqlWhere(ddlPackBean);
if (workOrderList != null && !workOrderList.isEmpty()) {
MesWorkOrder mesWorkOrder = workOrderList.get(0);
String vpps = custSn.substring(8, 23);
String custPartNo = mesWorkOrder.getCustPartNo();
String duns = custSn.substring(36, 46);
String custSnAfterContent = custSn.substring(47, custSn.length() - 2);
data.put("custSn", custSn);
data.put("custPartNoPrefix", custPartNo.substring(0, custPartNo.length() - 4));
data.put("custPartNoAfterFour", custPartNo.substring(custPartNo.length() - 4).toUpperCase());
data.put("custSnVPPS", vpps);
data.put("custSnDUNS", duns);
data.put("custSnAfterContent", custSnAfterContent);
}
try {
ByteArrayOutputStream dataMatrixCode = BarCodeUtils.createDataMatrixCode(custSn);
data.put("custSnDataMatrix", Base64.getEncoder().encodeToString(dataMatrixCode.toByteArray()));
printDate.add(data);
} catch (Exception e) {
throw new ImppBusiException().setErrorDetail("生成条码出错!");
}
MesLabelTemplate mesLabelTemplate = getMesLabelTemplate(templateCode, organizeCode);
Map<String, Object> templateMap = new HashMap<>();
templateMap.put("labelTemplate", mesLabelTemplate);
templateMap.put("templateData", printDate);
return templateMap;
}
private MesLabelTemplate getMesLabelTemplate(String templateCode,String organizeCode) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(templateCode,"templateCode",ddlPackBean);
List<MesLabelTemplate> mesLabelTemplates = labelTemplateRepository.findByHqlWhere(ddlPackBean);
if (mesLabelTemplates == null ||mesLabelTemplates.isEmpty()){
log.error(String.format("标签模板代码【%s】在标签模板表不存在", templateCode));
throw ImppExceptionBuilder.newInstance().setErrorDetail(String.format("标签模板代码【%s】在标签模板表不存在", templateCode)).build();
}
DdlPackBean templateParamPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(templateCode,"templateCode",templateParamPackBean);
List<MesLabelTemplateParam> mesLabelTemplateParams = labelTemplateParamRepository.findByHqlWhere(templateParamPackBean);
if (mesLabelTemplateParams == null || mesLabelTemplateParams.isEmpty()){
log.error(String.format("标签模板代码【%s】在标签模板明细表不存在", templateCode));
throw ImppExceptionBuilder.newInstance().setErrorDetail(String.format("标签模板代码【%s】在标签模板明细表不存在", templateCode)).build();
}
MesLabelTemplate mesLabelTemplate = mesLabelTemplates.get(0);
mesLabelTemplate.setLabelTemplateParamList(mesLabelTemplateParams);
return mesLabelTemplate;
}
}

@ -89,12 +89,21 @@ public class AssemblyVisualListPrintStrategy implements IPrintTemplateStrategySe
resultMap.put(MesPcnExtConstWords.REPLACE_CSN,MesPcnExtConstWords.REPLACE_CSN_CP+workOrder.getCustPartNo().substring(workOrder.getCustPartNo().length() -4));
// 总个数
Integer totalCount = partProdGroup.getTotalCount();
Map<Integer, List<MesWorkOrderAssembly>> collect = workOrderAssemblyList.stream().collect(Collectors.groupingBy(MesWorkOrderAssembly::getDisplaySeq));
// 为空时显示内容
String isNullViewContent = StringUtils.isEmpty(partProdGroup.getIsNullViewContent()) ? "" : partProdGroup.getIsNullViewContent();
for (Integer index = 0; index < totalCount; index++) {
String displayValue = workOrderAssemblyList.size() -1 < index ? isNullViewContent : workOrderAssemblyList.get(index).getDisplayValue();
for (int index = 0; index < collect.size(); index++) {
List<MesWorkOrderAssembly> orderAssemblyList = collect.get(index+1);
List<String> disPlayValues = orderAssemblyList.stream().map(MesWorkOrderAssembly::getDisplayValue).distinct().collect(Collectors.toList());
String displayValue =isNullViewContent;
if(!disPlayValues.isEmpty()){
displayValue = String.join("\r\n", disPlayValues);
}
// String displayValue = workOrderAssemblyList.size() -1 < index ? isNullViewContent : workOrderAssemblyList.get(index).getDisplayValue();
resultMap.put(MesPcnExtConstWords.ASSEMBLY_PARAM + (index+1), StringUtils.isEmpty(displayValue) ? StringUtils.isEmpty(isNullViewContent) ? "" : isNullViewContent : displayValue);
// resultMap.put(MesPcnExtConstWords.ASSEMBLY_PARAM + (index+1), StringUtils.isEmpty(displayValue) ? StringUtils.isEmpty(isNullViewContent) ? "" : isNullViewContent : displayValue);
resultMap.put(MesPcnExtConstWords.ASSEMBLY_PARAM + (index+1), displayValue);
}
printDataMapList.add(resultMap);

Loading…
Cancel
Save