skyouc
2025-03-20 b051c20595c8563df49a50092a11468c8a99de46
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);
    }