|
|
|
@ -1,21 +1,36 @@
|
|
|
|
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.spot.IMesSpotCheckOrderService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSpotCheckOrderModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesSpotCheckOrder;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesSpotCheckOrderPart;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.MesSpotCheckOrderResult;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesSpotCheckOrderPartRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesSpotCheckOrderRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesSpotCheckOrderResultRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.*;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.unit.MesExtEnumUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.collections4.ListUtils;
|
|
|
|
|
import org.springframework.beans.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.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description :
|
|
|
|
@ -24,6 +39,8 @@ import java.util.List;
|
|
|
|
|
* @CreateDate : 2024-05-15 20:50
|
|
|
|
|
* @Modify:
|
|
|
|
|
**/
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@ -34,6 +51,14 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesSpotCheckOrderPartRepository spotCheckOrderPartRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesProduceSnRepository produceSnRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISyncFuncService syncFuncService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesEquipmentLogRepository equipmentLogRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ListPager<MesSpotCheckOrder> querySpotCheckOrder(MesSpotCheckOrder spotCheckOrder, Pager pager) {
|
|
|
|
|
|
|
|
|
@ -48,16 +73,246 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesSpotCheckOrderModel scanProduceSn(MesSpotCheckOrder spotCheckOrder) {
|
|
|
|
|
return null;
|
|
|
|
|
public List<MesSpotCheckOrderPart> scanProduceSn(MesSpotCheckOrderModel model, String org) {
|
|
|
|
|
|
|
|
|
|
//校验点检单
|
|
|
|
|
checkSpotCheckOrder(model.getSpotCheckOrder());
|
|
|
|
|
//检查条码
|
|
|
|
|
MesProduceSn produceSn = checkProduceSn(model.getProduceSn(), org);
|
|
|
|
|
|
|
|
|
|
boolean flg = false;
|
|
|
|
|
for (MesSpotCheckOrderPart spotCheckOrderPart : model.getOrderPartList()) {
|
|
|
|
|
|
|
|
|
|
if (spotCheckOrderPart.getPartNo().equals(produceSn.getPartNo()) && StringUtils.isEmpty(spotCheckOrderPart.getSn())) {
|
|
|
|
|
flg = true;
|
|
|
|
|
spotCheckOrderPart.setSn(model.getProduceSn());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flg) {
|
|
|
|
|
throw new ImppBusiException(String.format("扫描的条码【%s】对应的物料号【%s】在点检单中不存在", produceSn.getProductSn(), produceSn.getPartNo()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model.getOrderPartList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询点检数据
|
|
|
|
|
*
|
|
|
|
|
* @param model
|
|
|
|
|
* @param org
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public MesSpotCheckOrderModel queryEquipInfo(MesSpotCheckOrderModel model, String org) {
|
|
|
|
|
|
|
|
|
|
//点检单类型为产品首检时 需要判断单据的条码是否都扫描完成
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取设定值设备变量ID
|
|
|
|
|
List<Long> setEquipVariableIdList =
|
|
|
|
|
model.getOrderResultList().stream().filter(k -> k.getSpotCheckItemType() == MesExtEnumUtil.SPOT_CHECK_ITEM_TYPE.AUTO.getValue()).map(k -> k.getSetEquipVariableId()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
//获取实际值设备变量ID
|
|
|
|
|
List<Long> realEquipVariableIdList =
|
|
|
|
|
model.getOrderResultList().stream().filter(k -> k.getSpotCheckItemType() == MesExtEnumUtil.SPOT_CHECK_ITEM_TYPE.AUTO.getValue()).map(k -> k.getSetEquipVariableId()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
//获取设定值设备数据
|
|
|
|
|
List<MesEquipmentLog> setEquipmentLogList = new ArrayList<>();
|
|
|
|
|
for (List<Long> tmp : ListUtils.partition(setEquipVariableIdList, MesCommonConstant.MAX_PAGER_SIZE)) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getInPackList(tmp, "equipVariableId", packBean);
|
|
|
|
|
// DdlPreparedPack.getNumEqualPack(model.getSpotCheckOrder().getEquipId(), "equipId", packBean);
|
|
|
|
|
setEquipmentLogList.addAll(equipmentLogRepository.findByHqlWhere(packBean));
|
|
|
|
|
}
|
|
|
|
|
//设定值地址数据Map
|
|
|
|
|
Map<Long, List<MesEquipmentLog>> setMap = setEquipmentLogList.stream().collect(Collectors.groupingBy(k -> k.getEquipVariableId()));
|
|
|
|
|
//获取实际值值设备数据
|
|
|
|
|
List<MesEquipmentLog> realEquipmentLogList = new ArrayList<>();
|
|
|
|
|
for (List<Long> tmp : ListUtils.partition(realEquipVariableIdList, MesCommonConstant.MAX_PAGER_SIZE)) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getInPackList(tmp, "equipVariableId", packBean);
|
|
|
|
|
// DdlPreparedPack.getNumEqualPack(model.getSpotCheckOrder().getEquipId(), "equipId", packBean);
|
|
|
|
|
realEquipmentLogList.addAll(equipmentLogRepository.findByHqlWhere(packBean));
|
|
|
|
|
}
|
|
|
|
|
//实际值地址数据Map
|
|
|
|
|
Map<Long, List<MesEquipmentLog>> realMap = realEquipmentLogList.stream().collect(Collectors.groupingBy(k -> k.getEquipVariableId()));
|
|
|
|
|
|
|
|
|
|
for (MesSpotCheckOrderResult result : model.getOrderResultList()) {
|
|
|
|
|
|
|
|
|
|
//只获取自动的地址
|
|
|
|
|
if (result.getSpotCheckItemType() == MesExtEnumUtil.SPOT_CHECK_ITEM_TYPE.AUTO.getValue()) {
|
|
|
|
|
|
|
|
|
|
//获取设定值地址数据
|
|
|
|
|
if (setMap.containsKey(result.getSetEquipVariableId())) {
|
|
|
|
|
String value = setMap.get(result.getSetEquipVariableId()).get(0).getEquipVariableValue();
|
|
|
|
|
result.setSpotCheckSetValue(value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//获取实际值地址数据
|
|
|
|
|
if (realMap.containsKey(result.getRealEquipVariableId())) {
|
|
|
|
|
String value = realMap.get(result.getRealEquipVariableId()).get(0).getEquipVariableValue();
|
|
|
|
|
result.setSpotCheckRealValue(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 点检单完成
|
|
|
|
|
*
|
|
|
|
|
* @param model
|
|
|
|
|
* @param org
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void saveCheck(MesSpotCheckOrderModel model, String org) {
|
|
|
|
|
|
|
|
|
|
//校验点检单
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model.getOrderPartList().forEach(k -> {
|
|
|
|
|
ConvertBean.serviceModelUpdate(k, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
});
|
|
|
|
|
spotCheckOrderPartRepository.saveAll(model.getOrderPartList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Integer orderResult = MesExtEnumUtil.SPOT_CHECK_ORDER_RESULT.OK.getValue();
|
|
|
|
|
for (MesSpotCheckOrderResult result : model.getOrderResultList()) {
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(result.getSpotCheckResult())) {
|
|
|
|
|
throw new ImppBusiException(String.format("点检单明细未填写完成,请继续质检", result.getSpotCheckResult()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result.getIsTolerance() != MesCommonConstant.TRUE_INTEGER && orderResult == MesExtEnumUtil.SPOT_CHECK_ORDER_RESULT.OK.getValue()) {
|
|
|
|
|
orderResult = MesExtEnumUtil.SPOT_CHECK_ORDER_RESULT.NOK.getValue();
|
|
|
|
|
}
|
|
|
|
|
ConvertBean.serviceModelUpdate(result, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spotCheckOrderResultRepository.saveAll(model.getOrderResultList());
|
|
|
|
|
|
|
|
|
|
spotCheckOrder.setSpotCheckOrderResult(orderResult);
|
|
|
|
|
spotCheckOrder.setSpotCheckTime(TimeTool.getNowTime(true));
|
|
|
|
|
spotCheckOrder.setSpotCheckUser(AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
spotCheckOrder.setStatus(MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.COMPLETE.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(spotCheckOrder, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
spotCheckOrderRepository.save(spotCheckOrder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重新点检-根据原单据生成新点检单
|
|
|
|
|
*
|
|
|
|
|
* @param model
|
|
|
|
|
* @param org
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void saveReCheck(MesSpotCheckOrderModel model, String org) {
|
|
|
|
|
|
|
|
|
|
//校验点检单
|
|
|
|
|
MesSpotCheckOrder spotCheckOrder = checkSpotCheckOrder(model.getSpotCheckOrder());
|
|
|
|
|
// MesSpotCheckOrder spotCheckOrder = spotCheckOrderRepository.getById(model.getId());
|
|
|
|
|
|
|
|
|
|
//生成新点检单
|
|
|
|
|
MesSpotCheckOrder spotCheckOrderTemp = new MesSpotCheckOrder();
|
|
|
|
|
BeanUtils.copyProperties(spotCheckOrder, spotCheckOrderTemp, "id");
|
|
|
|
|
|
|
|
|
|
//生成单据号
|
|
|
|
|
GenSerialNoModel genSerialNoModel = new GenSerialNoModel(MesCommonConstant.SPOT_CHECK_ORDER_NO_COPY_RULE);
|
|
|
|
|
genSerialNoModel.setSerialNumber(spotCheckOrder.getSpotCheckOrderNo());
|
|
|
|
|
List<String> resultList = syncFuncService.syncSerialNo(genSerialNoModel, spotCheckOrder.getCreateUser(), spotCheckOrder.getOrganizeCode(), 1).getResultList();
|
|
|
|
|
|
|
|
|
|
//保存新点检单
|
|
|
|
|
spotCheckOrderTemp.setSpotCheckOrderNo(resultList.get(0));
|
|
|
|
|
// ConvertBean.serviceModelInitialize(spotCheckOrderTemp, "LML");
|
|
|
|
|
ConvertBean.serviceModelInitialize(spotCheckOrderTemp, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
spotCheckOrderTemp = spotCheckOrderRepository.insert(spotCheckOrderTemp);
|
|
|
|
|
|
|
|
|
|
//查询点检明细
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(spotCheckOrder.getOrganizeCode());
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(spotCheckOrder.getId(), "pid", packBean);
|
|
|
|
|
List<MesSpotCheckOrderResult> orderResultList = spotCheckOrderResultRepository.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
|
|
//查询新点检明细
|
|
|
|
|
List<MesSpotCheckOrderResult> orderResultNewList = new ArrayList<>();
|
|
|
|
|
MesSpotCheckOrder finalOrderTemp = spotCheckOrderTemp;
|
|
|
|
|
orderResultList.forEach(k -> {
|
|
|
|
|
MesSpotCheckOrderResult result = new MesSpotCheckOrderResult();
|
|
|
|
|
BeanUtils.copyProperties(k, result, "id");
|
|
|
|
|
result.setPid(finalOrderTemp.getId());
|
|
|
|
|
result.setSpotCheckOrderNo(finalOrderTemp.getSpotCheckOrderNo());
|
|
|
|
|
// ConvertBean.serviceModelInitialize(result, "LML");
|
|
|
|
|
ConvertBean.serviceModelInitialize(result, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
orderResultNewList.add(result);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询点检零件
|
|
|
|
|
DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(spotCheckOrder.getOrganizeCode());
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(spotCheckOrder.getId(), "spotCheckOrderId", partPackBean);
|
|
|
|
|
List<MesSpotCheckOrderPart> orderPartList = spotCheckOrderPartRepository.findByHqlWhere(partPackBean);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(orderPartList)) {
|
|
|
|
|
//保存新点检单零件
|
|
|
|
|
List<MesSpotCheckOrderPart> spotCheckOrderPartList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
orderPartList.forEach(k -> {
|
|
|
|
|
MesSpotCheckOrderPart spotCheckOrderPart = new MesSpotCheckOrderPart();
|
|
|
|
|
BeanUtils.copyProperties(k, spotCheckOrderPart, "id");
|
|
|
|
|
spotCheckOrderPart.setSpotCheckOrderId(finalOrderTemp.getId());
|
|
|
|
|
// ConvertBean.serviceModelInitialize(spotCheckOrderPart, "LML");
|
|
|
|
|
ConvertBean.serviceModelInitialize(spotCheckOrderPart, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
spotCheckOrderPartList.add(spotCheckOrderPart);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
spotCheckOrderPartRepository.saveAll(spotCheckOrderPartList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//保存新点检单明细
|
|
|
|
|
spotCheckOrderResultRepository.saveAll(orderResultNewList);
|
|
|
|
|
//保存旧点检单
|
|
|
|
|
spotCheckOrder.setStatus(MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.CLOSE.getValue());
|
|
|
|
|
// ConvertBean.serviceModelUpdate(spotCheckOrder, "LML");
|
|
|
|
|
ConvertBean.serviceModelUpdate(spotCheckOrder, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
spotCheckOrderRepository.save(spotCheckOrder);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesSpotCheckOrderModel querySpotCheckOrderResult(MesSpotCheckOrder spotCheckOrder) {
|
|
|
|
|
|
|
|
|
|
//校验点检单
|
|
|
|
|
checkSpotCheckOrder(spotCheckOrder);
|
|
|
|
|
|
|
|
|
|
//查询点检明细
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(spotCheckOrder.getOrganizeCode());
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(spotCheckOrder.getId(), "pid", packBean);
|
|
|
|
|
List<MesSpotCheckOrderResult> orderResultList = spotCheckOrderResultRepository.findByHqlWhere(packBean);
|
|
|
|
|
List<MesSpotCheckOrderPart> orderPartList = spotCheckOrderPartRepository.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
|
|
//查询点检零件
|
|
|
|
|
DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(spotCheckOrder.getOrganizeCode());
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(spotCheckOrder.getId(), "spotCheckOrderId", partPackBean);
|
|
|
|
|
List<MesSpotCheckOrderPart> orderPartList = spotCheckOrderPartRepository.findByHqlWhere(partPackBean);
|
|
|
|
|
|
|
|
|
|
MesSpotCheckOrderModel model = new MesSpotCheckOrderModel();
|
|
|
|
|
model.setOrderResultList(orderResultList);
|
|
|
|
@ -71,6 +326,52 @@ public class MesSpotCheckOrderService implements IMesSpotCheckOrderService {
|
|
|
|
|
DdlPreparedPack.getStringLikerPack(spotCheckOrder.getWorkCenterCode(), "workCenterCode", packBean);
|
|
|
|
|
DdlPreparedPack.getStringLikerPack(spotCheckOrder.getWorkCellCode(), "workCellCode", packBean);
|
|
|
|
|
DdlPreparedPack.getStringLikerPack(spotCheckOrder.getSpotCheckOrderNo(), "spotCheckOrderNo", packBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.CREATE.getValue(), "status", packBean);
|
|
|
|
|
return packBean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验点检单
|
|
|
|
|
*
|
|
|
|
|
* @param spotCheckOrder
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private MesSpotCheckOrder checkSpotCheckOrder(MesSpotCheckOrder spotCheckOrder) {
|
|
|
|
|
|
|
|
|
|
MesSpotCheckOrder result = spotCheckOrderRepository.getById(spotCheckOrder.getId());
|
|
|
|
|
if (result.getStatus() != MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.CREATE.getValue()) {
|
|
|
|
|
throw new ImppBusiException(String.format("【%s】单据状态为【%s】,请选择状态为【%s】的单据",
|
|
|
|
|
spotCheckOrder.getId(), MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.valueOfDescription(result.getStatus()),
|
|
|
|
|
MesExtEnumUtil.SPOT_CHECK_ORDER_STATUS.CREATE.getDescription()));
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private MesProduceSn checkProduceSn(String serialNumber, String org) {
|
|
|
|
|
//根据扫描的条码查询条码是否存在
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(serialNumber, "productSn", packBean);
|
|
|
|
|
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
|
|
|
|
|
MesProduceSn produceSn = produceSnRepository.getByProperty(packBean);
|
|
|
|
|
|
|
|
|
|
//若不存在则提示条码不存在
|
|
|
|
|
if (StringUtils.isEmpty(produceSn)) {
|
|
|
|
|
throw new ImppBusiException(String.format("【%s】此条码不存在,请检查数据", serialNumber));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据条码状态判断 是不是已下线条码
|
|
|
|
|
//若不是已下线的条码则提示 条码状态 请选择已下线的条码
|
|
|
|
|
if (produceSn.getSnStatus() != MesPcnExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue()) {
|
|
|
|
|
throw new ImppBusiException(String.format("【%s】此条码状态为【%s】,请选择【%s】状态的条码", serialNumber, produceSn.getSnStatus(), MesPcnExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//是否需要判断条码质量状态
|
|
|
|
|
if (produceSn.getQcStatus() != MesPcnExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()) {
|
|
|
|
|
throw new ImppBusiException(String.format("【%s】此条码状态为【%s】,请选择【%s】状态的条码", serialNumber, produceSn.getSnStatus(), MesPcnExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue()));
|
|
|
|
|
}
|
|
|
|
|
return produceSn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|