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/MesToPiscesMesLoadingListDe...

73 lines
3.2 KiB
Groovy

import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesLoadingList
import cn.estsh.i3plus.pojo.mes.dbinterface.MesInterfaceDataMapper
import cn.estsh.i3plus.pojo.mes.repository.MesLoadingListRepository
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 MesToPiscesMesLoadingListDetail {
public static final Logger LOGGER = LoggerFactory.getLogger(MesToPiscesMesLoadingListDetail.class)
@Autowired
private MesLoadingListRepository mesLoadingListRepository;
@Autowired
private MesShippingOrderManagementRepository mesShippingRepository;
def filterData(MesInterfaceDataMapper mapper, List<Map<String, Object>> srcData) throws Exception {
if (srcData == null || srcData.size() == 0) {
return srcData
}
Map<Long, MesShippingOrderManagement> mesProductionRecordMap = new HashMap<>();
Map<Long, MesLoadingList> mesLoadingListMap = new HashMap<>();
for (Map<String, Object> rowMap : srcData) {
//发运单
if (!StringUtils.isEmpty(rowMap.get("shipping_id"))) {
long shippingId = Long.parseLong(String.valueOf(rowMap.get("shipping_id")));
if (Objects.isNull(mesProductionRecordMap) || !mesProductionRecordMap.containsKey(shippingId)) {
mesProductionRecordMap.put(shippingId, mesShippingRepository.getById(shippingId))
}
MesShippingOrderManagement mesProductionRecord = mesProductionRecordMap.get(shippingId)
if (!Objects.isNull(mesProductionRecord)) {
rowMap.put("SHIPPING_FID", mesProductionRecord.getFid())
} else {
rowMap.put("SHIPPING_FID", null)
LOGGER.info("发运单id{},信息不存在", String.valueOf(rowMap.get(rowMap.get("shipping_id"))))
}
}else{
rowMap.put("SHIPPING_FID", null)
}
//装车单
if (!StringUtils.isEmpty(rowMap.get("pid"))) {
long id = Long.parseLong(String.valueOf(rowMap.get("pid")));
if (Objects.isNull(mesLoadingListMap) || !mesLoadingListMap.containsKey(id)) {
mesLoadingListMap.put(id, mesLoadingListRepository.getById(id))
}
MesLoadingList mesLoadingList = mesLoadingListMap.get(id)
if (!Objects.isNull(mesLoadingList)) {
rowMap.put("LOADING_LIST_FID", mesLoadingList.getFid())
} else {
rowMap.put("LOADING_LIST_FID", null)
LOGGER.info("装车id{},信息不存在", String.valueOf(rowMap.get(rowMap.get("pid"))))
}
}else{
rowMap.put("LOADING_LIST_FID", null)
}
}
return srcData;
}
}