5 changed files with 395 additions and 0 deletions
-
74cclqms-java/src/main/java/com/gaotao/modules/api/controller/QcInspectionTaskApiController.java
-
154cclqms-java/src/main/java/com/gaotao/modules/api/dto/AutogenerateInspectionTaskRequestDto.java
-
60cclqms-java/src/main/java/com/gaotao/modules/api/dto/AutogenerateInspectionTaskResponseDto.java
-
98cclqms-java/src/main/java/com/gaotao/modules/pms/service/Impl/QcServiceImpl.java
-
9cclqms-java/src/main/java/com/gaotao/modules/pms/service/QcService.java
@ -0,0 +1,74 @@ |
|||||
|
package com.gaotao.modules.api.controller; |
||||
|
|
||||
|
import com.gaotao.modules.api.dto.AutogenerateInspectionTaskRequestDto; |
||||
|
import com.gaotao.modules.api.dto.AutogenerateInspectionTaskResponseDto; |
||||
|
import com.gaotao.modules.pms.data.QcFAIRecordData; |
||||
|
import com.gaotao.modules.pms.service.QcService; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.BeanUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.validation.BindingResult; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import jakarta.validation.Valid; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 检验任务对外开放接口 |
||||
|
* 供其它系统调用自动生成检验任务(GetAutogenerateinspectiontasks) |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Api(tags = "QC检验任务开放接口") |
||||
|
@RestController |
||||
|
@RequestMapping("/api/qc") |
||||
|
public class QcInspectionTaskApiController { |
||||
|
|
||||
|
@Autowired |
||||
|
private QcService qcService; |
||||
|
|
||||
|
/** |
||||
|
* 自动生成检验任务 |
||||
|
* |
||||
|
* @param request 请求参数 |
||||
|
* @return 响应结果(含检验单号) |
||||
|
*/ |
||||
|
@ApiOperation(value = "自动生成检验任务", notes = "其它系统调用,自动生成 IQC/IPQC/FQC/OQC/SQC 等检验任务") |
||||
|
@PostMapping(value = "/autogenerateInspectionTasks", |
||||
|
consumes = MediaType.APPLICATION_JSON_VALUE, |
||||
|
produces = MediaType.APPLICATION_JSON_VALUE) |
||||
|
public AutogenerateInspectionTaskResponseDto autogenerateInspectionTasks( |
||||
|
@Valid @RequestBody AutogenerateInspectionTaskRequestDto request) { |
||||
|
try { |
||||
|
log.info("收到自动生成检验任务请求,inspectionType: {}, site: {}, buNo: {}, partNo: {}, orderNo: {}", |
||||
|
request.getInspectionType(), request.getSite(), request.getBuNo(), |
||||
|
request.getPartNo(), request.getOrderNo()); |
||||
|
QcFAIRecordData data = new QcFAIRecordData(); |
||||
|
BeanUtils.copyProperties(request, data); |
||||
|
if (StringUtils.isBlank(data.getBu()) |
||||
|
&& StringUtils.isNotBlank(request.getSite()) |
||||
|
&& StringUtils.isNotBlank(request.getBuNo())) { |
||||
|
data.setBu(request.getSite() + "_" + request.getBuNo()); |
||||
|
} |
||||
|
|
||||
|
Map<String, Object> result = qcService.autogenerateInspectionTasksApi(data, request.getInspectionType()); |
||||
|
String inspectionNo = data.getInspectionNo(); |
||||
|
if (StringUtils.isBlank(inspectionNo) && result != null && result.get("inspectionNo") != null) { |
||||
|
inspectionNo = String.valueOf(result.get("inspectionNo")); |
||||
|
} |
||||
|
|
||||
|
log.info("自动生成检验任务完成,inspectionType: {}, inspectionNo: {}", |
||||
|
request.getInspectionType(), inspectionNo); |
||||
|
return AutogenerateInspectionTaskResponseDto.success(inspectionNo, result); |
||||
|
} catch (RuntimeException e) { |
||||
|
log.error("自动生成检验任务业务异常", e); |
||||
|
return AutogenerateInspectionTaskResponseDto.failure("处理失败: " + e.getMessage()); |
||||
|
} catch (Exception e) { |
||||
|
log.error("自动生成检验任务未预期异常", e); |
||||
|
return AutogenerateInspectionTaskResponseDto.failure("系统内部错误,请联系管理员"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,154 @@ |
|||||
|
package com.gaotao.modules.api.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import jakarta.validation.constraints.NotBlank; |
||||
|
import java.math.BigDecimal; |
||||
|
|
||||
|
/** |
||||
|
* 自动生成检验任务对外开放接口请求DTO |
||||
|
*/ |
||||
|
@Data |
||||
|
public class AutogenerateInspectionTaskRequestDto { |
||||
|
|
||||
|
/** |
||||
|
* 检验类型:IQC / IPQC / FQC / OQC / SQC 等 |
||||
|
*/ |
||||
|
@NotBlank(message = "检验类型不能为空") |
||||
|
private String inspectionType; |
||||
|
|
||||
|
/** |
||||
|
* 工厂编码(可与 buNo 分开传,也可通过 bu=site_buNo 合并传) |
||||
|
*/ |
||||
|
private String site; |
||||
|
|
||||
|
/** |
||||
|
* 部门/事业部编码 |
||||
|
*/ |
||||
|
private String buNo; |
||||
|
|
||||
|
/** |
||||
|
* site_buNo 合并字段,如 1001_01 |
||||
|
*/ |
||||
|
private String bu; |
||||
|
|
||||
|
/** |
||||
|
* 标签条码 / 卷号 |
||||
|
*/ |
||||
|
private String rollNo; |
||||
|
|
||||
|
/** |
||||
|
* 批次号 |
||||
|
*/ |
||||
|
private String batchNo; |
||||
|
|
||||
|
/** |
||||
|
* 工单号(或订单号) |
||||
|
*/ |
||||
|
private String orderNo; |
||||
|
|
||||
|
/** |
||||
|
* 派工单号 / 工序序号 |
||||
|
*/ |
||||
|
private String seqNo; |
||||
|
|
||||
|
/** |
||||
|
* 采购订单号(优先于 orderNo) |
||||
|
*/ |
||||
|
private String poOrderNo; |
||||
|
|
||||
|
/** |
||||
|
* 采购订单行号(优先于 seqNo) |
||||
|
*/ |
||||
|
private String poItemNo; |
||||
|
|
||||
|
/** |
||||
|
* 下达号 |
||||
|
*/ |
||||
|
private String releaseNo; |
||||
|
|
||||
|
/** |
||||
|
* 行号 |
||||
|
*/ |
||||
|
private String lineNo; |
||||
|
|
||||
|
/** |
||||
|
* 工序名称 |
||||
|
*/ |
||||
|
private String operationDesc; |
||||
|
|
||||
|
/** |
||||
|
* 机台号 |
||||
|
*/ |
||||
|
private String resourceId; |
||||
|
|
||||
|
/** |
||||
|
* 物料编码 |
||||
|
*/ |
||||
|
private String partNo; |
||||
|
|
||||
|
/** |
||||
|
* IPQC 细分类型编码(如巡检编码),会与 IPQC 前缀组合 |
||||
|
*/ |
||||
|
private String inspectionTypeNo; |
||||
|
|
||||
|
/** |
||||
|
* 送检数量 |
||||
|
*/ |
||||
|
private BigDecimal rollQty; |
||||
|
|
||||
|
/** |
||||
|
* 工单数量 / 批量 |
||||
|
*/ |
||||
|
private String lotsize; |
||||
|
|
||||
|
/** |
||||
|
* 创建人账号(无登录态时建议传入) |
||||
|
*/ |
||||
|
private String createBy; |
||||
|
|
||||
|
/** |
||||
|
* 用户名(可作为 createBy / inspectorBy 兜底) |
||||
|
*/ |
||||
|
private String userName; |
||||
|
|
||||
|
/** |
||||
|
* 检验员 / 送检人账号 |
||||
|
*/ |
||||
|
private String inspectorBy; |
||||
|
|
||||
|
/** |
||||
|
* 供应商编码 |
||||
|
*/ |
||||
|
private String supplierNo; |
||||
|
|
||||
|
/** |
||||
|
* 客户编码 |
||||
|
*/ |
||||
|
private String customerNo; |
||||
|
|
||||
|
/** |
||||
|
* 模板编码,默认 * |
||||
|
*/ |
||||
|
private String templateId; |
||||
|
|
||||
|
/** |
||||
|
* 特殊要求 |
||||
|
*/ |
||||
|
private String specialRequirements; |
||||
|
|
||||
|
/** |
||||
|
* 任务来源 |
||||
|
*/ |
||||
|
private String taskSource; |
||||
|
|
||||
|
/** |
||||
|
* 关联单据号(如 FQC 检验单号) |
||||
|
*/ |
||||
|
private String documentNo; |
||||
|
|
||||
|
/** |
||||
|
* 语言:CN / EN |
||||
|
*/ |
||||
|
private String languageCode; |
||||
|
} |
||||
@ -0,0 +1,60 @@ |
|||||
|
package com.gaotao.modules.api.dto; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 自动生成检验任务对外开放接口响应DTO |
||||
|
*/ |
||||
|
@Data |
||||
|
public class AutogenerateInspectionTaskResponseDto { |
||||
|
|
||||
|
/** |
||||
|
* 返回编码(0成功/1失败) |
||||
|
*/ |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 返回消息 |
||||
|
*/ |
||||
|
private String msg; |
||||
|
|
||||
|
/** |
||||
|
* 生成的检验单号 |
||||
|
*/ |
||||
|
private String inspectionNo; |
||||
|
|
||||
|
/** |
||||
|
* 存储过程原始返回数据 |
||||
|
*/ |
||||
|
private Map<String, Object> data; |
||||
|
|
||||
|
public static AutogenerateInspectionTaskResponseDto success() { |
||||
|
AutogenerateInspectionTaskResponseDto response = new AutogenerateInspectionTaskResponseDto(); |
||||
|
response.setCode("0"); |
||||
|
response.setMsg("创建检验任务成功"); |
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
public static AutogenerateInspectionTaskResponseDto success(String message) { |
||||
|
AutogenerateInspectionTaskResponseDto response = new AutogenerateInspectionTaskResponseDto(); |
||||
|
response.setCode("0"); |
||||
|
response.setMsg(message); |
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
public static AutogenerateInspectionTaskResponseDto success(String inspectionNo, Map<String, Object> data) { |
||||
|
AutogenerateInspectionTaskResponseDto response = success(); |
||||
|
response.setInspectionNo(inspectionNo); |
||||
|
response.setData(data); |
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
public static AutogenerateInspectionTaskResponseDto failure(String message) { |
||||
|
AutogenerateInspectionTaskResponseDto response = new AutogenerateInspectionTaskResponseDto(); |
||||
|
response.setCode("1"); |
||||
|
response.setMsg(message); |
||||
|
return response; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue