pcn发运单打印

uat-temp-nht-2503130000-chengdu-shipping
王杰 2 months ago
parent 7a4a4db923
commit 804b34cd56

@ -1,23 +1,29 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingPrintForCqLxModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresSrmRunSheetJis;
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresSrmRunSheetJisDetail;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import cn.estsh.i3plus.pojo.mes.repository.seres.IMesCimSeresSrmRunSheetJisDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.seres.IMesCimSeresSrmRunSheetJisRepository;
import cn.estsh.impp.framework.boot.util.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
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.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -30,6 +36,9 @@ public class CqCxSortShippingPrintStrategyService extends SortShippingDispatchSt
@Autowired
private IMesCimSeresSrmRunSheetJisRepository cimSeresSrmRunSheetJisRepository;
@Autowired
private IMesCimSeresSrmRunSheetJisDetailRepository cimSeresSrmRunSheetJisDetailRepository;
@Override
public List<MesShippingOrderManagement> getShippingOrderManagementList(MesShippingOrderManagement bean) {
return super.getShippingOrderManagementList(bean);
@ -48,29 +57,71 @@ public class CqCxSortShippingPrintStrategyService extends SortShippingDispatchSt
@Override
public ResultBean execute(MesShippingOrderManagement bean, List<MesShippingOrderManagement> shippingOrderManagementList) {
List<Long> pidList = shippingOrderManagementList.stream().map(MesShippingOrderManagement::getId).collect(Collectors.toList());
List<String> shippingCodeList = shippingOrderManagementList.stream().map(MesShippingOrderManagement::getShippingCode).collect(Collectors.toList());
List<MesShippingOrderManagementDetail> shippingOrderManagementDetailList = getShippingOrderManagementDetailList(bean.getOrganizeCode(), pidList, null, null);
log.info("工厂{}排序发运打印 --- 查询发运单明细信息:{}条 --- {}", bean.getOrganizeCode(),
CollectionUtils.isEmpty(shippingOrderManagementDetailList) ? MesPcnExtConstWords.ZERO : shippingOrderManagementDetailList.size(), Thread.currentThread().getName());
Map<Long, List<MesShippingOrderManagementDetail>> detailByPidMap = CollectionUtils.isEmpty(shippingOrderManagementDetailList) ? null :
shippingOrderManagementDetailList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).collect(Collectors.groupingBy(MesShippingOrderManagementDetail::getPid));
// List<MesCimSeresSrmRunSheetJis> cimSeresSrmRunSheetJisList = getCimSeresSrmRunSheetJisList(bean.getOrganizeCode(), shippingCodeList);
List<MesSortShippingPrintForCqLxModel> resultList = new ArrayList<>();
List<String> shippingCodeList = shippingOrderManagementList.stream().map(MesShippingOrderManagement::getShippingCode).collect(Collectors.toList());
List<MesCimSeresSrmRunSheetJis> cimSeresSrmRunSheetJisList = getCimSeresSrmRunSheetJisList(bean.getOrganizeCode(), shippingCodeList);
Map<String, List<MesCimSeresSrmRunSheetJis>> jisByScMap = CollectionUtils.isEmpty(cimSeresSrmRunSheetJisList) ? null :
cimSeresSrmRunSheetJisList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getDocNo()))).collect(Collectors.groupingBy(MesCimSeresSrmRunSheetJis::getDocNo));
log.info("工厂{}排序发运打印 --- 查询JIS单信息:{}条 --- {}", bean.getOrganizeCode(),
CollectionUtils.isEmpty(cimSeresSrmRunSheetJisList) ? MesPcnExtConstWords.ZERO : cimSeresSrmRunSheetJisList.size(), Thread.currentThread().getName());
List<Long> jisIdList = CollectionUtils.isEmpty(cimSeresSrmRunSheetJisList) ? null :
cimSeresSrmRunSheetJisList.stream().map(MesCimSeresSrmRunSheetJis::getId).collect(Collectors.toList());
List<MesCimSeresSrmRunSheetJisDetail> cimSeresSrmRunSheetJisDetailList = getCimSeresSrmRunSheetJisDetailList(bean.getOrganizeCode(), jisIdList);
Map<Long, List<MesCimSeresSrmRunSheetJisDetail>> jisDetailByPidMap = CollectionUtils.isEmpty(cimSeresSrmRunSheetJisDetailList) ? null :
cimSeresSrmRunSheetJisDetailList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).collect(Collectors.groupingBy(MesCimSeresSrmRunSheetJisDetail::getPid));
log.info("工厂{}排序发运打印 --- 查询JIS单详情信息:{}条 --- {}", bean.getOrganizeCode(),
CollectionUtils.isEmpty(cimSeresSrmRunSheetJisDetailList) ? MesPcnExtConstWords.ZERO : cimSeresSrmRunSheetJisDetailList.size(), Thread.currentThread().getName());
//遍历处理每个发运单主表
for (MesShippingOrderManagement shippingOrderManagement : shippingOrderManagementList) {
//一张实体发运单包含三部分信息(顶部的通用数据、中部的第一份表格数据,底部的第二份表格数据)
//取出当前发运单的明细信息
List<MesShippingOrderManagementDetail> details = null == detailByPidMap ? null : detailByPidMap.get(shippingOrderManagement.getId());
shippingOrderManagement.setPrintCount(StringUtil.isEmpty(shippingOrderManagement.getPrintCount())? 1 : shippingOrderManagement.getPrintCount()+1);
if (null == shippingOrderManagement) continue;
List<MesCimSeresSrmRunSheetJis> sheetJis = CollectionUtils.isEmpty(jisByScMap) ? null : jisByScMap.get(shippingOrderManagement.getShippingCode());
if (CollectionUtils.isEmpty(sheetJis)) continue;
MesSortShippingPrintForCqLxModel result = new MesSortShippingPrintForCqLxModel();
BeanUtils.copyProperties(sheetJis.get(0), result);
if (shippingOrderManagement.getShippingCode().length() >= 4) {
result.setCarsNo(shippingOrderManagement.getShippingCode().substring(shippingOrderManagement.getShippingCode().length() - 4));
result.setDocNoOther(shippingOrderManagement.getShippingCode().substring(0, shippingOrderManagement.getShippingCode().length() - 4));
}
List<MesCimSeresSrmRunSheetJisDetail> sheetJisDetailList = CollectionUtils.isEmpty(jisDetailByPidMap) ? new ArrayList<>() : jisDetailByPidMap.get(sheetJis.get(0).getId());
if (!CollectionUtils.isEmpty(sheetJisDetailList)) sheetJisDetailList = sheetJisDetailList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesCimSeresSrmRunSheetJisDetail::getMaterielCode)).collect(Collectors.toList());
Integer index = MesPcnExtConstWords.ONE;
for (MesCimSeresSrmRunSheetJisDetail cimSeresSrmRunSheetJisDetail : sheetJisDetailList) {
if (null == cimSeresSrmRunSheetJisDetail) continue;
MesSortShippingPrintForCqLxModel jisDetail = new MesSortShippingPrintForCqLxModel();
BeanUtils.copyProperties(cimSeresSrmRunSheetJisDetail, jisDetail);
jisDetail.setXh(index);
index ++;
result.addJisDetail(jisDetail);
}
Map<String, List<MesSortShippingPrintForCqLxModel>> sheetJisDetailMap = CollectionUtils.isEmpty(result.getJisDetailList()) ? new HashMap<>() :
result.getJisDetailList().stream().filter(o -> null != o).collect(Collectors.groupingBy(MesSortShippingPrintForCqLxModel::getMaterielCode));
for (Map.Entry<String, List<MesSortShippingPrintForCqLxModel>> entry : sheetJisDetailMap.entrySet()) {
if (null == entry) continue;
List<MesSortShippingPrintForCqLxModel> amountList = entry.getValue();
if (CollectionUtils.isEmpty(amountList)) continue;
MesSortShippingPrintForCqLxModel amount = new MesSortShippingPrintForCqLxModel();
amount.setPartNo(amountList.get(0).getMaterielCode());
amount.setAmountQty(amountList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getUseQty()))).mapToDouble(MesSortShippingPrintForCqLxModel::getUseQty).sum());
StringJoiner appendRows = new StringJoiner(MesPcnExtConstWords.COMMA);
amountList.forEach(o -> appendRows.add(o.getXh().toString()));
amount.setAppendRows(appendRows.toString());
amount.setMaterielNames(amountList.get(0).getMaterielNames());
result.addAmount(amount);
}
resultList.add(result);
shippingOrderManagement.setPrintCount(StringUtil.isEmpty(shippingOrderManagement.getPrintCount()) ? MesPcnExtConstWords.ONE : shippingOrderManagement.getPrintCount() + MesPcnExtConstWords.ONE);
shippingOrderManagement.setLastPrintTime(TimeTool.getNowTime(true));
shippingOrderManagement.setLastPrintUser(bean.getUserInfo());
ConvertBean.serviceModelUpdate(shippingOrderManagement, bean.getUserInfo());
@ -78,8 +129,24 @@ public class CqCxSortShippingPrintStrategyService extends SortShippingDispatchSt
saveShippingOrderManagementList(shippingOrderManagementList);
return ResultBean.success("发运单打印成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(null);
return ResultBean.success("发运单打印成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(resultList);
}
private List<MesCimSeresSrmRunSheetJis> getCimSeresSrmRunSheetJisList(String organizeCode, List<String> shippingCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(shippingCodeList)) return null;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (shippingCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(shippingCodeList.get(0), "docNo", packBean);
else DdlPreparedPack.getInPackList(shippingCodeList, "docNo", packBean);
return cimSeresSrmRunSheetJisRepository.findByHqlWhere(packBean);
}
private List<MesCimSeresSrmRunSheetJisDetail> getCimSeresSrmRunSheetJisDetailList(String organizeCode, List<Long> jisIdList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(jisIdList)) return null;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (jisIdList.size() == 1) DdlPreparedPack.getNumEqualPack(jisIdList.get(0), MesPcnExtConstWords.PID, packBean);
else DdlPreparedPack.getInPackList(jisIdList, MesPcnExtConstWords.PID, packBean);
return cimSeresSrmRunSheetJisDetailRepository.findByHqlWhere(packBean);
}
}

@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
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.Arrays;
import java.util.List;
@ -47,6 +48,7 @@ public abstract class SortShippingDispatchStrategyService implements ISortShippi
@Override
public List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(idList)) return null;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (idList.size() == 1) DdlPreparedPack.getNumEqualPack(idList.get(0), MesPcnExtConstWords.PID, packBean);
else DdlPreparedPack.getInPackList(idList, MesPcnExtConstWords.PID, packBean);
@ -56,6 +58,7 @@ public abstract class SortShippingDispatchStrategyService implements ISortShippi
@Override
public void saveShippingOrderManagementList(List<MesShippingOrderManagement> shippingOrderManagementList) {
if (CollectionUtils.isEmpty(shippingOrderManagementList)) return;
shippingOrderManagementRepository.saveAll(shippingOrderManagementList);
}

@ -128,12 +128,14 @@ public class WuhuSortShippingPrintStrategyService extends SortShippingDispatchSt
}
private List<MesCimCheryOrder> getCheryOrder(String organizeCode, String sheetNo) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(sheetNo)) return null;
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(sheetNo, "sheetNo", ddlPackBean);
return cimCheryOrderRepository.findByHqlWhere(ddlPackBean);
}
private String getWorkshopName(String organizeCode, String workshopNo) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workshopNo)) return null;
MesConfig config = configService.getMesConfigNoError(organizeCode, workshopNo);
return (null == config || StringUtils.isEmpty(config.getCfgValue())) ? MesPcnExtConstWords.EMPTY : config.getCfgValue();
}

@ -0,0 +1,112 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.springframework.util.CollectionUtils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Description : MODEL
**/
@Data
public class MesSortShippingPrintForCqLxModel implements Serializable {
private static final long serialVersionUID = -4576439891171509409L;
@ApiParam("流水线")
private String flowLine;
@ApiParam("流水线")
private String docNo;
@ApiParam("拉动单号后四位")
private String carsNo;
@ApiParam("拉动单号除后四位")
private String docNoOther;
@ApiParam("零件类")
private String partClassCode;
@ApiParam("零件类名称")
private String partClassName;
@ApiParam("供应商代码")
private String jisProviderCode;
@ApiParam("线边库位")
private String lineLocation;
@ApiParam("DOCK")
private String dock;
@ApiParam("开始车号")
private String beginNumber;
@ApiParam("结束车号")
private String endNumber;
@ApiParam("单据生成时间")
private String jisCreationtime;
@ApiParam("挑选完成时间")
private String pickingOverTime;
@ApiParam("预计出发时间")
private String goOutTime;
@ApiParam("预计到达时间")
private String goToTime;
@ApiParam("第一个表格")
private List<MesSortShippingPrintForCqLxModel> jisDetailList;
@ApiParam("序号")
private Integer xh;
@ApiParam("物料编码")
private String materielCode;
@ApiParam("车型颜色")
private String modelColor;
@ApiParam("用量")
private Double useQty;
@ApiParam("流水号")
private String serialNumber;
@ApiParam("VIN码")
private String vin;
@ApiParam("厂家代码")
private String factoryCode;
@ApiParam("第二个表格")
private List<MesSortShippingPrintForCqLxModel> amountList;
@ApiParam("零件号")
private String partNo;
@ApiParam("数量")
private Double amountQty;
@ApiParam("单元格")
private String appendRows;
@ApiParam("物料名称")
private String materielNames;
public void addJisDetail(MesSortShippingPrintForCqLxModel jisDetail) {
if (CollectionUtils.isEmpty(jisDetailList)) jisDetailList = new ArrayList<>();
jisDetailList.add(jisDetail);
}
public void addAmount(MesSortShippingPrintForCqLxModel amount) {
if (CollectionUtils.isEmpty(amountList)) amountList = new ArrayList<>();
amountList.add(amount);
}
}
Loading…
Cancel
Save