| | |
| | | package com.fzzy.igds.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.fzzy.igds.constant.AuditStatus; |
| | | import com.fzzy.igds.constant.Constant; |
| | | import com.fzzy.igds.data.ExportWordParam; |
| | | import com.fzzy.igds.data.NoticeDto; |
| | | import com.fzzy.igds.data.NoticeParam; |
| | | import com.fzzy.igds.constant.InoutConstant; |
| | | import com.fzzy.igds.data.*; |
| | | import com.fzzy.igds.domain.*; |
| | | import com.fzzy.igds.mapper.InoutNoticeInMapper; |
| | | import com.fzzy.igds.mapper.InoutNoticeOutMapper; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | import com.fzzy.work.data.WorkBizType; |
| | | import com.fzzy.work.data.WorkStatus; |
| | | import com.fzzy.work.domain.WorkOrderConf; |
| | | import com.fzzy.work.service.BizWorkService; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.time.DateFormatUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | @Resource |
| | | private PledgeContractService pledgeContractService; |
| | | |
| | | @Resource |
| | | private BizWorkService workService; |
| | | |
| | | /*----------------------入库通知单信息-------------------------*/ |
| | | |
| | | /** |
| | | * 分页查询数据 |
| | | * @param page |
| | |
| | | public void pageQueryIn(Page<InoutNoticeIn> page, NoticeParam param) { |
| | | QueryWrapper<InoutNoticeIn> queryWrapper = new QueryWrapper<>(); |
| | | |
| | | if(null == param) { |
| | | if (null == param) { |
| | | param = new NoticeParam(); |
| | | } |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | |
| | | queryWrapper.eq("company_id", param.getCompanyId()); |
| | | if(StringUtils.isNotBlank(param.getCustomerName())){ |
| | | if (StringUtils.isNotBlank(param.getCustomerName())) { |
| | | queryWrapper.like("customer_name", param.getCustomerName()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getFoodVariety())){ |
| | | if (StringUtils.isNotBlank(param.getFoodVariety())) { |
| | | queryWrapper.like("food_variety", param.getFoodVariety()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getCompleteStatus())){ |
| | | if (StringUtils.isNotBlank(param.getCompleteStatus())) { |
| | | queryWrapper.like("complete_status", param.getCompleteStatus()); |
| | | } |
| | | |
| | |
| | | public List<InoutNoticeIn> getNoticeIn(NoticeParam param) { |
| | | |
| | | QueryWrapper<InoutNoticeIn> queryWrapper = new QueryWrapper<>(); |
| | | if(StringUtils.isNotBlank(param.getCompanyId())){ |
| | | if (StringUtils.isNotBlank(param.getCompanyId())) { |
| | | queryWrapper.eq("company_id", param.getCompanyId()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getDeptId())){ |
| | | if (StringUtils.isNotBlank(param.getDeptId())) { |
| | | queryWrapper.eq("dept_id", param.getDeptId()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getCompleteStatus())){ |
| | | if (StringUtils.isNotBlank(param.getCompleteStatus())) { |
| | | queryWrapper.eq("complete_status", param.getCompleteStatus()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getKey())){ |
| | | if (StringUtils.isNotBlank(param.getKey())) { |
| | | queryWrapper.like("name", param.getKey()); |
| | | } |
| | | queryWrapper.orderByDesc("create_time"); |
| | | |
| | | |
| | | return noticeInMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public String saveOrUpdateIn(InoutNoticeIn data) { |
| | | //如果入库通知单类型为库区通知单,验证仓库是否是未解压得仓库,是则不允许保存 |
| | | //获取所有质押合同数据 |
| | | List<PledgeContract> pledgeContracts = pledgeContractService.listAll(null); |
| | | if("10".equals(data.getType())){ |
| | | //在质押合同找到未解压,且质押仓库包含当前仓库的数据 |
| | | for (PledgeContract pledgeContract : pledgeContracts) { |
| | | if(pledgeContract.getDepotIds().contains(data.getDepotId())){ |
| | | if(pledgeContract.getStatus().equals(Constant.YN_N)){ |
| | | return "入库仓库未解压,无法保存!"; |
| | | } |
| | | } |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResp saveOrUpdateIn(InoutNoticeIn data) { |
| | | |
| | | //如果是库区自建通知单 |
| | | if (InoutConstant.NOTICE_IN_TYPE_10.equals(data.getType())) { |
| | | //获取质押合同数据 |
| | | PledgeContract pledge = this.getPledgeByDepotId(data); |
| | | if (null != pledge && pledge.getStatus().equals(Constant.YN_N)) { |
| | | return BaseResp.error("当前仓库有未解压的质押合同,质押合同=" + pledge.getName()); |
| | | } |
| | | } |
| | | //如果入库通知单类型为监管通知单 |
| | | if("20".equals(data.getType())){ |
| | | //1.验证银行是否填写,未填写,则不允许保存 |
| | | if(StringUtils.isEmpty(data.getBankId())){ |
| | | return "监督银行不能为空!"; |
| | | |
| | | //如果质押通知单 |
| | | if (InoutConstant.NOTICE_IN_TYPE_20.equals(data.getType())) { |
| | | //1.验证银行是否填写,未填写,则不允许保存 |
| | | if (StringUtils.isEmpty(data.getBankId())) { |
| | | return BaseResp.error("质押银行不能为空!"); |
| | | } |
| | | //2.验证银行和仓库的对应关系是否正确,不正确则不允许保存 |
| | | //在质押合同找到未解压,且质押仓库包含当前仓库的 银行-仓库(质押合同关系) |
| | | Map<String, PledgeContract> bankDepotMap = new HashMap<>(); |
| | | for (PledgeContract pledgeContract : pledgeContracts) { |
| | | if(pledgeContract.getDepotIds().contains(data.getDepotId())){ |
| | | if(pledgeContract.getStatus().equals(Constant.YN_N)){ |
| | | bankDepotMap.put(pledgeContract.getPledgeBank(), pledgeContract); |
| | | } |
| | | } |
| | | } |
| | | //在map中寻找匹配银行的数据,如果没有匹配的数据,则不允许保存 |
| | | if(!bankDepotMap.containsKey(data.getBankId())){ |
| | | return "未找到对应的质押合同,请检查监督银行或者入库仓库填写是否正确!"; |
| | | |
| | | PledgeContract pledge = this.getPledgeByDepotIdAndBankId(data); |
| | | if (null == pledge) { |
| | | return BaseResp.error("未获取到当前库区、仓库和银行之间的质押信息!"); |
| | | } |
| | | } |
| | | |
| | | //修改和提交是两个逻辑判断 |
| | | if (null == data.getUpdateBy()) { |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCreateTime(new Date()); |
| | | data.setAuditStatus(AuditStatus.STATUS_10.getCode()); |
| | | data.setCompleteStatus(Constant.COMPLETE_STATUS_NONE); |
| | | noticeInMapper.insert(data); |
| | | return this.saveInAddStartWork(data); |
| | | } else { |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | noticeInMapper.updateById(data); |
| | | return BaseResp.success(); |
| | | } |
| | | } |
| | | |
| | | private BaseResp saveInAddStartWork(InoutNoticeIn data) { |
| | | //数据保存 |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCreateTime(new Date()); |
| | | data.setAuditStatus(WorkStatus.STATUS_10.getCode()); |
| | | data.setCompleteStatus(Constant.COMPLETE_STATUS_NONE); |
| | | |
| | | //执行流程 |
| | | WorkOrderConf conf = workService.getConfByDeptId(data.getDeptId(), WorkBizType.TYPE_10); |
| | | //流程不启用 |
| | | if (null == conf || Constant.YN_N.equals(conf.getValTag())) { |
| | | data.setAuditStatus(WorkStatus.STATUS_50.getCode()); |
| | | } else { |
| | | BaseResp resp = workService.startByNoticeIn(data, conf); |
| | | log.info("---------启动工单流程------{}", resp); |
| | | } |
| | | |
| | | return null; |
| | | noticeInMapper.insert(data); |
| | | |
| | | return BaseResp.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断当前仓库是否在质押合同中未解压 |
| | | * @param data 当前数据 |
| | | * @return true-在质押合同中未解压,false-在质押合同中已解压 |
| | | */ |
| | | private PledgeContract getPledgeByDepotId(InoutNoticeIn data) { |
| | | IgdsBaseParam param = new IgdsBaseParam(); |
| | | param.setCompanyId(data.getCompanyId()); |
| | | param.setDeptId(data.getDeptId()); |
| | | param.setDepotId(data.getDepotId()); |
| | | return pledgeContractService.getByDepotId(param); |
| | | } |
| | | |
| | | private PledgeContract getPledgeByDepotIdAndBankId(InoutNoticeIn data) { |
| | | IgdsBaseParam param = new IgdsBaseParam(); |
| | | param.setCompanyId(data.getCompanyId()); |
| | | param.setDeptId(data.getDeptId()); |
| | | param.setDepotId(data.getDepotId()); |
| | | param.setBankId(data.getBankId()); |
| | | return pledgeContractService.getByDepotId(param); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /*----------------------出库通知单信息-------------------------*/ |
| | | |
| | | /** |
| | | * 分页查询数据 |
| | | * @param page |
| | |
| | | public void pageQueryOut(Page<InoutNoticeOut> page, NoticeParam param) { |
| | | QueryWrapper<InoutNoticeOut> queryWrapper = new QueryWrapper<>(); |
| | | |
| | | if(null == param) { |
| | | if (null == param) { |
| | | param = new NoticeParam(); |
| | | } |
| | | param.setCompanyId(ContextUtil.getCompanyId()); |
| | | |
| | | queryWrapper.eq("company_id", param.getCompanyId()); |
| | | if(StringUtils.isNotBlank(param.getCustomerName())){ |
| | | if (StringUtils.isNotBlank(param.getCustomerName())) { |
| | | queryWrapper.like("customer_name", param.getCustomerName()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getFoodVariety())){ |
| | | if (StringUtils.isNotBlank(param.getFoodVariety())) { |
| | | queryWrapper.like("food_variety", param.getFoodVariety()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getCompleteStatus())){ |
| | | if (StringUtils.isNotBlank(param.getCompleteStatus())) { |
| | | queryWrapper.like("complete_status", param.getCompleteStatus()); |
| | | } |
| | | |
| | |
| | | */ |
| | | public List<InoutNoticeOut> getNoticeOut(NoticeParam param) { |
| | | QueryWrapper<InoutNoticeOut> queryWrapper = new QueryWrapper<>(); |
| | | if(StringUtils.isNotBlank(param.getCompanyId())){ |
| | | if (StringUtils.isNotBlank(param.getCompanyId())) { |
| | | queryWrapper.eq("company_id", param.getCompanyId()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getDeptId())){ |
| | | if (StringUtils.isNotBlank(param.getDeptId())) { |
| | | queryWrapper.eq("dept_id", param.getDeptId()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getCompleteStatus())){ |
| | | if (StringUtils.isNotBlank(param.getCompleteStatus())) { |
| | | queryWrapper.eq("complete_status", param.getCompleteStatus()); |
| | | } |
| | | if(StringUtils.isNotBlank(param.getKey())){ |
| | | if (StringUtils.isNotBlank(param.getKey())) { |
| | | queryWrapper.like("name", param.getKey()); |
| | | } |
| | | queryWrapper.orderByDesc("create_time"); |
| | |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public String saveOrUpdateOut(InoutNoticeOut data) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BaseResp saveOrUpdateOut(InoutNoticeOut data) { |
| | | //如果出库通知单类型为库区通知单,验证仓库是否是未解压得仓库,是则不允许保存 |
| | | //获取所有质押合同数据 |
| | | List<PledgeContract> pledgeContracts = pledgeContractService.listAll(null); |
| | | if("10".equals(data.getType())){ |
| | | if (InoutConstant.NOTICE_IN_TYPE_10.equals(data.getType())) { |
| | | //在质押合同找到未解压,且质押仓库包含当前仓库的数据 |
| | | for (PledgeContract pledgeContract : pledgeContracts) { |
| | | if(pledgeContract.getDepotIds().contains(data.getDepotId())){ |
| | | if(pledgeContract.getStatus().equals(Constant.YN_N)){ |
| | | return "出库仓库未解压,无法保存!"; |
| | | } |
| | | } |
| | | //获取质押合同数据 |
| | | PledgeContract pledge = this.getPledgeByDepotIdOut(data); |
| | | if (null != pledge && pledge.getStatus().equals(Constant.YN_N)) { |
| | | return BaseResp.error("当前仓库有未解压的质押合同,质押合同=" + pledge.getName()); |
| | | } |
| | | } |
| | | //如果出库通知单类型为监管通知单 |
| | | if("20".equals(data.getType())){ |
| | | //如果质押通知单 |
| | | if (InoutConstant.NOTICE_IN_TYPE_20.equals(data.getType())) { |
| | | //1.验证银行是否填写,未填写,则不允许保存 |
| | | if(StringUtils.isEmpty(data.getBankId())){ |
| | | return "监督银行不能为空!"; |
| | | |
| | | if (StringUtils.isEmpty(data.getBankId())) { |
| | | return BaseResp.error("质押银行不能为空!"); |
| | | } |
| | | //2.验证银行和仓库的对应关系是否正确,不正确则不允许保存 |
| | | //在质押合同找到未解压,且质押仓库包含当前仓库的 银行-仓库(质押合同关系) |
| | | Map<String, PledgeContract> bankDepotMap = new HashMap<>(); |
| | | for (PledgeContract pledgeContract : pledgeContracts) { |
| | | if(pledgeContract.getDepotIds().contains(data.getDepotId())){ |
| | | if(pledgeContract.getStatus().equals(Constant.YN_N)){ |
| | | bankDepotMap.put(pledgeContract.getPledgeBank(), pledgeContract); |
| | | } |
| | | } |
| | | } |
| | | //在map中寻找匹配银行的数据,如果没有匹配的数据,则不允许保存 |
| | | if(!bankDepotMap.containsKey(data.getBankId())){ |
| | | return "未找到对应的质押合同,请检查监督银行或者出库仓库填写是否正确!"; |
| | | |
| | | PledgeContract pledge = this.getPledgeByDepotIdAndBankIdOut(data); |
| | | if (null == pledge) { |
| | | return BaseResp.error("未获取到当前库区、仓库和银行之间的质押信息!"); |
| | | } |
| | | } |
| | | |
| | | if (null == data.getUpdateBy()) { |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCreateTime(new Date()); |
| | | data.setAuditStatus(AuditStatus.STATUS_10.getCode()); |
| | | data.setCompleteStatus(Constant.COMPLETE_STATUS_NONE); |
| | | noticeOutMapper.insert(data); |
| | | return this.saveOutAddStartWork(data); |
| | | } else { |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | noticeOutMapper.updateById(data); |
| | | return BaseResp.success(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | public String delDataOut(InoutNoticeOut data) { |
| | | noticeOutMapper.deleteById(data); |
| | | return null; |
| | | } |
| | | |
| | | private BaseResp saveOutAddStartWork(InoutNoticeOut data) { |
| | | //数据保存 |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | | data.setCreateBy(ContextUtil.getLoginUserName()); |
| | | data.setCreateTime(new Date()); |
| | | data.setAuditStatus(WorkStatus.STATUS_10.getCode()); |
| | | data.setCompleteStatus(Constant.COMPLETE_STATUS_NONE); |
| | | |
| | | //执行流程 |
| | | WorkOrderConf conf = workService.getConfByDeptId(data.getDeptId(), WorkBizType.TYPE_20); |
| | | //流程不启用 |
| | | if (null == conf || Constant.YN_N.equals(conf.getValTag())) { |
| | | data.setAuditStatus(WorkStatus.STATUS_50.getCode()); |
| | | } else { |
| | | BaseResp resp = workService.startByNoticeOut(data, conf); |
| | | log.info("---------启动工单流程------{}", resp); |
| | | } |
| | | |
| | | noticeOutMapper.insert(data); |
| | | |
| | | return BaseResp.success(); |
| | | } |
| | | |
| | | /** |
| | | * 判断当前仓库是否在质押合同中未解压 |
| | | * @param data 当前数据 |
| | | * @return true-在质押合同中未解压,false-在质押合同中已解压 |
| | | */ |
| | | private PledgeContract getPledgeByDepotIdOut(InoutNoticeOut data) { |
| | | IgdsBaseParam param = new IgdsBaseParam(); |
| | | param.setCompanyId(data.getCompanyId()); |
| | | param.setDeptId(data.getDeptId()); |
| | | param.setDepotId(data.getDepotId()); |
| | | return pledgeContractService.getByDepotId(param); |
| | | } |
| | | |
| | | private PledgeContract getPledgeByDepotIdAndBankIdOut(InoutNoticeOut data) { |
| | | IgdsBaseParam param = new IgdsBaseParam(); |
| | | param.setCompanyId(data.getCompanyId()); |
| | | param.setDeptId(data.getDeptId()); |
| | | param.setDepotId(data.getDepotId()); |
| | | param.setBankId(data.getBankId()); |
| | | return pledgeContractService.getByDepotId(param); |
| | | } |
| | | |
| | | /** |
| | |
| | | map.put("name", notice.getName()); |
| | | |
| | | String type = ""; |
| | | if("10".equals(notice.getType())){ |
| | | if ("10".equals(notice.getType())) { |
| | | type = "库区通知单"; |
| | | } |
| | | if("20".equals(notice.getType())){ |
| | | if ("20".equals(notice.getType())) { |
| | | type = "监管通知单"; |
| | | } |
| | | map.put("type", type); |
| | |
| | | |
| | | String unitName = ""; |
| | | Dept dept = coreDeptService.getDeptById(notice.getUnitName()); |
| | | if(dept != null){ |
| | | if (dept != null) { |
| | | unitName = dept.getKqmc(); |
| | | } |
| | | map.put("unitName", unitName); |
| | | |
| | | Depot depot = depotService.getCacheDepot(notice.getCompanyId(), notice.getDepotId()); |
| | | String depotId = ""; |
| | | if(dept != null){ |
| | | if (dept != null) { |
| | | depotId = depot.getName(); |
| | | } |
| | | map.put("depotId", depotId); |
| | |
| | | map.put("name", notice.getName()); |
| | | |
| | | String type = ""; |
| | | if("10".equals(notice.getType())){ |
| | | if ("10".equals(notice.getType())) { |
| | | type = "库区通知单"; |
| | | } |
| | | if("20".equals(notice.getType())){ |
| | | if ("20".equals(notice.getType())) { |
| | | type = "监管通知单"; |
| | | } |
| | | map.put("type", type); |
| | |
| | | |
| | | String unitName = ""; |
| | | Dept dept = coreDeptService.getDeptById(notice.getUnitName()); |
| | | if(dept != null){ |
| | | if (dept != null) { |
| | | unitName = dept.getKqmc(); |
| | | } |
| | | map.put("unitName", unitName); |
| | | |
| | | Depot depot = depotService.getCacheDepot(notice.getCompanyId(), notice.getDepotId()); |
| | | String depotId = ""; |
| | | if(dept != null){ |
| | | if (dept != null) { |
| | | depotId = depot.getName(); |
| | | } |
| | | map.put("depotId", depotId); |