1
luxiaotao1123
2021-09-24 33817dd27d0527bf7eff142bf74c09fceb628590
src/main/java/com/zy/asrs/controller/LocNormalController.java
@@ -1,6 +1,7 @@
package com.zy.asrs.controller;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -12,10 +13,13 @@
import com.core.common.R;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.zy.asrs.entity.LocNormal;
import com.zy.asrs.entity.LocNormalLog;
import com.zy.asrs.entity.LocNormalReport;
import com.zy.asrs.entity.param.LocNormalParam;
import com.zy.asrs.service.LocNormalLogService;
import com.zy.asrs.service.LocNormalReportService;
import com.zy.asrs.service.LocNormalService;
import com.zy.asrs.utils.VersionUtils;
import com.zy.common.service.erp.ErpService;
import com.zy.common.service.erp.ErpSqlServer;
import com.zy.common.utils.excel.locNomal.LocNormalExcel;
@@ -23,6 +27,7 @@
import com.zy.common.utils.excel.matcode.MatCodeExcel;
import com.zy.common.utils.excel.matcode.MatCodeExcelListener;
import com.zy.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
@@ -42,6 +47,7 @@
import static jdk.nashorn.api.scripting.ScriptUtils.convert;
@Slf4j
@RestController
public class LocNormalController extends BaseController {
    @Autowired
@@ -50,6 +56,8 @@
    private LocNormalReportService locNormalReportService;
    @Autowired
    private ErpSqlServer erpSqlServer;
    @Autowired
    private LocNormalLogService locNormalLogService;
    @RequestMapping(value = "/locNomal/list/auth")
    @ManagerAuth
@@ -127,6 +135,17 @@
        ErpSql = MessageFormat.format(ErpSql, param.getMatnr(), erpCount);
        erpSqlServer.update(ErpSql);
        locNormalService.updateLocNormal(param.getMatnr(), param.getAnfme(), modiUser, modiTime, param.getId());
        // 生成平仓出入库记录
        LocNormalLog locLog = new LocNormalLog();
        VersionUtils.setLocNormalLog(locLog, param);
        locLog.setAnfme(erpCount.doubleValue());
        locLog.setIoType(3); // 修改
        locLog.setCreateTime(new Date());
        locLog.setCreateUser(modiUser);
        if (!locNormalLogService.insert(locLog)) {
            String logStr = JSON.toJSONString(locLog);
            log.info("平仓修改库存记录插入失败,数据:" + logStr);
        }
    }
    @RequestMapping(value = "/locNormal/outLoc/auth")
@@ -153,6 +172,19 @@
        LocNormalExcelListener listener = new LocNormalExcelListener(getUserId());
        EasyExcel.read(file.getInputStream(), LocNormalExcel.class, listener).sheet().doRead();
        return R.ok("成功导入" + listener.getTotal() + "条物料信息");
    }
    /* 导出 */
    @RequestMapping(value = "/locNormal/export/auth")
    @ManagerAuth(memo = "平仓管理导出")
    public R export(@RequestBody JSONObject param){
        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
        EntityWrapper<LocNormal> wrapper = new EntityWrapper<LocNormal>();
        wrapper.ne("state", "3");
        Map<String, Object> map = excludeTrash(param.getJSONObject("exportData"));
        convert(map, wrapper);
        List<LocNormal> list = locNormalService.selectList(wrapper);
        return R.ok(exportSupport(list, fields));
    }
    /* 平仓入库 成品 */
@@ -257,15 +289,11 @@
                  @RequestParam(required = false) String condition,
                  @RequestParam Map<String, Object> param) {
        excludeTrash(param);
        EntityWrapper<LocNormalReport> wrapper = new EntityWrapper<>();
        List<String> orderList = new ArrayList<>();
        orderList.add("time");
        wrapper.eq("state", param.get("state").toString()).orderDesc(orderList);
        String timeRange = "";
        EntityWrapper<LocNormalLog> wrapper = new EntityWrapper<>();
        String time1 = "";
        String time2 = "";
        if (!Cools.isEmpty(param.get("query_date"))) {
            timeRange = param.get("query_date").toString();
            String timeRange = param.get("query_date").toString();
            time1 = timeRange.substring(0, 19);
            time2 = timeRange.substring(21, timeRange.length());
        }
@@ -281,9 +309,22 @@
            } catch (Exception e) {
                e.printStackTrace();
            }
            wrapper.ge("time", dateTime1).and().le("time", dateTime2);
            wrapper.ge("create_time", dateTime1).and().le("create_time", dateTime2);
        }
        allLike(LocNormalReport.class, param.keySet(), wrapper, condition);
        return R.ok(locNormalReportService.selectPage(new Page<>(curr, limit), wrapper));
        List<String> oderCol = new ArrayList<>();
        oderCol.add("create_time");
        wrapper.orderDesc(oderCol);
        allLike(LocNormalLog.class, param.keySet(), wrapper, condition);
        return R.ok(locNormalLogService.selectPage(new Page<>(curr, limit), wrapper));
    }
    //excel导出
    @RequestMapping("/locNomal/normalReportExport.action")
    @ManagerAuth(memo = "日入库明细统计导出")
    public R normalReportExport(@RequestBody JSONObject param){
        List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
        @SuppressWarnings("unchecked")
        List<LocNormalLog> list = JSONObject.parseArray(param.getJSONArray("exportData").toJSONString(), LocNormalLog.class);
        return R.ok(exportSupport(list, fields));
    }
}