|
|
|
@ -3,6 +3,7 @@ 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.ext.mes.apiservice.utils.MesException;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
@ -16,15 +17,13 @@ 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.apache.commons.beanutils.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.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@ -105,10 +104,10 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public List<MesEquipmentSpotCheckDetail> validateReturnImport(List<MesEquipmentSpotCheckDetail> beanList) {
|
|
|
|
|
public List<MesEquipmentSpotCheckDetail> validateReturnImport(List<MesEquipmentSpotCheckDetail> beanList, String equipmentCode) {
|
|
|
|
|
if (CollectionUtils.isEmpty(beanList)) return beanList;
|
|
|
|
|
//设备变量MAP
|
|
|
|
|
Map<String, MesEquipmentVariable> variableMap = getEquipmentVariableMap(beanList);
|
|
|
|
|
Map<String, MesEquipmentVariable> variableMap = getEquipmentVariableMap(beanList, equipmentCode);
|
|
|
|
|
for (MesEquipmentSpotCheckDetail item : beanList) {
|
|
|
|
|
// 数据校验
|
|
|
|
|
if(StringUtil.isEmpty(item.getPid())){
|
|
|
|
@ -154,8 +153,10 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
|
|
|
|
|
return beanList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<String, MesEquipmentVariable> getEquipmentVariableMap(List<MesEquipmentSpotCheckDetail> beanList) {
|
|
|
|
|
private Map<String, MesEquipmentVariable> getEquipmentVariableMap(List<MesEquipmentSpotCheckDetail> beanList, String equipmentCode) {
|
|
|
|
|
String organizeCode = AuthUtilExt.getOrganizeCode();
|
|
|
|
|
//String organizeCode = "CK01";
|
|
|
|
|
|
|
|
|
|
List<String> addressList = new ArrayList<>();
|
|
|
|
|
//查询设备变量信息
|
|
|
|
|
List<String> realAddress = beanList.stream().map(MesEquipmentSpotCheckDetail::getRealValueAddress).filter(t-> !StringUtils.isEmpty(t)).distinct().collect(Collectors.toList());
|
|
|
|
@ -163,6 +164,19 @@ public class MesEquipmentSpotCheckDetailService extends BaseMesService<MesEquipm
|
|
|
|
|
if (!CollectionUtils.isEmpty(realAddress)) addressList.addAll(realAddress);
|
|
|
|
|
if (!CollectionUtils.isEmpty(setAddress)) addressList.addAll(setAddress);
|
|
|
|
|
if (CollectionUtils.isEmpty(addressList)) return null;
|
|
|
|
|
return BeanMapUtilsExt.getBeanMap(mesEquipmentVariableRepository, "tagName", organizeCode, addressList, "设备变量");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, MesEquipmentVariable> beanMap = new HashMap();
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getInPackList(addressList, "tagName", packBean);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(equipmentCode, "equipmentCode", packBean);
|
|
|
|
|
List<MesEquipmentVariable> baseDataList = mesEquipmentVariableRepository.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(baseDataList)) {
|
|
|
|
|
beanMap = baseDataList.stream().collect(Collectors.toMap(mesEquipmentVariable -> mesEquipmentVariable.getTagName(), o-> o));
|
|
|
|
|
} else {
|
|
|
|
|
MesException.throwMesBusiException(addressList + "信息不存在");
|
|
|
|
|
}
|
|
|
|
|
return beanMap;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|