自动化立体仓库 - WMS系统
1
昨天 51889b97a85b070cbb80a5bb2893149c80448d5d
src/main/java/com/zy/asrs/controller/LocDetlController.java
@@ -12,10 +12,12 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.zy.asrs.entity.FrozenParam;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.LocOwner;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.param.AbnormalLocDetlParam;
import com.zy.asrs.entity.param.ExportParam;
import com.zy.asrs.entity.result.LocDetlAll;
import com.zy.asrs.entity.result.LocDetlDTO;
import com.zy.asrs.mapper.LocDetlMapper;
@@ -25,7 +27,7 @@
import com.zy.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
@@ -252,6 +254,26 @@
        return R.ok();
    }
    @PostMapping(value = "/locDetl/frozenInventory")
    @ManagerAuth(memo = "库存冻结")
    public R frozen(@RequestBody List<FrozenParam> param){
        if (param.size() == 0)  {
            return R.parse("未收到数据");
        }
        return locDetlService.frozenInventory(param);
    }
    @PostMapping(value = "/locDetl/unfreezeInventory")
    @ManagerAuth(memo = "库存解冻")
    public R unfreeze(@RequestBody List<FrozenParam> param){
        if (param.size() == 0)  {
            return R.parse("未收到数据");
        }
        return locDetlService.unfreezeInventory(param);
    }
    @RequestMapping(value = "/locDetl/export/auth")
    @ManagerAuth(memo = "库位明细导出")
    public R export(@RequestBody JSONObject param){
@@ -275,42 +297,28 @@
                    .where("loc_no like '" + row + "%'");
        }
        List<LocDetl> list = locDetlService.selectList(wrapper);
        List<AbnormalLocDetlParam> result = new ArrayList<>();
        Page<LocDetl> groupLocDetl = locDetlService.getStockStatis2(toPage(1, 10000, param, LocDetl.class));
        for (LocDetl locDetl : groupLocDetl.getRecords()) {
            AbnormalLocDetlParam abnormalLocDetlParam = new AbnormalLocDetlParam();
            Mat mat = matService.selectOne(new EntityWrapper<Mat>()
                    .eq("matnr", locDetl.getMatnr()));
            if (Cools.isEmpty(mat)) {
                continue;
            }
            if (!Cools.isEmpty(mat                                                                          .getStoreMax()) || !Cools.isEmpty(mat.getStoreMin())) {
                abnormalLocDetlParam.setStoreMax(mat.getStoreMax());
                abnormalLocDetlParam.setStoreMaxDate(mat.getStoreMaxDate());
                abnormalLocDetlParam.setStoreMin(mat.getStoreMin());
                abnormalLocDetlParam.setAnfme(locDetl.getAnfme());
                abnormalLocDetlParam.setMaktx(mat.getMaktx());
                abnormalLocDetlParam.setMatnr(mat.getMatnr());
                abnormalLocDetlParam.setSpecs(mat.getSpecs());
                abnormalLocDetlParam.setBatch(locDetl.getBatch());
//                SimpleDateFormat simple = new SimpleDateFormat("yyyyMMdd");
//                Date maxDate = simple.parse(locDetl.getBatch());
//                long time = maxDate.getTime();
//                Date now = new Date();
//                long time1 = now.getTime();
//                abnormalLocDetlParam.setNowTime((int) ((time1 - time) / (1000 * 60 * 60 * 24)));
                if (!Cools.isEmpty(mat.getStoreMax()) && locDetl.getAnfme() > mat.getStoreMax()) {
                    result.add(abnormalLocDetlParam);
                } else if (!Cools.isEmpty(mat.getStoreMin()) && locDetl.getAnfme() < mat.getStoreMin()) {
                    result.add(abnormalLocDetlParam);
                }
            }
        List<LocDetl> result = new ArrayList<>();
        for (LocDetl locDetl : list) {
            result.add(locDetl);
        }
        return R.ok(exportSupport(result, fields));
    }
//
//    @RequestMapping(value = "/locDetl/statis/export/auth")
//    @ManagerAuth(memo = "库存统计导出(当前筛选条件)")
//    public R statisExport(@RequestBody JSONObject json) {
//        // 获取前端传的字段列表
//        List<String> fields = JSONObject.parseArray(json.getJSONArray("fields").toJSONString(), String.class);
//
//        // 获取搜索参数,转成 DTO
//        ExportParam param = json.getJSONObject("locDetl").toJavaObject(ExportParam.class);
//
//        // 直接调用 Mapper 方法(全量数据,不分页)
//        List<LocDetl> list = locDetlMapper.selectStatisForExport(param);
//
//        // 导出
//        return R.ok(exportSupport(list, fields));
//    }
    @RequestMapping(value = "/locDetl/selectOwner/list/auth")
    @ManagerAuth
@@ -399,29 +407,57 @@
        }
        return R.ok().add(stockStatis);
    }
    @RequestMapping(value = "/locDetl/statis/export/auth")
    @ManagerAuth(memo = "库存统计导出")
    public R statisExport(@RequestBody JSONObject json) {
        // 获取搜索参数
        ExportParam param = json.getJSONObject("locDetl").toJavaObject(ExportParam.class);
    @Autowired
    private LocDetlMapper LocDetlMapper;
        // 查询全量汇总数据
        List<LocDetl> list = locDetlMapper.selectStockStatisExport(param);
    @RequestMapping(value = "/locDetl/statis/export")
//    @ManagerAuth
    public void statisExport(HttpServletResponse response) throws IOException {
        List<LocDetl> excel = LocDetlMapper.getStockStatisExcel();
        for (LocDetl locDetl : excel) {
        // 同步物料信息(保持原有逻辑)
        for (LocDetl locDetl : list) {
            Mat mat = matService.selectByMatnr(locDetl.getMatnr());
            if (mat != null) {
                locDetl.sync(mat);
            }
        }
        // 直接返回 JSON 数据数组
        return R.ok(list);  // 或 R.ok().put("data", list)
    }
    private void exportExcel(HttpServletResponse response, List<LocDetl> list, List<String> fields, String fileName) throws Exception {
        response.setContentType("application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        String fileName = URLEncoder.encode("库存明细统计报表", "UTF-8");
        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
        response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "UTF-8"));
        EasyExcel.write(response.getOutputStream(), LocDetl.class)
                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
                .sheet("表1")
                .doWrite(excel);
                .sheet("库存统计")
                .doWrite(list);
    }
    @Autowired
    private LocDetlMapper LocDetlMapper;
//    @RequestMapping(value = "/locDetl/statis/export")
////    @ManagerAuth
//    public void statisExport(HttpServletResponse response) throws IOException {
//        List<LocDetl> excel = LocDetlMapper.getStockStatisExcel();
//        for (LocDetl locDetl : excel) {
//            Mat mat = matService.selectByMatnr(locDetl.getMatnr());
//            if (mat != null) {
//                locDetl.sync(mat);
//            }
//        }
//        response.setContentType("application/vnd.ms-excel");
//        response.setCharacterEncoding("utf-8");
//        String fileName = URLEncoder.encode("库存明细统计报表", "UTF-8");
//        response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
//        EasyExcel.write(response.getOutputStream(), LocDetl.class)
//                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
//                .sheet("表1")
//                .doWrite(excel);
//    }
    /**
     * 获取库存总数