Merge remote-tracking branch 'origin/dev' into dev

tags/yfai-pcn-ext-v1.0
LML丶 12 months ago
commit 0cc30e4f19

@ -0,0 +1,40 @@
package cn.estsh.i3plus.ext.mes.pcn.api.base;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssembly;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.bean.MesShift;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTask;
import io.swagger.annotations.ApiOperation;
import java.util.List;
/**
* @Description:
* @Author: zxw
* @Date: 2024/5/25 18:16
* @Modify:
*/
public interface IMesReworkTaskService {
@ApiOperation(value = "查询返工单")
ListPager<MesReworkTask> queryReworkTask(MesReworkTask mesReworkTask, Pager pager);
@ApiOperation(value = "查询返工单")
MesReworkTaskModel queryReworkTaskModel(MesReworkTaskRequestModel requestModel);
void reworkRecord(long detailId);
List<MesProductionAssembly> assemblyQuery(MesReworkTaskRequestModel requestModel);
void assemblySnRepeat(MesReworkTaskRequestModel requestModel);
void reworkSuccess(MesReworkTaskRequestModel requestModel);
}

@ -0,0 +1,133 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesReworkTaskService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesShiftService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssembly;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.bean.MesShift;
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTask;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @Description:
* @Author: zxw
* @Date: 2024/5/25 18:16
* @Modify:
*/
@RestController
@RequestMapping(MesCommonConstant.MES_YANFEN + "/reworkTask")
public class MesReworkTaskController {
@Autowired
private IMesReworkTaskService mesReworkTaskService;
@GetMapping("/query-pager")
@ApiOperation(value = "查询所有返工单")
public ResultBean queryReworkTaskByPager(MesReworkTask reworkTask, Pager pager) {
try {
reworkTask.setOrganizeCode(AuthUtil.getOrganizeCode());
ListPager<MesReworkTask> mesReworkTaskListPager = mesReworkTaskService.queryReworkTask(reworkTask, pager);
return ResultBean.success("查询成功").setListPager(mesReworkTaskListPager);
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping("/queryBySn")
@ApiOperation(value = "根据条码查询返工详情")
public ResultBean queryBySn(MesReworkTaskRequestModel requestModel) {
try {
requestModel.setOrganizeCode(AuthUtil.getOrganizeCode());
MesReworkTaskModel mesReworkTaskModel = mesReworkTaskService.queryReworkTaskModel(requestModel);
return ResultBean.success("查询成功").setResultObject(mesReworkTaskModel);
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping("/reworkRecord")
@ApiOperation(value = "返工")
public ResultBean reworkRecord(long[] inspectionDetailIds) {
try {
for (long inspectionDetailId : inspectionDetailIds) {
mesReworkTaskService.reworkRecord(inspectionDetailId);
}
return ResultBean.success("返工成功");
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping("/assemblyQuery")
@ApiOperation(value = "装配件查询")
public ResultBean assemblyQuery(MesReworkTaskRequestModel requestModel) {
// 数据校验
ValidatorBean.checkNotNull(requestModel.getCustSn(), "客户条码不能为空");
ValidatorBean.checkNotNull(requestModel.getPartNo(), "零件号不能为空");
try {
List<MesProductionAssembly> mesProductionRecords = mesReworkTaskService.assemblyQuery(requestModel);
return ResultBean.success("返工成功").setResultObject(mesProductionRecords);
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping("/assemblySnRepeat")
@ApiOperation(value = "装配件替换")
public ResultBean assemblySnRepeat(MesReworkTaskRequestModel requestModel) {
try {
// 数据校验
ValidatorBean.checkNotNull(requestModel.getCustSn(), "客户条码不能为空");
ValidatorBean.checkNotNull(requestModel.getPartNo(), "零件号不能为空");
ValidatorBean.checkNotNull(requestModel.getSn(), "替换条码不能为空");
ValidatorBean.checkNotNull(requestModel.getDetailId(), "缺陷位置id不能为空");
mesReworkTaskService.assemblySnRepeat(requestModel);
return ResultBean.success("返工成功");
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping("/reworkSuccess")
@ApiOperation(value = "返工成功")
public ResultBean reworkSuccess(MesReworkTaskRequestModel requestModel) {
// 数据校验
ValidatorBean.checkNotNull(requestModel.getSn(), "条码不能为空");
try {
mesReworkTaskService.reworkSuccess(requestModel);
return ResultBean.success("返工成功");
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
}

@ -0,0 +1,286 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesReworkTaskService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesShiftService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
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.*;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTask;
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTaskDetail;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @Description:
* @Author: zxw
* @Date: 2024/5/21 14:16
* @Modify:
*/
@Service
@Slf4j
public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
private static final Logger LOGGER = LoggerFactory.getLogger(MesReworkTaskServiceImpl.class);
@Autowired
private MesReworkTaskRepository mesReworkTaskRepository;
@Autowired
private MesPartTypePictureRepository mesPartTypePictureRepository;
@Autowired
private MesPartRepository mesPartRepository;
@Autowired
private MesPartInspectionRepository mesPartInspectionRepository;
@Autowired
private MesPartInspectionDetailRepository mesPartInspectionDetailRepository;
@Autowired
private MesReworkTaskDetailRepository mesReworkTaskDetailRepository;
@Autowired
private MesProductionAssemblyRepository mesProductionAssemblyRepository;
@Autowired
private MesProduceSnRepository mesProduceSnRepository;
@Override
public ListPager<MesReworkTask> queryReworkTask(MesReworkTask mesReworkTask, Pager pager) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(AuthUtil.getOrganizeCode());
if (mesReworkTask.getSn() != null) {
DdlPreparedPack.getStringEqualPack(mesReworkTask.getSn(), "sn", packBean);
}
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.CREATE.getValue(), "status", packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
pager = PagerHelper.getPager(pager, mesReworkTaskRepository.findByHqlWhereCount(packBean));
List<MesReworkTask> resultList = mesReworkTaskRepository.findByHqlWherePage(packBean, pager);
return new ListPager<>(resultList, pager);
}
@Override
public MesReworkTaskModel queryReworkTaskModel(MesReworkTaskRequestModel requestModel){
/**
*
*/
MesReworkTask res = getMesReworkTask(requestModel);
/**
*
*/
List<MesReworkTaskDetail> reworkTaskDetails = getMesReworkTaskDetail(res);
/**
*
*/
MesPartTypePicture mesPartTypePicture = getMesPartTypePicture(res);
/**
*
*/
MesPartInspection mesPartInspection = getMesPartInspection(res);
/**
*
*/
List<MesPartInspectionDetail> mesPartInspectionDetails = getMesPartInspectionDetail(reworkTaskDetails);
/**
*
*/
MesReworkTaskModel mesReworkTaskModel = MesReworkTaskModel.builder()
.reworkOrder(res.getReworkOrder())
.sn(res.getSn())
.mesPartTypePicture(mesPartTypePicture)
.mesPartInspection(mesPartInspection)
.mesPartInspectionDetails(mesPartInspectionDetails).build();
return mesReworkTaskModel;
}
@Override
public void reworkRecord(long detailId) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(AuthUtil.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(detailId, "partInspectionDetailId", packBean);
MesReworkTaskDetail mesReworkTaskDetail = mesReworkTaskDetailRepository.getByProperty(packBean);
if (mesReworkTaskDetail == null) {
MesPcnException.throwFlowException("返工单详情不存在");
}
mesReworkTaskDetail.setStatus(MesExtEnumUtil.REWORK_TASK_DETAIL_STATUS.REWORK_TASK_DETAIL_STATUS_20.getValue());
mesReworkTaskDetailRepository.save(mesReworkTaskDetail);
}
@Override
public List<MesProductionAssembly> assemblyQuery(MesReworkTaskRequestModel requestModel) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(requestModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(requestModel.getCustSn(), "custSn", packBean);
DdlPreparedPack.getStringEqualPack(requestModel.getPartNo(), "partNo", packBean);
if (!StringUtils.isEmpty(requestModel.getAssemblyPartNo())) {
DdlPreparedPack.getStringEqualPack(requestModel.getAssemblyPartNo(), "assemblyPartNo", packBean);
}
if (!Objects.isNull(requestModel.getAssemblyPartStatus())) {
DdlPreparedPack.getNumEqualPack(requestModel.getAssemblyPartStatus(), "assemblyStatus", packBean);
}
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"assemblyStatus"}, packBean);
List<MesProductionAssembly> mesProductionAssemblies = mesProductionAssemblyRepository.findByHqlWhere(packBean);
if (CollectionUtils.isEmpty(mesProductionAssemblies)) {
MesPcnException.throwFlowException("装配件信息不存在");
}
return mesProductionAssemblies;
}
@Override
public void reworkSuccess(MesReworkTaskRequestModel requestModel) {
MesReworkTask mesReworkTask = getMesReworkTask(requestModel);
/**
*
*/
List<MesReworkTaskDetail> reworkTaskDetails = getMesReworkTaskDetail(mesReworkTask);
if (!CollectionUtils.isEmpty(reworkTaskDetails)) {
MesPcnException.throwFlowException("还有位置未返工完成,请检查");
}
mesReworkTask.setStatus(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue());
mesReworkTaskRepository.update(mesReworkTask);
}
@Override
public void assemblySnRepeat(MesReworkTaskRequestModel requestModel) {
try {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(requestModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(requestModel.getSn(), "sn", packBean);
MesProduceSn mesProduceSn = mesProduceSnRepository.getByProperty(packBean);
if (mesProduceSn == null) {
MesPcnException.throwFlowException("条码信息不存在");
}
requestModel.setAssemblyPartNo(mesProduceSn.getPartNo());
requestModel.setAssemblyPartStatus(MesExtEnumUtil.ASSEMBLY_PART_STATUS.ASSEMBLY_PART_STATUS_10.getValue());
List<MesProductionAssembly> mesProductionAssemblies = assemblyQuery(requestModel);
if (CollectionUtils.isEmpty(mesProductionAssemblies)) {
MesPcnException.throwFlowException("未匹配到该条码的零件号");
}
// 需要变更之前的记录
MesProductionAssembly mesProductionAssembly = mesProductionAssemblies.get(0);
mesProductionAssembly.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_PART_STATUS.ASSEMBLY_PART_STATUS_20.getValue());
// 需要新增一条替换条码的记录
MesProductionAssembly mesProductionRepeatAssembly = new MesProductionAssembly();
BeanUtils.copyProperties(mesProductionAssembly, mesProductionRepeatAssembly);
mesProductionRepeatAssembly.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_PART_STATUS.ASSEMBLY_PART_STATUS_10.getValue());
mesProductionRepeatAssembly.setId(null);
mesProductionAssembly.setRepeatAssemblySn(requestModel.getSn());
mesProductionAssemblyRepository.update(mesProductionAssembly);
mesProductionAssemblyRepository.insert(mesProductionRepeatAssembly);
/**
* NC
*/
reworkRecord(requestModel.getDetailId());
} catch (Exception e) {
log.error("替换条码异常", e);
}
}
private MesPartInspection getMesPartInspection(MesReworkTask mesReworkTask) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesReworkTask.getSn(), "sn", packBean);
MesPartInspection mesPartInspection = mesPartInspectionRepository.getByProperty(packBean);
if (mesPartInspection == null) {
throw new ImppBusiException("返工单信息不存在");
}
return mesPartInspection;
}
private List<MesPartInspectionDetail> getMesPartInspectionDetail(List<MesReworkTaskDetail> reworkTaskDetails) {
List<Long> ids = reworkTaskDetails.stream().map(MesReworkTaskDetail::getPartInspectionDetailId).collect(Collectors.toList());
DdlPackBean packBean = DdlPackBean.getDdlPackBean(reworkTaskDetails.get(0).getOrganizeCode());
DdlPreparedPack.getInPackList(ids, "id", packBean);
return mesPartInspectionDetailRepository.findByHqlWhere(packBean);
}
private MesPartTypePicture getMesPartTypePicture(MesReworkTask mesReworkTask) {
DdlPackBean partBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesReworkTask.getPartNo(), "partNo", partBean);
MesPart mesPart = mesPartRepository.getByProperty(partBean);
if (mesPart == null) {
MesPcnException.throwFlowException(String.format("零件信息不存在,根据物料号查询[%s]", mesReworkTask.getPartNo()));
}
DdlPackBean pictureBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesPart.getPartTypeCode(), "partTypeCode", pictureBean);
MesPartTypePicture mesPartTypePicture = mesPartTypePictureRepository.getByProperty(pictureBean);
if (mesPartTypePicture == null) {
throw new ImppBusiException(String.format("图片信息不存在,根据物料号查询[%s]", mesReworkTask.getPartNo()));
}
return mesPartTypePicture;
}
private MesReworkTask getMesReworkTask(MesReworkTaskRequestModel requestModel) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(requestModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(requestModel.getSn(), "sn", packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.CREATE.getValue(), "status", packBean);
MesReworkTask res = mesReworkTaskRepository.getByProperty(packBean);
if (res == null) {
throw new ImppBusiException("返工单信息不存在");
}
return res;
}
private List<MesReworkTaskDetail> getMesReworkTaskDetail(MesReworkTask mesReworkTask) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(mesReworkTask.getId(), "pid", packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_DETAIL_STATUS.REWORK_TASK_DETAIL_STATUS_10.getValue(), "status", packBean);
List<MesReworkTaskDetail> res = mesReworkTaskDetailRepository.findByHqlWhere(packBean);
if (CollectionUtils.isEmpty(res)) {
throw new ImppBusiException("返工单详情信息不存在");
}
return res;
}
}

@ -5,9 +5,11 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseModuleService;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesStateMachineStatus;
import cn.estsh.i3plus.pojo.mes.model.AttrBean;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.util.PojoAttrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -34,6 +36,8 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
*/
StationResultBean resultBean = getStationResultBean(reqBean);
StationResultBean resultBean1 = getStationResultBean1(reqBean);
//TODO 获取 头部上下文 信息
// productionProcessContextStepService.getProductionProcessContext();
@ -120,6 +124,7 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CUSTOM_CONTENT.getValue());
resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue());
resultBean.setCustomPageName(MesPcnExtConstWords.CUSTOM_PAGE_NAME_DEFAULT);
resultBean.setDataAttrList(packDataAttrList());
resultBean.setSpecialDisplayData(getStepColIndent(reqBean));
List<List<StationKvBean>> stationKvBeansList = new ArrayList<>();
@ -163,25 +168,20 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
stationKvBeans1.add(stationKvBean6);
stationKvBeansList.add(stationKvBeans1);
List<StationKvBean> stationKvBeans3 = new ArrayList<>();
StationKvBean stationKvBean7 = new StationKvBean();
stationKvBean7.setKey("shiftCode");
stationKvBean7.setName("班次");
stationKvBean7.setValue("白班");
stationKvBeans3.add(stationKvBean7);
StationKvBean stationKvBean8 = new StationKvBean();
stationKvBean8.setKey("shiftGroup");
stationKvBean8.setName("班组");
stationKvBean8.setValue("注塑2班");
stationKvBeans3.add(stationKvBean8);
resultBean.setResultObj(stationKvBeans3);
//resultBean.setResultObj(stationKvBeans3);
resultBean.setResultList(stationKvBeansList);
return resultBean;
}
private List<AttrBean> packDataAttrList() {
List<AttrBean> attrBeanList = new ArrayList<>();
PojoAttrUtil.loadPojoAttrs(attrBeanList, "index", "序号",true);
PojoAttrUtil.loadPojoAttrs(attrBeanList, "custPartNo", "客户零件号", true);
PojoAttrUtil.loadPojoAttrs(attrBeanList, "orderNo", "工单号", true);
return attrBeanList;
}
@Override
public boolean execStateModule(StationRequestBean reqBean, List<MesStateMachineStatus> states, Map<String, String> wcpcMap) {
return true;

@ -0,0 +1,99 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesMouldMultiCavityService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipVariableCfgRuleMatchDispatchService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipmentLogExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesCellEquipContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCfgCollectContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.i3plus.pojo.mes.repository.IMesMouldMappingCfgRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesProdMouldRecordRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
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.*;
/**
* @Description :
* @Author : zxw
**/
@Slf4j
@Service("mesMouldRecordGenerateStepService")
public class MesMouldRecordGenerateStepService extends BaseStepService {
@Autowired
private MesProdMouldRecordRepository mesProdMouldRecordRepository;
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesMouldMappingCfgRepository mesMouldMappingCfgRepository;
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue());
List<MesProduceSn> mesProduceSns = productionProcessContext.getProduceSnDataList();
List<MesProdMouldRecord> mesProdMouldRecords = new ArrayList<>();
for (MesProduceSn mesProduceSn : mesProduceSns) {
MesCellEquipContext mesCellEquipContext = productionProcessContext.getCurCellEquip();
String equipmentCode = mesCellEquipContext.getEquipmentCode();
String mouldNo = "";
if (productionProcessContext.getFirstMouldNo() != null) {
mouldNo = productionProcessContext.getFirstMouldNo().getEquipVariableValue();
} else if (productionProcessContext.getFirstMouldNo() == null && productionProcessContext.getMouldNo() != null) {
mouldNo = productionProcessContext.getMouldNo().getEquipVariableValue();
}
DdlPackBean packBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getStringEqualPack(equipmentCode, "equipmentCode", packBean);
DdlPreparedPack.getStringEqualPack(mouldNo, "mouldNo", packBean);
MesMouldMappingCfg mesMouldMappingCfg = mesMouldMappingCfgRepository.getByProperty(packBean);
//配置错误 抛出异常
if (mesMouldMappingCfg == null) execExpSendMsgAndThrowEx(reqBean, resultBean,
String.format("请检查模具映射关系维护,根据设备[%s],模具号[%s]", equipmentCode, mouldNo));
MesProdMouldRecord mesProductionRecord = getMesProdMouldRecord(mesCellEquipContext, mouldNo, mesMouldMappingCfg);
mesProdMouldRecords.add(mesProductionRecord);
}
mesProdMouldRecordRepository.saveAll(mesProdMouldRecords);
return StepResult.getSuccessComplete();
}
private MesProdMouldRecord getMesProdMouldRecord(MesCellEquipContext mesCellEquipContext, String mouldNo, MesMouldMappingCfg mesMouldMappingCfg) {
MesProdMouldRecord mesProdMouldRecord = new MesProdMouldRecord();
mesProdMouldRecord.setEquipId(mesCellEquipContext.getEquipId());
mesProdMouldRecord.setMeterName(mesMouldMappingCfg.getMeterName());
mesProdMouldRecord.setAssetNum(mesMouldMappingCfg.getAssetNum());
mesProdMouldRecord.setEquipmentCode(mesCellEquipContext.getEquipmentCode());
return mesProdMouldRecord;
}
}

@ -0,0 +1,71 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.util;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
/**
* @Description :
* @Reference :
* @Author : junsheng.li
* @CreateDate 2024/5/8 17:16
* @Modify:
**/
public class MesPcnException {
/**
*
* @param errorDetail
* @param errorSolution
* @throws ImppBusiException
*/
public static void throwFlowException(String errorDetail, String errorSolution)
throws ImppBusiException {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode())
.setErrorDetail(errorDetail)
.setErrorSolution(errorSolution)
.build();
}
/**
*
* @param errorDetail
* @throws ImppBusiException
*/
public static void throwFlowException(String errorDetail)
throws ImppBusiException {
throwFlowException(errorDetail, "");
}
/**
* WMS
* @param errorCode
* @param errorDetail
* @param errorSoluction
*/
public static void throwBusiException(String errorCode,String errorDetail,String errorSoluction,Object...args){
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(errorCode)
.setErrorDetail(errorDetail,args)
.setErrorSolution(errorSoluction)
.build();
}
/**
*
*
* @param
*/
public static void throwMesBusiException(String errorDetailString, Object... args) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES_PCN.getCode())
.setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode())
.setErrorDetail(errorDetailString,args)
.build();
}
}

@ -0,0 +1,36 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import cn.estsh.i3plus.pojo.mes.bean.MesPartTypePicture;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@Builder
public class MesReworkTaskModel {
/**
*
*/
private String sn;
/**
*
*/
private String reworkOrder;
/**
*
*/
private MesPartTypePicture mesPartTypePicture;
/**
*
*/
private MesPartInspection mesPartInspection;
/**
*
*/
private List<MesPartInspectionDetail> mesPartInspectionDetails;
}

@ -0,0 +1,44 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import cn.estsh.i3plus.pojo.mes.bean.MesPartTypePicture;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import lombok.Builder;
import lombok.Data;
import java.util.List;
@Data
public class MesReworkTaskRequestModel {
/**
*
*/
private String sn;
/**
*
*/
private String custSn;
/**
*
*/
private String reworkOrder;
/**
*
*/
private String partNo;
/**
*
*/
private String assemblyPartNo;
/**
*
*/
private String organizeCode;
private Integer assemblyPartStatus;
private Long detailId;
}
Loading…
Cancel
Save