|  |  |  | 
|---|
|  |  |  | package com.ld.igds.inout.manager; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.bstek.bdf2.core.business.IUser; | 
|---|
|  |  |  | import com.ld.igds.check.CheckStandardManager; | 
|---|
|  |  |  | import com.ld.igds.check.dto.CheckItemData; | 
|---|
|  |  |  | import com.ld.igds.check.dto.CheckUpdateResult; | 
|---|
|  |  |  | import com.ld.igds.common.CoreCommonService; | 
|---|
|  |  |  | import com.ld.igds.constant.RespCodeEnum; | 
|---|
|  |  |  | import com.ld.igds.data.Page; | 
|---|
|  |  |  | import com.ld.igds.data.PageResponse; | 
|---|
|  |  |  | import com.ld.igds.file.CoreFileService; | 
|---|
|  |  |  | import com.ld.igds.file.dto.FileData; | 
|---|
|  |  |  | import com.ld.igds.inout.InoutConstant; | 
|---|
|  |  |  | import com.ld.igds.inout.dto.*; | 
|---|
|  |  |  | import com.ld.igds.inout.dto.InoutCheckData; | 
|---|
|  |  |  | import com.ld.igds.inout.dto.InoutCheckParam; | 
|---|
|  |  |  | import com.ld.igds.inout.dto.InoutData; | 
|---|
|  |  |  | import com.ld.igds.inout.dto.InoutParam; | 
|---|
|  |  |  | import com.ld.igds.inout.service.InoutService; | 
|---|
|  |  |  | import com.ld.igds.m.service.InoutCommonService; | 
|---|
|  |  |  | import com.ld.igds.models.Depot; | 
|---|
|  |  |  | import com.ld.igds.models.InoutConf; | 
|---|
|  |  |  | import com.ld.igds.models.InoutPrice; | 
|---|
|  |  |  | import com.ld.igds.models.InoutSysConf; | 
|---|
|  |  |  | import com.ld.igds.util.ContextUtil; | 
|---|
|  |  |  | import com.ld.igds.util.DateUtil; | 
|---|
|  |  |  | import com.ld.igds.util.NumberUtil; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.apache.commons.lang3.time.DateFormatUtils; | 
|---|
|  |  |  | import org.apache.commons.lang3.time.DateUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  | import org.springframework.transaction.annotation.Transactional; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @author | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class InoutManager { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private InoutService inoutService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private CoreFileService fileService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CoreCommonService commonService; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private InoutCommonService inoutCommonService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private CheckStandardManager checkStandardManager; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private InoutDeviceManager inoutDeviceManager; | 
|---|
|  |  |  | private InoutEventControlManager inoutEventControl; | 
|---|
|  |  |  | @Resource | 
|---|
|  |  |  | private CoreFileService coreFileService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 直接从数据库查询,不考虑信息状态 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public PageResponse<InoutData> inoutQueryBack(InoutParam param) { | 
|---|
|  |  |  | if (StringUtils.isEmpty(param.getPlateNum()) | 
|---|
|  |  |  | && StringUtils.isEmpty(param.getIntelCard()) | 
|---|
|  |  |  | && StringUtils.isEmpty(param.getUserId())) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), | 
|---|
|  |  |  | "查询参数不完整,查询失败!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取三天以内最后一天记录 | 
|---|
|  |  |  | param.setStart(DateUtil.getNewByDay(new Date(), -3)); | 
|---|
|  |  |  | param.setType(null); | 
|---|
|  |  |  | param.setProgress(null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | InoutData result = inoutService.getLastRecord(param); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == result) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), | 
|---|
|  |  |  | "根据当前条件未查询到车辆信息!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(result.getProgress())) { | 
|---|
|  |  |  | 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_0000, result); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 首先从缓存中获取,缓存中,从数据库中获取 | 
|---|
|  |  |  | 
|---|
|  |  |  | 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)) { | 
|---|
|  |  |  | if (result.getProgress().equals( | 
|---|
|  |  |  | InoutConstant.PROGRESS_WEIGHT_EMPTY) | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public PageResponse<InoutData> outNextStep(InoutData data) throws Exception { | 
|---|
|  |  |  | String msg; | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String curProgress = data.getProgress(); | 
|---|
|  |  |  | List<FileData> files = data.getFiles(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新下一个状态和基本信息 | 
|---|
|  |  |  | InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf( | 
|---|
|  |  |  | data.getCompanyId(), data.getDeptId()); | 
|---|
|  |  |  | if (null == inoutSysConf | 
|---|
|  |  |  | || StringUtils.isEmpty(inoutSysConf.getProgressIn())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前库区未配置出库流程信息,请联系管理员配置。", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | data = updateBasicInfo(data, inoutSysConf); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果当前节点是注册,则需要验证下,是否有为完成的流程在执行中 | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) { | 
|---|
|  |  |  | InoutData progressData = this.inoutProgressQuery(data); | 
|---|
|  |  |  | if (null != progressData) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前卡片/车牌号有流程未结束。", progressData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != data.getPrice() && null != data.getRecordWeight()) { | 
|---|
|  |  |  | data.setSettleMoney(NumberUtil.keepPrecision(data.getPrice() * data.getRecordWeight(), 2)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 流程完成,直接调用流程完成接口 | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { | 
|---|
|  |  |  | inoutService.updateData(data); | 
|---|
|  |  |  | // 执行附件信息 | 
|---|
|  |  |  | if (null != files) { | 
|---|
|  |  |  | fileService.saveInoutFiles(files, data.getCompanyId(), | 
|---|
|  |  |  | data.getId(), curProgress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 通知称重主控流程结束 | 
|---|
|  |  |  | inoutDeviceManager.noticeProgressComplete(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return inoutComplete(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 调用保存方法执行 | 
|---|
|  |  |  | if (StringUtils.isEmpty(data.getId())) { | 
|---|
|  |  |  | msg = inoutService.insertData(data); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | msg = inoutService.updateData(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 执行附件信息 | 
|---|
|  |  |  | if (null != files) { | 
|---|
|  |  |  | fileService.saveInoutFiles(files, data.getCompanyId(), | 
|---|
|  |  |  | data.getId(), curProgress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, | 
|---|
|  |  |  | data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", | 
|---|
|  |  |  | data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public PageResponse<InoutData> inNextStep(InoutData data) throws Exception { | 
|---|
|  |  |  | String msg; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String curProgress = data.getProgress(); | 
|---|
|  |  |  | List<FileData> files = data.getFiles(); | 
|---|
|  |  |  | if (StringUtils.isEmpty(data.getIntelCard())) { | 
|---|
|  |  |  | data.setIntelCard(data.getUserId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新下一个状态和基本信息 | 
|---|
|  |  |  | InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == inoutSysConf | 
|---|
|  |  |  | || StringUtils.isEmpty(inoutSysConf.getProgressIn())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前库区未配置入库流程信息,请联系管理员配置。", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | data = updateBasicInfo(data, inoutSysConf); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果当前节点是注册,则需要验证下,是否有为完成的流程在执行中 | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) { | 
|---|
|  |  |  | InoutData progressData = this.inoutProgressQuery(data); | 
|---|
|  |  |  | if (null != progressData) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前卡片/车牌号有流程未结束。", progressData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != data.getPrice() && null != data.getRecordWeight()) { | 
|---|
|  |  |  | data.setSettleMoney(NumberUtil.keepPrecision(data.getPrice() * data.getRecordWeight(), 2)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 流程完成,直接调用流程完成接口 | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { | 
|---|
|  |  |  | if (StringUtils.isEmpty(data.getCompanyId())) { | 
|---|
|  |  |  | data.setCompanyId(ContextUtil.getCompanyId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | inoutService.updateData(data); | 
|---|
|  |  |  | // 执行附件信息 | 
|---|
|  |  |  | if (null != files) { | 
|---|
|  |  |  | fileService.saveInoutFiles(files, data.getCompanyId(), | 
|---|
|  |  |  | data.getId(), curProgress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 通知称重主控流程结束 | 
|---|
|  |  |  | inoutDeviceManager.noticeProgressComplete(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return inoutComplete(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 调用保存方法执行 | 
|---|
|  |  |  | if (StringUtils.isEmpty(data.getId())) { | 
|---|
|  |  |  | msg = inoutService.insertData(data); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | msg = inoutService.updateData(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 执行附件信息 | 
|---|
|  |  |  | if (null != files) { | 
|---|
|  |  |  | fileService.saveInoutFiles(files, data.getCompanyId(), | 
|---|
|  |  |  | data.getId(), curProgress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", | 
|---|
|  |  |  | data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public InoutData inoutProgressQuery(InoutData data) throws Exception { | 
|---|
|  |  |  | InoutParam param = new InoutParam(); | 
|---|
|  |  |  | param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | param.setPlateNum(data.getPlateNum()); | 
|---|
|  |  |  | param.setIntelCard(data.getIntelCard()); | 
|---|
|  |  |  | param.setType(data.getType()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return inoutService.inoutProgressQuery(param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | //    public PageResponse<InoutData> updateCheck(InoutData data) throws Exception { | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { | 
|---|
|  |  |  | //            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | //                    "当前流程已经结束,不支持修改", data); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        CheckUpdateResult checkResult = this.updateCheckItems(data); | 
|---|
|  |  |  | //        String tag = checkResult.getMsg(); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        if (null != tag) { | 
|---|
|  |  |  | //            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | //                    "后台执行异常:" + tag, data); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        // 获取业务数据信息 | 
|---|
|  |  |  | //        InoutParam param = new InoutParam(); | 
|---|
|  |  |  | //        param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | //        param.setId(data.getId()); | 
|---|
|  |  |  | //        InoutData progressData = inoutService.inoutProgressQuery(param); | 
|---|
|  |  |  | //        if (null == progressData) { | 
|---|
|  |  |  | //            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | //                    "没有获取到出入库业务数据信息,更新失败", data); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if (InoutConstant.PROGRESS_RECORD.equals(progressData.getProgress())) { | 
|---|
|  |  |  | //            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | //                    "当前流程已经结束,不支持修改"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        progressData.setCheckStatus(data.getCheckStatus()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        // 更新下一个状态和基本信息 | 
|---|
|  |  |  | //        if (InoutConstant.PROGRESS_CHECK.equals(progressData.getProgress())) { | 
|---|
|  |  |  | //            progressData = updateBasicInfo(progressData, null); | 
|---|
|  |  |  | //            // 若化验结果不合格,判断配置后续流程 | 
|---|
|  |  |  | //            if (InoutConstant.STATUS_UNPASS.equals(progressData | 
|---|
|  |  |  | //                    .getCheckStatus())) { | 
|---|
|  |  |  | //                progressData = checkNoPass(progressData); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        progressData.setCheckUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        if (StringUtils.isNotEmpty(data.getDepotId())) { | 
|---|
|  |  |  | //            progressData.setDepotId(data.getDepotId()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if (StringUtils.isNotEmpty(data.getFoodVariety())) { | 
|---|
|  |  |  | //            progressData.setFoodVariety(data.getFoodVariety()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if (StringUtils.isNotEmpty(data.getFoodLevel())) { | 
|---|
|  |  |  | //            progressData.setFoodLevel(data.getFoodLevel()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if (StringUtils.isNotEmpty(data.getFoodLocation())) { | 
|---|
|  |  |  | //            progressData.setFoodLocation(data.getFoodLocation()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if (StringUtils.isNotEmpty(data.getFoodYear())) { | 
|---|
|  |  |  | //            progressData.setFoodYear(data.getFoodYear()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if (null != data.getPrice()) { | 
|---|
|  |  |  | //            progressData.setPrice(data.getPrice()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if (StringUtils.isNotEmpty(data.getRemarks())) { | 
|---|
|  |  |  | //            progressData.setRemarks(data.getRemarks()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if (StringUtils.isNotEmpty(data.getNoticeId())) { | 
|---|
|  |  |  | //            progressData.setNoticeId(data.getNoticeId()); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        String msg = inoutService.updateData(progressData); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        if (null != msg) { | 
|---|
|  |  |  | //            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        if (InoutConstant.PROGRESS_RECORD.equals(progressData.getProgress())) { | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //            inoutComplete(progressData); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | //        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 化验结果不通过时校验配置信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 更新质检信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private CheckUpdateResult updateCheckItems(InoutData data) { | 
|---|
|  |  |  | CheckUpdateResult result = new CheckUpdateResult(); | 
|---|
|  |  |  | if (null == data.getCheckItems()) return result; | 
|---|
|  |  |  | private InoutData updateCheckItems(InoutData data, boolean toSave) throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 更新检验项数据 | 
|---|
|  |  |  | result = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems()); | 
|---|
|  |  |  | if (null == data.getCheckItems()) return data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 将化验数据存入缓存中 | 
|---|
|  |  |  | inoutService.setCheckCache(data); | 
|---|
|  |  |  | //设置没有质检ID,取消执行持久化 | 
|---|
|  |  |  | if (!toSave) data.setCheckId(null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | // 更新检验项数据 | 
|---|
|  |  |  | CheckUpdateResult checkUpdateResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("后台异常:{}", e); | 
|---|
|  |  |  | result.setMsg("执行异常:" + e.getMessage()); | 
|---|
|  |  |  | if (data.getDeCheck() == 0) { | 
|---|
|  |  |  | data.setDeCheck(checkUpdateResult.getDeSum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | if (data.getAddCheck() == 0) { | 
|---|
|  |  |  | data.setAddCheck(checkUpdateResult.getAddSum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return data; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @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)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | * @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()); | 
|---|
|  |  |  | 
|---|
|  |  |  | data.setProgress(nextProgress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //如果下一个数据状态=流程结束,直接补充完整信息 | 
|---|
|  |  |  | // 如果下一个数据状态=流程结束,直接补充完整信息 | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(nextProgress)) { | 
|---|
|  |  |  | data.setCompleteTime(DateUtils.addMinutes(new Date(), 2)); | 
|---|
|  |  |  | data.setCompleteUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 当前方法需要删除 | 
|---|
|  |  |  | * <p> | 
|---|
|  |  |  | * 根据需要保存的数据,调整下一个流程状态 不同的仓库组织流程可能不一样,需要根据实际调整 | 
|---|
|  |  |  | * 卡回收逻辑处理 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private InoutData updateBasicInfo(InoutData data, InoutSysConf sysConf) { | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_REGISTER.equals(data.getProgress())) { | 
|---|
|  |  |  | data.setRegisterTime(new Date()); | 
|---|
|  |  |  | data.setRegisterUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | data.setProgress(getNextProgress(data.getProgress(), | 
|---|
|  |  |  | data.getType(), sysConf)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return data; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_CHECK.equals(data.getProgress())) { | 
|---|
|  |  |  | data.setCheckUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | data.setProgress(getNextProgress(data.getProgress(), | 
|---|
|  |  |  | data.getType(), sysConf)); | 
|---|
|  |  |  | return data; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(data.getProgress())) { | 
|---|
|  |  |  | data.setEmptyWeightTime(new Date()); | 
|---|
|  |  |  | data.setEmptyWeightUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | data.setProgress(getNextProgress(data.getProgress(), | 
|---|
|  |  |  | data.getType(), sysConf)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return data; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_HANDLE.equals(data.getProgress())) { | 
|---|
|  |  |  | // 查询缓存中仓库信息,根据仓库id设置值仓人为仓库保管员 | 
|---|
|  |  |  | Depot depot = commonService.getCacheDepot(data.getCompanyId(), | 
|---|
|  |  |  | data.getDepotId()); | 
|---|
|  |  |  | data.setHandleUser(depot == null ? "" : depot.getStoreKeeperName()); | 
|---|
|  |  |  | data.setProgress(getNextProgress(data.getProgress(), | 
|---|
|  |  |  | data.getType(), sysConf)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return data; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(data.getProgress())) { | 
|---|
|  |  |  | data.setFullWeightTime(new Date()); | 
|---|
|  |  |  | data.setFullWeightUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | data.setProgress(getNextProgress(data.getProgress(), | 
|---|
|  |  |  | data.getType(), sysConf)); | 
|---|
|  |  |  | public PageResponse<InoutData> submitCardBack(InoutData data) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 如果当前数据已经结束 | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { | 
|---|
|  |  |  | data.setCompleteTime(DateUtils.addMinutes(new Date(), 2)); | 
|---|
|  |  |  | data.setCompleteUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 删除缓存 | 
|---|
|  |  |  | inoutService.delFromCache(data.getDeptId(), data.getType(), | 
|---|
|  |  |  | data.getId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), | 
|---|
|  |  |  | "当车辆流程已经完成,卡片已回收", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return data; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果当前流程不是卡回收 | 
|---|
|  |  |  | if (!InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前流程环节不正确,不能执行卡回收", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果当前流程状态是卡回收状态,就是完成流程。 | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) { | 
|---|
|  |  |  | return submitComplete(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "后端执行异常:" + e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) { | 
|---|
|  |  |  | data.setCompleteTime(new Date()); | 
|---|
|  |  |  | data.setCompleteUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | data.setProgress(getNextProgress(data.getProgress(), | 
|---|
|  |  |  | data.getType(), sysConf)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return data; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return data; | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", | 
|---|
|  |  |  | data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public PageResponse<InoutData> inoutComplete(InoutData data) throws Exception { | 
|---|
|  |  |  | public PageResponse<InoutData> submitComplete(InoutData data) | 
|---|
|  |  |  | throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isEmpty(data.getId()) | 
|---|
|  |  |  | || StringUtils.isEmpty(data.getType())) { | 
|---|
|  |  |  | || StringUtils.isEmpty(data.getType()) | 
|---|
|  |  |  | || StringUtils.isEmpty(data.getProgress())) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), | 
|---|
|  |  |  | "没有获取到车辆信息。", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | data.setUpdateTime(new Date()); | 
|---|
|  |  |  | if (null == data.getCompleteTime()) { | 
|---|
|  |  |  | data.setCompleteTime(DateUtil.getNewByMinute(new Date(), 2)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null == data.getCompleteUser()) { | 
|---|
|  |  |  | data.setCompleteUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置流程节点直接完成 | 
|---|
|  |  |  | InoutParam param = new InoutParam(); | 
|---|
|  |  |  | param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | param.setId(data.getId()); | 
|---|
|  |  |  | param.setType(data.getType()); | 
|---|
|  |  |  | param.setDeptId(data.getDeptId()); | 
|---|
|  |  |  | param.setIntelCard(data.getIntelCard()); | 
|---|
|  |  |  | param.setUserId(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | param.setUserId(data.getCompleteUser()); | 
|---|
|  |  |  | param.setDepotId(data.getDepotId()); | 
|---|
|  |  |  | param.setCompleteTime(data.getCompleteTime()); | 
|---|
|  |  |  | if (null == param.getCompleteTime()) { | 
|---|
|  |  |  | param.setCompleteTime(new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 设置流程节点直接完成 | 
|---|
|  |  |  | param.setCompleteTime(new Date()); | 
|---|
|  |  |  | param.setProgress(InoutConstant.PROGRESS_RECORD); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == data.getCompleteTime()) { | 
|---|
|  |  |  | data.setCompleteTime(DateUtil.getNewByMinute(new Date(), 2)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String msg = inoutService.toComplete(param); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 库存调整 | 
|---|
|  |  |  | commonService.initInoutDepotStore(data); | 
|---|
|  |  |  | data.setCompleteTime(param.getCompleteTime()); | 
|---|
|  |  |  | data.setProgress(InoutConstant.PROGRESS_RECORD); | 
|---|
|  |  |  | inoutService.updateInoutCache(data); | 
|---|
|  |  |  | // 流程完成收事件 | 
|---|
|  |  |  | inoutEventControl.onInoutComplete(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    /** | 
|---|
|  |  |  | //     * 扦样化验页面获取检验项条目信息 | 
|---|
|  |  |  | //     * | 
|---|
|  |  |  | //     * @param data | 
|---|
|  |  |  | //     * @return | 
|---|
|  |  |  | //     */ | 
|---|
|  |  |  | //    public PageResponse<List<CheckItemData>> getCheckItem(InoutData data) { | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        List<CheckItemData> result = checkStandardManager.listCheckItem( | 
|---|
|  |  |  | //                data.getCheckId(), data.getCompanyId(), data.getDeptId(), | 
|---|
|  |  |  | //                data.getFoodVariety()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        return new PageResponse<>(RespCodeEnum.CODE_0000, result); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 删除并完成 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public PageResponse<InoutData> deleteInoutData(InoutData data, String msg) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | data.setRemarks(msg); | 
|---|
|  |  |  | String result = this.delInoutData(data, false); | 
|---|
|  |  |  | if (null != result) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | result, data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("后台异常:{}", e); | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "后台异常:" | 
|---|
|  |  |  | + e.getMessage(), data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行完成", | 
|---|
|  |  |  | data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 卡回收逻辑处理 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public PageResponse<InoutData> inoutBack(InoutData data) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 从缓存中获取最新的数据,如果没有则表示流程已经结束。 | 
|---|
|  |  |  | InoutParam param = new InoutParam(); | 
|---|
|  |  |  | param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | param.setId(data.getId()); | 
|---|
|  |  |  | InoutData curData = inoutService.inoutProgressQuery(param); | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), | 
|---|
|  |  |  | "当前卡流程已经完成,无需执行卡回收", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_DEL.equals(curData | 
|---|
|  |  |  | .getRecordStatus())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), | 
|---|
|  |  |  | "当前卡信息已被删除,不能执行卡回收", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果当前流程状态是卡回收状态,就是完成流程。 | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_CARD_BACK.equals(curData.getProgress())) { | 
|---|
|  |  |  | return inoutComplete(curData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果是其他状态,则执行删除逻辑 | 
|---|
|  |  |  | return deleteInoutData(curData, "卡回收删除"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "后端执行异常:" + e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* ============================== 详单页面相关操作 ================================= */ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 补单操作 补单因为完成时间不确定,所以需要系统根据当前数据进行自动检测,调整原来流水信息和库存 | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public String addInoutData(InoutData data) throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (data.getSettleWeight() <= 0.0) { | 
|---|
|  |  |  | return "补单数据要求结算重量必须大于0"; | 
|---|
|  |  |  | return "系统:补单数据要求结算重量必须大于0"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 补单数据直接到结果状态 | 
|---|
|  |  |  | 
|---|
|  |  |  | data.setCompleteTime(new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 注册时间比完成时间早一个小时 | 
|---|
|  |  |  | data.setRegisterTime(DateUtil.getNewByMinute(new Date(), -60)); | 
|---|
|  |  |  | data.setRegisterTime(DateUtils.addMinutes(new Date(), -80)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isEmpty(data.getUserId())) { | 
|---|
|  |  |  | data.setUserId(InoutConstant.DEFAULT_ID_CARD); | 
|---|
|  |  |  | 
|---|
|  |  |  | data.setCheckUser(loginUser); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 保存检测项目 | 
|---|
|  |  |  | if (InoutConstant.TYPE_IN.equals(data.getType())) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.TYPE_IN.equals(data.getType())) { | 
|---|
|  |  |  | if (null == data.getFullWeightTime()) { | 
|---|
|  |  |  | data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -50)); | 
|---|
|  |  |  | data.setFullWeightTime(DateUtils.addMinutes(new Date(), -50)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null == data.getEmptyWeightTime()) { | 
|---|
|  |  |  | data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -10)); | 
|---|
|  |  |  | data.setEmptyWeightTime(DateUtils.addMinutes(new Date(), -10)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 先执行化验信息保存 | 
|---|
|  |  |  | 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 (data.getCompleteTime().before(data.getEmptyWeightTime())) { | 
|---|
|  |  |  | data.setEmptyWeightTime(DateUtils.addMinutes(data.getCompleteTime(), -10)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.getEmptyWeightTime().before(data.getFullWeightTime())) { | 
|---|
|  |  |  | data.setFullWeightTime(DateUtils.addMinutes(data.getEmptyWeightTime(), -40)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.getFullWeightTime().before(data.getRegisterTime())) { | 
|---|
|  |  |  | data.setRegisterTime(DateUtils.addMinutes(data.getFullWeightTime(), -30)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | data = this.updateCheckItems(data, false); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (null == data.getEmptyWeightTime()) { | 
|---|
|  |  |  | data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -50)); | 
|---|
|  |  |  | data.setEmptyWeightTime(DateUtils.addMinutes(new Date(), -50)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null == data.getFullWeightTime()) { | 
|---|
|  |  |  | data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -10)); | 
|---|
|  |  |  | data.setFullWeightTime(DateUtils.addMinutes(new Date(), -10)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.getCompleteTime().before(data.getFullWeightTime())) { | 
|---|
|  |  |  | data.setFullWeightTime(DateUtils.addMinutes(data.getCompleteTime(), -10)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.getFullWeightTime().before(data.getEmptyWeightTime())) { | 
|---|
|  |  |  | data.setEmptyWeightTime(DateUtils.addMinutes(data.getEmptyWeightTime(), -40)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.getEmptyWeightTime().before(data.getRegisterTime())) { | 
|---|
|  |  |  | data.setRegisterTime(DateUtils.addMinutes(data.getFullWeightTime(), -30)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 添加补单数据 | 
|---|
|  |  |  | String msg = inoutService.insertData(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 初始化验证出入库库存 | 
|---|
|  |  |  | commonService.initInoutDepotStore(data); | 
|---|
|  |  |  | return msg; | 
|---|
|  |  |  | //先保存主表,后执行子表 | 
|---|
|  |  |  | inoutService.insertData(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.TYPE_IN.equals(data.getType())) { | 
|---|
|  |  |  | this.updateCheckItems(data, true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), null); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @javax.transaction.Transactional(rollbackOn = Exception.class) | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public String updateInoutData(InoutData data) throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { | 
|---|
|  |  |  | return "系统:已经删除的数据不支持修改!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) { | 
|---|
|  |  |  | return "系统:异常终止的数据不支持修改!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果流程未结束,只更新数据 | 
|---|
|  |  |  | if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { | 
|---|
|  |  |  | return inoutService.updateData(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果是已经完成的数据,先获取到修改直接的数据根据数据进行对比 | 
|---|
|  |  |  | InoutParam param = new InoutParam(); | 
|---|
|  |  |  | param.setId(data.getId()); | 
|---|
|  |  |  | param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | param.setType(data.getType()); | 
|---|
|  |  |  | InoutData record = inoutService.inoutQueryById(param); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == record) { | 
|---|
|  |  |  | return "当前修改数据已经不存在!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 避免数据库中的数据已经被其他人修改 | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_DEL.equals(record.getRecordStatus())) { | 
|---|
|  |  |  | return "系统:已经删除的数据不支持修改!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_ERROR.equals(record.getRecordStatus())) { | 
|---|
|  |  |  | return "系统:异常终止的数据不支持修改!"; | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { | 
|---|
|  |  |  | return "系统:流程已经结束的数据不支持修改!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 保存检测项目 | 
|---|
|  |  |  | if (InoutConstant.TYPE_IN.equals(data.getType())) { | 
|---|
|  |  |  | // 先执行化验信息保存 | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | data = updateCheckItems(data, true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新数据 | 
|---|
|  |  |  | inoutService.updateData(data); | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | return inoutService.updateData(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 删除操作 删除数据为软删除,删除数据后需要根据删除情况联动库存等信息 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param data | 
|---|
|  |  |  | * @param selected 是否已经查询过数据 | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public String delInoutData(InoutData data, boolean selected) | 
|---|
|  |  |  | throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 避免页面缓存首先获取数据库中最新的当前数据信息 | 
|---|
|  |  |  | InoutParam param = new InoutParam(); | 
|---|
|  |  |  | param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | param.setId(data.getId()); | 
|---|
|  |  |  | param.setMsg(" [" + ContextUtil.getLoginUserCName() + "]执行删除,原因:" | 
|---|
|  |  |  | + data.getRemarks()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!selected) { | 
|---|
|  |  |  | data = inoutService.inoutQueryById(param); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { | 
|---|
|  |  |  | return "已经删除的数据,不支持重复删除!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_ERROR | 
|---|
|  |  |  | .equals(data.getRecordStatus())) { | 
|---|
|  |  |  | return "当前数据已经被标记为异常,不支持删除!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 执行删除 | 
|---|
|  |  |  | param.setProgress(InoutConstant.PROGRESS_RECORD); | 
|---|
|  |  |  | param.setRecordStatus(InoutConstant.RECORD_STATUS_DEL); | 
|---|
|  |  |  | param.setType(data.getType()); | 
|---|
|  |  |  | inoutService.deleteData(param); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 如果流程未结束,直接删除,不牵扯到联动调整 | 
|---|
|  |  |  | if (!InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 异常终止操作 设置异常 为了避免页面数据缓存,需要重新获取最新数据判断 | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | * @throws Exception | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public String errorInoutData(InoutData data) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String errorInoutData(InoutData data) throws Exception { | 
|---|
|  |  |  | InoutParam param = new InoutParam(); | 
|---|
|  |  |  | param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | param.setId(data.getId()); | 
|---|
|  |  |  | param.setMsg(" [" + ContextUtil.getLoginUserCName() + "]执行异常终止,原因:" | 
|---|
|  |  |  | + data.getRemarks()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | param.setMsg(" 于" + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm") + " 被 " + ContextUtil.getLoginUserCName() + " 执行终止,原因:" + data.getRemarks()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | data = inoutService.inoutQueryById(param); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { | 
|---|
|  |  |  | return "已经删除的数据,不支持异常处理!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) { | 
|---|
|  |  |  | return "不支持重复异常处理!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { | 
|---|
|  |  |  | return "流程结束的数据不支持异常处理!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { | 
|---|
|  |  |  | return "当前信息已做异常处理,不支持重复执行!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | param.setDeptId(data.getDeptId()); | 
|---|
|  |  |  | param.setType(data.getType()); | 
|---|
|  |  |  | return inoutService.inoutStop(param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String completeInoutData(InoutData data) throws Exception { | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_DEL.equals(data.getRecordStatus())) { | 
|---|
|  |  |  | return "已经删除的数据,不支持完成!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_ERROR.equals(data.getRecordStatus())) { | 
|---|
|  |  |  | return "异常终止的数据,不支持完成!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) { | 
|---|
|  |  |  | return "流程已完成的数据,不支持完成!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 从新查询数据 | 
|---|
|  |  |  | InoutParam param = new InoutParam(); | 
|---|
|  |  |  | param.setId(data.getId()); | 
|---|
|  |  |  | param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | param.setType(data.getType()); | 
|---|
|  |  |  | InoutData cuData = inoutService.inoutProgressQuery(param); | 
|---|
|  |  |  | InoutData cuData = inoutService.inoutQueryById(param); | 
|---|
|  |  |  | if (null == cuData) { | 
|---|
|  |  |  | return "当前车辆流程状态已经变化,请刷新页面重新操作!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!cuData.getProgress().equals(data.getProgress())) { | 
|---|
|  |  |  | return "当前车辆流程状态已经变化,请刷新页面重新操作!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.RECORD_STATUS_DEL.equals(cuData.getRecordStatus())) { | 
|---|
|  |  |  | return "当前信息已经被异常终止,不支持当前处理!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(cuData.getProgress())) { | 
|---|
|  |  |  | return "流程已完成的数据,不支持完成!"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == data.getCompleteTime()) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String msg = inoutService.quickComplete(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == msg) { | 
|---|
|  |  |  | data.setProgress(InoutConstant.PROGRESS_RECORD); | 
|---|
|  |  |  | commonService.initInoutDepotStore(data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return msg; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void initLpr(InoutConf conf) { | 
|---|
|  |  |  | inoutDeviceManager.initLpr(conf); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 出入库登记初始化 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | * @param conf 车牌识别配置信息 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void initInoutRegister(InoutConf conf) { | 
|---|
|  |  |  | inoutEventControl.initInoutRegister(conf); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public PageResponse<InoutData> submitRegisterInout(InoutData data) throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //首先判断流程中是否有已经存在的车辆信息未执行完成,直接从数据库中查询 | 
|---|
|  |  |  | // 首先判断流程中是否有已经存在的车辆信息未执行完成,直接从数据库中查询 | 
|---|
|  |  |  | InoutParam param = new InoutParam(); | 
|---|
|  |  |  | param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | param.setPlateNum(data.getPlateNum()); | 
|---|
|  |  |  | 
|---|
|  |  |  | "当前车牌或智慧卡有正在执行流程未结束,请联系管理员", 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取下一个流程状态 | 
|---|
|  |  |  | List<FileData> files = data.getFiles(); | 
|---|
|  |  |  | // 获取下一个流程状态 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | if(null != files && files.size()>0){ | 
|---|
|  |  |  | // 执行附件信息 | 
|---|
|  |  |  | fileService.saveInoutFiles(files, data.getCompanyId(), data.getId(), curProgress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //登记完成事件 | 
|---|
|  |  |  | inoutEventControl.onInoutRegister(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data); | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", | 
|---|
|  |  |  | data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<FileData> files = data.getFiles(); | 
|---|
|  |  |  | // 获取下一个流程状态 | 
|---|
|  |  |  | String curProgress = data.getProgress(); | 
|---|
|  |  |  | String nextProgress = getNextProgress(curProgress, data.getType(), | 
|---|
|  |  |  | inoutSysConf); | 
|---|
|  |  |  | data = updateBasicInfo(data, curProgress, nextProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 入库称重可能调整质检单 | 
|---|
|  |  |  | data = updateCheckItems(data, true); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 执行数据更新 | 
|---|
|  |  |  | String msg = inoutService.updateData(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, | 
|---|
|  |  |  | data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(null != files && files.size()>0){ | 
|---|
|  |  |  | // 执行附件信息 | 
|---|
|  |  |  | fileService.saveInoutFiles(files, data.getCompanyId(), data.getId(), curProgress); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 称重完成事件 | 
|---|
|  |  |  | inoutEventControl.onInoutWeight(data, curProgress, nextProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public PageResponse<InoutData> submitWeightOut(InoutData data) | 
|---|
|  |  |  | throws Exception { | 
|---|
|  |  |  | // 获取系统参数配置 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | if (data.getDeCheck() == 0) { | 
|---|
|  |  |  | data.setDeCheck(checkUpdateResult.getDeSum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (data.getAddCheck() == 0) { | 
|---|
|  |  |  | data.setAddCheck(checkUpdateResult.getAddSum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //执行数据更新 | 
|---|
|  |  |  | // 执行数据更新 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 称重完成事件 | 
|---|
|  |  |  | inoutEventControl.onInoutWeight(data, curProgress, nextProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public PageResponse<InoutData> submitWeightOut(InoutData data) throws Exception { | 
|---|
|  |  |  | //获取系统参数配置 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | data = updateBasicInfo(data, curProgress, nextProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //执行数据更新 | 
|---|
|  |  |  | String msg = inoutService.updateData(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 执行附件信息 | 
|---|
|  |  |  | fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //称重后根据当前流程状态和下一个状态,通知称重控制器 | 
|---|
|  |  |  | inoutDeviceManager.controlWeight(data, curProgress, nextProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | if (null == inoutSysConf) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "提示:当前系统中流程配置异常,请联系管理员", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取下一个流程状态 | 
|---|
|  |  |  | // 获取下一个流程状态 | 
|---|
|  |  |  | String curProgress = data.getProgress(); | 
|---|
|  |  |  | String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf); | 
|---|
|  |  |  | data = updateBasicInfo(data, curProgress, nextProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //执行数据更新 | 
|---|
|  |  |  | // 执行数据更新 | 
|---|
|  |  |  | String msg = inoutService.updateDataByHandle(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | 
|---|
|  |  |  | // 执行附件信息 | 
|---|
|  |  |  | fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 值仓完成触发事件 | 
|---|
|  |  |  | inoutEventControl.onInoutHandle(data, curProgress, nextProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 根据条件获取扦样数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | * @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()); | 
|---|
|  |  |  | 
|---|
|  |  |  | param.setDeptId(ContextUtil.subDeptId(null)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //若查询条件为已扦样,则流程置空;若未扦样,则流程不处理,仍为扦样化验流程(CHECK) | 
|---|
|  |  |  | // 若查询条件为已扦样,则流程置空;若未扦样,则流程不处理,仍为扦样化验流程(CHECK) | 
|---|
|  |  |  | if (!"NONE".equals(param.getSampleStatus())) { | 
|---|
|  |  |  | param.setProgress(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取扦样数据 | 
|---|
|  |  |  | // 获取扦样数据 | 
|---|
|  |  |  | 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 { | 
|---|
|  |  |  | // 获取业务数据信息 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前流程已经结束,不支持修改"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public PageResponse<InoutCheckData> submitSample(InoutCheckData data) throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //扦样时间和扦样人 | 
|---|
|  |  |  | if (StringUtils.isEmpty(data.getSampleUser())) { | 
|---|
|  |  |  | data.setSampleUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null == data.getSampleTime()) { | 
|---|
|  |  |  | data.setSampleTime(new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String msg = inoutService.updateSampleData(data); | 
|---|
|  |  |  | // 获取业务数据信息 | 
|---|
|  |  |  | InoutParam param = new InoutParam(); | 
|---|
|  |  |  | param.setCompanyId(data.getCompanyId()); | 
|---|
|  |  |  | param.setId(data.getId()); | 
|---|
|  |  |  | InoutData curData = inoutService.inoutProgressQuery(param); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("后台异常:{}", e); | 
|---|
|  |  |  | if (null == curData) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "后台异常:" + e.getMessage(), null); | 
|---|
|  |  |  | "没有获取到入库业务数据信息,更新失败", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前流程已经结束,不支持修改"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 扦样时间和扦样人 | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 扦样完成触发事件 | 
|---|
|  |  |  | inoutEventControl.onInSimple(data); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public PageResponse<InoutCheckData> submitCheck(InoutCheckData data) throws Exception { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取系统参数配置 | 
|---|
|  |  |  | InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId()); | 
|---|
|  |  |  | if (null == inoutSysConf) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "提示:当前库区未配置出入库流程信息,请联系管理员", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取业务数据信息 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前流程已经结束,不支持修改"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新化验项信息 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置化验信息 | 
|---|
|  |  |  | if (checkResult.getDeSum() > 0) { | 
|---|
|  |  |  | curData.setDeCheck(checkResult.getDeSum()); | 
|---|
|  |  |  | data.setDeCheck(checkResult.getDeSum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (checkResult.getAddSum() > 0) { | 
|---|
|  |  |  | curData.setAddCheck(checkResult.getAddSum()); | 
|---|
|  |  |  | data.setAddCheck(checkResult.getAddSum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null == data.getCheckTime()) { | 
|---|
|  |  |  | curData.setCheckTime(new Date()); | 
|---|
|  |  |  | data.setCheckTime(new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | curData.setCheckStatus(data.getCheckStatus()); | 
|---|
|  |  |  | curData.setFoodYear(data.getFoodYear()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取下一个流程状态 | 
|---|
|  |  |  | String curProgress = curData.getProgress(); | 
|---|
|  |  |  | String nextProgress = getNextProgress(curProgress, curData.getType(), inoutSysConf); | 
|---|
|  |  |  | curData = updateBasicInfo(curData, curProgress, nextProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 若化验结果不合格,判断配置后续流程 | 
|---|
|  |  |  | if (InoutConstant.STATUS_UNPASS.equals(curData.getCheckStatus())) { | 
|---|
|  |  |  | curData = checkNoPass(curData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | curData.setProgress(curData.getProgress()); | 
|---|
|  |  |  | curData.setType(curData.getType()); | 
|---|
|  |  |  | curData.setFoodLevel(data.getFoodLevel()); | 
|---|
|  |  |  | curData.setFoodVariety(data.getFoodVariety()); | 
|---|
|  |  |  | curData.setPrice(data.getPrice()); | 
|---|
|  |  |  | curData.setRemarks(data.getRemarks()); | 
|---|
|  |  |  | curData.setCheckItems(data.getCheckItems()); | 
|---|
|  |  |  | curData.setCheckTime(data.getCheckTime()); | 
|---|
|  |  |  | curData.setDepotId(data.getDepotId()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isEmpty(data.getCheckUser())) { | 
|---|
|  |  |  | curData.setCheckUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null == data.getCheckTime()) { | 
|---|
|  |  |  | curData.setCheckTime(new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String msg = inoutService.updateCheckData(curData); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 质检完成触发事件 | 
|---|
|  |  |  | inoutEventControl.onInCheck(data, curProgress, nextProgress); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public PageResponse<InoutCheckData> submitCheckData(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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前流程已经结束,不支持修改"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 更新化验项信息 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | curData.setType(curData.getType()); | 
|---|
|  |  |  | curData.setFoodLevel(data.getFoodLevel()); | 
|---|
|  |  |  | curData.setFoodVariety(data.getFoodVariety()); | 
|---|
|  |  |  | curData.setPrice(data.getPrice()); | 
|---|
|  |  |  | curData.setDepotId(data.getDepotId()); | 
|---|
|  |  |  | curData.setCheckItems(data.getCheckItems()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String msg = inoutService.updateCheckData(curData); | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "保存成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @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()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Page<InoutCheckData> checkList = inoutService.pageCheckData(param); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (null == checkList.getRecords() || checkList.getRecords().isEmpty()) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), | 
|---|
|  |  |  | "获取到数据信息为空"); | 
|---|
|  |  |  | 
|---|
|  |  |  | * @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.getCompanyId(), param.getCheckId(), | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional(rollbackFor = Exception.class) | 
|---|
|  |  |  | public PageResponse<InoutCheckData> updateCheckData(InoutCheckData data) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取业务数据信息 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_RECORD.equals(curData.getProgress())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "当前流程已经结束,不支持修改"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新化验项信息 | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //设置化验信息 | 
|---|
|  |  |  | if (checkResult.getDeSum() > 0) { | 
|---|
|  |  |  | data.setDeCheck(checkResult.getDeSum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (checkResult.getAddSum() > 0) { | 
|---|
|  |  |  | data.setAddCheck(checkResult.getAddSum()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null == data.getCheckTime()) { | 
|---|
|  |  |  | data.setCheckTime(new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | curData.setCheckStatus(data.getCheckStatus()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取系统参数配置 | 
|---|
|  |  |  | InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId()); | 
|---|
|  |  |  | if (null == inoutSysConf) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "提示:当前库区未配置出入库流程信息,请联系管理员", data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //更新下一流程状态 | 
|---|
|  |  |  | if (InoutConstant.PROGRESS_CHECK.equals(curData.getProgress())) { | 
|---|
|  |  |  | curData = updateBasicInfo(curData, inoutSysConf); | 
|---|
|  |  |  | // 若化验结果不合格,判断配置后续流程 | 
|---|
|  |  |  | if (InoutConstant.STATUS_UNPASS.equals(curData.getCheckStatus())) { | 
|---|
|  |  |  | curData = checkNoPass(curData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //化验人、化验时间 | 
|---|
|  |  |  | data.setCheckStatus(curData.getCheckStatus()); | 
|---|
|  |  |  | data.setProgress(curData.getProgress()); | 
|---|
|  |  |  | if (StringUtils.isEmpty(data.getCheckUser())) { | 
|---|
|  |  |  | data.setCheckUser(ContextUtil.getLoginUserCName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (null == data.getCheckTime()) { | 
|---|
|  |  |  | data.setCheckTime(new Date()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String msg = inoutService.updateCheckData(data); | 
|---|
|  |  |  | if (null != msg) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), | 
|---|
|  |  |  | "后台异常:" + e.getMessage(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取单价信息 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @param param | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public PageResponse<InoutCheckData> inoutDataByCheckId(InoutCheckParam param) { | 
|---|
|  |  |  | if (StringUtils.isEmpty(param.getCheckId())) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), | 
|---|
|  |  |  | "查询参数不完整,查询失败!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | InoutCheckData result; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | param.setProgress(InoutConstant.PROGRESS_CHECK); | 
|---|
|  |  |  | result = inoutService.inoutDataByCheckId(param); | 
|---|
|  |  |  | if (null == result) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), | 
|---|
|  |  |  | "系统未查询到执行中的车辆信息", null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_0000, result); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), | 
|---|
|  |  |  | e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void initInoutWeight(List<InoutConf> listInoutConf, String sort) { | 
|---|
|  |  |  | inoutEventControl.initInoutWeight(listInoutConf, sort); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|