| | |
| | | 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.InoutData; |
| | | import com.ld.igds.inout.dto.InoutGateDto; |
| | | import com.ld.igds.inout.dto.InoutParam; |
| | | import com.ld.igds.inout.dto.*; |
| | | import com.ld.igds.inout.service.InoutService; |
| | | import com.ld.igds.m.service.InoutCommonService; |
| | | import com.ld.igds.models.Depot; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.commons.lang3.time.DateUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private InoutDeviceManager inoutDeviceManager; |
| | | |
| | | /** |
| | | * 当前先从当日缓存中获取数据,如果缓存中没有再从数据库获取 |
| | | * 首先从缓存中获取,缓存中,从数据库中获取 |
| | | * |
| | | * @param param |
| | | * @return |
| | |
| | | && StringUtils.isEmpty(param.getUserId())) { |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), |
| | | "参数不完整,无法获取信息!"); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(param.getCompanyId())) { |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | "查询参数不完整,查询失败!"); |
| | | } |
| | | |
| | | InoutData result; |
| | | String progress = param.getProgress(); |
| | | try { |
| | | param.setProgress(null); |
| | | |
| | | result = inoutService.inoutProgressQuery(param); |
| | | if (null == result) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), |
| | | "未找到流程中的车辆!", null); |
| | | "系统为查询到执行中的车辆信息", null); |
| | | } |
| | | |
| | | // 如果没有流程条件说明不需要做判断,直接返回 |
| | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, result); |
| | | } |
| | | |
| | | |
| | | //流程类型验证 |
| | | if (!result.getType().equals(param.getType())) { |
| | | if (InoutConstant.TYPE_IN.equals(result.getType())) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), |
| | | "系统:当前车辆业务为【入库】", result); |
| | | } else { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), |
| | | "系统:当前车辆业务为【出库】", result); |
| | | } |
| | | String msg = "流程错误:当前车辆流程为【入库】"; |
| | | 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) |
| | |
| | | // 表示当前流程正常 |
| | | } else { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), |
| | | "非当前流程,请到" |
| | | "提示:非当前环节,请到" |
| | | + InoutConstant.getProcessName( |
| | | param.getType(), |
| | | result.getProgress()), result); |
| | |
| | | } else { |
| | | if (!result.getProgress().equals(progress)) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), |
| | | "非当前流程,请到" |
| | | "提示:非当前环节,请到" |
| | | + InoutConstant.getProcessName( |
| | | param.getType(), |
| | | result.getProgress()), result); |
| | | } |
| | | } |
| | | |
| | | // 根据当前数据判断是否推送 |
| | | inoutService.notifyWeb(result); |
| | | |
| | | //为当前数据添加化验项目和水分和杂质的化验结果,用于出入库增扣重计算 |
| | | if (InoutConstant.TYPE_IN.equals(result.getType())) { |
| | | List<CheckItemData> checkItemDataList = inoutService.getCheckCache(result.getCompanyId(), result.getCheckId()); |
| | | result.setCheckItems(checkItemDataList); |
| | | if (null != checkItemDataList && checkItemDataList.size() > 0) { |
| | | for (CheckItemData checkItem : checkItemDataList) { |
| | | if (StringUtils.isEmpty(checkItem.getValue())) { |
| | | continue; |
| | | } |
| | | |
| | | // if (InoutConstant.CHECK_ITEM_C01.equals(checkItem.getStandardId())) { |
| | | // result.setWet(Double.valueOf(checkItem.getValue())); |
| | | // } |
| | | // if (InoutConstant.CHECK_ITEM_C02.equals(checkItem.getStandardId())) { |
| | | // result.setImpurity(Double.valueOf(checkItem.getValue())); |
| | | // } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | return data; |
| | | } |
| | | |
| | | public PageResponse<Page<InoutData>> pageRecordData(InoutParam param) { |
| | | // public PageResponse<Page<InoutData>> pageRecordData(InoutParam param) { |
| | | // |
| | | // log.debug("分页信息--page={},limit={},cuur={}", param.getPage(), |
| | | // param.getLimit(), param.getCurr()); |
| | | // |
| | | // Page<InoutData> result = inoutService.pageRecordData(param); |
| | | // |
| | | // if (null == result.getRecords() || result.getRecords().isEmpty()) { |
| | | // return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), |
| | | // "获取到数据信息为空"); |
| | | // } |
| | | // |
| | | // return new PageResponse<>(RespCodeEnum.CODE_0000, result); |
| | | // } |
| | | |
| | | log.debug("分页信息--page={},limit={},cuur={}", param.getPage(), |
| | | param.getLimit(), param.getCurr()); |
| | | |
| | | Page<InoutData> result = inoutService.pageRecordData(param); |
| | | |
| | | if (null == result.getRecords() || result.getRecords().isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), |
| | | "获取到数据信息为空"); |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, result); |
| | | } |
| | | |
| | | /** |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<Page<InoutData>> pageCheckData(InoutParam param) { |
| | | // 如果是已化验,则将流程状态置空,如果是未化验,则流程状态不处理,仍是CHECK状态 |
| | | if (!"NONE".equals(param.getCheckStatus())) { |
| | | param.setProgress(null); |
| | | } |
| | | // 设置分库Id |
| | | String deptId = ContextUtil.subDeptId(null); |
| | | param.setDeptId(deptId); |
| | | return pageRecordData(param); |
| | | } |
| | | // /** |
| | | // * @param param |
| | | // * @return |
| | | // */ |
| | | // public PageResponse<Page<InoutData>> pageCheckData(InoutParam param) { |
| | | // // 如果是已化验,则将流程状态置空,如果是未化验,则流程状态不处理,仍是CHECK状态 |
| | | // if (!"NONE".equals(param.getCheckStatus())) { |
| | | // param.setProgress(null); |
| | | // } |
| | | // // 设置分库Id |
| | | // String deptId = ContextUtil.subDeptId(null); |
| | | // param.setDeptId(deptId); |
| | | // return pageRecordData(param); |
| | | // } |
| | | |
| | | |
| | | public PageResponse<InoutData> inoutComplete(InoutData data) throws Exception { |
| | |
| | | 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<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); |
| | | // } |
| | | |
| | | /** |
| | | * 删除并完成 |
| | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 根据条件获取扦样数据 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<Page<InoutCheckData>> pageSampleData(InoutCheckParam param) { |
| | | |
| | | if (StringUtils.isEmpty(param.getCompanyId())) { |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(param.getDeptId())) { |
| | | param.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | //若查询条件为已扦样,则流程置空;若未扦样,则流程不处理,仍为扦样化验流程(CHECK) |
| | | if (!"NONE".equals(param.getSampleStatus())) { |
| | | param.setProgress(null); |
| | | } |
| | | |
| | | //获取扦样数据 |
| | | Page<InoutCheckData> sampleList = inoutService.pageSampleData(param); |
| | | |
| | | |
| | | 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(), |
| | | "当前流程已经结束,不支持修改"); |
| | | } |
| | | |
| | | //扦样时间和扦样人 |
| | | 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); |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); |
| | | } catch (Exception e) { |
| | | log.error("后台异常:{}", e); |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), |
| | | "后台异常:" + e.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<Page<InoutCheckData>> pageCheckData(InoutCheckParam param) { |
| | | |
| | | if (StringUtils.isEmpty(param.getCompanyId())) { |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(param.getDeptId())) { |
| | | param.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | // 如果是已化验,则将流程状态置空,如果是未化验,则流程状态不处理,仍是CHECK状态 |
| | | if (!"NONE".equals(param.getCheckStatus())) { |
| | | param.setProgress(null); |
| | | } |
| | | |
| | | Page<InoutCheckData> checkList = inoutService.pageCheckData(param); |
| | | |
| | | |
| | | if (null == checkList.getRecords() || checkList.getRecords().isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), |
| | | "获取到数据信息为空"); |
| | | } |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, checkList); |
| | | } |
| | | |
| | | /** |
| | | * 获取化验项信息 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<List<CheckItemData>> getCheckItemData(InoutCheckParam param) { |
| | | |
| | | try { |
| | | List<CheckItemData> result = checkStandardManager.listCheckItem(param.getCheckId(), |
| | | param.getCompanyId(), param.getFoodVariety()); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, result); |
| | | } catch (Exception e) { |
| | | return new PageResponse<>( |
| | | RespCodeEnum.CODE_1111.getCode(), "后台异常:" + e.getMessage(), null); |
| | | } |
| | | } |
| | | |
| | | @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(), |
| | | "当前流程已经结束,不支持修改"); |
| | | } |
| | | curData.setCheckStatus(data.getCheckStatus()); |
| | | |
| | | //更新下一流程状态 |
| | | if (InoutConstant.PROGRESS_CHECK.equals(curData.getProgress())) { |
| | | curData = updateInBasicInfo(curData, null); |
| | | // 若化验结果不合格,判断配置后续流程 |
| | | if (InoutConstant.STATUS_UNPASS.equals(curData.getCheckStatus())) { |
| | | curData = checkNoPass(curData); |
| | | } |
| | | } |
| | | |
| | | data.setCheckStatus(curData.getCheckStatus()); |
| | | //化验人、化验时间 |
| | | 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); |
| | | } |
| | | //TODO 更新化验项信息 |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); |
| | | } catch (Exception e) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), |
| | | "后台异常:" + e.getMessage(), null); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |