update 通过planDetailId和processId生成质检任务
parent
925694f554
commit
7f1b6f5843
@ -0,0 +1,12 @@
|
||||
package org.dromara.pda.api.model.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class GenerateInspectionTaskBo implements Serializable {
|
||||
private String tenantId;
|
||||
private Long planDetailId;
|
||||
private Long processId;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package org.dromara.common.core.utils;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.autoconfigure.thread.Threading;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public final class ProcessWorkshopUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 工序ID转换车间ID
|
||||
* @param processId
|
||||
* @return
|
||||
*/
|
||||
public static Long Conversion(Long processId) {
|
||||
if (processId == null) {
|
||||
return null;
|
||||
}
|
||||
if (processId == 17L) {
|
||||
return 3L;
|
||||
} else if (processId == 18L) {
|
||||
return 4L;
|
||||
} else {
|
||||
return 2L;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.dromara.qms.service;
|
||||
|
||||
|
||||
import org.dromara.pda.api.model.bo.GenerateInspectionTaskBo;
|
||||
|
||||
/**
|
||||
* PDA接口Service接口
|
||||
*
|
||||
* @author YinQ
|
||||
* @date 2025-07-24
|
||||
*/
|
||||
public interface IQcPDAService {
|
||||
|
||||
/**
|
||||
* 通过planDetailId和processId生成质检任务
|
||||
*/
|
||||
Boolean generateInspectionTask(GenerateInspectionTaskBo bo);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package org.dromara.qms.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.pda.api.RemotePdaMesApiService;
|
||||
import org.dromara.pda.api.model.ProdQmsPlanDetail;
|
||||
import org.dromara.pda.api.model.bo.GenerateInspectionTaskBo;
|
||||
import org.dromara.qms.domain.bo.QcInspectionTemplateBo;
|
||||
import org.dromara.qms.domain.vo.QcInspectionTemplateVo;
|
||||
import org.dromara.qms.service.IQcInspectionTemplateService;
|
||||
import org.dromara.qms.service.IQcPDAService;
|
||||
import org.dromara.qms.service.IQcTemplateItemService;
|
||||
import org.dromara.system.api.RemoteCodeRuleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.qms.service.IQcInspectionMainService;
|
||||
import org.dromara.qms.domain.bo.QcInspectionMainBo;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PDA接口Service业务层处理
|
||||
*
|
||||
* @author YinQ
|
||||
* @date 2025-07-24
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
@DubboService
|
||||
public class QcPDAServiceImpl implements IQcPDAService {
|
||||
|
||||
private final IQcInspectionMainService qcInspectionMainService;
|
||||
|
||||
private final IQcInspectionTemplateService qcInspectionTemplateService;
|
||||
|
||||
private final IQcTemplateItemService qcTemplateItemService;
|
||||
|
||||
@DubboReference
|
||||
private final RemotePdaMesApiService remotePdaMesApiService;
|
||||
|
||||
@DubboReference
|
||||
private final RemoteCodeRuleService remoteCodeRuleService;
|
||||
|
||||
|
||||
/**
|
||||
* 通过planDetailId和processId生成质检任务
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean generateInspectionTask(GenerateInspectionTaskBo bo) {
|
||||
ProdQmsPlanDetail planDetail = remotePdaMesApiService.remoteGetProductionPlanDetail(bo);
|
||||
if (StringUtils.isNull(planDetail)) {
|
||||
throw new ServiceException("获取生产计划失败");
|
||||
}
|
||||
String inspectionNo = remoteCodeRuleService.selectCodeRuleCode("3");
|
||||
if (StringUtils.isNull(inspectionNo)) {
|
||||
throw new ServiceException("获取质检编号失败");
|
||||
}
|
||||
String materialCode = planDetail.getMaterialCode();
|
||||
|
||||
QcInspectionTemplateBo templateBo = new QcInspectionTemplateBo();
|
||||
templateBo.setMaterialCode(materialCode);
|
||||
List<QcInspectionTemplateVo> templateVos = qcInspectionTemplateService.queryList(templateBo);
|
||||
if (templateVos.size() != 1) {
|
||||
throw new ServiceException("此物料无可用检测模板!");
|
||||
}
|
||||
QcInspectionTemplateVo templateVo = templateVos.get(0);
|
||||
QcInspectionMainBo inspectionBo = new QcInspectionMainBo();
|
||||
inspectionBo.setInspectionNo(inspectionNo);
|
||||
inspectionBo.setPlanDetailId(planDetail.getPlanDetailId());
|
||||
inspectionBo.setTemplateId(templateVo.getTemplateId());
|
||||
inspectionBo.setTemplateName(templateVo.getTemplateName());
|
||||
inspectionBo.setInspectionType(templateVo.getQcInspectionType());
|
||||
inspectionBo.setMaterialCode(planDetail.getMaterialCode());
|
||||
inspectionBo.setMaterialName(planDetail.getMaterialName());
|
||||
inspectionBo.setProcessName(planDetail.getProcessName());
|
||||
inspectionBo.setStationName(planDetail.getReleaseName());
|
||||
inspectionBo.setInspectionQty(planDetail.getCompleteAmount());
|
||||
inspectionBo.setShift(planDetail.getShiftName());
|
||||
inspectionBo.setTeam(planDetail.getTeamName());
|
||||
inspectionBo.setProductionOrder(planDetail.getPlanCode());
|
||||
inspectionBo.setBarcode(planDetail.getReturnBarcode());
|
||||
inspectionBo.setStatus(0L);
|
||||
qcInspectionMainService.insertByBo(inspectionBo);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue