forked from I3-YF/i3plus-mes-yfai
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.
54 lines
2.3 KiB
Groovy
54 lines
2.3 KiB
Groovy
10 months ago
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean
|
||
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack
|
||
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipment
|
||
|
import cn.estsh.i3plus.pojo.mes.dbinterface.MesInterfaceDataMapper
|
||
|
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentRepository
|
||
|
import org.slf4j.Logger
|
||
|
import org.slf4j.LoggerFactory
|
||
|
import org.springframework.beans.factory.annotation.Autowired
|
||
|
import org.springframework.util.StringUtils
|
||
|
|
||
|
/**
|
||
|
* @Description : 装配件绑定记录表
|
||
|
* @Reference :
|
||
|
* @Author : junsheng.li
|
||
|
* @CreateDate 2024/7/13 17:59
|
||
|
* @Modify:
|
||
|
* */
|
||
|
class PiscesToMesProductionAssembly {
|
||
|
|
||
|
public static final Logger LOGGER = LoggerFactory.getLogger(PiscesToMesProductionAssembly.class)
|
||
|
|
||
|
@Autowired
|
||
|
private MesEquipmentRepository mesEquipmentRepository;
|
||
|
|
||
|
def filterData(MesInterfaceDataMapper mapper, List<Map<String, Object>> srcData) throws Exception {
|
||
|
if (srcData == null || srcData.size() == 0) {
|
||
|
return srcData
|
||
|
}
|
||
|
Map<String, MesEquipment> mesEquipmentMap = new HashMap<>();
|
||
|
String organizeCode = mapper.getOrganizeCode();
|
||
|
for (Map<String, Object> rowMap : srcData) {
|
||
|
//获取设备名称&设备代码
|
||
|
if (!StringUtils.isEmpty(rowMap.get("EQUIPMENT_FID"))) {
|
||
|
MesEquipment mesEquipment = getMesEquipment(organizeCode, String.valueOf(rowMap.get("EQUIPMENT_FID")), mesEquipmentMap)
|
||
|
if (!Objects.isNull(mesEquipment)) {
|
||
|
rowMap.put("EQUIPMENT_CODE", mesEquipment.getEquipmentCode())
|
||
|
rowMap.put("EQUIPMENT_NAME", mesEquipment.getEquipmentName())
|
||
|
} else {
|
||
|
LOGGER.info("EQUIPMENT_FID:{}信息不存在", String.valueOf(rowMap.get("EQUIPMENT_FID")))
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return srcData;
|
||
|
}
|
||
|
|
||
|
private MesEquipment getMesEquipment(String organizeCode, String equipmentFid, Map<String, MesEquipment> mesEquipmentMap) {
|
||
|
if (Objects.isNull(mesEquipmentMap) || !mesEquipmentMap.containsKey(equipmentFid)) {
|
||
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
||
|
DdlPreparedPack.getStringEqualPack(equipmentFid, "fid", ddlPackBean);
|
||
|
mesEquipmentMap.put(equipmentFid, mesEquipmentRepository.getByProperty(ddlPackBean))
|
||
|
}
|
||
|
return mesEquipmentMap.get(equipmentFid);
|
||
|
}
|
||
|
}
|