jiazx0107@163.com
2023-06-08 08cea428e888b6fdd2a3c3783e87e4f828385783
igds-inout/src/main/java/com/ld/igds/inout/manager/InoutManager.java
@@ -11,9 +11,7 @@
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;
@@ -49,15 +47,15 @@
    private CoreFileService fileService;
    @Autowired
    private CoreCommonService commonService;
    @Autowired
    private InoutCommonService inoutManagerService;
    @Resource
    private InoutCommonService inoutCommonService;
    @Autowired
    private CheckStandardManager checkStandardManager;
    @Resource
    private InoutDeviceManager inoutDeviceManager;
    /**
     * 当前先从当日缓存中获取数据,如果缓存中没有再从数据库获取
     * 首先从缓存中获取,缓存中,从数据库中获取
     *
     * @param param
     * @return
@@ -68,22 +66,17 @@
                && 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);
            }
            // 如果没有流程条件说明不需要做判断,直接返回
@@ -91,17 +84,16 @@
                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)
@@ -110,7 +102,7 @@
                    // 表示当前流程正常
                } else {
                    return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(),
                            "非当前流程,请到"
                            "提示:非当前环节,请到"
                                    + InoutConstant.getProcessName(
                                    param.getType(),
                                    result.getProgress()), result);
@@ -118,33 +110,10 @@
            } 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()));
//                  }
                    }
                }
            }
@@ -173,14 +142,14 @@
        List<FileData> files = data.getFiles();
        // 更新下一个状态和基本信息
        InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                data.getCompanyId(), data.getDeptId());
        if (null == inoutSysConf
                || StringUtils.isEmpty(inoutSysConf.getProgressIn())) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(),
                    "当前库区未配置出库流程信息,请联系管理员配置。", data);
        }
        data = updateOutBasicInfo(data, inoutSysConf);
        data = updateBasicInfo(data, inoutSysConf);
        // 如果当前节点是注册,则需要验证下,是否有为完成的流程在执行中
        if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
@@ -241,7 +210,7 @@
        }
        // 更新下一个状态和基本信息
        InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(data.getCompanyId(), data.getDeptId());
        if (null == inoutSysConf
                || StringUtils.isEmpty(inoutSysConf.getProgressIn())) {
@@ -249,7 +218,7 @@
                    "当前库区未配置入库流程信息,请联系管理员配置。", data);
        }
        data = updateInBasicInfo(data, inoutSysConf);
        data = updateBasicInfo(data, inoutSysConf);
        // 如果当前节点是注册,则需要验证下,是否有为完成的流程在执行中
        if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
@@ -347,7 +316,7 @@
        // 更新下一个状态和基本信息
        if (InoutConstant.PROGRESS_CHECK.equals(progressData.getProgress())) {
            progressData = updateInBasicInfo(progressData, null);
            progressData = updateBasicInfo(progressData, null);
            // 若化验结果不合格,判断配置后续流程
            if (InoutConstant.STATUS_UNPASS.equals(progressData
                    .getCheckStatus())) {
@@ -355,10 +324,7 @@
            }
        }
        progressData.setCheckUser(ContextUtil.getLoginUserCName());
//      if (StringUtils.isNotEmpty(data.getCustomerName())) {
//         progressData.setCustomerId(data.getCustomerId());
//         progressData.setCustomerName(data.getCustomerName());
//      }
        if (StringUtils.isNotEmpty(data.getDepotId())) {
            progressData.setDepotId(data.getDepotId());
        }
@@ -384,15 +350,6 @@
            progressData.setNoticeId(data.getNoticeId());
        }
//      // 回填水分和杂质
//      if (checkResult.getWet() > 0) {
//         progressData.setWet(checkResult.getWet());
//      }
//
//      if (checkResult.getImpurity() > 0) {
//         progressData.setImpurity(checkResult.getImpurity());
//      }
        String msg = inoutService.updateData(progressData);
        if (null != msg) {
@@ -412,7 +369,7 @@
     * @return
     */
    private InoutData checkNoPass(InoutData data) {
        InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(
        InoutSysConf inoutSysConf = inoutCommonService.getCacheInoutSysConf(
                data.getCompanyId(), data.getDeptId());
        if (inoutSysConf.getNoPassNext().equals(InoutConstant.CHECK_NOPASS_RECORD)) {
@@ -427,14 +384,20 @@
        return data;
    }
    /**
     * 更新质检信息
     *
     * @param data
     * @return
     */
    private CheckUpdateResult updateCheckItems(InoutData data) {
        CheckUpdateResult result = new CheckUpdateResult();
        if (null == data.getCheckItems())
            return result;
        if (null == data.getCheckItems()) return result;
        try {
            // 更新检验项数据
            result = checkStandardManager.updateCheckItems(data.getCheckId(),
                    data.getCompanyId(), data.getCheckItems());
            result = checkStandardManager.updateCheckItems(data.getCheckId(), data.getCompanyId(), data.getCheckItems());
            // 将化验数据存入缓存中
            inoutService.setCheckCache(data);
@@ -474,82 +437,59 @@
    }
    /**
     * 根据需要保存的数据,调整下一个流程状态 不同的仓库组织流程可能不一样,需要根据实际调整
     * 根据数据当前状态和下一个状态,更新基础信息
     *
     * @param data
     * @return
     */
    private InoutData updateInBasicInfo(InoutData data, InoutSysConf sysConf) {
        if (null == sysConf) {
            sysConf = inoutManagerService.getCacheInoutSysConf(
                    data.getCompanyId(), data.getDeptId());
        }
    private InoutData updateBasicInfo(InoutData data, String curProgress, String nextProgress) {
        if (InoutConstant.PROGRESS_REGISTER.equals(data.getProgress())) {
        if (InoutConstant.PROGRESS_REGISTER.equals(curProgress)) {
            data.setRegisterTime(new Date());
            data.setRegisterUser(ContextUtil.getLoginUserCName());
            data.setProgress(getNextProgress(data.getProgress(),
                    data.getType(), sysConf));
            return data;
            data.setProgress(nextProgress);
        }
        if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(data.getProgress())) {
            data.setFullWeightTime(new Date());
            data.setFullWeightUser(ContextUtil.getLoginUserCName());
            data.setProgress(getNextProgress(data.getProgress(),
                    data.getType(), sysConf));
            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())) {
        if (InoutConstant.PROGRESS_WEIGHT_EMPTY.equals(curProgress)) {
            data.setEmptyWeightTime(new Date());
            data.setEmptyWeightUser(ContextUtil.getLoginUserCName());
            data.setProgress(nextProgress);
            data.setProgress(getNextProgress(data.getProgress(),
                    data.getType(), sysConf));
        }
        if (InoutConstant.PROGRESS_WEIGHT_FULL.equals(curProgress)) {
            data.setFullWeightTime(new Date());
            data.setFullWeightUser(ContextUtil.getLoginUserCName());
            data.setProgress(nextProgress);
        }
            if (InoutConstant.PROGRESS_RECORD.equals(data.getProgress())) {
                data.setCompleteTime(DateUtils.addMinutes(new Date(), 2));
                data.setCompleteUser(ContextUtil.getLoginUserCName());
        if (InoutConstant.PROGRESS_HANDLE.equals(curProgress)) {
            if (null == data.getHandleUser()) {
                data.setHandleUser(ContextUtil.getLoginUserCName());
            }
            return data;
            data.setProgress(nextProgress);
        }
        if (InoutConstant.PROGRESS_HANDLE.equals(data.getProgress())) {
            // 查询缓存中仓库信息,根据仓库id设置值仓人为仓库保管员
            Depot depot = commonService.getCacheDepot(data.getCompanyId(),
                    data.getDepotId());
            data.setHandleUser(depot == null ? "" : depot.getStoreKeeperName());
            data.setProgress(getNextProgress(data.getProgress(),
                    data.getType(), sysConf));
            return data;
        }
        if (InoutConstant.PROGRESS_CARD_BACK.equals(data.getProgress())) {
            data.setCompleteTime(new Date());
        //如果下一个数据状态=流程结束,直接补充完整信息
        if (InoutConstant.PROGRESS_RECORD.equals(nextProgress)) {
            data.setCompleteTime(DateUtils.addMinutes(new Date(), 2));
            data.setCompleteUser(ContextUtil.getLoginUserCName());
            data.setProgress(getNextProgress(data.getProgress(),
                    data.getType(), sysConf));
            return data;
            data.setProgress(nextProgress);
        }
        return data;
    }
    /**
     * 当前方法需要删除
     * <p>
     * 根据需要保存的数据,调整下一个流程状态 不同的仓库组织流程可能不一样,需要根据实际调整
     *
     * @param data
     * @return
     */
    private InoutData updateOutBasicInfo(InoutData data, InoutSysConf sysConf) {
    private InoutData updateBasicInfo(InoutData data, InoutSysConf sysConf) {
        if (InoutConstant.PROGRESS_REGISTER.equals(data.getProgress())) {
            data.setRegisterTime(new Date());
            data.setRegisterUser(ContextUtil.getLoginUserCName());
@@ -600,36 +540,6 @@
        }
        return data;
    }
    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);
    }
    /**
     * @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);
    }
@@ -672,20 +582,20 @@
        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);
//    }
    /**
     * 删除并完成
@@ -798,9 +708,6 @@
            if (null == data.getFullWeightTime()) {
                data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -50));
            }
            if (null == data.getHandleEnd()) {
                data.setHandleEnd(DateUtil.getNewByMinute(new Date(), -40));
            }
            if (null == data.getEmptyWeightTime()) {
                data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -10));
            }
@@ -814,9 +721,6 @@
        } else {
            if (null == data.getEmptyWeightTime()) {
                data.setEmptyWeightTime(DateUtil.getNewByMinute(new Date(), -50));
            }
            if (null == data.getHandleEnd()) {
                data.setHandleEnd(DateUtil.getNewByMinute(new Date(), -40));
            }
            if (null == data.getFullWeightTime()) {
                data.setFullWeightTime(DateUtil.getNewByMinute(new Date(), -10));
@@ -888,7 +792,6 @@
        // 更新数据
        inoutService.updateData(data);
        // this.autoCheckByUpdate(data, record);
        return null;
    }
@@ -1002,9 +905,6 @@
        if (StringUtils.isEmpty(data.getDepotId())) {
            return "请填写仓库信息!";
        }
//      if (StringUtils.isEmpty(data.getCustomerId())) {
//         return "请填写往来单位信息!";
//      }
        if (StringUtils.isEmpty(data.getFoodYear())) {
            return "请填写粮食年份信息!";
        }
@@ -1027,28 +927,6 @@
    public void initLpr(InoutConf conf) {
        inoutDeviceManager.initLpr(conf);
    }
    /**
     * 获取出入库设备配置信息
     *
     * @param companyId
     * @param deptId
     * @return
     */
    public List<InoutConf> getListInoutConf(String companyId, String deptId) {
        return inoutManagerService.getCacheInoutConf(companyId, deptId);
    }
    /**
     * 操作道闸设备
     *
     * @param param
     * @return
     */
    public PageResponse<List<CheckItemData>> gateCtrl(InoutGateDto param) {
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "", null);
    }
    /**
@@ -1076,19 +954,19 @@
        //获取系统参数配置
        InoutSysConf inoutSysConf = inoutManagerService.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 curProgress = data.getProgress();
        String nextProgress = getNextProgress(curProgress, data.getType(), inoutSysConf);
        data.setRegisterTime(new Date());
        data.setRegisterUser(ContextUtil.getLoginUserCName());
        data.setProgress(nextProgress);
        data = updateBasicInfo(data, curProgress, nextProgress);
        String msg = inoutService.insertData(data);
@@ -1104,4 +982,269 @@
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data);
    }
}
    public PageResponse<InoutData> submitWeightIn(InoutData data) throws Exception {
        //获取系统参数配置
        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);
        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());
        }
        //执行数据更新
        String msg = inoutService.updateData(data);
        if (null != msg) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
        }
        // 执行附件信息
        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
        //称重完成,调用出入库控制逻辑处理
        inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data);
    }
    public PageResponse<InoutData> submitWeightOut(InoutData data) throws Exception {
        //获取系统参数配置
        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);
        data = updateBasicInfo(data, curProgress, nextProgress);
        //执行数据更新
        String msg = inoutService.updateData(data);
        if (null != msg) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
        }
        // 执行附件信息
        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
        //称重后根据当前流程状态和下一个状态,通知称重控制器
        inoutDeviceManager.controlWeight(data, curProgress, nextProgress);
        return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data);
    }
    public PageResponse<InoutData> submitHandle(InoutData data) throws Exception {
        //获取系统参数配置
        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);
        data = updateBasicInfo(data, curProgress, nextProgress);
        //执行数据更新
        String msg = inoutService.updateDataByHandle(data);
        if (null != msg) {
            return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), msg, data);
        }
        // 执行附件信息
        fileService.saveInoutFiles(data.getFiles(), data.getCompanyId(), data.getId(), curProgress);
        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 = updateBasicInfo(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);
        }
    }
}