From 51e9b24c421dd2e77ec5809a62c35fec115d5876 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期四, 20 三月 2025 14:12:02 +0800 Subject: [PATCH] #添加 1. 添加库位逻辑分区 2. 物料添加自动生成编码 3. 库区字段显示优化 --- rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/MatnrController.java | 31 ++++++++++++++++++++++++------- 1 files changed, 24 insertions(+), 7 deletions(-) diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/MatnrController.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/MatnrController.java index 12ed36f..c992c2d 100644 --- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/MatnrController.java +++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/MatnrController.java @@ -17,13 +17,16 @@ import com.vincent.rsf.server.manager.entity.Matnr; import com.vincent.rsf.server.manager.entity.excel.MatnrsTemplate; import com.vincent.rsf.server.manager.service.MatnrService; +import com.vincent.rsf.server.system.constant.SerialRuleCode; import com.vincent.rsf.server.system.controller.BaseController; +import com.vincent.rsf.server.system.utils.SerialRuleUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -76,22 +79,26 @@ if (Objects.isNull(matnr.get("matnr"))) { throw new CoolException("鍚嶇О涓嶈兘涓虹┖锛侊紒"); } - if (Objects.isNull(matnr.get("code"))) { - throw new CoolException("缂栫爜涓嶈兘涓虹┖锛侊紒"); - } if (Objects.isNull(matnr.get("groupId"))) { throw new CoolException("鐗╂枡鍒嗙粍涓嶈兘涓虹┖锛侊紒"); } + Matnr matnr1 = JSONObject.parseObject(JSONObject.toJSONString(matnr), Matnr.class); + if (Objects.isNull(matnr1.getCode())) { + String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_MATNR_CODE, null); + System.out.println("=========>"); + System.out.println(ruleCode); + matnr1.setCode(ruleCode); + } /** * 鎵╁睍瀛楁瀛樺叆搴� */ + String uuid16 = CommonUtil.randomUUID16(); if (!FieldsUtils.getFieldsSta().isEmpty()) { - String uuid16 = CommonUtil.randomUUID16(); FieldsUtils.saveFields(matnr, uuid16); + matnr1.setFieldsIndex(uuid16); } - Matnr matnr1 = JSONObject.parseObject(JSONObject.toJSONString(matnr), Matnr.class); matnr1.setCreateBy(getLoginUserId()); matnr1.setUpdateBy(getLoginUserId()); @@ -104,12 +111,22 @@ @PreAuthorize("hasAuthority('manager:matnr:update')") @OperationLog("Update 鐗╂枡淇℃伅琛�") @PostMapping("/matnr/update") - public R update(@RequestBody Matnr matnr) { + @Transactional(rollbackFor = Exception.class) + public R update(@RequestBody Map<String, Object> params) { + Matnr matnr = JSONObject.parseObject(JSONObject.toJSONString(params), Matnr.class); + if (Objects.isNull(matnr.getCode())) { + throw new CoolException("缂栫爜涓嶈兘涓虹┖锛侊紒"); + } + if (Objects.isNull(matnr.getName())) { + throw new CoolException("鍚嶇О涓嶈兘涓虹┖锛侊紒"); + } matnr.setUpdateBy(getLoginUserId()); - matnr.setUpdateTime(new Date()); if (!matnrService.updateById(matnr)) { return R.error("Update Fail"); } + if (!Objects.isNull(params.get("fieldsIndex"))) { + FieldsUtils.updateFieldsValue(params); + } return R.ok("Update Success").add(matnr); } -- Gitblit v1.9.1