jiazx0107@163.com
2023-06-05 7f5ecaf7dbd07e218fbda575e45d8264a560a1e6
igds-inout/src/main/java/com/ld/igds/inout/controller/InoutController.java
@@ -1,6 +1,7 @@
package com.ld.igds.inout.controller;
import com.bstek.bdf2.core.business.IUser;
import com.bstek.bdf2.core.model.DefaultDept;
import com.ld.igds.check.dto.CheckItemData;
import com.ld.igds.common.manager.CommonManager;
import com.ld.igds.constant.BizType;
@@ -9,13 +10,11 @@
import com.ld.igds.data.BaseParam;
import com.ld.igds.data.Page;
import com.ld.igds.data.PageResponse;
import com.ld.igds.data.SimpleDepot;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.inout.dto.InoutGateDto;
import com.ld.igds.inout.dto.InoutParam;
import com.ld.igds.inout.dto.*;
import com.ld.igds.inout.manager.InoutCommonManager;
import com.ld.igds.inout.manager.InoutManager;
import com.ld.igds.io.dto.WeightDto;
import com.ld.igds.models.Depot;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.models.InoutConf;
@@ -92,7 +91,6 @@
        // 车牌识别参数封装
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_10, InoutConstant.PROGRESS_REGISTER, 1);
        if(null != conf) conf.setSort(sort);
        view.addObject("lprDto", conf);
        //初始化车牌识别
@@ -174,7 +172,6 @@
        }
        ModelAndView view = new ModelAndView();
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
@@ -184,59 +181,52 @@
        view.addObject("deptId", deptId);
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listInDepot();
        List<SimpleDepot> listDepot = commonManager.getCacheDeptIn(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
        // 当前流程标签
        view.addObject("progress", InoutConstant.PROGRESS_WEIGHT_TAG);
        //入库流程
        //入库流程配置
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), deptId, InoutConstant.TYPE_IN);
        view.addObject("inoutProgress", inoutProgress);
        //称重结果是否可修改
        String weightEditTag = inoutCommonManager.getWeightEditTag(user.getCompanyId(), ContextUtil.subDeptId(user));
        //称重是否可编辑标签
        String weightEditTag = inoutCommonManager.getWeightEditTag(user.getCompanyId(), deptId);
        view.addObject("weightEditTag", weightEditTag);
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
        // 获取出入库配置信息
        // 获取出入库设备配置信息
        List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId);
        //获取所有的地磅列表用于页面用户选择
        List<WeightDto> listWeight = inoutCommonManager.getInoutWeightAll(listInoutConf, InoutConstant.CONF_TYPE_30);
        //根据出入库设备信息筛选地磅配置信息,所有地磅,支持用户手动选择
        List<InoutConf> listWeight = inoutCommonManager.getInoutConf(listInoutConf, InoutConstant.CONF_TYPE_30);
        view.addObject("listWeight", listWeight);
        // 获取当前地磅信息
        WeightDto weightDto = inoutCommonManager.getInoutCurWeight(listWeight, sort);
        // 获取当前地磅
        InoutConf weightDto = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_30);
        view.addObject("weightDto", weightDto);
        // 过程摄像头1
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60,
                InoutConstant.PROGRESS_WEIGHT_TAG, 1);
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60, InoutConstant.PROGRESS_WEIGHT_TAG, 1);
        view.addObject("snapDto1", conf);
        // 过程摄像头2
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60,
                InoutConstant.PROGRESS_WEIGHT_TAG, 2);
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60, InoutConstant.PROGRESS_WEIGHT_TAG, 2);
        view.addObject("snapDto2", conf);
        // 过程摄像头3
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60,
                InoutConstant.PROGRESS_WEIGHT_TAG, 3);
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_60, InoutConstant.PROGRESS_WEIGHT_TAG, 3);
        view.addObject("snapDto3", conf);
         conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_70,
                InoutConstant.PROGRESS_WEIGHT_TAG, 1);
        view.addObject("gateDto", conf);
        // 智慧卡
        // 远程智慧卡
        conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_80, InoutConstant.PROGRESS_WEIGHT_TAG, 1);
        if(null != conf) conf.setSort(sort);
        if (null != conf) conf.setSort(sort);
        view.addObject("cardDto", conf);
        view.setViewName("admin/inout/in-weight");
        return view;
@@ -255,12 +245,13 @@
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_IN.getCode());
        view.addObject("deptId", ContextUtil.subDeptId(user));
        view.addObject("deptId", deptId);
        view.addObject("type", InoutConstant.TYPE_IN);
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listInDepot();
        List<SimpleDepot> listDepot = commonManager.getCacheDeptIn(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
        //入库流程
@@ -297,12 +288,13 @@
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_IN.getCode());
        view.addObject("deptId", ContextUtil.subDeptId(user));
        view.addObject("deptId", deptId);
        view.addObject("type", InoutConstant.TYPE_IN);
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listInDepot();
        List<SimpleDepot> listDepot = commonManager.getCacheDeptIn(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
        //入库流程
@@ -390,7 +382,7 @@
        view.addObject("deptId", deptId);
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listInDepot();
        List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
        // 当前流程标签
@@ -412,11 +404,11 @@
        List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId);
        //获取所有的地磅列表用于页面用户选择
        List<WeightDto> listWeight = inoutCommonManager.getInoutWeightAll(listInoutConf, InoutConstant.CONF_TYPE_30);
        List<InoutConf> listWeight = inoutCommonManager.getInoutConf(listInoutConf, InoutConstant.CONF_TYPE_30);
        view.addObject("listWeight", listWeight);
        // 获取当前地磅信息
        WeightDto weightDto = inoutCommonManager.getInoutCurWeight(listWeight, sort);
        InoutConf weightDto = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_30);
        view.addObject("weightDto", weightDto);
        // 过程摄像头1
@@ -457,7 +449,7 @@
        view.addObject("type", InoutConstant.TYPE_OUT);
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listOutDepot();
        List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
        //出库流程
@@ -492,15 +484,19 @@
        ModelAndView view = new ModelAndView();
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listOutDepot();
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
        IUser user = ContextUtil.getLoginUser();
        String deptId = ContextUtil.subDeptId(user);
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
        view.addObject("bizType", BizType.INOUT_OUT.getCode());
        view.addObject("deptId", ContextUtil.subDeptId(user));
        view.addObject("deptId", deptId);
        view.addObject("type", InoutConstant.TYPE_OUT);
        // 仓库列表做下拉框使用
        List<SimpleDepot> listDepot = commonManager.getCacheDeptOut(user.getCompanyId(), deptId);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
        //出库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(),
@@ -532,6 +528,7 @@
     */
    @RequestMapping("/inout-query")
    public PageResponse<InoutData> inoutQuery(@RequestBody InoutParam param) {
        if (null == param.getCompanyId()) param.setCompanyId(ContextUtil.getCompanyId());
        return inoutManager.inoutQuery(param);
    }
@@ -557,6 +554,14 @@
    @Transactional
    public PageResponse<InoutData> inoutNextStep(@RequestBody InoutData data) {
        try {
            IUser user = ContextUtil.getLoginUser();
            if (StringUtils.isEmpty(data.getCompanyId())) {
                data.setCompanyId(user.getCompanyId());
            }
            if (StringUtils.isEmpty(data.getDeptId())) {
                data.setDeptId(ContextUtil.subDeptId(user));
            }
            if (InoutConstant.TYPE_IN.equals(data.getType())) {
                return inoutManager.inNextStep(data);
            } else {
@@ -570,6 +575,50 @@
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "后台异常:" + e.getMessage());
        }
    }
    /**
     * 出入库数据保存,登记提交
     *
     * @param data
     * @return
     */
    @RequestMapping("/submit-register")
    @Transactional
    public PageResponse<InoutData> submitRegister(@RequestBody InoutData data) throws Exception {
        IUser user = ContextUtil.getLoginUser();
        if (StringUtils.isEmpty(data.getCompanyId())) {
            data.setCompanyId(user.getCompanyId());
        }
        if (StringUtils.isEmpty(data.getDeptId())) {
            data.setDeptId(ContextUtil.subDeptId(user));
        }
        //如果注册时候没有使用智慧卡,默认使用身份证号作为智慧卡号
        if (StringUtils.isEmpty(data.getIntelCard())) {
            data.setIntelCard(data.getUserId());
        }
        return inoutManager.submitRegisterInout(data);
    }
    /**
     * 出入库称重环节提交
     *
     * @param data
     * @return
     */
    @RequestMapping("/submit-weight")
    @Transactional
    public PageResponse<InoutData> submitWeight(@RequestBody InoutData data) throws Exception {
        if(null == data.getJjlx()) data.setJjlx("0");
        if (InoutConstant.TYPE_IN.equals(data.getType())) {
            return inoutManager.submitWeightIn(data);
        } else {
            return inoutManager.submitWeightOut(data);
        }
    }
@@ -618,34 +667,34 @@
        }
    }
    /**
     * 根据入库数据信息,获取检查项信息,如果当前数据已经检测完成,查询检测结果,如果没有检测完成则根据检测项配置获取需要检测的项目信息
     *
     * @param data
     * @return
     */
    @RequestMapping("/get-check-item")
    public PageResponse<List<CheckItemData>> getCheckItem(@RequestBody InoutData data) {
        try {
            return inoutManager.getCheckItem(data);
        } catch (Exception e) {
            log.error("后台异常:{}", e);
            return new PageResponse<List<CheckItemData>>(
                    RespCodeEnum.CODE_1111.getCode(), "后台异常:" + e.getMessage());
        }
    }
//    /**
//     * 根据入库数据信息,获取检查项信息,如果当前数据已经检测完成,查询检测结果,如果没有检测完成则根据检测项配置获取需要检测的项目信息
//     *
//     * @param data
//     * @return
//     */
//    @RequestMapping("/get-check-item")
//    public PageResponse<List<CheckItemData>> getCheckItem(@RequestBody InoutData data) {
//        try {
//            return inoutManager.getCheckItem(data);
//        } catch (Exception e) {
//            log.error("后台异常:{}", e);
//            return new PageResponse<List<CheckItemData>>(
//                    RespCodeEnum.CODE_1111.getCode(), "后台异常:" + e.getMessage());
//        }
//    }
    /**
     * 分页获取数据信息
     *
     * @param param
     * @return
     */
    @RequestMapping("/page-check-data")
    public PageResponse<Page<InoutData>> pageCheckData(
            @RequestBody InoutParam param) {
        return inoutManager.pageCheckData(param);
    }
//    /**
//     * 分页获取数据信息
//     *
//     * @param param
//     * @return
//     */
//    @RequestMapping("/page-check-data")
//    public PageResponse<Page<InoutData>> pageCheckData(
//            @RequestBody InoutParam param) {
//        return inoutManager.pageCheckData(param);
//    }
    /**
     * 道闸控制
@@ -659,6 +708,7 @@
        return null;
    }
    /**
     * 更新用户选择地磅,根据用户IP保存期选择
     *
@@ -683,4 +733,121 @@
                    "后台异常:" + e.getMessage());
        }
    }
    /**
     * 扦样页面
     *
     * @param sort 表示使用的出入库设备配套号,不传递默认为1
     * @return
     */
    @RequestMapping("/in-sample")
    public ModelAndView inSample(HttpServletRequest httpRequest, @RequestParam(value = "sort", required = false) String sort) {
        if (StringUtils.isEmpty(sort)) {
            sort = commonManager.getInoutWeightByClient(httpRequest);
        }
        ModelAndView view = new ModelAndView();
        // 仓库列表做下拉框使用
        List<Depot> listDepot = commonManager.listDepot(true);
        view.addObject(Constant.MODEL_KEY_DEPOT_LIST, listDepot);
        IUser user = ContextUtil.getLoginUser();
        view.addObject(Constant.MODEL_KEY_LOGIN_USER, user);
        String deptId = ContextUtil.subDeptId(user);
        view.addObject("bizType", BizType.INOUT_IN.getCode());
        view.addObject("type", InoutConstant.TYPE_IN);
        view.addObject("deptId", deptId);
        DefaultDept dept = commonManager.getSubDept(user, deptId);
        view.addObject("deptName", dept.getName());
        //入库流程
        String inoutProgress = inoutCommonManager.getInoutProgressConf(user.getCompanyId(), deptId, InoutConstant.TYPE_IN);
        view.addObject("inoutProgress", inoutProgress);
        // 当前流程节点
        view.addObject("progress", InoutConstant.PROGRESS_CHECK);
        // 粮食品种下拉框
        List<DicTrigger> listFoodVariety = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_VARIETY, user.getCompanyId());
        view.addObject("listFoodVariety", listFoodVariety);
        // 粮食等级下拉框
        List<DicTrigger> listFoodLevel = inoutCommonManager.getDicTrigger(
                Constant.TRIGGER_PARENT_FOOD_LEVEL, user.getCompanyId());
        view.addObject("listFoodLevel", listFoodLevel);
        view.addObject("endTime",
                DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
        view.addObject("startTime", DateFormatUtils.format(
                DateUtil.getNewByDay(null, -10), "yyyy-MM-dd"));
        // 获取出入库配置信息
        List<InoutConf> listInoutConf = inoutCommonManager.getListInoutConf(user.getCompanyId(), deptId);
        // 获取扦样机信息
        InoutConf conf = inoutCommonManager.getInoutConf(listInoutConf, sort, InoutConstant.CONF_TYPE_20, InoutConstant.PROGRESS_CHECK, 1);
        view.addObject("checkDto", conf);
        view.setViewName("admin/inout/in-sample");
        return view;
    }
    /**
     * 分页获取扦样数据
     *
     * @param param
     * @return
     */
    @RequestMapping("/page-sample-data")
    public PageResponse<Page<InoutCheckData>> pageSampleData(@RequestBody InoutCheckParam param) {
        return inoutManager.pageSampleData(param);
    }
    /**
     * 扦样页面提交更新
     *
     * @param data
     * @return
     */
    @RequestMapping("/update-sample")
    public PageResponse<InoutCheckData> updateSample(@RequestBody InoutCheckData data) {
        return inoutManager.updateSampleData(data);
    }
    /**
     * 分页获取化验数据
     *
     * @param param
     * @return
     */
    @RequestMapping("/page-check-data")
    public PageResponse<Page<InoutCheckData>> pageCheckData(@RequestBody InoutCheckParam param) {
        return inoutManager.pageCheckData(param);
    }
    /**
     * 获取化验项信息
     *
     * @param param
     * @return
     */
    @RequestMapping("/get-check-item")
    public PageResponse<List<CheckItemData>> getCheckItem(@RequestBody InoutCheckParam param) {
            return inoutManager.getCheckItemData(param);
    }
    /**
     * 化验页面提交更新
     *
     * @param data
     * @return
     */
    @RequestMapping("/update-check1")
    public PageResponse<InoutCheckData> updateCheck1(@RequestBody InoutCheckData data) {
        return inoutManager.updateCheckData(data);
    }
}