| | |
| | | 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.domain.*; |
| | | import com.fzzy.igds.mapper.InoutNoticeInMapper; |
| | | import com.fzzy.igds.mapper.InoutNoticeOutMapper; |
| | | import com.fzzy.igds.domain.InoutNoticeIn; |
| | | import com.fzzy.igds.domain.InoutNoticeOut; |
| | | import com.fzzy.igds.utils.ContextUtil; |
| | | 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 javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description 出入库通知单service层,包含入库通知单和出库通知单 |
| | |
| | | private InoutNoticeInMapper noticeInMapper; |
| | | @Resource |
| | | private InoutNoticeOutMapper noticeOutMapper; |
| | | @Resource |
| | | private DepotService depotService; |
| | | @Resource |
| | | private CoreDeptService coreDeptService; |
| | | @Resource |
| | | private PledgeContractService pledgeContractService; |
| | | |
| | | /*----------------------入库通知单信息-------------------------*/ |
| | | /** |
| | |
| | | * @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 "入库仓库未解压,无法保存!"; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //如果入库通知单类型为监管通知单 |
| | | if("20".equals(data.getType())){ |
| | | //1.验证银行是否填写,未填写,则不允许保存 |
| | | if(StringUtils.isEmpty(data.getBankId())){ |
| | | return "监督银行不能为空!"; |
| | | |
| | | } |
| | | //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 "未找到对应的质押合同,请检查监督银行或者入库仓库填写是否正确!"; |
| | | |
| | | } |
| | | } |
| | | |
| | | if (null == data.getUpdateBy()) { |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | |
| | | * @return |
| | | */ |
| | | public String saveOrUpdateOut(InoutNoticeOut 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 "出库仓库未解压,无法保存!"; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //如果出库通知单类型为监管通知单 |
| | | if("20".equals(data.getType())){ |
| | | //1.验证银行是否填写,未填写,则不允许保存 |
| | | if(StringUtils.isEmpty(data.getBankId())){ |
| | | return "监督银行不能为空!"; |
| | | |
| | | } |
| | | //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 "未找到对应的质押合同,请检查监督银行或者出库仓库填写是否正确!"; |
| | | |
| | | } |
| | | } |
| | | |
| | | if (null == data.getUpdateBy()) { |
| | | data.setUpdateBy(ContextUtil.getLoginUserName()); |
| | | data.setUpdateTime(new Date()); |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public ExportWordParam handleInData(ExportWordParam param) { |
| | | |
| | | InoutNoticeIn notice = this.getNoticeInOne(param.getBizId()); |
| | | |
| | | //转换为模板需要的map数据源 |
| | | Map<String, Object> map = new HashMap(); |
| | | |
| | | map.put("serId", notice.getId()); |
| | | map.put("name", notice.getName()); |
| | | |
| | | String type = ""; |
| | | if("10".equals(notice.getType())){ |
| | | type = "库区通知单"; |
| | | } |
| | | if("20".equals(notice.getType())){ |
| | | type = "监管通知单"; |
| | | } |
| | | map.put("type", type); |
| | | |
| | | map.put("customerName", notice.getCustomerName()); |
| | | |
| | | String unitName = ""; |
| | | Dept dept = coreDeptService.getDeptById(notice.getUnitName()); |
| | | if(dept != null){ |
| | | unitName = dept.getKqmc(); |
| | | } |
| | | map.put("unitName", unitName); |
| | | |
| | | Depot depot = depotService.getCacheDepot(notice.getCompanyId(), notice.getDepotId()); |
| | | String depotId = ""; |
| | | if(dept != null){ |
| | | depotId = depot.getName(); |
| | | } |
| | | map.put("depotId", depotId); |
| | | |
| | | map.put("year", notice.getYear()); |
| | | map.put("targetNumber", notice.getTargetNumber()); |
| | | map.put("completeNumber", notice.getCompleteNumber()); |
| | | map.put("completeStatus", notice.getCompleteStatus()); |
| | | map.put("contract", notice.getContract()); |
| | | map.put("remark", notice.getRemark()); |
| | | map.put("createUser", notice.getCreateBy()); |
| | | map.put("createTime", DateFormatUtils.format(notice.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | param.setDataMap(map); |
| | | return param; |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | public ExportWordParam handleOutData(ExportWordParam param) { |
| | | |
| | | InoutNoticeOut notice = this.getNoticeOutOne(param.getBizId()); |
| | | |
| | | //转换为模板需要的map数据源 |
| | | Map<String, Object> map = new HashMap(); |
| | | |
| | | map.put("serId", notice.getId()); |
| | | map.put("name", notice.getName()); |
| | | |
| | | String type = ""; |
| | | if("10".equals(notice.getType())){ |
| | | type = "库区通知单"; |
| | | } |
| | | if("20".equals(notice.getType())){ |
| | | type = "监管通知单"; |
| | | } |
| | | map.put("type", type); |
| | | |
| | | map.put("customerName", notice.getCustomerName()); |
| | | |
| | | String unitName = ""; |
| | | Dept dept = coreDeptService.getDeptById(notice.getUnitName()); |
| | | if(dept != null){ |
| | | unitName = dept.getKqmc(); |
| | | } |
| | | map.put("unitName", unitName); |
| | | |
| | | Depot depot = depotService.getCacheDepot(notice.getCompanyId(), notice.getDepotId()); |
| | | String depotId = ""; |
| | | if(dept != null){ |
| | | depotId = depot.getName(); |
| | | } |
| | | map.put("depotId", depotId); |
| | | |
| | | map.put("year", notice.getYear()); |
| | | map.put("targetNumber", notice.getTargetNumber()); |
| | | map.put("completeNumber", notice.getCompleteNumber()); |
| | | map.put("completeStatus", notice.getCompleteStatus()); |
| | | map.put("contract", notice.getContract()); |
| | | map.put("remark", notice.getRemark()); |
| | | map.put("createUser", notice.getCreateBy()); |
| | | map.put("createTime", DateFormatUtils.format(notice.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | param.setDataMap(map); |
| | | return param; |
| | | } |
| | | |
| | | } |