| | |
| | | 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 com.ld.igds.util.ContextUtil; |
| | | import com.ld.igds.util.DateUtil; |
| | | import com.ld.igds.util.NumberUtil; |
| | | import com.ld.igds.util.RespUtil; |
| | | 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 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 ("SAMPLE".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(), |
| | | "当前流程已经结束,不支持修改"); |
| | | } |
| | | |
| | | //扦样信息 |
| | | curData.setSampleTime(data.getSampleTime()); |
| | | curData.setSampleType(data.getSampleType()); |
| | | curData.setSampleUser(data.getSampleUser()); |
| | | |
| | | String msg = inoutService.updateSampleData(curData); |
| | | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | } |