| | |
| | | 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; |
| | |
| | | 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(), "执行成功"); |
| | | } |
| | | // @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(), "执行成功"); |
| | | // } |
| | | |
| | | /** |
| | | * 化验结果不通过时校验配置信息 |
| | |
| | | data.setProgress(nextProgress); |
| | | } |
| | | |
| | | if (InoutConstant.PROGRESS_CHECK.equals(data.getProgress())) { |
| | | data.setCheckUser(ContextUtil.getLoginUserCName()); |
| | | data.setProgress(nextProgress); |
| | | return data; |
| | | } |
| | | |
| | | if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(curProgress)) { |
| | | data.setEmptyWeightTime(new Date()); |
| | | data.setEmptyWeightUser(ContextUtil.getLoginUserCName()); |
| | | data.setProgress(nextProgress); |
| | | |
| | | } |
| | | |
| | | if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(curProgress)) { |
| | | data.setFullWeightTime(new Date()); |
| | | data.setFullWeightUser(ContextUtil.getLoginUserCName()); |
| | |
| | | data.setProgress(nextProgress); |
| | | } |
| | | |
| | | |
| | | //如果下一个数据状态=流程结束,直接补充完整信息 |
| | | if (InoutConstant.PROGRESS_RECORD.equals(nextProgress)) { |
| | | data.setCompleteTime(DateUtils.addMinutes(new Date(), 2)); |
| | | data.setCompleteUser(ContextUtil.getLoginUserCName()); |
| | | data.setProgress(nextProgress); |
| | | } |
| | | |
| | | |
| | | return data; |
| | | } |
| | |
| | | |
| | | 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()); |
| | |
| | | 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, null); |
| | | curData = updateBasicInfo(curData, inoutSysConf); |
| | | // 若化验结果不合格,判断配置后续流程 |
| | | if (InoutConstant.STATUS_UNPASS.equals(curData.getCheckStatus())) { |
| | | curData = checkNoPass(curData); |
| | | } |
| | | } |
| | | |
| | | data.setCheckStatus(curData.getCheckStatus()); |
| | | //化验人、化验时间 |
| | | data.setCheckStatus(curData.getCheckStatus()); |
| | | data.setProgress(curData.getProgress()); |
| | | if (StringUtils.isEmpty(data.getCheckUser())) { |
| | | data.setCheckUser(ContextUtil.getLoginUserCName()); |
| | | } |
| | |
| | | } |
| | | |
| | | String msg = inoutService.updateCheckData(data); |
| | | |
| | | if (null != msg) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); |
| | | } |
| | | //TODO 更新化验项信息 |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); |
| | | } catch (Exception e) { |
| | |
| | | "后台异常:" + e.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取单价信息 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<InoutPrice> getPrice(InoutCheckParam param) { |
| | | try { |
| | | |
| | | List<InoutPrice> price = inoutService.getPrice(param); |
| | | if(null == price || price.isEmpty()){ |
| | | 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); |
| | | } |
| | | } |
| | | } |