| | |
| | | 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.models.InoutSysConf; |
| | | import com.ld.igds.util.ContextUtil; |
| | | import com.ld.igds.util.DateUtil; |
| | | |
| | | 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.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | @Resource |
| | | private CoreFileService fileService; |
| | | @Resource |
| | | private CoreCommonService commonService; |
| | | @Resource |
| | | private InoutCommonService inoutCommonService; |
| | | @Resource |
| | | private CheckStandardManager checkStandardManager; |
| | | @Resource |
| | | private InoutDeviceManager inoutDeviceManager; |
| | | private InoutEventControlManager inoutEventControl; |
| | | |
| | | /** |
| | | * 直接从数据库查询,不考虑信息状态 |
| | |
| | | * @param data |
| | | * @return |
| | | */ |
| | | private InoutData updateCheckItems(InoutData data) throws Exception { |
| | | private InoutData updateCheckItems(InoutData data, boolean toSave) throws Exception { |
| | | |
| | | if (null == data.getCheckItems()) return data; |
| | | |
| | | //设置没有质检ID,取消执行持久化 |
| | | if (!toSave) data.setCheckId(null); |
| | | |
| | | // 更新检验项数据 |
| | | CheckUpdateResult checkUpdateResult = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems()); |
| | |
| | | return data; |
| | | } |
| | | |
| | | public PageResponse<InoutData> submitComplete(InoutData data) |
| | | throws Exception { |
| | | |
| | | if (StringUtils.isEmpty(data.getId()) |
| | | || 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(data.getCompleteUser()); |
| | | param.setDepotId(data.getDepotId()); |
| | | param.setCompleteTime(data.getCompleteTime()); |
| | | param.setProgress(InoutConstant.PROGRESS_RECORD); |
| | | |
| | | String msg = inoutService.toComplete(param); |
| | | |
| | | if (null != msg) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data); |
| | | } |
| | | |
| | | /** |
| | | * 卡回收逻辑处理 |
| | | * |
| | |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", |
| | | data); |
| | | } |
| | | |
| | | |
| | | public PageResponse<InoutData> submitComplete(InoutData data) |
| | | throws Exception { |
| | | |
| | | if (StringUtils.isEmpty(data.getId()) |
| | | || 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(data.getCompleteUser()); |
| | | param.setDepotId(data.getDepotId()); |
| | | param.setCompleteTime(new Date()); |
| | | param.setProgress(InoutConstant.PROGRESS_RECORD); |
| | | |
| | | String msg = inoutService.toComplete(param); |
| | | |
| | | if (null != msg) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); |
| | | } |
| | | |
| | | |
| | | // 流程完成收事件 |
| | | inoutEventControl.onInoutComplete(data); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), null, data); |
| | | } |
| | | |
| | | /** |
| | |
| | | data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -10)); |
| | | } |
| | | |
| | | data = this.updateCheckItems(data); |
| | | data = this.updateCheckItems(data, false); |
| | | } else { |
| | | if (null == data.getEmptyWeightTime()) { |
| | | data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -50)); |
| | |
| | | } |
| | | } |
| | | |
| | | // 添加补单数据 |
| | | return inoutService.insertData(data); |
| | | |
| | | //先保存主表,后执行子表 |
| | | inoutService.insertData(data); |
| | | |
| | | if (InoutConstant.TYPE_IN.equals(data.getType())) { |
| | | this.updateCheckItems(data, true); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // 保存检测项目 |
| | | if (InoutConstant.TYPE_IN.equals(data.getType())) { |
| | | data = updateCheckItems(data); |
| | | data = updateCheckItems(data, true); |
| | | } |
| | | |
| | | return inoutService.updateData(data); |
| | |
| | | return msg; |
| | | } |
| | | |
| | | public void initLpr(InoutConf conf) { |
| | | inoutDeviceManager.initLpr(conf); |
| | | /** |
| | | * 出入库登记初始化 |
| | | * |
| | | * @param conf 车牌识别配置信息 |
| | | */ |
| | | public void initInoutRegister(InoutConf conf) { |
| | | inoutEventControl.initInoutRegister(conf); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public PageResponse<InoutData> submitRegisterInout(InoutData data) |
| | | throws Exception { |
| | | public PageResponse<InoutData> submitRegisterInout(InoutData data) throws Exception { |
| | | |
| | | // 首先判断流程中是否有已经存在的车辆信息未执行完成,直接从数据库中查询 |
| | | InoutParam param = new InoutParam(); |
| | |
| | | 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); |
| | | fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress); |
| | | |
| | | //登记完成事件 |
| | | inoutEventControl.onInoutRegister(data); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", |
| | | data); |
| | | } |
| | | |
| | | public PageResponse<InoutData> submitWeightIn(InoutData data) |
| | | throws Exception { |
| | | public PageResponse<InoutData> submitWeightIn(InoutData data) throws Exception { |
| | | // 获取系统参数配置 |
| | | InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf( |
| | | data.getCompanyId(), data.getDeptId()); |
| | |
| | | data = updateBasicInfo(data, curProgress, nextProgress); |
| | | |
| | | // 入库称重可能调整质检单 |
| | | data = updateCheckItems(data); |
| | | data = updateCheckItems(data, true); |
| | | |
| | | // 执行数据更新 |
| | | String msg = inoutService.updateData(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); |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data); |
| | | } |
| | | |
| | | public PageResponse<InoutData> submitWeightOut(InoutData data) |
| | |
| | | fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), |
| | | data.getId(), curProgress); |
| | | |
| | | // 称重后根据当前流程状态和下一个状态,通知称重控制器 |
| | | inoutDeviceManager.controlWeight(data, curProgress, nextProgress); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", |
| | | data); |
| | | // 称重完成事件 |
| | | inoutEventControl.onInoutWeight(data, curProgress, nextProgress); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data); |
| | | } |
| | | |
| | | public PageResponse<InoutData> submitHandle(InoutData data) |
| | |
| | | |
| | | // 执行附件信息 |
| | | fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress); |
| | | |
| | | // 值仓完成触发事件 |
| | | inoutEventControl.onInoutHandle(data, curProgress, nextProgress); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data); |
| | | } |
| | |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); |
| | | } |
| | | |
| | | // 扦样完成触发事件 |
| | | inoutEventControl.onInSimple(data); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); |
| | | } |
| | | |
| | |
| | | |
| | | 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()); |
| | |
| | | if (null != msg) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg); |
| | | } |
| | | |
| | | |
| | | // 质检完成触发事件 |
| | | inoutEventControl.onInCheck(data,curProgress,nextProgress); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功"); |
| | | } |
| | |
| | | |
| | | try { |
| | | List<CheckItemData> result = checkStandardManager.listCheckItem( |
| | | param.getCheckId(), param.getCompanyId(), |
| | | param.getCompanyId(), param.getCheckId(), |
| | | param.getFoodVariety()); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, result); |