jiazx0107@163.com
2023-06-22 a4d556ff6f8191637be669e7884fc3e500021516
igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java
@@ -57,7 +57,6 @@
    @Resource
    private InoutDeviceManager inoutDeviceManager;
    /**
     * 直接从数据库查询,不考虑信息状态
     *
@@ -86,11 +85,13 @@
        }
        if (InoutConstant.PROGRESS_RECORD.equals(result.getProgress())) {
            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "当前车辆流程已经结束", result);
            return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
                    "当前车辆流程已经结束", result);
        }
        if (!InoutConstant.PROGRESS_CARD_BACK.equals(result.getProgress())) {
            return new PageResponse<>(RespCodeEnum.CODE_1008.getCode(), "当前车辆流程不在当前环节,无法执行出库", result);
            return new PageResponse<>(RespCodeEnum.CODE_1008.getCode(),
                    "当前车辆流程不在当前环节,无法执行出库", result);
        }
        return new PageResponse<>(RespCodeEnum.CODE_0000, result);
@@ -126,14 +127,14 @@
                return new PageResponse<>(RespCodeEnum.CODE_0000, result);
            }
            //流程类型验证
            if (!result.getType().equals(param.getType())) {
                String msg = "流程错误:当前车辆流程为【入库】";
                if (InoutConstant.TYPE_OUT.equals(result.getType())) msg = "流程错误:当前车辆流程为【出库】";
                return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), msg, result);
                if (InoutConstant.TYPE_OUT.equals(result.getType()))
                    msg = "流程错误:当前车辆流程为【出库】";
                return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
                        msg, result);
            }
            //流程环节验证
            if (progress.equals(InoutConstant.PROGRESS_WEIGHT_TAG)) {
@@ -167,7 +168,6 @@
        }
    }
    public InoutData inoutProgressQuery(InoutData data) throws Exception {
        InoutParam param = new InoutParam();
        param.setCompanyId(data.getCompanyId());
@@ -188,18 +188,19 @@
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                data.getCompanyId(), data.getDeptId());
        if (inoutSysConf.getNoPassNext().equals(InoutConstant.CHECK_NOPASS_RECORD)) {
        if (inoutSysConf.getNoPassNext().equals(
                InoutConstant.CHECK_NOPASS_RECORD)) {
            // 流程结束
            data.setProgress(InoutConstant.PROGRESS_RECORD);
            data.setCompleteTime(new Date());
        }
        if (inoutSysConf.getNoPassNext().equals(InoutConstant.CHECK_NOPASS_BACK)) {
        if (inoutSysConf.getNoPassNext()
                .equals(InoutConstant.CHECK_NOPASS_BACK)) {
            // 离库收卡
            data.setProgress(InoutConstant.PROGRESS_CARD_BACK);
        }
        return data;
    }
    /**
     * 更新质检信息
@@ -209,11 +210,13 @@
     */
    private CheckUpdateResult updateCheckItems(InoutData data) {
        CheckUpdateResult result = new CheckUpdateResult();
        if (null == data.getCheckItems()) return result;
        if (null == data.getCheckItems())
            return result;
        try {
            // 更新检验项数据
            result = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems());
            result = checkStandardManager.updateCheckItems(data.getCheckId(),
                    data.getCompanyId(), data.getCheckItems());
            // 将化验数据存入缓存中
            inoutService.setCheckCache(data);
@@ -232,7 +235,8 @@
     *
     * @return
     */
    private String getNextProgress(String curProgress, String type, InoutSysConf sysConf) {
    private String getNextProgress(String curProgress, String type,
                                   InoutSysConf sysConf) {
        String nextProgress = null;
        List<String> list = null;
        if (InoutConstant.TYPE_IN.equals(type)) {
@@ -258,7 +262,8 @@
     * @param data
     * @return
     */
    private InoutData updateBasicInfo(InoutData data, String curProgress, String nextProgress) {
    private InoutData updateBasicInfo(InoutData data, String curProgress,
                                      String nextProgress) {
        if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
            data.setRegisterTime(new Date());
@@ -370,8 +375,8 @@
        return data;
    }
    public PageResponse<InoutData> submitComplete(InoutData data) throws Exception {
    public PageResponse<InoutData> submitComplete(InoutData data)
            throws Exception {
        if (StringUtils.isEmpty(data.getId())
                || StringUtils.isEmpty(data.getType())
@@ -380,7 +385,6 @@
            return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(),
                    "没有获取到车辆信息。", data);
        }
        data.setUpdateTime(new Date());
        if (null == data.getCompleteTime()) {
@@ -401,7 +405,6 @@
        param.setDepotId(data.getDepotId());
        param.setCompleteTime(data.getCompleteTime());
        param.setProgress(InoutConstant.PROGRESS_RECORD);
        String msg = inoutService.toComplete(param);
@@ -424,12 +427,12 @@
            if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
                //删除缓存
                inoutService.delFromCache(data.getDeptId(), data.getType(), data.getId());
                inoutService.delFromCache(data.getDeptId(), data.getType(),
                        data.getId());
                return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(),
                        "当车辆流程已经完成,卡片已回收", data);
            }
            //如果当前流程不是卡回收
            if (!InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) {
@@ -448,10 +451,9 @@
                    "后端执行异常:" + e.getMessage());
        }
        
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(),
                "执行成功", data);
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功",
                data);
    }
        /**
         * 补单操作 补单因为完成时间不确定,所以需要系统根据当前数据进行自动检测,调整原来流水信息和库存
@@ -502,18 +504,23 @@
                    data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -50));
                }
                if (null == data.getEmptyWeightTime()) {
                    data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -10));
                data.setEmptyWeightTime(DateUtil
                        .getNewByMinute(new Date(), -10));
                }
                // 先执行化验信息保存
                CheckUpdateResult checkResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems());
            CheckUpdateResult checkResult = checkStandardManager
                    .updateCheckItems(data.getCheckId(), data.getCompanyId(),
                            data.getCheckItems());
                if (null != checkResult) {
//            if (null == data.getWet())data.setWet(checkResult.getWet());
//            if (null == data.getImpurity())data.setImpurity(checkResult.getImpurity());
                // if (null ==
                // data.getImpurity())data.setImpurity(checkResult.getImpurity());
                }
            } else {
                if (null == data.getEmptyWeightTime()) {
                    data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -50));
                data.setEmptyWeightTime(DateUtil
                        .getNewByMinute(new Date(), -50));
                }
                if (null == data.getFullWeightTime()) {
                    data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -10));
@@ -729,7 +736,8 @@
         * @return
         * @throws Exception
         */
        public PageResponse<InoutData> submitRegisterInout (InoutData data) throws Exception {
    public PageResponse<InoutData> submitRegisterInout(InoutData data)
            throws Exception {
            //首先判断流程中是否有已经存在的车辆信息未执行完成,直接从数据库中查询
            InoutParam param = new InoutParam();
@@ -745,50 +753,51 @@
                        "当前车牌或智慧卡有正在执行流程未结束,请联系管理员", data);
            }
            //获取系统参数配置
            InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                data.getCompanyId(), data.getDeptId());
            if (null == inoutSysConf) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        "提示:当前库区未配置出入库流程信息,请联系管理员", data);
            }
            //获取下一个流程状态
            String curProgress = data.getProgress();
            String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
        String nextProgress = getNextProgress(curProgress, data.getType(),
                inoutSysConf);
            data = updateBasicInfo(data, curProgress, nextProgress);
            String msg = inoutService.insertData(data);
            if (null != msg) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        msg, data);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg,
                    data);
            }
            // 执行附件信息
            fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
                data.getId(), curProgress);
            return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data);
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功",
                data);
        }
        public PageResponse<InoutData> submitWeightIn (InoutData data) throws Exception {
    public PageResponse<InoutData> submitWeightIn(InoutData data)
            throws Exception {
            //获取系统参数配置
            InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                data.getCompanyId(), data.getDeptId());
            if (null == inoutSysConf) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        "提示:当前系统中流程配置异常,请联系管理员", data);
            }
            //获取下一个流程状态
            String curProgress = data.getProgress();
            String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
        String nextProgress = getNextProgress(curProgress, data.getType(),
                inoutSysConf);
            data = updateBasicInfo(data, curProgress, nextProgress);
            //入库称重可能调整质检单
            CheckUpdateResult checkUpdateResult = updateCheckItems(data);
@@ -803,58 +812,66 @@
            String msg = inoutService.updateData(data);
            if (null != msg) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg,
                    data);
            }
            // 执行附件信息
            fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
                data.getId(), curProgress);
            //称重完成,调用出入库控制逻辑处理
            inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
            return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data);
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功",
                data);
        }
        public PageResponse<InoutData> submitWeightOut (InoutData data) throws Exception {
    public PageResponse<InoutData> submitWeightOut(InoutData data)
            throws Exception {
            //获取系统参数配置
            InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                data.getCompanyId(), data.getDeptId());
            if (null == inoutSysConf) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        "提示:当前系统中流程配置异常,请联系管理员", data);
            }
            //获取下一个流程状态
            String curProgress = data.getProgress();
            String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
        String nextProgress = getNextProgress(curProgress, data.getType(),
                inoutSysConf);
            data = updateBasicInfo(data, curProgress, nextProgress);
            //执行数据更新
            String msg = inoutService.updateData(data);
            if (null != msg) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg,
                    data);
            }
            // 执行附件信息
            fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
                data.getId(), curProgress);
            //称重后根据当前流程状态和下一个状态,通知称重控制器
            inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
            return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data);
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功",
                data);
        }
        public PageResponse<InoutData> submitHandle (InoutData data) throws Exception {
    public PageResponse<InoutData> submitHandle(InoutData data)
            throws Exception {
            if (null == data.getHandleUser()) {
                data.setHandleUser(ContextUtil.getLoginUserCName());
            }
            //获取系统参数配置
            InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                data.getCompanyId(), data.getDeptId());
            if (null == inoutSysConf) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        "提示:当前系统中流程配置异常,请联系管理员", data);
@@ -862,23 +879,25 @@
            //获取下一个流程状态
            String curProgress = data.getProgress();
            String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
        String nextProgress = getNextProgress(curProgress, data.getType(),
                inoutSysConf);
            data = updateBasicInfo(data, curProgress, nextProgress);
            //执行数据更新
            String msg = inoutService.updateDataByHandle(data);
            if (null != msg) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg,
                    data);
            }
            // 执行附件信息
            fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(),
                data.getId(), curProgress);
            return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data);
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功",
                data);
        }
        /**
         * 根据条件获取扦样数据
@@ -886,7 +905,8 @@
         * @param param
         * @return
         */
        public PageResponse<Page<InoutCheckData>> pageSampleData (InoutCheckParam param){
    public PageResponse<Page<InoutCheckData>> pageSampleData(
            InoutCheckParam param) {
            if (StringUtils.isEmpty(param.getCompanyId())) {
                param.setCompanyId(ContextUtil.getCompanyId());
@@ -903,23 +923,24 @@
            //获取扦样数据
            Page<InoutCheckData> sampleList = inoutService.pageSampleData(param);
            if (null == sampleList.getRecords() || sampleList.getRecords().isEmpty()) {
        if (null == sampleList.getRecords()
                || sampleList.getRecords().isEmpty()) {
                return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
                        "获取到数据信息为空");
            }
            return new PageResponse<>(RespCodeEnum.CODE_0000, sampleList);
        }
        @Transactional(rollbackFor = Exception.class)
        public PageResponse<InoutCheckData> updateSampleData (InoutCheckData data){
            try {
    public PageResponse<InoutCheckData> submitSample(InoutCheckData data) throws Exception {
                // 获取业务数据信息
                InoutParam param = new InoutParam();
                param.setCompanyId(data.getCompanyId());
                param.setId(data.getId());
                InoutData curData = inoutService.inoutProgressQuery(param);
                if (null == curData) {
                    return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                            "没有获取到入库业务数据信息,更新失败", data);
@@ -933,9 +954,11 @@
                if (StringUtils.isEmpty(data.getSampleUser())) {
                    data.setSampleUser(ContextUtil.getLoginUserCName());
                }
                if (null == data.getSampleTime()) {
                    data.setSampleTime(new Date());
                }
                String msg = inoutService.updateSampleData(data);
                if (null != msg) {
@@ -943,18 +966,14 @@
                }
                return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功");
            } catch (Exception e) {
                log.error("后台异常:{}", e);
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        "后台异常:" + e.getMessage(), null);
            }
        }
        /**
         * @param param
         * @return
         */
        public PageResponse<Page<InoutCheckData>> pageCheckData (InoutCheckParam param){
    public PageResponse<Page<InoutCheckData>> pageCheckData(
            InoutCheckParam param) {
            if (StringUtils.isEmpty(param.getCompanyId())) {
                param.setCompanyId(ContextUtil.getCompanyId());
@@ -969,7 +988,6 @@
            Page<InoutCheckData> checkList = inoutService.pageCheckData(param);
            if (null == checkList.getRecords() || checkList.getRecords().isEmpty()) {
                return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
                        "获取到数据信息为空");
@@ -983,16 +1001,18 @@
         * @param param
         * @return
         */
        public PageResponse<List<CheckItemData>> getCheckItemData (InoutCheckParam param){
    public PageResponse<List<CheckItemData>> getCheckItemData(
            InoutCheckParam param) {
            try {
                List<CheckItemData> result = checkStandardManager.listCheckItem(param.getCheckId(),
                        param.getCompanyId(), param.getFoodVariety());
            List<CheckItemData> result = checkStandardManager.listCheckItem(
                    param.getCheckId(), param.getCompanyId(),
                    param.getFoodVariety());
                return new PageResponse<>(RespCodeEnum.CODE_0000, result);
            } catch (Exception e) {
                return new PageResponse<>(
                        RespCodeEnum.CODE_1111.getCode(), "后台异常:" + e.getMessage(), null);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "后台异常:"
                    + e.getMessage(), null);
            }
        }
@@ -1015,7 +1035,9 @@
                }
                //更新化验项信息
                CheckUpdateResult checkResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems());
            CheckUpdateResult checkResult = checkStandardManager
                    .updateCheckItems(data.getCheckId(), data.getCompanyId(),
                            data.getCheckItems());
                if (StringUtils.isNotEmpty(checkResult.getMsg())) {
                    return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                            "后台执行异常:" + checkResult.getMsg(), data);
@@ -1034,7 +1056,8 @@
                curData.setCheckStatus(data.getCheckStatus());
                //获取系统参数配置
                InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
            InoutSysConf inoutSysConf = inoutCommonService
                    .getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
                if (null == inoutSysConf) {
                    return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                            "提示:当前库区未配置出入库流程信息,请联系管理员", data);
@@ -1043,7 +1066,8 @@
                if (InoutConstant.PROGRESS_CHECK.equals(curData.getProgress())) {
                    curData = updateBasicInfo(curData, inoutSysConf);
                    // 若化验结果不合格,判断配置后续流程
                    if (InoutConstant.STATUS_UNPASS.equals(curData.getCheckStatus())) {
                if (InoutConstant.STATUS_UNPASS
                        .equals(curData.getCheckStatus())) {
                        curData = checkNoPass(curData);
                    }
                }
@@ -1065,8 +1089,8 @@
                return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功");
            } catch (Exception e) {
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        "后台异常:" + e.getMessage(), null);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "后台异常:"
                    + e.getMessage(), null);
            }
        }
@@ -1081,15 +1105,15 @@
                List<InoutPrice> price = inoutService.getPrice(param);
                if (null == price || price.isEmpty()) {
                    return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "未获取到粮食定价配置信息");
                return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                        "未获取到粮食定价配置信息");
                }
                return new PageResponse<>(RespCodeEnum.CODE_0000, price.get(0));
            } catch (Exception e) {
                return new PageResponse<>(
                        RespCodeEnum.CODE_1111.getCode(), "后台异常:" + e.getMessage(), null);
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "后台异常:"
                    + e.getMessage(), null);
            }
        }
    }