forked from I3-YF/i3plus-mes-yfai
龙兴发运单
parent
87e3a192a2
commit
12402b188c
@ -0,0 +1,57 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.controller.base;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.api.base.IMesConfigService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.api.base.IMesLabelTemplateService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.constant.MesCommonConstant;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
||||||
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Api("获取系统配置的模版信息")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(MesCommonConstant.MES_YANFEN)
|
||||||
|
public class MesLabelTemplateExtController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesConfigService configService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesLabelTemplateService labelTemplateService;
|
||||||
|
|
||||||
|
@GetMapping("/label-template/by-module-or-template/get")
|
||||||
|
@ApiOperation(value = "获取系统配置的模版信息")
|
||||||
|
public ResultBean queryMesLabelTemplate(String organizeCode, String moduleCode, String templateCode) {
|
||||||
|
try {
|
||||||
|
ValidatorBean.checkNotNull(organizeCode, "工厂代码不能为空");
|
||||||
|
if (StringUtils.isEmpty(moduleCode) && StringUtils.isEmpty(templateCode)) {
|
||||||
|
ValidatorBean.checkNotNull(moduleCode, "模版配置代码不能为空");
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(moduleCode)) {
|
||||||
|
Map<String, String> configMap = configService.getConfigMapByCfgCode(moduleCode, organizeCode);
|
||||||
|
String templateCustomHtml = configMap.get(MesExtConstWords.TEMPLATE_CUSTOM_HTML);
|
||||||
|
if (!StringUtils.isEmpty(templateCustomHtml)) return ResultBean.success("查询成功").setResultObject(templateCustomHtml);
|
||||||
|
String templateCfg = configMap.get(moduleCode);
|
||||||
|
if (!StringUtils.isEmpty(templateCfg)) templateCode = templateCfg;
|
||||||
|
}
|
||||||
|
ValidatorBean.checkNotNull(templateCode, "模版代码不能为空");
|
||||||
|
return ResultBean.success("查询成功").setResultObject(labelTemplateService.getLabelTemplate(templateCode, organizeCode));
|
||||||
|
|
||||||
|
} catch (ImppBusiException imppException) {
|
||||||
|
return ResultBean.fail(imppException);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.print.sortshipping;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 排序发运处理接口
|
||||||
|
**/
|
||||||
|
public interface ISortShippingDispatchStrategyService {
|
||||||
|
|
||||||
|
default List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
default void saveShippingOrderManagementList(List<MesShippingOrderManagement> pullingOrderInfos) {}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,153 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.print.sortshipping.strategy;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.model.MesSortShippingPrintForCqLxModel;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
|
||||||
|
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.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 重庆龙兴发运单
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class CqCxSortShippingPrintStrategyService extends SortShippingDispatchStrategyService implements IPrintTemplateStrategyService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesCimSeresSrmRunSheetJisRepository cimSeresSrmRunSheetJisRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesCimSeresSrmRunSheetJisDetailRepository cimSeresSrmRunSheetJisDetailRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
|
||||||
|
return super.getShippingOrderManagementDetailList(organizeCode, idList, obj, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveShippingOrderManagementList(List<MesShippingOrderManagement> shippingOrderManagementList) {
|
||||||
|
super.saveShippingOrderManagementList(shippingOrderManagementList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultBean execute(String organizeCode, String userName, List<MesShippingOrderManagement> shippingOrderManagementList) {
|
||||||
|
|
||||||
|
List<MesSortShippingPrintForCqLxModel> resultList = new ArrayList<>();
|
||||||
|
|
||||||
|
List<String> shippingCodeList = shippingOrderManagementList.stream().map(MesShippingOrderManagement::getShippingCode).collect(Collectors.toList());
|
||||||
|
List<MesCimSeresSrmRunSheetJis> cimSeresSrmRunSheetJisList = getCimSeresSrmRunSheetJisList(organizeCode, 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单信息:{}条 --- {}", organizeCode,
|
||||||
|
CollectionUtils.isEmpty(cimSeresSrmRunSheetJisList) ? MesExtConstWords.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(organizeCode, 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单详情信息:{}条 --- {}", organizeCode,
|
||||||
|
CollectionUtils.isEmpty(cimSeresSrmRunSheetJisDetailList) ? MesExtConstWords.ZERO : cimSeresSrmRunSheetJisDetailList.size(), Thread.currentThread().getName());
|
||||||
|
|
||||||
|
//遍历处理每个发运单主表
|
||||||
|
for (MesShippingOrderManagement shippingOrderManagement : shippingOrderManagementList) {
|
||||||
|
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);
|
||||||
|
result.setRePrintDatetime(TimeTool.getNowTime(MesExtConstWords.DATETIME_FORMAT_SINGLE_SLASH));
|
||||||
|
result.setRePrintUser(userName);
|
||||||
|
result.setIsRePrint("重打印");
|
||||||
|
result.setShippingCode(shippingOrderManagement.getShippingCode());
|
||||||
|
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 = MesExtConstWords.ONE;
|
||||||
|
for (MesCimSeresSrmRunSheetJisDetail cimSeresSrmRunSheetJisDetail : sheetJisDetailList) {
|
||||||
|
if (null == cimSeresSrmRunSheetJisDetail) continue;
|
||||||
|
MesSortShippingPrintForCqLxModel jisDetail = new MesSortShippingPrintForCqLxModel();
|
||||||
|
BeanUtils.copyProperties(cimSeresSrmRunSheetJisDetail, jisDetail);
|
||||||
|
//跟cc确认过可以直接写死
|
||||||
|
jisDetail.setFactoryCode("000003263");
|
||||||
|
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(MesExtConstWords.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()) ? MesExtConstWords.ONE : shippingOrderManagement.getPrintCount() + MesExtConstWords.ONE);
|
||||||
|
shippingOrderManagement.setLastPrintTime(TimeTool.getNowTime(true));
|
||||||
|
shippingOrderManagement.setLastPrintUser(userName);
|
||||||
|
ConvertBean.serviceModelUpdate(shippingOrderManagement, userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveShippingOrderManagementList(shippingOrderManagementList);
|
||||||
|
|
||||||
|
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), MesExtConstWords.PID, packBean);
|
||||||
|
else DdlPreparedPack.getInPackList(jisIdList, MesExtConstWords.PID, packBean);
|
||||||
|
return cimSeresSrmRunSheetJisDetailRepository.findByHqlWhere(packBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.print.sortshipping.strategy;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.print.sortshipping.ISortShippingDispatchStrategyService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||||
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
||||||
|
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.MesShippingOrderManagementDetailRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementRepository;
|
||||||
|
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.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 发运单查询
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public abstract class SortShippingDispatchStrategyService implements ISortShippingDispatchStrategyService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public MesShippingOrderManagementRepository shippingOrderManagementRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public MesShippingOrderManagementDetailRepository shippingOrderManagementDetailRepository;
|
||||||
|
|
||||||
|
@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), MesExtConstWords.PID, packBean);
|
||||||
|
else DdlPreparedPack.getInPackList(idList, MesExtConstWords.PID, packBean);
|
||||||
|
if (null != obj && null != str) DdlPreparedPack.getOrderByPack(obj, str, packBean);
|
||||||
|
return shippingOrderManagementDetailRepository.findByHqlWhere(packBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveShippingOrderManagementList(List<MesShippingOrderManagement> shippingOrderManagementList) {
|
||||||
|
if (CollectionUtils.isEmpty(shippingOrderManagementList)) return;
|
||||||
|
shippingOrderManagementRepository.saveAll(shippingOrderManagementList);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,137 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.print.sortshipping.strategy;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.api.base.IMesConfigService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
|
||||||
|
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.CommonEnumUtil;
|
||||||
|
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.MesConfig;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.edi.wuhu.MesCimCheryOrder;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementDetailModel;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementModel;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.repository.MesCimCheryOrderRepository;
|
||||||
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
||||||
|
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.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description : 芜湖发运单
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class WuhuSortShippingPrintStrategyService extends SortShippingDispatchStrategyService implements IPrintTemplateStrategyService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IMesConfigService configService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MesCimCheryOrderRepository cimCheryOrderRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
|
||||||
|
return super.getShippingOrderManagementDetailList(organizeCode, idList, obj, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveShippingOrderManagementList(List<MesShippingOrderManagement> shippingOrderManagementList) {
|
||||||
|
super.saveShippingOrderManagementList(shippingOrderManagementList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResultBean execute(String organizeCode, String userName, List<MesShippingOrderManagement> shippingOrderManagementList) {
|
||||||
|
|
||||||
|
MesConfig config = configService.getMesConfigNoError(organizeCode, "WU_HU_SUPPLIER");
|
||||||
|
String supplierNo = (null == config || StringUtils.isEmpty(config.getCfgValue())) ? MesExtConstWords.EMPTY : config.getCfgValue();
|
||||||
|
|
||||||
|
List<MesShippingOrderManagementModel> modelList = new ArrayList<>();
|
||||||
|
//把查出来的发运单打印并修改打印状态为已打印-
|
||||||
|
for (MesShippingOrderManagement shippingOrderManagement : shippingOrderManagementList) {
|
||||||
|
MesShippingOrderManagementModel model = new MesShippingOrderManagementModel();
|
||||||
|
String shippingCodePrefix = shippingOrderManagement.getShippingCode().substring(0, shippingOrderManagement.getShippingCode().length() - 3);
|
||||||
|
String shippingCodeSuffix = shippingOrderManagement.getShippingCode().substring(shippingOrderManagement.getShippingCode().length() - 3);
|
||||||
|
model.setShippingCode(shippingCodePrefix);
|
||||||
|
model.setShippingCodeAfter3(shippingCodeSuffix);
|
||||||
|
model.setShippingCodeWhole(shippingOrderManagement.getShippingCode());
|
||||||
|
|
||||||
|
//查询原始报文
|
||||||
|
List<MesCimCheryOrder> cheryOrderList = getCheryOrder(shippingOrderManagement.getOrganizeCode(), shippingOrderManagement.getShippingCode());
|
||||||
|
Map<String, List<MesCimCheryOrder>> cheryOrderMap = new HashMap<>();
|
||||||
|
if (cheryOrderList != null && !cheryOrderList.isEmpty()) {
|
||||||
|
MesCimCheryOrder cheryOrder = cheryOrderList.get(0);
|
||||||
|
model.setPlantName(cheryOrder.getPlantName());
|
||||||
|
model.setPartkitName(cheryOrder.getPartkitName());
|
||||||
|
model.setDeliverySendSequence(cheryOrder.getDeliverySendSequence());
|
||||||
|
model.setReceiveDockName(cheryOrder.getReceiveDockNo()+"--"+cheryOrder.getReceiveDockName());
|
||||||
|
model.setLastRecRequireTime(cheryOrder.getLastRecRequireTime());
|
||||||
|
//根据cheryOrder的workshopNo获取对应的车间名称
|
||||||
|
String workshopName = getWorkshopName(cheryOrder.getOrganizeCode(), cheryOrder.getWorkshopNo());
|
||||||
|
model.setWorkShop(workshopName);
|
||||||
|
model.setCreateDateTime(cheryOrder.getCreateDatetime());
|
||||||
|
model.setPrintDateTime(TimeTool.getNowTime(true));
|
||||||
|
cheryOrderMap = cheryOrderList.stream().collect(Collectors.groupingBy(MesCimCheryOrder::getVin));
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询发运单明细
|
||||||
|
List<MesShippingOrderManagementDetail> shipOrderPartInfos = getShippingOrderManagementDetailList(
|
||||||
|
organizeCode, Stream.of(shippingOrderManagement.getId()).collect(Collectors.toList()),
|
||||||
|
new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"boxNum"});
|
||||||
|
if (!CollectionUtils.isEmpty(shipOrderPartInfos)) {
|
||||||
|
List<MesShippingOrderManagementDetailModel> detailList = new ArrayList<>();
|
||||||
|
shipOrderPartInfos = shipOrderPartInfos.stream().sorted(Comparator.comparing(MesShippingOrderManagementDetail::getCustInfoSeq)).collect(Collectors.toList());
|
||||||
|
for (MesShippingOrderManagementDetail shipOrderPartInfo : shipOrderPartInfos) {
|
||||||
|
MesShippingOrderManagementDetailModel detailModel = new MesShippingOrderManagementDetailModel();
|
||||||
|
detailModel.setPartNo(shipOrderPartInfo.getPartNo());
|
||||||
|
detailModel.setPartName(shipOrderPartInfo.getPartName());
|
||||||
|
detailModel.setQty(shipOrderPartInfo.getPlanQty());
|
||||||
|
detailModel.setBoxNo(shipOrderPartInfo.getCustInfoSeq());
|
||||||
|
detailModel.setSupplierNo(supplierNo);
|
||||||
|
detailModel.setVin(shipOrderPartInfo.getVin().substring(shipOrderPartInfo.getVin().length()-8));
|
||||||
|
MesCimCheryOrder order = cheryOrderMap.get(shipOrderPartInfo.getVin()).get(0);
|
||||||
|
if (order != null) {
|
||||||
|
detailModel.setWholePartNo(order.getMaterialNo());
|
||||||
|
}
|
||||||
|
detailList.add(detailModel);
|
||||||
|
}
|
||||||
|
model.setShipOrderPartInfos(detailList);
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询原有报文 根据shippingCode;
|
||||||
|
shippingOrderManagement.setPrintCount(StringUtil.isEmpty(shippingOrderManagement.getPrintCount())?1:shippingOrderManagement.getPrintCount()+1);
|
||||||
|
shippingOrderManagement.setLastPrintTime(TimeTool.getNowTime(true));
|
||||||
|
shippingOrderManagement.setLastPrintUser(userName);
|
||||||
|
ConvertBean.serviceModelUpdate(shippingOrderManagement, userName);
|
||||||
|
modelList.add(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveShippingOrderManagementList(shippingOrderManagementList);
|
||||||
|
|
||||||
|
return ResultBean.success("发运单打印成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(modelList);
|
||||||
|
}
|
||||||
|
|
||||||
|
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())) ? MesExtConstWords.EMPTY : config.getCfgValue();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,125 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pojo.model;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pojo.util.MesExtConstWords;
|
||||||
|
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 = 8268700875815941870L;
|
||||||
|
|
||||||
|
@ApiParam("是否重打印")
|
||||||
|
private String isRePrint = MesExtConstWords.EMPTY;
|
||||||
|
|
||||||
|
@ApiParam("重打印操作人")
|
||||||
|
private String rePrintUser = MesExtConstWords.EMPTY;
|
||||||
|
|
||||||
|
@ApiParam("重打印时间")
|
||||||
|
private String rePrintDatetime = MesExtConstWords.EMPTY;
|
||||||
|
|
||||||
|
@ApiParam("发运单号")
|
||||||
|
private String shippingCode;
|
||||||
|
|
||||||
|
@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…
Reference in New Issue