CCSC检测,重新打开

tags/yfai-mes-ext-v1.0
jun 10 months ago
parent 86c9ec3ecf
commit a6c1d5a485

@ -16,4 +16,6 @@ public interface IMesCcscTaskService extends IBaseMesService<MesCcscTask> {
MesCcscTask insert(MesWorkOrder mesWorkOrder,String testType,String orderNo,Integer frequency,Integer rule,Integer qtyRule);
void doCcscTaskByMesWorkOrder(String organizeCode,List<MesWorkOrder> mesWorkOrderList);
void insertMesCcscTask(String organizeCode,List<MesWorkOrder> mesWorkOrderList);
}

@ -40,7 +40,7 @@ public interface IMesWorkOrderService extends IBaseMesService<MesWorkOrder> {
void doReportWorkReversal(WmsProductModel model);
@ApiOperation("重新打开")
void doReopen(String[] ids,String userName,String organizeCode);
void doReopen(Long[] ids,String userName,String organizeCode);
List<MesProductionRecord> getPreDayReportMesProductionRecord(String organizeCode , List<MesShift> mesShiftList, String workCenterCode);

@ -185,11 +185,11 @@ public class MesWorkOrderController extends BaseMesController<MesWorkOrder> {
@PutMapping(value = "/reopen")
@ApiOperation(value = "重新打开")
public ResultBean doReopen(String[] ids) {
public ResultBean doReopen(Long[] ids) {
try {
ValidatorBean.checkNotNull(ids);
mesWorkOrderService.doReopen(ids, AuthUtil.getSessionUser().getUserName(),AuthUtil.getOrganizeCode());
return ResultBean.success("反向冲销成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
return ResultBean.success("重新打开成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {

@ -12,8 +12,9 @@ import cn.estsh.i3plus.pojo.base.bean.BaseResultBean;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.bean.MesCcscRule;
import cn.estsh.i3plus.pojo.mes.bean.MesCcscTask;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.repository.MesCcscRuleRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesCcscTaskRepository;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
@ -66,6 +67,7 @@ public class MesCcscTaskServiceImpl extends BaseMesService<MesCcscTask> implemen
//查ccsc规则表
LOGGER.info("-------- doCcscTaskByMesWorkOrder---{}",organizeCode);
DdlPackBean ddlPackBeanRule = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(mesWorkOrderList.stream().map(MesWorkOrder::getPartNo).collect(Collectors.toList()), "partNo",ddlPackBeanRule);
List<MesCcscRule> ccscRuleList = ccscRuleRDao.findByHqlWhere(ddlPackBeanRule);
Map<String, List<MesCcscRule>> ccscRulePartMap = ccscRuleList.stream().collect(Collectors.groupingBy(MesCcscRule::getPartNo));
Map<String, List<MesWorkOrder>> workOrderPartMap = mesWorkOrderList.stream().collect(Collectors.groupingBy(MesWorkOrder::getPartNo));
@ -155,4 +157,50 @@ public class MesCcscTaskServiceImpl extends BaseMesService<MesCcscTask> implemen
}
}
}
@Override
public void insertMesCcscTask(String organizeCode, List<MesWorkOrder> mesWorkOrderList) {
if (CollectionUtils.isEmpty(mesWorkOrderList)) return;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(mesWorkOrderList.stream().map(MesWorkOrder::getPartNo).collect(Collectors.toList()), "partNo", packBean);
List<MesCcscRule> ccscRuleList = ccscRuleRDao.findByHqlWhere(packBean);
if (CollectionUtils.isEmpty(ccscRuleList)) return;
Map<String, List<MesCcscRule>> ccscRulePartMap = ccscRuleList.stream().collect(Collectors.groupingBy(MesCcscRule::getPartNo));
//根据物料对工单表分组
Map<String, List<MesWorkOrder>> workOrderPartMap = mesWorkOrderList.stream().collect(Collectors.groupingBy(MesWorkOrder::getPartNo));
for (Map.Entry<String, List<MesWorkOrder>> stringListEntry : workOrderPartMap.entrySet()) {
List<MesWorkOrder> mesWorkOrders = stringListEntry.getValue();
MesWorkOrder mesWorkOrder = mesWorkOrders.iterator().next();
if (CollectionUtils.isEmpty(ccscRulePartMap.get(mesWorkOrder.getPartNo()))) continue;
MesCcscRule ccscRule = ccscRulePartMap.get(mesWorkOrder.getPartNo()).iterator().next();
for (MesWorkOrder workOrder : mesWorkOrders) {
saveCcscTask(organizeCode, workOrder, ccscRule);
}
}
}
private void saveCcscTask(String organizeCode, MesWorkOrder workOrder, MesCcscRule ccscRule) {
String orderNo = "1_" + workOrder.getWorkOrderNo();
int ccscRuleQty = 1;
//新增质量检验任务 MesCcscTask
MesCcscTask mesCcscTask = getMesCcscTask(organizeCode, workOrder);
if (!Objects.isNull(mesCcscTask)) {
ccscRuleQty = mesCcscTask.getQty().intValue();
if (mesCcscTask.getTaskNo().startsWith(MesCommonConstant.CCSC_RETEST_NO.substring(0,6))) {
String[] split = mesCcscTask.getTaskNo().split("_");
orderNo = (Integer.parseInt(split[1]) + 1)+ "_" + split[2];
} else {
orderNo = "1_" + mesCcscTask.getTaskNo();
}
}
insert(workOrder, ccscRule.getTestType(), String.format(MesCommonConstant.CCSC_RETEST_NO, orderNo), ccscRule.getFrequency(), ccscRule.getRule(), ccscRuleQty);
}
private MesCcscTask getMesCcscTask(String organizeCode, MesWorkOrder mesWorkOrder) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesWorkOrder.getWorkOrderNo(), "workOrderNo", ddlPackBean);
DdlPreparedPack.getStringEqualPack(mesWorkOrder.getPartNo(), "partNo", ddlPackBean);
DdlPreparedPack.getOrderBy(null, null, ddlPackBean);
return baseRDao.getByProperty(ddlPackBean);
}
}

@ -1057,7 +1057,7 @@ public class MesWorkOrderService extends BaseMesService<MesWorkOrder> implements
}
@Override
public void doReopen(String[] ids,String userName,String organizeCode) {
public void doReopen(Long[] ids,String userName,String organizeCode) {
//获取工单信息
List<MesWorkOrder> mesWorkOrderList = getMesWorkOrderList(ids, organizeCode);
//数据更新
@ -1076,11 +1076,13 @@ public class MesWorkOrderService extends BaseMesService<MesWorkOrder> implements
mesWorkOrder.setCcscStatus("");
updateMesWorkOrder(mesWorkOrder,MesExtEnumUtil.WORK_ORDER_LOG_TYPE.UPDATE,mesWorkOrder.getQty());
}
//重新生成CCSC task
mesCcscTaskService.insertMesCcscTask(organizeCode,mesWorkOrderList);
}
private List<MesWorkOrder> getMesWorkOrderList(String[] ids, String organizeCode) {
private List<MesWorkOrder> getMesWorkOrderList(Long[] ids, String organizeCode) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPack(String.join(",", ids),"id",packBean);
DdlPreparedPack.getInPackArray(ids,"id",packBean);
List<MesWorkOrder> mesWorkOrderList = baseRDao.findByHqlWhere(packBean);
if (CollectionUtils.isEmpty(mesWorkOrderList)) {
MesException.throwMesBusiException("选择工单信息不存在");

@ -38,6 +38,7 @@ public class MesCommonConstant {
//CCSC生成任务号
public static final String CCSC_TASK_NO = "CCSC_TASK_NO";
public static final String CCSC_RETEST_NO = "RETEST_%s";
//OBS
public static final String OBS_AK = "TPNXQ2LUMRHNYYOBO8QO";

Loading…
Cancel
Save