| | |
| | | package com.fzzy.sys.manager.inout; |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fzzy.igds.constant.Constant; |
| | | import com.fzzy.igds.domain.InoutConf; |
| | | import com.fzzy.igds.domain.InoutSysConf; |
| | | import com.fzzy.igds.service.InoutConfService; |
| | | import com.fzzy.igds.constant.RespCodeEnum; |
| | | import com.fzzy.igds.data.*; |
| | | import com.fzzy.igds.domain.*; |
| | | import com.fzzy.igds.service.*; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.fzzy.igds.utils.SystemUtil; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Description 出入库业务处理 |
| | |
| | | private RedisCache redisCache; |
| | | @Resource |
| | | private InoutConfService inoutConfService; |
| | | @Resource |
| | | private FileService fileService; |
| | | @Resource |
| | | private InoutRecordService inoutRecordService; |
| | | @Resource |
| | | private DicAreaService dicAreaService; |
| | | @Resource |
| | | private InoutNoticeService inoutNoticeService; |
| | | |
| | | /** |
| | | * 根据用户请求信息,根据当前客户电脑IP,获取出入库称重上次选择的地磅 |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 根据配置获取出入库的配置参数 |
| | | * |
| | | * @param listInoutConf |
| | | * @param type |
| | | * @return |
| | | */ |
| | | public List<InoutConf> getInoutConf(List<InoutConf> listInoutConf, String type) { |
| | | List<InoutConf> result = new ArrayList<>(); |
| | | if (null == listInoutConf) return result; |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 根据配置获取出入库的配置参数 |
| | | * |
| | | * @param listInoutConf |
| | | * @param sort |
| | | * @param type |
| | | * @return |
| | | */ |
| | | public InoutConf getInoutConf(List<InoutConf> listInoutConf, String sort, String type) { |
| | | if (null == listInoutConf) return new InoutConf(sort); |
| | | if (StringUtils.isEmpty(sort)) sort = "1"; |
| | |
| | | |
| | | return weightEditTag; |
| | | } |
| | | |
| | | /** |
| | | * 出入库注册数据提交,出入库登记使用同一个方法,包含称重时直接登记 |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public PageResponse<InoutData> submitRegister(InoutData data) { |
| | | if (StringUtils.isEmpty(data.getCompanyId())) { |
| | | data.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(data.getDeptId())) { |
| | | data.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | int num = inoutRecordService.checkExist(data.getCompanyId(), data.getPlateNum()); |
| | | if (num > 0) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "当前车牌号正在执行流程未结束,请核查车牌或联系管理员", data); |
| | | } |
| | | |
| | | // 获取系统参数配置 |
| | | InoutSysConf inoutSysConf = inoutConfService.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.setProgress(nextProgress); |
| | | |
| | | //去除身份证号中的空格 |
| | | if (StringUtils.isNotEmpty(data.getUserId())) { |
| | | data.setUserId(data.getUserId().trim()); |
| | | } |
| | | //去除姓名中的空格 |
| | | if (StringUtils.isNotEmpty(data.getUserName())) { |
| | | data.setUserName(data.getUserName().trim()); |
| | | } |
| | | //登记人及登记时间 |
| | | data.setRegisterUser(ContextUtil.getLoginUserName()); |
| | | data.setRegisterTime(new Date()); |
| | | |
| | | num = inoutRecordService.addInoutRecord(data); |
| | | |
| | | if (num == 0) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "登记失败!", data); |
| | | } |
| | | |
| | | //附件处理 |
| | | fileService.saveInoutFiles(data.getFiles(), data.getId(), curProgress, "INOUT"); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "登记成功!", data); |
| | | } |
| | | |
| | | /** |
| | | * 化验信息提交 |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public PageResponse<InoutData> submitCheck(InoutData data) { |
| | | SysUser user = ContextUtil.getLoginUser(); |
| | | if (StringUtils.isEmpty(data.getCompanyId())) { |
| | | data.setCompanyId(user.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(data.getDeptId())) { |
| | | data.setDeptId(ContextUtil.subDeptId(user)); |
| | | } |
| | | |
| | | //化验人及时间 |
| | | data.setCheckUser(user.getUserName()); |
| | | data.setCheckTime(new Date()); |
| | | data.setCheckStatus(Constant.STATUS_CHECK); |
| | | |
| | | int num = inoutRecordService.updateInoutRecord(data); |
| | | |
| | | if (num == 0) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "提交失败!", data); |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "提交成功!", data); |
| | | } |
| | | |
| | | /** |
| | | * 称重提交,包含称重登记提交及单独称重提交 |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public PageResponse<InoutData> submitWeight(InoutData data) { |
| | | if (Constant.PROGRESS_WEIGHT_EMPTY.equals(data.getProgress())) { |
| | | data.setEmptyWeightTime(new Date()); |
| | | data.setEmptyWeightUser(ContextUtil.getLoginUserName()); |
| | | } |
| | | if (Constant.PROGRESS_WEIGHT_FULL.equals(data.getProgress())) { |
| | | data.setFullWeightTime(new Date()); |
| | | data.setFullWeightUser(ContextUtil.getLoginUserName()); |
| | | } |
| | | if (StringUtils.isBlank(data.getId())) { |
| | | //表示称重时直接登记 |
| | | return submitRegister(data); |
| | | } |
| | | |
| | | //获取系统参数配置 |
| | | InoutSysConf inoutSysConf = inoutConfService.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.setProgress(nextProgress); |
| | | |
| | | if(Constant.PROGRESS_RECORD.equals(nextProgress)){ |
| | | //流程结束时,设置完成时间和完成人 |
| | | data.setCompleteTime(new Date()); |
| | | data.setCompleteUser(ContextUtil.getLoginUserName()); |
| | | } |
| | | //称重数据更新 |
| | | int num = inoutRecordService.updateInoutRecord(data); |
| | | |
| | | if (num == 0) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "提交失败!", data); |
| | | } |
| | | |
| | | //附件处理 |
| | | fileService.saveInoutFiles(data.getFiles(), data.getId(), curProgress, "INOUT"); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "执行成功", data); |
| | | } |
| | | |
| | | /** |
| | | * 值仓信息提交 |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public PageResponse<InoutData> submitHandle(InoutData data) { |
| | | |
| | | // 获取系统参数配置 |
| | | InoutSysConf inoutSysConf = inoutConfService.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.setProgress(nextProgress); |
| | | |
| | | data.setHandleEnd(new Date()); |
| | | data.setHandleUser(ContextUtil.getLoginUserName()); |
| | | // 执行数据更新 |
| | | int num = inoutRecordService.updateInoutRecord(data); |
| | | |
| | | if (num == 0) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "提交失败!", data); |
| | | } |
| | | |
| | | //附件处理 |
| | | fileService.saveInoutFiles(data.getFiles(), data.getId(), curProgress, "INOUT"); |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000.getCode(), "提交成功", data); |
| | | } |
| | | |
| | | /** |
| | | * 获取下一流程 |
| | | * |
| | | * @param curProgress |
| | | * @param type |
| | | * @param sysConf |
| | | * @return |
| | | */ |
| | | private String getNextProgress(String curProgress, String type, InoutSysConf sysConf) { |
| | | String nextProgress = null; |
| | | List<String> list = null; |
| | | if (Constant.TYPE_IN.equals(type)) { |
| | | list = Arrays.asList(sysConf.getProgressIn().split("-")); |
| | | } |
| | | if (Constant.TYPE_OUT.equals(type)) { |
| | | list = Arrays.asList(sysConf.getProgressOut().split("-")); |
| | | } |
| | | if (list != null) { |
| | | for (int i = 0; i < list.size() - 1; i++) { |
| | | if (curProgress.equals(list.get(i))) { |
| | | nextProgress = list.get(i + 1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return nextProgress; |
| | | } |
| | | |
| | | /** |
| | | * 分页查询数据 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<Page<InoutRecord>> pageInoutData(InoutParam param) { |
| | | if (StringUtils.isEmpty(param.getCompanyId())) { |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(param.getDeptId())) { |
| | | param.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | param.setProgressTag(Constant.PROGRESS_RECORD); |
| | | |
| | | Page<InoutRecord> corePage = new Page<>(param.getPage(), param.getLimit()); |
| | | inoutRecordService.listPageInout(corePage, param); |
| | | |
| | | if (null == corePage.getRecords() || corePage.getRecords().isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "获取到数据信息为空"); |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, corePage); |
| | | } |
| | | |
| | | /** |
| | | * 查询待称重的数据 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<List<InoutRecord>> listWeightData(InoutParam param) { |
| | | if (StringUtils.isEmpty(param.getCompanyId())) { |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(param.getDeptId())) { |
| | | param.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | //设置称重流程标记 |
| | | param.setWeightTag("WEIGHT"); |
| | | |
| | | List<InoutRecord> inoutRecords = inoutRecordService.listInout(param); |
| | | |
| | | if (null == inoutRecords || inoutRecords.isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "获取到数据信息为空"); |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, inoutRecords); |
| | | } |
| | | |
| | | /** |
| | | * 查询待值仓的数据 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<List<InoutRecord>> listHandleData(InoutParam param) { |
| | | if (StringUtils.isEmpty(param.getCompanyId())) { |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(param.getDeptId())) { |
| | | param.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | List<InoutRecord> inoutRecords = inoutRecordService.listInout(param); |
| | | |
| | | if (null == inoutRecords || inoutRecords.isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "获取到数据信息为空"); |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, inoutRecords); |
| | | } |
| | | |
| | | /** |
| | | * 查询数据 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<InoutRecord> inoutQuery(InoutParam param) { |
| | | |
| | | if (StringUtils.isEmpty(param.getId()) && StringUtils.isEmpty(param.getPlateNum())) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1007.getCode(), "查询参数不完整,查询失败!"); |
| | | } |
| | | if (StringUtils.isEmpty(param.getCompanyId())) { |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | } |
| | | if (StringUtils.isEmpty(param.getDeptId())) { |
| | | param.setDeptId(ContextUtil.subDeptId(null)); |
| | | } |
| | | |
| | | if(Constant.PROGRESS_WEIGHT_EMPTY.equals(param.getProgress()) || Constant.PROGRESS_WEIGHT_FULL.equals(param.getProgress())){ |
| | | //设置查询待称重的 |
| | | param.setProgress(null); |
| | | //设置称重流程标记 |
| | | param.setWeightTag("WEIGHT"); |
| | | } |
| | | |
| | | InoutRecord result = inoutRecordService.selectOne(param); |
| | | if (null == result) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), |
| | | "系统未查询到执行中的单据信息", null); |
| | | } |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, result); |
| | | } |
| | | |
| | | /** |
| | | * 分页获取区划信息 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<Page<DicArea>> pageDicArea(IgdsBaseParam param) { |
| | | |
| | | Page<DicArea> corePage = new Page<>(param.getPage(), param.getLimit()); |
| | | |
| | | dicAreaService.listPageData(corePage, param.getKey()); |
| | | |
| | | if (null == corePage.getRecords() || corePage.getRecords().isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_2000.getCode(), "获取到数据信息为空"); |
| | | } |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, corePage); |
| | | } |
| | | |
| | | /** |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<List<InoutNoticeIn>> listNoticeIn(NoticeParam param) { |
| | | |
| | | SysUser user = ContextUtil.getLoginUser(); |
| | | if (org.apache.commons.lang3.StringUtils.isEmpty(param.getCompanyId())) { |
| | | param.setCompanyId(user.getCompanyId()); |
| | | } |
| | | param.setDeptId(ContextUtil.subDeptId(user)); |
| | | param.setCompleteStatus(Constant.COMPLETE_STATUS_NONE); |
| | | List<InoutNoticeIn> list = inoutNoticeService.getNoticeIn(param); |
| | | |
| | | if (null == list || list.isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "查询结果为空!"); |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, list); |
| | | } |
| | | |
| | | /** |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public PageResponse<List<InoutNoticeOut>> listNoticeOut(NoticeParam param) { |
| | | SysUser user = ContextUtil.getLoginUser(); |
| | | if (org.apache.commons.lang3.StringUtils.isEmpty(param.getCompanyId())) { |
| | | param.setCompanyId(user.getCompanyId()); |
| | | } |
| | | param.setDeptId(ContextUtil.subDeptId(user)); |
| | | param.setCompleteStatus(Constant.COMPLETE_STATUS_NONE); |
| | | List<InoutNoticeOut> list = inoutNoticeService.getNoticeOut(param); |
| | | |
| | | if (null == list || list.isEmpty()) { |
| | | return new PageResponse<>(RespCodeEnum.CODE_1111.getCode(), "查询结果为空!"); |
| | | } |
| | | |
| | | return new PageResponse<>(RespCodeEnum.CODE_0000, list); |
| | | } |
| | | } |