合并代码冲突问题

tags/yfai-pcn-ext-v2.5
xiangwei.zhang 5 months ago
parent b775ab0fa1
commit a611078a51

@ -11,6 +11,7 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSpotCheckOrderModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.icloud.core.sdk.ICoreUtilCloud;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
import cn.estsh.i3plus.mes.pcn.util.DateUtil;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
@ -29,7 +30,6 @@ import cn.estsh.impp.framework.boot.exception.ImppBusiException;
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.collections.map.HashedMap;
import org.apache.commons.collections4.ListUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -39,6 +39,7 @@ import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description :
@ -86,13 +87,16 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
@Autowired
private MesEquipmentRepository mesEquipmentRepository;
@Autowired
private MesEquipmentSpotCheckTagRepository mesEquipmentSpotCheckTagRepository;
@Override
public ListPager<MesSpotCheckOrder> querySpotCheckOrder(MesSpotCheckOrder spotCheckOrder, Pager pager) {
DdlPackBean packBean = getDdlPackBean(spotCheckOrder);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
pager = PagerHelper.getPager(pager, spotCheckOrderRepository.findByHqlWhereCount(packBean));
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue(),CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"status","createDatetime"}, packBean);
List<MesSpotCheckOrder> resultList = spotCheckOrderRepository.findByHqlWherePage(packBean, pager);
if (CollectionUtils.isEmpty(resultList)) {
return new ListPager<>(resultList, pager);
@ -203,16 +207,19 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
//校验点检单
checkSpotCheckOrder(model.getSpotCheckOrder());
//点检单类型为产品首检时 需要判断单据的条码是否都扫描完成
if (model.getSpotCheckOrder().getSpotCheckOrderType() == MesExtEnumUtil.SPOT_CHECK_ORDER_TYPE.FIRST_PRODUCT_INSPECTION.getValue()) {
List<String> partNoList = model.getOrderPartList().stream().filter(k -> StringUtils.isEmpty(k.getSn())).map(k -> k.getPartNo()).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(partNoList)) {
throw new ImppBusiException(String.format("剩余物料号【%s】对应的条码未扫描请扫描完成后再完成质检", partNoList));
//点检单类型为产品首检,产品末检时 需要判断单据的条码是否都扫描完成
if (Stream.of(MesExtEnumUtil.EQUIPMENT_CHECK_ORDER_TYPE.FIRST_INSPECTION.getValue(),MesExtEnumUtil.EQUIPMENT_CHECK_ORDER_TYPE.END_INSPECTION.getValue()).collect(Collectors.toList()).contains(model.getSpotCheckOrder().getSpotCheckOrderType())) {
Optional<MesSpotCheckOrderPart> orderPartOptional = model.getOrderPartList().stream().filter(k -> !StringUtils.isEmpty(k.getSn())).findFirst();
if (!orderPartOptional.isPresent()) {
throw new ImppBusiException("未扫描条码,请扫描条码后再查询设备数据,请检查数据");
}
}
//根据设备代码获取EQUIP_ID
MesEquipment mesEquipment = mesEquipmentExtService.getMesEquipment(org, model.getSpotCheckOrder().getEquipCode());
//是否允许开始点检
allowSpotCheckOrder(model.getSpotCheckOrder(), org, mesEquipment.getEquipId());
Map<Long, List<MesEquipVariableCollectContext>> setMap = null;
//实际值地址数据Map
Map<Long, List<MesEquipVariableCollectContext>> realMap = null;
@ -230,13 +237,19 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
//获取设定值设备数据
List<MesEquipVariableCollectContext> setEquipmentLogList = new ArrayList<>();
for (List<Long> tmp : ListUtils.partition(setEquipVariableIdList, MesCommonConstant.MAX_PAGER_SIZE)) {
setEquipmentLogList.addAll(mesEquipmentLogExtService.getEquipmentLogCollectList(org, mesEquipment.getEquipId(), MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue(), MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PROCESS_FINISH.getValue(), tmp));
List<MesEquipVariableCollectContext> equipmentLogCollectList = mesEquipmentLogExtService.getEquipmentLogCollectList(org, mesEquipment.getEquipId(), MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue(), MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PROCESS_FINISH.getValue(), tmp);
if(!CollectionUtils.isEmpty(equipmentLogCollectList)){
setEquipmentLogList.addAll(equipmentLogCollectList);
}
}
//设定值地址数据Map
setMap = setEquipmentLogList.stream().collect(Collectors.groupingBy(MesEquipVariableCollectContext::getEquipVariableId));
for (List<Long> tmp : ListUtils.partition(realEquipVariableIdList, MesCommonConstant.MAX_PAGER_SIZE)) {
realEquipmentLogList.addAll(mesEquipmentLogExtService.getEquipmentLogCollectList(org,mesEquipment.getEquipId(), MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue(), MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PROCESS_FINISH.getValue(), tmp));
List<MesEquipVariableCollectContext> equipmentLogCollectList = mesEquipmentLogExtService.getEquipmentLogCollectList(org, mesEquipment.getEquipId(), MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue(), MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PROCESS_FINISH.getValue(), tmp);
if(!CollectionUtils.isEmpty(equipmentLogCollectList)){
realEquipmentLogList.addAll(equipmentLogCollectList);
}
}
//实际值地址数据Map
realMap = realEquipmentLogList.stream().collect(Collectors.groupingBy(MesEquipVariableCollectContext::getEquipVariableId));
@ -298,12 +311,11 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
//校验点检单
MesSpotCheckOrder spotCheckOrder = checkSpotCheckOrder(model.getSpotCheckOrder());
//点检单类型为产品首检时 需要判断单据的条码是否都扫描完成
if (model.getSpotCheckOrder().getSpotCheckOrderType() == MesExtEnumUtil.SPOT_CHECK_ORDER_TYPE.FIRST_PRODUCT_INSPECTION.getValue()) {
List<String> partNoList = model.getOrderPartList().stream().filter(k -> StringUtils.isEmpty(k.getSn())).map(k -> k.getPartNo()).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(partNoList)) {
throw new ImppBusiException(String.format("剩余物料号【%s】对应的条码未扫描请扫描完成后再完成质检", partNoList));
//点检单类型为产品首检,产品末检时 需要判断单据的条码是否都扫描完成
if (Stream.of(MesExtEnumUtil.EQUIPMENT_CHECK_ORDER_TYPE.FIRST_INSPECTION.getValue(),MesExtEnumUtil.EQUIPMENT_CHECK_ORDER_TYPE.END_INSPECTION.getValue()).collect(Collectors.toList()).contains(model.getSpotCheckOrder().getSpotCheckOrderType())) {
Optional<MesSpotCheckOrderPart> orderPartOptional = model.getOrderPartList().stream().filter(k -> !StringUtils.isEmpty(k.getSn())).findFirst();
if (!orderPartOptional.isPresent()) {
throw new ImppBusiException("未扫描条码,请扫描条码后再查询设备数据,请检查数据");
}
}
model.getOrderPartList().forEach(k -> {
@ -593,15 +605,13 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
}
private DdlPackBean getDdlPackBean(MesSpotCheckOrder spotCheckOrder) {
List<Integer> statusList = new ArrayList<>();
statusList.add(MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.CREATE.getValue());
statusList.add(MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.COMPLETE.getValue());
String createDateTime = TimeTool.pareDateToString(DateUtil.addDays(new Date(), -(Objects.isNull(spotCheckOrder.getDays()) ? MesPcnExtConstWords.SEVEN : spotCheckOrder.getDays())));
DdlPackBean packBean = DdlPackBean.getDdlPackBean(spotCheckOrder.getOrganizeCode());
DdlPreparedPack.getStringLikerPack(spotCheckOrder.getWorkCenterCode(), "workCenterCode", packBean);
DdlPreparedPack.getStringLikerPack(spotCheckOrder.getWorkCellCode(), "workCellCode", packBean);
DdlPreparedPack.getStringLikerPack(spotCheckOrder.getSpotCheckOrderNo(), "spotCheckOrderNo", packBean);
DdlPreparedPack.getInPackList(statusList, "status", packBean);
DdlPreparedPack.getStringEqualPack(spotCheckOrder.getEquipCode(), "equipCode", packBean);
packBean.setWhereAppend(packBean.getWhereAppend() + String.format(" and (model.status = %s or (model.status = %s and model.createDatetime >= '%s'))", MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.CREATE.getValue(), MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.COMPLETE.getValue(), createDateTime));
return packBean;
}
@ -665,5 +675,22 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
}
}
private void allowSpotCheckOrder(MesSpotCheckOrder spotCheckOrder, String org, Integer equipId) {
if(Objects.isNull(spotCheckOrder) || StringUtils.isEmpty(spotCheckOrder.getSpotCheckCode()) || StringUtils.isEmpty(org)){
return;
}
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
DdlPreparedPack.getStringEqualPack(spotCheckOrder.getSpotCheckCode(),"spotCheckCode",packBean);
MesEquipmentSpotCheckTag equipmentSpotCheckTag = mesEquipmentSpotCheckTagRepository.getByProperty(packBean);
if(Objects.isNull(equipmentSpotCheckTag)){
return;
}
List<MesEquipVariableCollectContext> equipmentLogCollectList = mesEquipmentLogExtService.getEquipmentLogCollectList(org, equipId, MesExtEnumUtil.EQUIP_VARIABLE_NEED_NEW_VALUE.TRUE.getValue(), MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PROCESS_FINISH.getValue(), Stream.of(equipmentSpotCheckTag.getEquipVariableId()).collect(Collectors.toList()));
if(CollectionUtils.isEmpty(equipmentLogCollectList)){
throw new ImppBusiException(String.format("点检项目代码【%s】设备地址【%s】未查询到设备返回值请检查数据", spotCheckOrder.getSpotCheckCode(),equipmentSpotCheckTag.getTagName()));
}
if (!equipmentLogCollectList.iterator().next().getEquipVariableValue().equals(equipmentSpotCheckTag.getSuccessValue())) {
throw new ImppBusiException(String.format("点检项目代码【%s】设备地址【%s】设备返回值【%s】与理论成功值【%s】不匹配请检查数据", spotCheckOrder.getSpotCheckCode(),equipmentSpotCheckTag.getTagName(),equipmentLogCollectList.iterator().next().getEquipVariableValue(),equipmentSpotCheckTag.getSuccessValue()));
}
}
}

Loading…
Cancel
Save