|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.apiservice.serviceimpl.base;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.api.base.IMesEquipmentSpotCheckDetailService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.config.AuthUtilExt;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.apiservice.utils.BeanMapUtilsExt;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
@ -8,15 +10,21 @@ import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.util.StringUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheck;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheckDetail;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentSpotCheckPart;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentSpotCheckRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentVariableRepository;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
@ -24,6 +32,10 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesEquipmentSpotCheckRepository equipmentSpotCheckRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesEquipmentVariableRepository mesEquipmentVariableRepository;
|
|
|
|
|
|
|
|
|
|
protected void setPackQueryBean(MesEquipmentSpotCheckDetail bean, DdlPackBean packBean) {
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(bean.getPid(), "pid", packBean);
|
|
|
|
|
DdlPreparedPack.getStringLikerPack(bean.getSpotCheckItemCode(), "spotCheckItemCode", packBean);
|
|
|
|
@ -91,7 +103,9 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public List<MesEquipmentSpotCheckDetail> validateReturnImport(List<MesEquipmentSpotCheckDetail> beanList) {
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(beanList)) return beanList;
|
|
|
|
|
//设备变量MAP
|
|
|
|
|
Map<String, MesEquipmentVariable> variableMap = getEquipmentVariableMap(beanList);
|
|
|
|
|
for (MesEquipmentSpotCheckDetail item : beanList) {
|
|
|
|
|
// 数据校验
|
|
|
|
|
if(StringUtil.isEmpty(item.getPid())){
|
|
|
|
@ -123,7 +137,29 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//实际值地址id
|
|
|
|
|
if (!Objects.isNull(variableMap) && !StringUtil.isEmpty(item.getRealValueAddress()) && variableMap.containsKey(item.getRealValueAddress())) {
|
|
|
|
|
item.setRealEquipVariableId(variableMap.get(item.getRealValueAddress()).getId());
|
|
|
|
|
item.setRealEquipId(variableMap.get(item.getRealValueAddress()).getEquipId().longValue());
|
|
|
|
|
}
|
|
|
|
|
//设定值地址id
|
|
|
|
|
if (!Objects.isNull(variableMap) && !StringUtil.isEmpty(item.getSetValueAddress()) && variableMap.containsKey(item.getSetValueAddress())) {
|
|
|
|
|
item.setSetEquipVariableId(variableMap.get(item.getSetValueAddress()).getId());
|
|
|
|
|
item.setSetEquipId(variableMap.get(item.getSetValueAddress()).getEquipId().longValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return beanList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<String, MesEquipmentVariable> getEquipmentVariableMap(List<MesEquipmentSpotCheckDetail> beanList) {
|
|
|
|
|
String organizeCode = AuthUtilExt.getOrganizeCode();
|
|
|
|
|
List<String> addressList = new ArrayList<>();
|
|
|
|
|
//查询设备变量信息
|
|
|
|
|
List<String> realAddress = beanList.stream().map(MesEquipmentSpotCheckDetail::getRealValueAddress).distinct().collect(Collectors.toList());
|
|
|
|
|
List<String> setAddress = beanList.stream().map(MesEquipmentSpotCheckDetail::getSetValueAddress).distinct().collect(Collectors.toList());
|
|
|
|
|
if (!CollectionUtils.isEmpty(realAddress)) addressList.addAll(realAddress);
|
|
|
|
|
if (!CollectionUtils.isEmpty(setAddress)) addressList.addAll(setAddress);
|
|
|
|
|
if (CollectionUtils.isEmpty(addressList)) return null;
|
|
|
|
|
return BeanMapUtilsExt.getBeanMap(mesEquipmentVariableRepository, "tagAddress", organizeCode, addressList, "设备变量");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|