fix:物料验收检化验节点自动执行;二维码组装与解析,支持只序列化指定的字段;

This commit is contained in:
shusir
2026-03-31 15:54:17 +08:00
parent c04e3d70ad
commit bb316b837f
14 changed files with 259 additions and 81 deletions

View File

@@ -0,0 +1,66 @@
package com.zt.plat.module.qms.core.util.qrcode;
import cn.hutool.core.lang.func.Func1;
import cn.hutool.core.lang.func.LambdaUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.zt.plat.framework.common.exception.ServiceException;
import com.zt.plat.module.qms.resource.material.controller.vo.assist.QrCodeContent;
import java.util.Map;
public class QrCodeJsonUtil {
@SafeVarargs
public static String getQrCode(QrCodeContent qrCode,
Func1<QrCodeContent, ?>... getters) {
JSONObject json = JSONUtil.createObj();
for (Func1<QrCodeContent, ?> getter : getters) {
String methodName = LambdaUtil.getMethodName(getter);
String fieldName = extractFieldName(methodName);
Object value;
try {
value = getter.call(qrCode);
} catch (Exception e) {
throw new RuntimeException(e);
}
if (value != null) {
json.set(fieldName, value);
}
}
return json.toString();
}
public static String getQrCode(Map<Func1<QrCodeContent, ?>, Object> fieldValueMap){
JSONObject json = JSONUtil.createObj();
for (Map.Entry<Func1<QrCodeContent, ?>, Object> entry : fieldValueMap.entrySet()) {
Func1<QrCodeContent, ?> getter = entry.getKey();
Object value = entry.getValue();
if (value != null) {
String methodName = LambdaUtil.getMethodName(getter);
String fieldName = extractFieldName(methodName);
json.set(fieldName, value);
}
}
return json.toString();
}
public static QrCodeContent parseQrCode(String json) {
QrCodeContent content;
try {
content = JSONUtil.toBean(json, QrCodeContent.class);
} catch (Exception e) {
throw new ServiceException(1_032_160_000,"二维码解析失败");
}
return content;
}
private static String extractFieldName(String methodName) {
if (methodName.startsWith("get")) {
String prop = methodName.substring(3);
return Character.toLowerCase(prop.charAt(0)) + prop.substring(1);
}
throw new UnsupportedOperationException("仅支持 getXxx 形式的 getter");
}
}

View File

@@ -31,7 +31,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 物料检化验关联信息")
@RestController
@RequestMapping("/qms/material-correlation-assay")
@RequestMapping("/qms/resource/material-correlation-assay")
@Validated
public class MaterialCorrelationAssayController implements BusinessControllerMarker {
@@ -39,7 +39,7 @@ public class MaterialCorrelationAssayController implements BusinessControllerMar
@Resource
private MaterialCorrelationAssayService materialCorrelationAssayService;
@PostMapping("/create")
// @PostMapping("/create")
@Operation(summary = "创建物料检化验关联信息")
@PreAuthorize("@ss.hasPermission('qms:material-correlation-assay:create')")
public CommonResult<MaterialCorrelationAssayRespVO> createMaterialCorrelationAssay(@Valid @RequestBody MaterialCorrelationAssaySaveReqVO createReqVO) {
@@ -48,13 +48,13 @@ public class MaterialCorrelationAssayController implements BusinessControllerMar
@PutMapping("/update")
@Operation(summary = "更新物料检化验关联信息")
@PreAuthorize("@ss.hasPermission('qms:material-correlation-assay:update')")
// @PreAuthorize("@ss.hasPermission('qms:material-correlation-assay:update')")
public CommonResult<Boolean> updateMaterialCorrelationAssay(@Valid @RequestBody MaterialCorrelationAssaySaveReqVO updateReqVO) {
materialCorrelationAssayService.updateMaterialCorrelationAssay(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
// @DeleteMapping("/delete")
@Operation(summary = "删除物料检化验关联信息")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('qms:material-correlation-assay:delete')")
@@ -63,7 +63,7 @@ public class MaterialCorrelationAssayController implements BusinessControllerMar
return success(true);
}
@DeleteMapping("/delete-list")
// @DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除物料检化验关联信息")
@PreAuthorize("@ss.hasPermission('qms:material-correlation-assay:delete')")
@@ -75,7 +75,7 @@ public class MaterialCorrelationAssayController implements BusinessControllerMar
@GetMapping("/get")
@Operation(summary = "获得物料检化验关联信息")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('qms:material-correlation-assay:query')")
// @PreAuthorize("@ss.hasPermission('qms:material-correlation-assay:query')")
public CommonResult<MaterialCorrelationAssayRespVO> getMaterialCorrelationAssay(@RequestParam("id") Long id) {
MaterialCorrelationAssayDO materialCorrelationAssay = materialCorrelationAssayService.getMaterialCorrelationAssay(id);
return success(BeanUtils.toBean(materialCorrelationAssay, MaterialCorrelationAssayRespVO.class));

View File

@@ -127,8 +127,9 @@ public class MaterialLifecycleController extends AbstractFileUploadController im
}
@GetMapping("/test")
public void test() {
materialAssayResultListener.bpmTest();
@Parameter(name = "flowId", description = "流程id", required = true)
public void test(@RequestParam("flowId") String flowId) {
materialAssayResultListener.bpmTest(flowId);
}
@GetMapping("/export-excel")

View File

@@ -1,9 +1,8 @@
package com.zt.plat.module.qms.resource.material.controller.vo;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.zt.plat.module.qms.core.aspect.annotation.Dict;
import com.zt.plat.module.qms.resource.material.controller.vo.assist.MaterialQrCode;
import com.zt.plat.module.qms.resource.material.controller.vo.assist.QrCodeContent;
import com.zt.plat.module.qms.core.util.qrcode.QrCodeJsonUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
@@ -58,7 +57,7 @@ public class MaterialInfomationRespVO {
private String code;
@Schema(description = "二维码内容")
private MaterialQrCode qrCode;
private QrCodeContent qrCode;
@Schema(description = "来源,批次入库,标液配置、危化品配置等")
@ExcelProperty("来源,批次入库,标液配置、危化品配置等")
@@ -223,10 +222,10 @@ public class MaterialInfomationRespVO {
// 设置二维码内容
public String getQrCode() {
MaterialQrCode qrCode = new MaterialQrCode();
QrCodeContent qrCode = new QrCodeContent();
qrCode.setCode(this.code);
// qrCode.setName(this.name);
return JSONUtil.toJsonStr(qrCode);
qrCode.setName(this.name);
return QrCodeJsonUtil.getQrCode(qrCode, QrCodeContent::getCode);
}
// 用于标签

View File

@@ -1,10 +1,9 @@
package com.zt.plat.module.qms.resource.material.controller.vo;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.zt.plat.module.qms.resource.material.controller.vo.assist.MaterialQrCode;
import com.zt.plat.module.qms.resource.material.controller.vo.assist.QrCodeContent;
import com.zt.plat.module.qms.core.util.qrcode.QrCodeJsonUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -105,14 +104,14 @@ public class MaterialInventoryInboundDetailRespVO {
private LocalDateTime createTime;
@Schema(description = "二维码内容")
private MaterialQrCode qrCode;
private QrCodeContent qrCode;
// 设置二维码内容
public String getQrCode() {
MaterialQrCode qrCode = new MaterialQrCode();
QrCodeContent qrCode = new QrCodeContent();
qrCode.setCode(this.infomationCode);
// qrCode.setName(this.infomationName);
return JSONUtil.toJsonStr(qrCode);
qrCode.setName(this.infomationName);
return QrCodeJsonUtil.getQrCode(qrCode, QrCodeContent::getCode);
}
}

View File

@@ -1,30 +0,0 @@
package com.zt.plat.module.qms.resource.material.controller.vo.assist;
import lombok.Data;
/**
* 物料二维码信息
*/
@Data
public class MaterialQrCode {
/**
* 编号
*/
private String code;
// /**
// * 名称
// */
// private String name;
// /**
// * 批次号
// */
// private String batchNo;
// /**
// * 规格
// */
// private String specification;
// /**
// * 制造商
// */
// private String manufacturer;
}

View File

@@ -0,0 +1,30 @@
package com.zt.plat.module.qms.resource.material.controller.vo.assist;
import lombok.Data;
/**
* 物料二维码信息
*/
@Data
public class QrCodeContent {
/**
* 编号
*/
private String code;
/**
* 名称
*/
private String name;
/**
* 批次号
*/
private String batchNo;
/**
* 规格
*/
private String specification;
/**
* 制造商
*/
private String manufacturer;
}

View File

@@ -3,7 +3,8 @@ package com.zt.plat.module.qms.resource.material.controller.vo.query;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.zt.plat.framework.common.exception.ServiceException;
import com.zt.plat.module.qms.resource.material.controller.vo.assist.MaterialQrCode;
import com.zt.plat.module.qms.core.util.qrcode.QrCodeJsonUtil;
import com.zt.plat.module.qms.resource.material.controller.vo.assist.QrCodeContent;
import com.zt.plat.module.qms.resource.material.enums.MaterialInfomationOneBusinessType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -98,13 +99,9 @@ public class MaterialInfomationQueryVO {
public String getCode() {
// 优先从二维码字符串中解析 code
if (StrUtil.isNotEmpty(this.qrCode)) {
try {
MaterialQrCode materialQrCode = JSONUtil.toBean(this.qrCode, MaterialQrCode.class);
QrCodeContent materialQrCode = QrCodeJsonUtil.parseQrCode(this.qrCode);
if (materialQrCode == null) return this.code;
return StrUtil.isNotEmpty(materialQrCode.getCode()) ? materialQrCode.getCode() : this.code;
} catch (Exception e) {
throw new ServiceException(1_032_160_000,"二维码解析失败");
}
}
return this.code;
}

View File

@@ -97,4 +97,19 @@ public interface MaterialCorrelationAssayService {
* @return 检化验关联信息列表
*/
List<MaterialCorrelationAssayRespVO> getRespListByIds(List<Long> ids);
/**
* 根据委托id查询
*
* @param entrustId 委托id
* @return 检化验关联信息
*/
MaterialCorrelationAssayDO getByEntrustId(Long entrustId);
/**
* 根据id更新
*
* @param assay 检化验关联信息
*/
void updateById(MaterialCorrelationAssayDO assay);
}

Some files were not shown because too many files have changed in this diff Show More