成品发货修改
This commit is contained in:
parent
4a7e044126
commit
c3916419ed
|
|
@ -1,5 +1,6 @@
|
|||
package com.nflg.qms.admin.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import com.nflg.wms.common.exception.NflgException;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiTaskRecordAddQO;
|
||||
|
|
@ -28,6 +29,8 @@ import java.util.Objects;
|
|||
@Service
|
||||
public class ExternalPdiTaskRecordControllerService {
|
||||
|
||||
private static final int PDI_TASK_RECORD_SERIAL_TYPE = 45;
|
||||
|
||||
@Resource
|
||||
private IQmsPdiTaskRecordService taskRecordService;
|
||||
|
||||
|
|
@ -43,6 +46,9 @@ public class ExternalPdiTaskRecordControllerService {
|
|||
@Resource
|
||||
private IQmsPdiInspectionResultsService inspectionResultsService;
|
||||
|
||||
@Resource
|
||||
private BasdeSerialNumberControllerService basdeSerialNumberControllerService;
|
||||
|
||||
// ========================= 新增 =========================
|
||||
|
||||
/**
|
||||
|
|
@ -54,7 +60,10 @@ public class ExternalPdiTaskRecordControllerService {
|
|||
@Transactional
|
||||
public void add(QmsPdiTaskRecordAddQO request) {
|
||||
// 查检测规则,获取 inspection_cycle
|
||||
QmsPdiDetectionRules rule = pdiDetectionRulesService.getById(request.getDetectionRulesId());
|
||||
QmsPdiDetectionRules rule = getPublishedRuleByOrderNo(request.getOrderNo());
|
||||
if (Objects.isNull(rule)) {
|
||||
rule = getPublishedRuleByModelNo(request.getModelNo());
|
||||
}
|
||||
if (Objects.isNull(rule)) {
|
||||
throw new NflgException(STATE.BusinessError, "PDI检测规则不存在");
|
||||
}
|
||||
|
|
@ -76,11 +85,15 @@ public class ExternalPdiTaskRecordControllerService {
|
|||
LocalDateTime requiredCompletionTime = submissionTime.plusDays(
|
||||
rule.getInspectionCycle() != null ? rule.getInspectionCycle() : 0
|
||||
);
|
||||
String taskNo = basdeSerialNumberControllerService.generateSerialNumber(PDI_TASK_RECORD_SERIAL_TYPE);
|
||||
if (StrUtil.isBlank(taskNo)) {
|
||||
throw new NflgException(STATE.BusinessError, "PDI检测任务编号生成失败");
|
||||
}
|
||||
|
||||
// 1. 保存任务单
|
||||
QmsPdiTaskRecord record = new QmsPdiTaskRecord()
|
||||
.setDetectionRulesId(request.getDetectionRulesId())
|
||||
.setTaskNo(request.getTaskNo())
|
||||
.setDetectionRulesId(rule.getId())
|
||||
.setTaskNo(taskNo)
|
||||
.setDeviceNo(request.getDeviceNo())
|
||||
.setOrderNo(request.getOrderNo())
|
||||
.setFactoryNo(request.getFactoryNo())
|
||||
|
|
@ -90,7 +103,7 @@ public class ExternalPdiTaskRecordControllerService {
|
|||
.setRequiredCompletionTime(requiredCompletionTime);
|
||||
taskRecordService.save(record);
|
||||
Long taskId = record.getId();
|
||||
Long detectionRulesId = request.getDetectionRulesId();
|
||||
Long detectionRulesId = rule.getId();
|
||||
|
||||
// 2. 初始化空白检测结果行
|
||||
List<QmsPdiInspectionResults> resultRows = new ArrayList<>();
|
||||
|
|
@ -142,5 +155,29 @@ public class ExternalPdiTaskRecordControllerService {
|
|||
inspectionResultsService.saveBatch(resultRows);
|
||||
}
|
||||
}
|
||||
|
||||
private QmsPdiDetectionRules getPublishedRuleByOrderNo(String orderNo) {
|
||||
return pdiDetectionRulesService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRules::getOrderNo, orderNo)
|
||||
.eq(QmsPdiDetectionRules::getInspectionType, 0)
|
||||
.eq(QmsPdiDetectionRules::getEnable, true)
|
||||
.eq(QmsPdiDetectionRules::getPublishEnable, true)
|
||||
.orderByDesc(QmsPdiDetectionRules::getPublishTime)
|
||||
.orderByDesc(QmsPdiDetectionRules::getId)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
}
|
||||
|
||||
private QmsPdiDetectionRules getPublishedRuleByModelNo(String modelNo) {
|
||||
return pdiDetectionRulesService.lambdaQuery()
|
||||
.eq(QmsPdiDetectionRules::getModelNo, modelNo)
|
||||
.eq(QmsPdiDetectionRules::getInspectionType, 0)
|
||||
.eq(QmsPdiDetectionRules::getEnable, true)
|
||||
.eq(QmsPdiDetectionRules::getPublishEnable, true)
|
||||
.orderByDesc(QmsPdiDetectionRules::getPublishTime)
|
||||
.orderByDesc(QmsPdiDetectionRules::getId)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.nflg.wms.admin.repository.InventoryForOutRepository;
|
|||
import com.nflg.wms.admin.repository.OutMaterialScanRecordRespository;
|
||||
import com.nflg.wms.admin.service.BasdeSerialNumberControllerService;
|
||||
import com.nflg.wms.admin.service.NoScanningBaseControllerService;
|
||||
import com.nflg.wms.admin.service.QmsService;
|
||||
import com.nflg.wms.admin.service.SapService;
|
||||
import com.nflg.wms.admin.util.PdfGeneratorUtil;
|
||||
import com.nflg.wms.admin.util.QRCodeUtil;
|
||||
|
|
@ -111,6 +112,9 @@ public class OutProduceController extends BaseController {
|
|||
@Resource
|
||||
private NoScanningBaseControllerService noScanningBaseControllerService;
|
||||
|
||||
@Resource
|
||||
private QmsService qmsService;
|
||||
|
||||
/**
|
||||
* 查询SAP领料订单数据
|
||||
*/
|
||||
|
|
@ -278,6 +282,17 @@ public class OutProduceController extends BaseController {
|
|||
return ApiResult.success(outProduceService.search(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起PDI检测任务
|
||||
*
|
||||
* @param id 成品发货单ID
|
||||
*/
|
||||
@PostMapping("pdi/apply")
|
||||
public ApiResult<Void> applyPdiInspection(@Valid @RequestParam @NotNull Long id) {
|
||||
qmsService.pushPdiInspection(id);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 解锁库存(根据订单)
|
||||
// * @deprecated 不需要这个方法了
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
package com.nflg.wms.admin.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.qo.ExternalIncomingInspectionApplyQO;
|
||||
import com.nflg.wms.common.pojo.qo.ExternalInventoryInspectionApplyQO;
|
||||
import com.nflg.wms.common.pojo.qo.InventoryDetectionApplyQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsPdiTaskRecordAddQO;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.WmsInventory;
|
||||
import com.nflg.wms.repository.entity.WmsOutProduce;
|
||||
import com.nflg.wms.repository.entity.WmsQrCodeMaster;
|
||||
import com.nflg.wms.repository.service.IWmsInventoryService;
|
||||
import com.nflg.wms.repository.service.IWmsOutProduceService;
|
||||
import com.nflg.wms.repository.service.IWmsQrCodeMasterService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -42,6 +46,9 @@ public class QmsService {
|
|||
@Resource
|
||||
private IWmsInventoryService inventoryService;
|
||||
|
||||
@Resource
|
||||
private IWmsOutProduceService outProduceService;
|
||||
|
||||
@Resource
|
||||
private IWmsQrCodeMasterService qrCodeMasterService;
|
||||
|
||||
|
|
@ -126,7 +133,44 @@ public class QmsService {
|
|||
VUtil.trueThrowBusinessError(!inventoryUpdated).throwMessage("未找到对应库存,无法更新检测状态");
|
||||
}
|
||||
|
||||
public void pushPdiInspection(Long outProduceId) {
|
||||
WmsOutProduce outProduce = outProduceService.getById(outProduceId);
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(outProduce)).throwMessage("未找到对应成品发货单");
|
||||
VUtil.trueThrowBusinessError(!Objects.equals(outProduce.getType(), 0) || !Objects.equals(outProduce.getDataType(), 1))
|
||||
.throwMessage("仅成品发货单允许发起PDI检测任务");
|
||||
VUtil.trueThrowBusinessError(StrUtil.hasBlank(outProduce.getPlnbez(), outProduce.getJtsn(), outProduce.getAufnr(), outProduce.getDwerk()))
|
||||
.throwMessage("成品物料号、机台编号、生产订单号、工厂编号不能为空");
|
||||
|
||||
QmsPdiTaskRecordAddQO apply = new QmsPdiTaskRecordAddQO();
|
||||
apply.setModelNo(outProduce.getPlnbez());
|
||||
apply.setDeviceNo(outProduce.getJtsn());
|
||||
apply.setOrderNo(outProduce.getAufnr());
|
||||
apply.setFactoryNo(outProduce.getDwerk());
|
||||
apply.setWarehouseNo(outProduce.getLgort2());
|
||||
|
||||
log.info("推送PDI检测任务到QMS:{}", JSONUtil.toJsonStr(apply));
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<QmsPdiTaskRecordAddQO> requestEntity = new HttpEntity<>(apply, headers);
|
||||
|
||||
ResponseEntity<ApiResult<Void>> response = restTemplate.exchange(
|
||||
qmsHost + "/external/pdi-task-record/add",
|
||||
HttpMethod.POST,
|
||||
requestEntity,
|
||||
new ParameterizedTypeReference<ApiResult<Void>>() {}
|
||||
);
|
||||
|
||||
ApiResult<Void> body = response.getBody();
|
||||
log.info("推送PDI检测任务到QMS结果:{},{}",
|
||||
response.getStatusCode().value(), JSONUtil.toJsonStr(body));
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(body) || body.getCode() != 200)
|
||||
.throwMessage("推送PDI检测任务到QMS失败:" + (Objects.isNull(body) ? "无响应内容" : body.getMessage()));
|
||||
|
||||
}
|
||||
|
||||
private String generateInventoryInspectionRequestNo(Long inventoryId) {
|
||||
return LocalDateTime.now().format(INVENTORY_INSPECTION_REQUEST_NO_FORMATTER) + inventoryId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -11,16 +10,10 @@ import lombok.Data;
|
|||
public class QmsPdiTaskRecordAddQO {
|
||||
|
||||
/**
|
||||
* PDI检测规则ID(必传)
|
||||
* 机型编号(必传)
|
||||
*/
|
||||
@NotNull(message = "PDI检测规则ID不能为空")
|
||||
private Long detectionRulesId;
|
||||
|
||||
/**
|
||||
* 检测任务编号(必传)
|
||||
*/
|
||||
@NotBlank(message = "检测任务编号不能为空")
|
||||
private String taskNo;
|
||||
@NotBlank(message = "机型编号不能为空")
|
||||
private String modelNo;
|
||||
|
||||
/**
|
||||
* 机台编号(必传)
|
||||
|
|
|
|||
|
|
@ -120,15 +120,5 @@ public class OutProduceTicketInfoVO {
|
|||
*/
|
||||
private String docYear;
|
||||
|
||||
/**
|
||||
* 检测状态:0=未检测,1=检测中,2=已检测
|
||||
*/
|
||||
private Short detectionStatus;
|
||||
|
||||
/**
|
||||
* 检测结果:true=合格,false=不合格
|
||||
*/
|
||||
private Boolean detectionResults;
|
||||
|
||||
private List<OutProduceInfoItemVO> items;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,13 +116,4 @@ public class OutProduceVO {
|
|||
*/
|
||||
private String docYear;
|
||||
|
||||
/**
|
||||
* 检测状态:0=未检测,1=检测中,2=已检测
|
||||
*/
|
||||
private Short detectionStatus;
|
||||
|
||||
/**
|
||||
* 检测结果:true=合格,false=不合格
|
||||
*/
|
||||
private Boolean detectionResults;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,13 +137,4 @@ public class WmsOutProduce implements Serializable {
|
|||
@TableField("data_type")
|
||||
private Integer dataType;
|
||||
|
||||
/**
|
||||
* 检测状态:0=未检测,1=检测中,2=已检测
|
||||
*/
|
||||
private Short detectionStatus;
|
||||
|
||||
/**
|
||||
* 检测结果:true=合格,false=不合格
|
||||
*/
|
||||
private Boolean detectionResults;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue