| | |
| | | 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; |
| | |
| | | * @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; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 从缓存中获取下一流程 |
| | |
| | | param.setIntelCard(data.getIntelCard()); |
| | | param.setUserId(data.getCompleteUser()); |
| | | param.setDepotId(data.getDepotId()); |
| | | param.setCompleteTime(data.getCompleteTime()); |
| | | param.setCompleteTime(new Date()); |
| | | param.setProgress(InoutConstant.PROGRESS_RECORD); |
| | | |
| | | String msg = inoutService.toComplete(param); |
| | |
| | | public String addInoutData(InoutData data) throws Exception { |
| | | |
| | | if (data.getSettleWeight() <= 0.0) { |
| | | return "补单数据要求结算重量必须大于0"; |
| | | return "系统:补单数据要求结算重量必须大于0"; |
| | | } |
| | | |
| | | // 补单数据直接到结果状态 |
| | |
| | | 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)); |
| | | } |
| | | 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()); |
| | | if (null != checkResult) { |
| | | // if (null == data.getWet())data.setWet(checkResult.getWet()); |
| | | // if (null == |
| | | // data.getImpurity())data.setImpurity(checkResult.getImpurity()); |
| | | } |
| | | data = this.updateCheckItems(data, false); |
| | | } 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)); |
| | | } |
| | | } |
| | | |
| | | // 添加补单数据 |
| | | String msg = inoutService.insertData(data); |
| | | |
| | | return msg; |
| | | //先保存主表,后执行子表 |
| | | inoutService.insertData(data); |
| | | |
| | | if (InoutConstant.TYPE_IN.equals(data.getType())) { |
| | | this.updateCheckItems(data, true); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | 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.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); |
| | | } |
| | | |
| | | |
| | |
| | | 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()); |
| | | } |
| | | data = updateCheckItems(data, true); |
| | | |
| | | // 执行数据更新 |
| | | String msg = inoutService.updateData(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.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); |
| | | } |
| | | |
| | | /** |
| | |
| | | "当前流程已经结束,不支持修改"); |
| | | } |
| | | |
| | | |
| | | // 更新化验项信息 |
| | | CheckUpdateResult checkResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems()); |
| | | if (StringUtils.isNotEmpty(checkResult.getMsg())) { |
| | |
| | | |
| | | 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()); |
| | | |
| | | if (StringUtils.isEmpty(data.getCheckUser())) { |
| | | curData.setCheckUser(ContextUtil.getLoginUserCName()); |
| | |
| | | |
| | | try { |
| | | List<CheckItemData> result = checkStandardManager.listCheckItem( |
| | | param.getCheckId(), param.getCompanyId(), |
| | | param.getCompanyId(),param.getCheckId(), |
| | | param.getFoodVariety()); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, result); |