WangHan
2025-04-02 a8ba678a3fe5a39da2c732014cebbb66e408e97c
consum-base/src/main/java/com/consum/base/controller/LWhWarningConfigController.java
@@ -1,39 +1,5 @@
package com.consum.base.controller;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.convert.Convert;
import com.consum.base.BaseController;
import com.consum.base.config.WhWarningImportVerifyHandler;
import com.consum.base.core.utils.CommonUtil;
import com.consum.base.pojo.WarnConfImEntity;
import com.consum.base.pojo.WhWarningConfigParam;
import com.consum.base.pojo.query.WhWarningConfigQry;
import com.consum.base.service.BaseWarehouseServiceImpl;
import com.consum.base.service.LWhWarningConfigServiceImpl;
import com.consum.model.po.BaseWarehouse;
import com.consum.model.po.FinSysTenantUser;
import com.consum.model.po.WhWarningConfig;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.walker.db.page.GenericPager;
import com.walker.file.FileInfo;
import com.walker.infrastructure.utils.NumberGenerator;
import com.walker.web.ResponseCode;
import com.walker.web.ResponseValue;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -44,6 +10,47 @@
import java.util.Map;
import java.util.stream.Collectors;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.consum.base.BaseController;
import com.consum.base.core.utils.CommonUtil;
import com.consum.base.core.utils.IdUtil;
import com.consum.base.handler.WhWarningImportVerifyHandler;
import com.consum.base.pojo.WarnConfImEntity;
import com.consum.base.pojo.WhWarningConfigParam;
import com.consum.base.pojo.query.WhWarningConfigQry;
import com.consum.base.service.BaseWarehouseService;
import com.consum.base.service.LWhWarningConfigService;
import com.consum.model.po.BaseWarehouse;
import com.consum.model.po.FinSysTenantUser;
import com.consum.model.po.WhWarningConfig;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.walker.db.page.GenericPager;
import com.walker.file.FileInfo;
import com.walker.infrastructure.utils.NumberGenerator;
import com.walker.web.ResponseCode;
import com.walker.web.ResponseValue;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.convert.Convert;
/**
 * @ClassName LWhWarningConfigController
 * @Author cy
@@ -53,13 +60,13 @@
 **/
@RestController
@RequestMapping("/pc/warehouse/warningConfig")
@Api(value = "库存阀值", tags = "库存阀值")
// @Api(value = "库存阀值", tags = "库存阀值")
public class LWhWarningConfigController extends BaseController {
    @Resource
    private LWhWarningConfigServiceImpl lWhWarningConfigService;
    private LWhWarningConfigService lWhWarningConfigService;
    @Resource
    private BaseWarehouseServiceImpl baseWarehouseService;
    private BaseWarehouseService baseWarehouseService;
    private ObjectMapper mapper = new ObjectMapper();
    /**
@@ -68,6 +75,10 @@
    @PostMapping("/add")
    public ResponseValue add() throws Exception {
        WhWarningConfigParam param = CommonUtil.getObjFromReqBody(WhWarningConfigParam.class);
        WhWarningConfigParam param2 = new WhWarningConfigParam();
        CommonUtil.copyProperties(param, param2);
        param = param2;
        String modelConfigStr = param.getModelConfigStr();
        Long baseWarehouseId = param.getBaseWarehouseId();
        Long baseGoodsTemplateId = param.getBaseGoodsTemplateId();
@@ -119,7 +130,7 @@
                return ResponseValue.error("库存上限不能小于下限!");
            }
            WhWarningConfig whWarningConfig = new WhWarningConfig();
            whWarningConfig.setId(NumberGenerator.getLongSequenceNumber());
            whWarningConfig.setId(IdUtil.generateId());
            whWarningConfig.setWarehouseType(0);
            whWarningConfig.setBaseWarehouseId(baseWarehouseId);
            whWarningConfig.setBaseGoodsTemplateId(baseGoodsTemplateId);
@@ -144,6 +155,10 @@
    @PostMapping("/upd")
    public ResponseValue upd() {
        WhWarningConfig param = CommonUtil.getObjFromReqBody(WhWarningConfig.class);
        WhWarningConfig param2 = new WhWarningConfig();
        CommonUtil.copyProperties(param, param2);
        param = param2;
        if (param.getId() == null || (param.getUpperLimit() == null && param.getLowerLimit() == null)) {
            return ResponseValue.error("库存上限、下限不能全为空!");
        }
@@ -160,6 +175,9 @@
    @DeleteMapping("del")
    public ResponseValue delById() {
        WhWarningConfig param = CommonUtil.getObjFromReqBody(WhWarningConfig.class);
        WhWarningConfig param2 = new WhWarningConfig();
        CommonUtil.copyProperties(param, param2);
        param = param2;
        if (param.getId() == null) {
            return ResponseValue.error("id为空");
        }
@@ -170,6 +188,9 @@
    @GetMapping("/getList")
    public ResponseValue getConfigList() {
        WhWarningConfigQry param = CommonUtil.getObjFromReq(WhWarningConfigQry.class);
        WhWarningConfigQry param2 = new WhWarningConfigQry();
        CommonUtil.copyProperties(param, param2);
        param = param2;
        /*当前登录人只能看到自己机构下的列表*/
        FinSysTenantUser sysInfo = this.getSysInfo();
        String tenantId = sysInfo.getTenantId();
@@ -184,12 +205,20 @@
    @GetMapping("/getById")
    public ResponseValue getById() {
        WhWarningConfig param = CommonUtil.getObjFromReq(WhWarningConfig.class);
        WhWarningConfig param2 = new WhWarningConfig();
        CommonUtil.copyProperties(param, param2);
        param = param2;
        WhWarningConfig whWarningConfig = lWhWarningConfigService.get(param);
        return ResponseValue.success(whWarningConfig);
    }
    @GetMapping("/getConfigList")
    public ResponseValue getConfigList(WhWarningConfig param) {
    public ResponseValue getWarnConfigList() {
        WhWarningConfig param = CommonUtil.getObjFromReq(WhWarningConfig.class);
        WhWarningConfig param2 = new WhWarningConfig();
        CommonUtil.copyProperties(param, param2);
        param = param2;
        if (param.getBaseWarehouseId() == null || param.getWarehouseType() == null || (param.getBaseGoodsModelsId() == null || param.getBaseGoodsTemplateId() == null)) {
            return ResponseValue.error("缺少必要参数");
        }
@@ -200,7 +229,7 @@
     * @return 获取项目导入的模板
     * @throws IOException
     */
    @PostMapping("getWarnConfImportTemplate")
    @GetMapping("getWarnConfImportTemplate")
    public ResponseEntity<InputStreamResource> getProjectImportTemplate() throws IOException {
        // 从当前项目资源目录获取文件
        org.springframework.core.io.Resource resource = new ClassPathResource("import/warningConfImp.xls");
@@ -277,7 +306,7 @@
                for (WarnConfImEntity warnConfImEntity : houseModelList) {
                    // 新增
                    WhWarningConfig whWarningConfig = new WhWarningConfig();
                    whWarningConfig.setId(NumberGenerator.getLongSequenceNumber());
                    whWarningConfig.setId(IdUtil.generateId());
                    whWarningConfig.setWarehouseType(0);
                    whWarningConfig.setBaseWarehouseId(warnConfImEntity.getBaseWarehouseId());
                    whWarningConfig.setBaseGoodsTemplateId(warnConfImEntity.getGoodsTemplateId());
@@ -310,7 +339,7 @@
                        limitEditByModeInfo(whWarningConfig);
                    } else {
                        // 新增
                        whWarningConfig.setId(NumberGenerator.getLongSequenceNumber());
                        whWarningConfig.setId(IdUtil.generateId());
                        whWarningConfig.setBaseGoodsTemplateId(warnConfImEntity.getGoodsTemplateId());
                        if (whWarningConfig.getBaseGoodsModelsId() == null) {
                            whWarningConfig.setGoodsType(1);