You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
i3plus-mes-yfai/modules/i3plus-ext-mes-apiservice/src/groovy/Mes2Pisces/MesToPiscesMesShippingDetai...

80 lines
3.6 KiB
Groovy

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import cn.estsh.i3plus.pojo.base.bean.DdlPackBean
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement
import cn.estsh.i3plus.pojo.mes.dbinterface.MesInterfaceDataMapper
import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository
import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementRepository
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.util.StringUtils
/**
* @Description : MES2PISCES 发运单明细
* @Reference :
* @Author : gsz
* @CreateDate 2024/7/14 10:59
* @Modify:
* */
class MesToPiscesMesShippingDetail {
public static final Logger LOGGER = LoggerFactory.getLogger(MesToPiscesMesShippingDetail.class)
@Autowired
private MesProduceSnRepository mesProduceSnRepository;
@Autowired
private MesShippingOrderManagementRepository mesShippingRepository;
def filterData(MesInterfaceDataMapper mapper, List<Map<String, Object>> srcData) throws Exception {
if (srcData == null || srcData.size() == 0) {
return srcData
}
Map<String, MesProduceSn> mesProduceSnMap = new HashMap<>();
Map<Long, MesShippingOrderManagement> mesProductionRecordMap = new HashMap<>();
String organizeCode = mapper.getOrganizeCode();
for (Map<String, Object> rowMap : srcData) {
//条码ID
if (!StringUtils.isEmpty(rowMap.get("bar_code"))) {
MesProduceSn mesProduceSn = getMesProduceSn(organizeCode, String.valueOf(rowMap.get("bar_code")), mesProduceSnMap)
if (!Objects.isNull(mesProduceSn)) {
rowMap.put("BARCODE_ID", mesProduceSn.getId())
} else {
rowMap.put("BARCODE_ID", null)
LOGGER.info("条码:{}信息不存在", String.valueOf(rowMap.get("bar_code")))
}
}else{
rowMap.put("BARCODE_ID", null)
}
//发运单
if (!StringUtils.isEmpty(rowMap.get("pid"))) {
long id = Long.parseLong(String.valueOf(rowMap.get("pid")));
if (Objects.isNull(mesProductionRecordMap) || !mesProductionRecordMap.containsKey(id)) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode)
DdlPreparedPack.getNumEqualPack(id,"id",packBean)
mesProductionRecordMap.put(id, mesShippingRepository.getByProperty(packBean))
}
MesShippingOrderManagement mesProductionRecord = mesProductionRecordMap.get(id)
if (!Objects.isNull(mesProductionRecord)) {
rowMap.put("SHIPPING_FID", mesProductionRecord.getFid())
} else {
rowMap.put("SHIPPING_FID", null)
LOGGER.info("发运单id{},信息不存在", String.valueOf(rowMap.get("pid")))
}
}else{
rowMap.put("SHIPPING_FID", null)
}
}
return srcData;
}
private MesProduceSn getMesProduceSn(String organizeCode, String sn, Map<String, MesProduceSn> mesProduceSnMap) {
if (Objects.isNull(mesProduceSnMap) || !mesProduceSnMap.containsKey(sn)) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(sn, "productSn", ddlPackBean);
mesProduceSnMap.put(sn, mesProduceSnRepository.getByProperty(ddlPackBean))
}
return mesProduceSnMap.get(sn);
}
}