package com.pashanhoo.receive.service.impl; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.pashanhoo.archive.entity.DgArchivesConverter; import com.pashanhoo.archive.entity.DgArchivesDO; import com.pashanhoo.archive.entity.vo.AddDgArchivesRequest; import com.pashanhoo.archive.mapper.DgArchivesMapper; import com.pashanhoo.archive.service.DgArchivesService; import com.pashanhoo.bdcdy.entity.DgBdcdyConverter; import com.pashanhoo.bdcdy.entity.DgBdcdyDO; import com.pashanhoo.bdcdy.entity.vo.AddDgBdcdyRequest; import com.pashanhoo.bdcdy.entity.vo.UpdateDgBdcdyRequest; import com.pashanhoo.bdcdy.service.DgBdcdyService; import com.pashanhoo.business.entity.DgBusinessDO; import com.pashanhoo.business.entity.vo.AddDgBusinessRequest; import com.pashanhoo.business.entity.vo.DgBusinessSearchRequest; import com.pashanhoo.business.mapper.DgBusinessMapper; import com.pashanhoo.business.service.DgBusinessService; import com.pashanhoo.common.Result; import com.pashanhoo.receive.entity.DgReceiveConverter; import com.pashanhoo.receive.entity.DgReceiveDO; import com.pashanhoo.receive.entity.vo.*; import com.pashanhoo.receive.mapper.DgReceiveMapper; import com.pashanhoo.receive.service.DgReceiveService; import com.pashanhoo.receiverelation.entity.DgReceiveRelationConverter; import com.pashanhoo.receiverelation.entity.DgReceiveRelationDO; import com.pashanhoo.receiverelation.entity.vo.AddDgReceiveRelationRequest; import com.pashanhoo.receiverelation.service.DgReceiveRelationService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * <p> * 档案接收记录 服务实现类 * </p> * * @author * @since 2021-11-05 */ @Service public class DgReceiveServiceImpl extends ServiceImpl<DgReceiveMapper, DgReceiveDO> implements DgReceiveService { @Autowired private DgReceiveConverter dgreceiveConverter; @Autowired private DgBdcdyConverter bdcdyConverter; @Autowired private DgReceiveMapper dgreceiveMapper; @Autowired private DgBusinessService businessService; @Autowired private DgBusinessMapper businessMapper; @Autowired private DgBdcdyService bdcdyService; @Autowired private DgArchivesService archivesService; @Autowired private DgArchivesMapper dgarchivesMapper; @Autowired private DgArchivesConverter archivesConverter; @Autowired private DgReceiveRelationService relationService; @Autowired private DgReceiveRelationConverter relationConverter; /** * 新增记录 * @param request * @return */ @Override public Result insertDgReceive(AddDgReceiveRequest request) { //获取接收编码 String receiveBsm= IdWorker.get32UUID(); request.setBms_receive(receiveBsm); //新增接收表信息=============start=========== DgReceiveDO dgreceiveDO = dgreceiveConverter.addRequest2DO(request); //TODO获取归档方式 if(dgreceiveDO.getGdfs()==null || "".equals(dgreceiveDO.getGdfs())){ dgreceiveDO.setGdfs("1"); } this.save(dgreceiveDO); //新增接收表信息=============end=========== //获取登记传入的不动产单元List集合数据 List<AddDgBdcdyRequest> bdcdyRequestList=request.getBdcdyRequestList(); //获取登记传入的业务数据 AddDgBusinessRequest businessRequest=request.getBusinessRequest(); //归档方式(1:按业务归档,2:按单元归档,3:档案补充归档) if("1".equals(dgreceiveDO.getGdfs())){ //新增档案表基础信息 AddDgArchivesRequest archivesRequest=new AddDgArchivesRequest(); String bsm_archives= IdWorker.get32UUID(); archivesRequest.setBsm_archives(bsm_archives); archivesRequest.setDazt(new BigDecimal("1")); archivesService.insertDgArchives(archivesRequest); //新增接收表和档案表关联关系表 AddDgReceiveRelationRequest relationRequest=new AddDgReceiveRelationRequest(); relationRequest.setBmsReceive(receiveBsm); relationRequest.setBsmArchives(bsm_archives); relationService.insertDgReceiveRelation(relationRequest); }else if("2".equals(dgreceiveDO.getGdfs())){ List<AddDgReceiveRelationRequest> relationRequestList=new ArrayList<AddDgReceiveRelationRequest>(); List<AddDgArchivesRequest> archivesRequest=new ArrayList<AddDgArchivesRequest>(bdcdyRequestList.size()); AddDgArchivesRequest request1=null; AddDgReceiveRelationRequest receiveRelationRequest=null; for (int i = 0; i < bdcdyRequestList.size(); i++) { //组装档案表基础信息 String bsm_archives= IdWorker.get32UUID(); request1=new AddDgArchivesRequest(); request1.setBsm_archives(bsm_archives); request1.setDazt(new BigDecimal("1")); archivesRequest.add(request1); //组装接收表和档案表关联关系表 receiveRelationRequest=new AddDgReceiveRelationRequest(); receiveRelationRequest.setBmsReceive(receiveBsm); receiveRelationRequest.setBsmArchives(bsm_archives); relationRequestList.add(receiveRelationRequest); } //批量新增接收表和档案表关联关系表 List<DgReceiveRelationDO> receiveRelationDOList=relationConverter.addReceiveRelationList(relationRequestList); relationService.saveBatch(receiveRelationDOList); //批量新增档案表基础信息 List<DgArchivesDO> archivesDOList=archivesConverter.addArchivesList(archivesRequest); archivesService.saveBatch(archivesDOList); }else if("3".equals(dgreceiveDO.getGdfs())){ //通过业务号和注销业务号查询业务表是否有数据,有数据则修改 DgBusinessSearchRequest request2=new DgBusinessSearchRequest(); request2.setYwh(businessRequest.getYwh()); request2.setZxywh(businessRequest.getZxywh()); DgBusinessDO businessDO=businessService.searchDgBusiness(request2); if(businessDO!=null){ businessDO.setZxlx(businessRequest.getZxlx()); //更新业务表中的注销类型 businessMapper.updateById(businessDO); Date zxsj=null; for (int i = 0; i < bdcdyRequestList.size(); i++) { if(businessDO.getBsmArchives().equals(bdcdyRequestList.get(i).getBsmArchives())){ zxsj=bdcdyRequestList.get(i).getZxsj(); break; } } //更新不动产单元表中的注销时间 UpdateDgBdcdyRequest updateDgBdcdyRequest=new UpdateDgBdcdyRequest(); updateDgBdcdyRequest.setBsmArchives(businessDO.getBsmArchives()); updateDgBdcdyRequest.setZxsj(zxsj); bdcdyService.updateDgBdcdyByArchive(updateDgBdcdyRequest); } } //新增业务表 businessService.insertDgBusiness(businessRequest); //新增不动产单元号表 List<DgBdcdyDO> bdcdyDOList=bdcdyConverter.addRequestListDO(bdcdyRequestList); bdcdyService.saveBatch(bdcdyDOList); return Result.ok(); } /** * 根据条件进行列表查询 * @param request * @return */ @Override public Result searchDgReceiveList(DgReceiveSearchRequest request) { Page<DgReceiveDO> pageParam = new Page<DgReceiveDO>(request.getCurrentPage(), request.getPageSize()); QueryWrapper<DgReceiveDO> wrapper = new QueryWrapper<>(); wrapper.eq(request.getYwh()!=null && !"".equals(request.getYwh()),"YWH",request.getYwh()); wrapper.eq(request.getQllx()!=null && !"".equals(request.getQllx()),"QLLX",request.getQllx()); wrapper.eq(request.getDjlx()!=null && !"".equals(request.getDjlx()),"DJLX",request.getDjlx()); wrapper.eq(request.getYwlyjbm()!=null && !"".equals(request.getYwlyjbm()),"YWLYJBM",request.getYwlyjbm()); wrapper.eq("STATE","0"); Page page = this.page(pageParam, wrapper); List<DgReceiveListVO> list=dgreceiveConverter.doList2ListVOList(page.getRecords()); return Result.ok(list); } @Override @Transactional(rollbackFor = Exception.class) public Result addBatchArchies(List<String> idList) { //更新接收表归档时间和归档状态 boolean receiveFlag=dgreceiveMapper.updateReceiveBatch(idList,"1");//整理状态(0:待处理,1:已归档) //查询接收表和档案表的关联关系表找出对应的档案 //档案状态(1:正在接收;2:正在补录;3:正在修改;4:在库;5:正在销毁;6:已销毁;7:正在借阅;8:已借阅) boolean archivesFlag=dgarchivesMapper.updateArchivesInfoByReceiveIdList(idList,"4"); if(receiveFlag && archivesFlag){ return Result.ok("操作成功"); }else{ return Result.ok("操作失败"); } } }