package com.doumee.service.business.impl; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.doumee.biz.system.SystemDictDataBiz; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; import com.doumee.core.model.LoginUserInfo; import com.doumee.core.model.PageData; import com.doumee.core.model.PageWrap; import com.doumee.core.utils.Constants; import com.doumee.core.utils.Constants.DeclareStatus; import com.doumee.core.utils.Constants.ProjectRecord; import com.doumee.core.utils.DateUtil; import com.doumee.core.utils.Utils; import com.doumee.dao.business.*; import com.doumee.dao.business.model.*; import com.doumee.dao.business.vo.DeclareServiceVo; import com.doumee.dao.system.model.SystemUser; import com.doumee.service.business.*; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.yulichang.query.MPJQueryWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; /** * 服务结构上传服务记录表Service实现 * * @author 江蹄蹄 * @date 2023/02/15 08:55 */ @Service public class DeclareServiceServiceImpl implements DeclareServiceService { @Autowired private DeclareServiceMapper declareServiceMapper; @Autowired private DeclaresMapper declaresMapper; @Autowired private MultifileService multifileService; @Autowired private ProjectService projectService; @Autowired private DeclareDiagnoseMapper declareDiagnoseMapper; @Autowired private ProjectDiagnoseMapper projectDiagnoseMapper; @Autowired private DeclareHistoryMapper declareHistoryMapper; @Autowired private DeclareDoneMapper declareDoneMapper; @Autowired private DeclareServiceJoinMapper declareServiceJoinMapper; @Autowired private DeclaresJoinMapper declaresJoinMapper; @Autowired private DeclareExpertMapper declareExpertMapper; @Autowired private DeclareDiagnoseService declareDiagnoseService; @Lazy @Autowired private SystemDictDataBiz systemDictDataBiz; @Override public Integer create(DeclareService declareService) { declareServiceMapper.insert(declareService); return declareService.getId(); } @Override public void deleteById(Integer id) { declareServiceMapper.deleteById(id); } @Override public void delete(DeclareService declareService) { UpdateWrapper deleteWrapper = new UpdateWrapper<>(declareService); declareServiceMapper.delete(deleteWrapper); } @Override public void deleteByIdInBatch(List ids) { if (CollectionUtils.isEmpty(ids)) { return; } declareServiceMapper.deleteBatchIds(ids); } @Override public void updateById(DeclareService declareService) { declareServiceMapper.updateById(declareService); } @Override public void updateByIdInBatch(List declareServices) { if (CollectionUtils.isEmpty(declareServices)) { return; } for (DeclareService declareService : declareServices) { this.updateById(declareService); } } @Override public DeclareService findById(Integer id) { return declareServiceMapper.selectById(id); } @Override public DeclareService findOne(DeclareService declareService) { QueryWrapper wrapper = new QueryWrapper<>(declareService); return declareServiceMapper.selectOne(wrapper); } @Override public List findList(DeclareService declareService) { QueryWrapper wrapper = new QueryWrapper<>(declareService); return declareServiceMapper.selectList(wrapper); } @Override public PageData findPage(PageWrap pageWrap) { IPage page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); MPJLambdaWrapper queryWrapper = new MPJLambdaWrapper<>(); pageWrap.getModel().setIsdeleted(Constants.ZERO); queryWrapper.selectAll(DeclareService.class); queryWrapper.leftJoin(SystemUser.class,SystemUser::getId,DeclareService::getCreator); queryWrapper.selectAs(SystemUser::getRealname,DeclareService::getCreatorName); Utils.MP.blankToNull(pageWrap.getModel()); if (pageWrap.getModel().getId() != null) { queryWrapper.eq(DeclareService::getId, pageWrap.getModel().getId()); } if (pageWrap.getModel().getCreator() != null) { queryWrapper.eq(DeclareService::getCreator, pageWrap.getModel().getCreator()); } if (pageWrap.getModel().getCreateDate() != null) { queryWrapper.ge(DeclareService::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); queryWrapper.le(DeclareService::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); } if (pageWrap.getModel().getEditor() != null) { queryWrapper.eq(DeclareService::getEditor, pageWrap.getModel().getEditor()); } if (pageWrap.getModel().getEditDate() != null) { queryWrapper.ge(DeclareService::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); queryWrapper.le(DeclareService::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); } if (pageWrap.getModel().getIsdeleted() != null) { queryWrapper.eq(DeclareService::getIsdeleted, pageWrap.getModel().getIsdeleted()); } if (pageWrap.getModel().getRemark() != null) { queryWrapper.eq(DeclareService::getRemark, pageWrap.getModel().getRemark()); } if (pageWrap.getModel().getDeclareId() != null) { queryWrapper.eq(DeclareService::getDeclareId, pageWrap.getModel().getDeclareId()); } if (pageWrap.getModel().getContent() != null) { queryWrapper.eq(DeclareService::getContent, pageWrap.getModel().getContent()); } if (pageWrap.getModel().getServiceDate() != null) { queryWrapper.ge(DeclareService::getServiceDate, Utils.Date.getStart(pageWrap.getModel().getServiceDate())); queryWrapper.le(DeclareService::getServiceDate, Utils.Date.getEnd(pageWrap.getModel().getServiceDate())); } if (pageWrap.getModel().getStatus() != null) { queryWrapper.eq(DeclareService::getStatus, pageWrap.getModel().getStatus()); } if (pageWrap.getModel().getType() != null) { queryWrapper.eq(DeclareService::getType, pageWrap.getModel().getType()); } for (PageWrap.SortData sortData : pageWrap.getSorts()) { if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { queryWrapper.orderByDesc(sortData.getProperty()); } else { queryWrapper.orderByAsc(sortData.getProperty()); } } IPage result = declareServiceJoinMapper.selectJoinPage(page,DeclareService.class,queryWrapper); if (result.getRecords().size() > 0) { String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+systemDictDataBiz.queryByCode(Constants.OSS,Constants.PROJECT_FILE).getCode(); for (int i = 0; i < result.getRecords().size(); i++) { DeclareService query = result.getRecords().get(i); Multifile mu = new Multifile(); mu.setIsdeleted(Constants.ZERO); mu.setObjId(query.getId()); // mu.setType(Constants.TWO); // mu.setObjType(Constants.MultiFile.BUSINESS_UP_SERVICE.getKey()); mu.setTypeList(new ArrayList<>()); if(Constants.equalsInteger(query.getType(),Constants.ONE)){ mu.getTypeList().add(Constants.MultiFile.BUSINESS_HC.getKey()); mu.getTypeList().add(Constants.MultiFile.BUSINESS_HC_EXTRA.getKey()); }else{ mu.getTypeList().add(Constants.MultiFile.BUSINESS_UP_SERVICE.getKey()); mu.getTypeList().add(Constants.MultiFile.BUSINESS_UP_EXTRA.getKey()); } List allList = multifileService.findList(mu); List filelist = new ArrayList<>(); List extralist = new ArrayList<>(); if(allList!=null){ allList.forEach(r->{ if(StringUtils.isNoneBlank(r.getFileurl())){ r.setFileurlfull(path+r.getFileurl()); } if(Constants.equalsInteger(query.getType(),Constants.ONE)){ if(Constants.equalsInteger(Constants.MultiFile.BUSINESS_HC.getKey(),r.getObjType())){ filelist.add(r); } if( Constants.equalsInteger(Constants.MultiFile.BUSINESS_HC_EXTRA.getKey(),r.getObjType())){ extralist.add(r); } } if(Constants.equalsInteger(query.getType(),Constants.ZERO)){ if(Constants.equalsInteger(Constants.MultiFile.BUSINESS_UP_SERVICE.getKey(),r.getObjType())){ filelist.add(r); } if( Constants.equalsInteger(Constants.MultiFile.BUSINESS_UP_EXTRA.getKey(),r.getObjType())){ extralist.add(r); } } }); } query.setFileList(filelist); query.setFileExtraList(extralist); } } return PageData.from(result); } @Override public long count(DeclareService declareService) { QueryWrapper wrapper = new QueryWrapper<>(declareService); return declareServiceMapper.selectCount(wrapper); } @Override public List doneServiceList(DeclareService declareService){ DeclareServiceVo dsv = new DeclareServiceVo(); dsv.setDeclareId(declareService.getDeclareId()); List finishServiceData = getFinishServiceData(dsv); if(finishServiceData!=null){ finishServiceData.forEach(s->{ Multifile mf = new Multifile(); mf.setIsdeleted(Constants.ZERO); mf.setObjId(s.getId()); //完成服务资料 企业评分 mf.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS_EXTRA.getKey()); List fileExtraList =getMultiFileList(mf); s.setFileExtraList(fileExtraList); mf.setObjType(Constants.MultiFile.BUSINESS_SCORE.getKey()); List fileScoreList =getMultiFileList(mf); s.setFileScoreList(fileScoreList); mf.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); List fileDiagnosisList =getMultiFileList(mf); s.setFileDiagnosisList(fileDiagnosisList); DeclareDiagnose dd=new DeclareDiagnose(); dd.setIsdeleted(Constants.ZERO); dd.setDeclareId(s.getId()); List ddList= declareDiagnoseService.findList(dd); s.setDeclareDiagnoseList(ddList); }); } return finishServiceData; } @Override public List findByDeclareId(DeclareService declareService) { if(declareService.getDeclareId()== null){ throw new BusinessException(ResponseStatus.DATA_EMPTY); } Declares declares = declaresMapper.selectById(declareService.getDeclareId()); if(declares==null){ throw new BusinessException(ResponseStatus.DATA_EMPTY); } QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda().eq(DeclareDone::getDeclareId,declareService.getDeclareId()) .orderByDesc(DeclareDone::getCreateDate); List declareDones = declareDoneMapper.selectList(wrapper); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(DeclareHistory::getDeclareId,declareService.getDeclareId()) .eq(DeclareHistory::getStatus, DeclareStatus.BACK_SERVER_ING.getKey()) .orderByDesc(DeclareHistory::getCreateDate); List list = new ArrayList<>(); for (DeclareDone s : declareDones){ DeclareService service = new DeclareService(); service.setDiagnoseScore(s.getDiagnoseScore()); service.setDiagnoseDate(s.getDiagnoseDate()); service.setDeclareStatus(declares.getStatus()); //查询完成服务数据 Multifile mf = new Multifile(); mf.setType(Constants.TWO); mf.setObjId(s.getId()); // BeanUtils.copyProperties(list.get(0), dsv); //完成服务资料 企业评分 mf.setObjType(Constants.MultiFile.BUSINESS_SCORE.getKey()); service.setFileScoreList(getMultiFileList(mf)); //完成服务资料 诊断报告 mf.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); service.setFileDiagnosisList(getMultiFileList(mf)); if(Constants.formatIntegerNum(declares.getStatus()) >= DeclareStatus.SERVICE_DONE.getKey()){ //如果已经完成服务,则返回实际填写数据,诊断填写信息 DeclareDiagnose dd=new DeclareDiagnose(); dd.setIsdeleted(Constants.ZERO); dd.setDeclareId(declareService.getDeclareId()); List ddList= declareDiagnoseService.findList(dd); declareService.setDeclareDiagnoseList(ddList); } list.add(service); }; // list.add(findByDeclareId2(declareService)); return list; } @Override public DeclareService findByDeclareId2(DeclareService declareService) { if(declareService.getDeclareId()== null){ throw new BusinessException(ResponseStatus.DATA_EMPTY); } Declares declares = declaresMapper.selectById(declareService.getDeclareId()); if(declares==null){ throw new BusinessException(ResponseStatus.DATA_EMPTY); } ProjectDiagnose p = new ProjectDiagnose(); p.setProjectId(declares.getProjectId()); p.setIsdeleted(Constants.ZERO); QueryWrapper wrapper1 = new QueryWrapper<>(p); wrapper1.lambda().orderByAsc(ProjectDiagnose::getSortnum); DeclareDone declareDone = null; if(Constants.formatIntegerNum(declares.getStatus()) >= DeclareStatus.SERVICE_DONE.getKey()){ //如果已经完成服务,则返回实际填写数据,诊断填写信息 /* DeclareDiagnose dd=new DeclareDiagnose(); dd.setIsdeleted(Constants.ZERO); dd.setDeclareId(declareService.getDeclareId()); List ddList= declareDiagnoseService.findList(dd); declareService.setDeclareDiagnoseList(ddList);*/ QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda().eq(DeclareDone::getDeclareId,declareService.getDeclareId()) .orderByDesc(DeclareDone::getCreateDate).last("limit 1"); declareDone = declareDoneMapper.selectOne(wrapper); if (Objects.nonNull(declareDone)){ declareService.setDiagnoseDate(declareDone.getDiagnoseDate()); declareService.setDiagnoseScore(declareDone.getDiagnoseScore()); Multifile query = new Multifile(); query.setIsdeleted(Constants.ZERO); query.setObjId(declareDone.getId()); //完成服务资料 企业评分 query.setObjType(Constants.MultiFile.BUSINESS_SCORE.getKey()); List fileList =getMultiFileList(query); declareService.setFileExtraList(fileList); //完成服务资料 企业评分 query.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS_EXTRA.getKey()); List fileExtraList =getMultiFileList(query); declareService.setFileExtraList(fileExtraList); query.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); List fileDiagnosisList =getMultiFileList(query); declareService.setFileDiagnosisList(fileDiagnosisList); } }else{ QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda() .eq(DeclareDone::getIsdeleted,Constants.ZERO) .eq(DeclareDone::getDeclareId,declareService.getDeclareId()) .orderByDesc(DeclareDone::getCreateDate).last("limit 1"); declareDone = declareDoneMapper.selectOne(wrapper); /*ProjectDiagnose p = new ProjectDiagnose(); p.setProjectId(declares.getProjectId()); p.setIsdeleted(Constants.ZERO); QueryWrapper wrapper1 = new QueryWrapper<>(p); if (Objects.nonNull(declareDone)){ wrapper1.select("*,(select b.content from declare_diagnose b where b.isdeleted=0 and b.declare_id="+declareDone.getId()+" and b.diagnose_id=project_diagnose.id) as saveContent"); } wrapper1.lambda().orderByAsc(ProjectDiagnose::getSortnum); List pList = projectDiagnoseMapper.selectList(wrapper1);*/ if (Objects.nonNull(declareDone)){ declareService.setDiagnoseDate(declareDone.getDiagnoseDate()); declareService.setDiagnoseScore(declareDone.getDiagnoseScore()); Multifile query = new Multifile(); query.setIsdeleted(Constants.ZERO); query.setObjId(declareDone.getId()); //完成服务资料 企业评分 query.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS_EXTRA.getKey()); List fileList =getMultiFileList(query); declareService.setFileExtraList(fileList); query.setObjType(Constants.MultiFile.BUSINESS_SCORE.getKey()); List fileScoreList =getMultiFileList(query); declareService.setFileScoreList(fileScoreList); query.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); List fileDiagnosisList =getMultiFileList(query); declareService.setFileDiagnosisList(fileDiagnosisList); DeclareDiagnose dd=new DeclareDiagnose(); dd.setIsdeleted(Constants.ZERO); dd.setDeclareId(declareDone.getId()); List ddList= declareDiagnoseService.findList(dd); declareService.setDeclareDiagnoseList(ddList); } } if(CollectionUtils.isEmpty(declareService.getDeclareDiagnoseList())){ if (Objects.nonNull(declareDone)) { wrapper1.select("*,(select b.content from declare_diagnose b where b.isdeleted=0 and b.declare_id=" + declareDone.getId() + " and b.diagnose_id=project_diagnose.id) as saveContent"); } List pList = projectDiagnoseMapper.selectList(wrapper1); if(pList!=null && pList.size()>0 && CollectionUtils.isEmpty(declareService.getDeclareDiagnoseList())){ List dpList = null; for(ProjectDiagnose d : pList){ DeclareDiagnose t = new DeclareDiagnose(); t.setDiagnoseId(d.getId()); t.setName(d.getName()); t.setContent(StringUtils.defaultString(d.getSaveContent(),d.getContent())); if(dpList == null){ dpList = new ArrayList<>(); } dpList.add(t); } declareService.setDeclareDiagnoseList(dpList); } } return declareService; } public DeclareService findByDeclareId3(DeclareService declareService) { if(declareService.getDeclareId()== null){ throw new BusinessException(ResponseStatus.DATA_EMPTY); } Declares declares = declaresMapper.selectById(declareService.getDeclareId()); if(declares==null){ throw new BusinessException(ResponseStatus.DATA_EMPTY); } if(Constants.formatIntegerNum(declares.getStatus()) >= DeclareStatus.SERVICE_DONE.getKey()){ //如果已经完成服务,则返回实际填写数据,诊断填写信息 /* DeclareDiagnose dd=new DeclareDiagnose(); dd.setIsdeleted(Constants.ZERO); dd.setDeclareId(declareService.getDeclareId()); List ddList= declareDiagnoseService.findList(dd); declareService.setDeclareDiagnoseList(ddList);*/ QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda().eq(DeclareDone::getDeclareId,declareService.getDeclareId()) .orderByDesc(DeclareDone::getCreateDate).last("limit 1"); DeclareDone declareDone = declareDoneMapper.selectOne(wrapper); if (Objects.nonNull(declareDone)){ declareService.setDiagnoseDate(declareDone.getDiagnoseDate()); declareService.setDiagnoseScore(declareDone.getDiagnoseScore()); Multifile query = new Multifile(); query.setIsdeleted(Constants.ZERO); query.setObjId(declareDone.getId()); //完成服务资料 企业评分 query.setObjType(Constants.MultiFile.BUSINESS_SCORE.getKey()); List fileList =getMultiFileList(query); declareService.setFileExtraList(fileList); //完成服务资料 企业评分 query.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS_EXTRA.getKey()); List fileExtraList =getMultiFileList(query); declareService.setFileExtraList(fileExtraList); query.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); List fileDiagnosisList =getMultiFileList(query); declareService.setFileDiagnosisList(fileDiagnosisList); } }else{ ProjectDiagnose p = new ProjectDiagnose(); p.setProjectId(declares.getProjectId()); p.setIsdeleted(Constants.ZERO); List pList = projectDiagnoseMapper.selectList( new QueryWrapper<>(p) // .select("*,(select b.content from declare_diagnose b where b.isdeleted=0 and b.declare_id="+declares.getId()+" and b.diagnose_id=project_diagnose.id) as saveContent") .lambda().orderByAsc(ProjectDiagnose::getSortnum)); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda() .eq(DeclareDone::getIsdeleted,Constants.ZERO) .eq(DeclareDone::getDeclareId,declareService.getDeclareId()) .orderByDesc(DeclareDone::getCreateDate).last("limit 1"); DeclareDone declareDone = declareDoneMapper.selectOne(wrapper); if (Objects.nonNull(declareDone)){ declareService.setDiagnoseDate(declareDone.getDiagnoseDate()); declareService.setDiagnoseScore(declareDone.getDiagnoseScore()); Multifile query = new Multifile(); query.setIsdeleted(Constants.ZERO); query.setObjId(declareDone.getId()); //完成服务资料 企业评分 query.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS_EXTRA.getKey()); List fileList =getMultiFileList(query); declareService.setFileExtraList(fileList); query.setObjType(Constants.MultiFile.BUSINESS_SCORE.getKey()); List fileScoreList =getMultiFileList(query); declareService.setFileScoreList(fileScoreList); query.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); List fileDiagnosisList =getMultiFileList(query); declareService.setFileDiagnosisList(fileDiagnosisList); DeclareDiagnose dd=new DeclareDiagnose(); dd.setIsdeleted(Constants.ZERO); dd.setDeclareId(declareDone.getId()); List ddList= declareDiagnoseService.findList(dd); declareService.setDeclareDiagnoseList(ddList); } if(pList!=null && pList.size()>0 && CollectionUtils.isEmpty(declareService.getDeclareDiagnoseList())){ List dpList = null; for(ProjectDiagnose d : pList){ DeclareDiagnose t = new DeclareDiagnose(); t.setDiagnoseId(d.getId()); t.setName(d.getName()); t.setContent(StringUtils.defaultString(d.getSaveContent(),d.getContent())); if(dpList == null){ dpList = new ArrayList<>(); } dpList.add(t); } declareService.setDeclareDiagnoseList(dpList); } } return declareService; } /** * 上传核查资料 * * @param declareService */ @Override public void uploadHCData(DeclareService declareService) throws BusinessException { LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); if (declareService.getDeclareId() == null || declareService.getStatus() == null || declareService.getType() == null) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); } if (declareService.getStatus().intValue() == 1 && ( declareService.getServiceDate() == null || CollectionUtils.isEmpty(declareService.getFileList()))) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); } /* if (declareService.getStatus().intValue() == 0 && ( StringUtils.isEmpty(declareService.getDiagnoseDate()) && CollectionUtils.isEmpty(declareService.getFileList()) )) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); } */ Declares declares = declaresMapper.selectById(declareService.getDeclareId()); //判断当前操作是否合法 isOptionValid(declares,user,declareService.getType()); Declares updateModel = new Declares(); DeclareService ingModel = getIngServiceData(declareService); DeclareHistory history= new DeclareHistory(); if(Constants.equalsInteger(declareService.getType(),Constants.ONE)){ //综合服务单位诊断资料上传 sdUploadFiles( declares,declareService,user,ingModel,history); }else{ //服务机构上传服务资料 soUploadFiles( declares,updateModel,declareService,user,ingModel,history); } if(history!=null && history.getCreateDate()!=null){ String checkinfo = history.getCheckInfo().replace("${param2}", Constants.UserType.getInfo(user.getType())) .replace("${param3}", StringUtils.defaultString(user.getRealname(),"")) .replace("${param4}", Constants.DeclareStatus.getInfo(declares.getStatus())); history.setCheckInfo(checkinfo); } if(updateModel.getEditDate()!=null){ //如果需要更新主表,这更新 updateModel.setCheckInfo(history.getCheckInfo()); updateModel.setCheckor(history.getCheckor()); updateModel.setCheckType(history.getType()); declaresMapper.updateById(updateModel); } dealFiles(declareService,ingModel,user); } private void dealFiles(DeclareService declareService, DeclareService ingModel, LoginUserInfo user) { // Integer objType = Constants.MultiFile.BUSINESS_UP_SERVICE.getKey(); // if (Constants.equalsInteger(declareService.getType(),Constants.ONE )) { // //综合单位上传核查资料 // objType =(Constants.MultiFile.BUSINESS_HC.getKey()); // } if(ingModel != null){ //删除原有的附件 Multifile multifile = new Multifile(); multifile.setIsdeleted(Constants.ZERO); multifile.setObjId(declareService.getId()); multifile.setTypeList(new ArrayList<>()); //删除企业评分上传 multifile.getTypeList().add(Constants.equalsInteger(declareService.getType(),Constants.ONE)? Constants.MultiFile.BUSINESS_HC.getKey(): Constants.MultiFile.BUSINESS_UP_SERVICE.getKey()); //删除诊断报告上传 multifile.getTypeList().add(Constants.equalsInteger(declareService.getType(),Constants.ONE)? Constants.MultiFile.BUSINESS_HC_EXTRA.getKey(): Constants.MultiFile.BUSINESS_UP_EXTRA.getKey()); // multifile.setObjType(objType); multifileService.delete(multifile); } for(Multifile table : declareService.getFileList()){ //录入新增的附件 table.setIsdeleted(Constants.ZERO); table.setCreateDate(new Date()); table.setObjId(declareService.getId()); table.setType(Constants.TWO); table.setObjType(Constants.equalsInteger(declareService.getType(),Constants.ONE)? Constants.MultiFile.BUSINESS_HC.getKey(): Constants.MultiFile.BUSINESS_UP_SERVICE.getKey()); multifileService.create(table); } if(declareService.getFileExtraList() !=null ){ for(Multifile table : declareService.getFileExtraList()){ //录入新增的附件 table.setIsdeleted(Constants.ZERO); table.setCreateDate(new Date()); table.setObjId(declareService.getId()); table.setType(Constants.TWO); table.setObjType(Constants.equalsInteger(declareService.getType(),Constants.ONE)? Constants.MultiFile.BUSINESS_HC_EXTRA.getKey(): Constants.MultiFile.BUSINESS_UP_EXTRA.getKey()); multifileService.create(table); } } } /** * 服务机构上传服务资料 * @param declares * @param updateModel * @param declareService * @param user * @param ingModel * @param history */ private void soUploadFiles(Declares declares,Declares updateModel, DeclareService declareService, LoginUserInfo user, DeclareService ingModel, DeclareHistory history) { Date date = new Date(); if(Constants.equalsInteger(declareService.getStatus(),Constants.ONE)){ //如果是保存,判断是否首次,如果是首次更新申报记录状态 if (Constants.equalsInteger(declares.getStatus(), Constants.DeclareStatus.SELECTED_SO.getKey())) { //为空 代表第一次上传 第一次上传更新declares 状态为诊断中 updateModel = new Declares(); updateModel.setId(declares.getId()); updateModel.setStatus(Constants.DeclareStatus.SERVING.getKey()); updateModel.setEditDate(date); updateModel.setEditor(user.getId()); declaresMapper.updateById(updateModel); } history.setIsdeleted(Constants.ZERO); history.setCreator(user.getId()); history.setCreateDate(date); history.setDeclareId(declares.getId()); history.setCheckor(user.getId()); history.setType(ProjectRecord.SO_SERVICE_UPLOAD.getKey()); history.setCheckInfo(ProjectRecord.SO_SERVICE_UPLOAD.getNoteinfo()); //如果是提交 if(ingModel !=null){ //有历史数据,直接更新资料数据 declareService.setEditor(user.getId()); declareService.setEditDate(date); declareService.setId(ingModel.getId()); declareService.setStatus(Constants.ONE); declareService.setCreator(user.getId()); declareServiceMapper.updateById(declareService); }else{ declareService.setCreator(user.getId()); declareService.setCreateDate(date); declareService.setStatus(Constants.ONE); declareService.setIsdeleted(Constants.ZERO); declareServiceMapper.insert(declareService); } }else{ //如果是保存 if(ingModel !=null){ //有历史数据,直接更新资料数据 declareService.setEditor(user.getId()); declareService.setEditDate(date); declareService.setId(ingModel.getId()); declareServiceMapper.updateById(declareService); }else{ declareService.setCreator(user.getId()); declareService.setCreateDate(date); declareService.setStatus(Constants.ZERO); declareService.setIsdeleted(Constants.ZERO); declareServiceMapper.insert(declareService); } } } /** * 综合服务单位诊断资料上传 */ private void sdUploadFiles(Declares declares, DeclareService declareService, LoginUserInfo user, DeclareService ingModel, DeclareHistory history) { Date date =new Date(); if(Constants.equalsInteger(declareService.getStatus(),Constants.ONE)){ //如果是提交 history.setIsdeleted(Constants.ZERO); history.setCreator(user.getId()); history.setCreateDate(date); history.setDeclareId(declares.getId()); history.setCheckor(user.getId()); history.setType(ProjectRecord.SD_SERVICE_UPLOAD.getKey()); history.setCheckInfo(ProjectRecord.SD_SERVICE_UPLOAD.getNoteinfo()); if(ingModel !=null){ //有历史数据,直接更新资料数据 declareService.setEditor(user.getId()); declareService.setEditDate(date); declareService.setId(ingModel.getId()); declareService.setStatus(Constants.ONE); declareService.setCreator(user.getId()); declareServiceMapper.updateById(declareService); }else{ declareService.setCreator(user.getId()); declareService.setCreateDate(date); declareService.setStatus(Constants.ONE); declareService.setIsdeleted(Constants.ZERO); declareServiceMapper.insert(declareService); } }else{ //如果是保存 if(ingModel !=null){ //有历史数据,直接更新资料数据 declareService.setEditor(user.getId()); declareService.setEditDate(date); declareService.setId(ingModel.getId()); declareServiceMapper.updateById(declareService); }else{ declareService.setCreator(user.getId()); declareService.setCreateDate(date); declareService.setStatus(Constants.ZERO); declareService.setIsdeleted(Constants.ZERO); declareServiceMapper.insert(declareService); } } } private DeclareService getIngServiceData(DeclareService declareService) { DeclareService tp = new DeclareService(); tp.setType(declareService.getType()); tp.setIsdeleted(Constants.ZERO); tp.setStatus(Constants.ZERO); tp.setDeclareId(declareService.getDeclareId()); return declareServiceMapper.selectOne(new QueryWrapper<>(tp).last(" limit 1")); } private void isOptionValid(Declares declares, LoginUserInfo user,Integer type) { if(Constants.equalsInteger(type,Constants.ONE)){ //综合服务单位诊断资料上传 if(!(Constants.formatIntegerNum(user.getType()) == Constants.UserType.SD_ADMIN.getKey()|| Constants.formatIntegerNum(user.getType()) == Constants.UserType.SD_CHILD.getKey())) { //用户角色必须是综合服务单位 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您没有当前操作权限!"); } if(Constants.formatIntegerNum(user.getType()) != Constants.UserType.SD_ADMIN.getKey()&&!(Constants.equalsInteger(declares.getSdUserId(),user.getId())&& Constants.equalsInteger(user.getType() , Constants.UserType.SD_CHILD.getKey()))) { //子账号只能操作自己负责的数据 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您没有当前操作权限!"); } if(!(Constants.equalsInteger(declares.getStatus(), DeclareStatus.SELECTED_SO.getKey())||Constants.equalsInteger(declares.getStatus(), DeclareStatus.SERVING.getKey()))){ //只有诊断中的申报记录可进行该操作 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该企业报名状态已流转,不允许当前操作!"); } }else{ //服务机构上传服务资料 if(!Constants.equalsInteger(user.getCompanyId(),declares.getSoId())){ //只能操作分配到自己的数据记录 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您没有当前操作权限!"); } if(!(Constants.formatIntegerNum(user.getType()) == Constants.UserType.SO_ADMIN.getKey()|| Constants.formatIntegerNum(user.getType()) == Constants.UserType.SO_CHILD.getKey())) { //用户角色必须是服務机构 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您没有当前操作权限!"); } if(Constants.formatIntegerNum(user.getType()) != Constants.UserType.SO_ADMIN.getKey()&&!(Constants.equalsInteger(declares.getSoUserId(),user.getId())&& Constants.equalsInteger(user.getType() , Constants.UserType.SO_CHILD.getKey()))) { //子账号只能操作自己负责的数据 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您没有当前操作权限!"); } if(!(Constants.equalsInteger(declares.getStatus(), DeclareStatus.SERVING.getKey()) ||Constants.equalsInteger(declares.getStatus(), DeclareStatus.SELECTED_SO.getKey()) ||Constants.equalsInteger(declares.getStatus(), DeclareStatus.BACK_SERVER_ING.getKey()))){ //只有诊断中和已分配服务机构的申报记录可进行该操作 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该企业报名状态已流转,不允许当前操作!"); } } } /** * 服务机构服务完成和保存 * * @param declareService */ @Transactional(rollbackFor = {BusinessException.class, Exception.class}) @Override public void finishHCData(DeclareService declareService) throws BusinessException { LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); if ( declareService.getDeclareId() == null ) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); } Declares declares = declaresMapper.selectById(declareService.getDeclareId()); DeclareService queryds = new DeclareService(); queryds.setDeclareId(declares.getId()); queryds.setIsdeleted(Constants.ZERO); queryds.setStatus(Constants.ONE); List dsList = declareServiceMapper.selectList(new QueryWrapper<>(queryds)); Project project = projectService.findById(declares.getProjectId()); //数据校验有效性 isfinishHCParamValid( declareService,declares,project, dsList,user,Constants.DeclareStatus.SERVING.getKey()); //更新诊断资料 DeclareDone doneModel = updataHCData(declareService,declares,user,Constants.ZERO); //新增完成服务数据 fileHCUpload(declareService,user,doneModel); } /** * 服务机构退回修改提交和保存 * @param declareService * @throws BusinessException */ @Transactional(rollbackFor = {BusinessException.class, Exception.class}) @Override public void editHCData(DeclareService declareService) throws BusinessException { LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); if ( declareService.getDeclareId() == null ) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); } Declares declares = declaresMapper.selectById(declareService.getDeclareId()); Project project = projectService.findById(declares.getProjectId()); //数据校验有效性 isfinishHCParamValid( declareService,declares,project, null,user, DeclareStatus.BACK_SERVER_ING.getKey());; //更新诊断资料 DeclareDone doneModel = updataHCData(declareService,declares,user,Constants.ONE); //新增完成服务数据 fileHCUpload(declareService,user,doneModel); } /** * 数据有效性校验 参 * @param declareService * @param declares * @param project * @param user */ private void isfinishHCParamValid(DeclareService declareService, Declares declares, Project project, List dsList, LoginUserInfo user,Integer status) { if(declares == null ||Constants.equalsInteger(declares.getIsdeleted(),Constants.ONE)){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,申报信息不存在,请返回刷新重试!"); } if(project == null ){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,申报项目信息不存在,请返回刷新重试!"); } if(declareService.getStatus() == null || declareService.getDeclareId() == null){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); } if (Constants.equalsInteger(declareService.getStatus(),Constants.ONE) && ( declareService.getDiagnoseDate() == null // || declareService.getDiagnoseScore() == null || CollectionUtils.isEmpty(declareService.getFileDiagnosisList()) // || CollectionUtils.isEmpty(declareService.getFileScoreList()) ) ) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); } QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda().eq(ProjectDiagnose::getProjectId,project.getId()); wrapper.lambda().eq(ProjectDiagnose::getIsdeleted,Constants.ZERO); Integer integer = projectDiagnoseMapper.selectCount(wrapper); if (integer > Constants.ZERO && CollectionUtils.isEmpty(declareService.getDeclareDiagnoseList())){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "项目配置诊断报告详情为必填项"); } if(!Constants.equalsInteger(declareService.getStatus(),Constants.ZERO) && declareService.getDeclareDiagnoseList() !=null){ for (int i = 0; i < declareService.getDeclareDiagnoseList().size(); i++) { DeclareDiagnose dd = declareService.getDeclareDiagnoseList().get(i); ProjectDiagnose pd = projectDiagnoseMapper.selectById(dd.getDiagnoseId()); if(Objects.isNull(pd)){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,诊断数据有误,请尝试返回刷新重试!"); } if (dd.getDiagnoseId() == null || StringUtils.isEmpty(dd.getContent())) { throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), ResponseStatus.BAD_REQUEST.getMessage()); } } } if (!Constants.equalsInteger(declares.getStatus(), status)) { //诊断中状态可进行该操作 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,该申报信息状态已流转,不能进行该操作!"); } //限制次数不配置表示不限制 if (Constants.equalsInteger(Constants.DeclareStatus.SERVING.getKey(),status) && Constants.formatIntegerNum(project.getServiceLimt() ) >0 &&( dsList == null ||dsList.size()(new DeclareDone()) .eq(DeclareDone::getDeclareId,declareDone.getDeclareId()) .eq(DeclareDone::getIsdeleted,Constants.ZERO) .eq(DeclareDone::getStatus,Constants.ZERO) .set(DeclareDone::getIsdeleted,Constants.ONE)); //完成服务记录赋值----------end if (Constants.equalsInteger(declareService.getStatus(), Constants.ONE)) { //审核记录表 DeclareHistory declareHistory = new DeclareHistory(); declareHistory.setCreateDate(date); declareHistory.setCreator(user.getId()); declareHistory.setIsdeleted(Constants.ZERO); declareHistory.setCheckInfo(declares.getCheckInfo()); declareHistory.setDeclareId(declares.getId()); declareHistory.setCheckDate(date); declareHistory.setCheckor(user.getId()); if(Constants.equalsInteger(Constants.ZERO,doneType)){ //如果是第一次完成服务 declareHistory.setType(Constants.ProjectRecord.SO_DONE_SERVICE.getKey()); declareHistory.setStatus(Constants.DeclareStatus.SERVICE_DONE.getKey()); declareHistory.setCheckInfo( ProjectRecord.SO_DONE_SERVICE.getNoteinfo().replace("${param2}", Constants.UserType.getName(user.getType())) .replace("${param3}", StringUtils.defaultString(user.getUsername(),"")) .replace("${param4}",Constants.DeclareStatus.getNoteinfo(declareHistory.getStatus()))); }else{ //如果是服务退回修改重新提交 declareHistory.setType(ProjectRecord.SO_BACK_SUBMIT.getKey()); declareHistory.setStatus(DeclareStatus.BACK_SERVER_DONE.getKey()); declareHistory.setCheckInfo( ProjectRecord.SO_BACK_SUBMIT.getNoteinfo().replace("${param2}", Constants.UserType.getName(user.getType())) .replace("${param3}", StringUtils.defaultString(user.getUsername(),"")) .replace("${param4}",Constants.DeclareStatus.getNoteinfo(declareHistory.getStatus()))); } declareHistoryMapper.insert(declareHistory); //提交 更改状态 declares.setStatus(declareHistory.getStatus()); declares.setCheckType(declareHistory.getType()); declares.setCheckDate(declareHistory.getCheckDate()); declares.setCheckInfo(declareHistory.getCheckInfo()); //如果提交状态,完成服务记录响应提交字段赋值 declareDone.setSubmitDate(date); declareDone.setSubmitUserId(user.getId()); } // declares.setDiagnoseScore(declareService.getDiagnoseScore()); // declares.setDiagnoseDate(declareService.getDiagnoseDate()); declares.setEditor(user.getId()); declares.setEditDate(date); declaresMapper.updateById(declares); return declareDone; } public void fileHCUpload(DeclareService declareService, LoginUserInfo user, DeclareDone doneModel ){ //完成服务记录数 declareDoneMapper.insert(doneModel); Multifile mu1 = new Multifile(); mu1.setIsdeleted(Constants.ZERO); mu1.setObjId(doneModel.getId()); mu1.setType(Constants.TWO); mu1.setTypeList(new ArrayList<>()); //删除企业评分上传 mu1.getTypeList().add(Constants.MultiFile.BUSINESS_SCORE.getKey()); //删除诊断报告上传 mu1.getTypeList().add(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); //删除诊断补充上传 mu1.getTypeList().add(Constants.MultiFile.BUSINESS_DIAGNOSIS_EXTRA.getKey()); //mu1.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); multifileService.delete(mu1); //企业评分上传 if (!CollectionUtils.isEmpty(declareService.getFileScoreList())) { declareService.getFileScoreList().forEach(table -> { Multifile multifile = new Multifile(); multifile.setIsdeleted(Constants.ZERO); multifile.setCreateDate(new Date()); multifile.setObjId(doneModel.getId()); multifile.setName(table.getName()); multifile.setType(Constants.TWO); multifile.setFileurl(table.getFileurl()); multifile.setObjType(Constants.MultiFile.BUSINESS_SCORE.getKey()); multifileService.create(multifile); }); } //诊断报告 if (!CollectionUtils.isEmpty(declareService.getFileDiagnosisList())) { declareService.getFileDiagnosisList().forEach(table -> { Multifile multifile = new Multifile(); multifile.setIsdeleted(Constants.ZERO); multifile.setCreateDate(new Date()); multifile.setObjId(doneModel.getId()); multifile.setName(table.getName()); multifile.setType(Constants.TWO); multifile.setFileurl(table.getFileurl()); multifile.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); multifileService.create(multifile); }); } if( !CollectionUtils.isEmpty(declareService.getFileExtraList())){ for(Multifile table : declareService.getFileExtraList()){ //录入新增的附件 table.setIsdeleted(Constants.ZERO); table.setCreateDate(new Date()); table.setObjId(doneModel.getId()); table.setType(Constants.TWO); table.setObjType( Constants.MultiFile.BUSINESS_DIAGNOSIS_EXTRA.getKey()); multifileService.create(table); } } if(declareService.getDeclareDiagnoseList()!=null){ declareService.getDeclareDiagnoseList().stream().forEach(table -> { DeclareDiagnose query=new DeclareDiagnose(); query.setIsdeleted(Constants.ZERO); query.setDeclareId(doneModel.getId()); query.setDiagnoseId(table.getDiagnoseId()); DeclareDiagnose dd = declareDiagnoseMapper.selectOne(new QueryWrapper<>(query) .last("limit 1") ); ProjectDiagnose pd = projectDiagnoseMapper.selectById(table.getDiagnoseId()); table.setDeclareId(doneModel.getId()); table.setSortnum(pd.getSortnum()); table.setName(pd.getName()); if (dd!=null&&dd.getId() != null) { table.setEditDate(new Date()); table.setEditor(user.getId()); table.setId(dd.getId()); declareDiagnoseMapper.updateById(table); } else { table.setCreateDate(new Date()); table.setCreator(user.getId()); table.setIsdeleted(Constants.ZERO); declareDiagnoseMapper.insert(table); } }); } } /** * 根据申报信息编码获取服务详情 * * @param declareService */ @Override public DeclareServiceVo serviceDetail(DeclareService declareService) throws BusinessException { LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); if(declareService.getDeclareId()==null){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "申报信息编码不能为空"); } MPJLambdaWrapper declaresMPJLambdaWrapper = new MPJLambdaWrapper<>(); declaresMPJLambdaWrapper.selectAll(Declares.class); declaresMPJLambdaWrapper.leftJoin(Company.class,Company::getId,Declares::getSoId); declaresMPJLambdaWrapper.leftJoin(Labels.class,Labels::getId,Company::getIndustryId); declaresMPJLambdaWrapper.leftJoin(Labels.class,Labels::getId,Company::getNatureId); declaresMPJLambdaWrapper.leftJoin(Labels.class,Labels::getId,Company::getLabelId); declaresMPJLambdaWrapper.select("t2.name as indusrtyName "); declaresMPJLambdaWrapper.select("t3.name as natureName "); declaresMPJLambdaWrapper.select("t4.name as labelName "); declaresMPJLambdaWrapper.selectAs(Company::getRegisterDate,Declares::getRegisterDate); declaresMPJLambdaWrapper.selectAs(Company::getName,Declares::getCompanyName); declaresMPJLambdaWrapper.selectAs(Company::getAreaId,Declares::getAreaId); declaresMPJLambdaWrapper.selectAs(Company::getCreditCode,Declares::getCreditCode); declaresMPJLambdaWrapper.selectAs(Company::getAddress,Declares::getAddress); declaresMPJLambdaWrapper.eq(Declares::getId,declareService.getDeclareId()); //查询服务机构数据 Declares declares = declaresJoinMapper.selectJoinOne(Declares.class,declaresMPJLambdaWrapper.last("limit 1" )); MPJLambdaWrapper wrapper = new MPJLambdaWrapper<>(); wrapper.selectAll(DeclareService.class); wrapper.selectAs(Declares::getDiagnoseScore,DeclareService::getDiagnoseScore); wrapper.selectAs(Declares::getDiagnoseDate,DeclareService::getDiagnoseDate); wrapper.selectAs(Declares::getStatus,DeclareService::getDeclareStatus); wrapper.selectAs(SystemUser::getRealname,DeclareService::getCreatorName); // wrapper.selectAs(Company::getName,DeclareService::getCompanyName); // wrapper.selectAs(Company::getCreditCode,DeclareService::getCreditCode); // wrapper.selectAs(Company::getAddress,DeclareService::getAddress); // wrapper.selectAs(Company::getRegisterDate,DeclareService::getRegisterDate); // wrapper.selectAs(Company::getLinkName,DeclareService::getLinkName); // wrapper.selectAs(Company::getLinkPhone,DeclareService::getLinkPhone); wrapper.leftJoin(Declares.class,Declares::getId,DeclareService::getDeclareId); wrapper.leftJoin(Company.class,Company::getId,Declares::getCompanyId); wrapper.leftJoin(SystemUser.class,SystemUser::getId,DeclareService::getCreator); wrapper.eq(DeclareService::getDeclareId,declareService.getDeclareId()); wrapper.eq(DeclareService::getIsdeleted,Constants.ZERO); wrapper.eq(DeclareService::getStatus,Constants.ONE); // wrapper.eq(Declares::getIsdeleted,Constants.ZERO); // wrapper.eq(Company::getIsdeleted,Constants.ZERO); wrapper.orderByAsc(DeclareService::getCreateDate); List list = declareServiceJoinMapper.selectJoinList(DeclareService.class,wrapper); DeclareServiceVo dsv=new DeclareServiceVo(); if(declares!=null){ //服务机构企业信息 dsv.setDeclareId(declareService.getDeclareId()); dsv.setCompanyName(declares.getCompanyName()); dsv.setAddress(declares.getAddress()); dsv.setCreditCode(declares.getCreditCode()); dsv.setRegisterDate(declares.getRegisterDate()); dsv.setNatureName(declares.getNatureName()); dsv.setIndusrtyName(declares.getIndusrtyName()); dsv.setLinkName(declares.getLinkname()); dsv.setLinkPhone(declares.getLinkphone()); // dsv.setDiagnoseDate(declares.getDiagnoseDate()); // dsv.setDiagnoseScore(Constants.formatBigdecimal(declares.getDiagnoseScore())); dsv.setStatus(Constants.formatIntegerNum(declares.getStatus())); dsv.setLabelName(declares.getLabelName()); if(Constants.equalsInteger(dsv.getStatus(), DeclareStatus.SERVICE_DONE.getKey()) ||Constants.equalsInteger(dsv.getStatus(), DeclareStatus.SELECT_EXPERT.getKey()) ||Constants.equalsInteger(dsv.getStatus(), DeclareStatus.DONE.getKey())){ dsv.setServiceDone(Constants.ONE); } } //获取完成服务资料 getFinishServiceData(dsv); //服务机构数据 List dsServiceList=new ArrayList<>(); //诊断资料 List dsZHList=new ArrayList<>(); Multifile mu = new Multifile(); list.stream().forEach(table -> { mu.setObjId(table.getId()); Integer id = table.getId(); if(Constants.equalsInteger(table.getType(),Constants.ZERO)){ //服务资料上传数据 mu.setTypeList(new ArrayList<>()); mu.getTypeList().add(Constants.MultiFile.BUSINESS_UP_SERVICE.getKey()); mu.getTypeList().add(Constants.MultiFile.BUSINESS_UP_EXTRA.getKey()); List allList =getMultiFileList(mu); if(allList !=null ){ List filelist = new ArrayList<>(); List extralist = new ArrayList<>(); allList.forEach(item -> { if(Constants.equalsInteger(item.getObjType(),Constants.MultiFile.BUSINESS_UP_SERVICE.getKey())){ filelist.add(item);//服务资料 }else if(Constants.equalsInteger(item.getObjType(),Constants.MultiFile.BUSINESS_UP_EXTRA.getKey())){ extralist.add(item);//补充资料 } }); table.setFileList(filelist); table.setFileExtraList(extralist); } dsServiceList.add(table); }else if(Constants.equalsInteger(table.getType(),Constants.ONE)){ //综合服务单位审核资料 mu.setTypeList(new ArrayList<>()); mu.getTypeList().add(Constants.MultiFile.BUSINESS_HC.getKey()); mu.getTypeList().add(Constants.MultiFile.BUSINESS_HC_EXTRA.getKey()); List allList =getMultiFileList(mu); List filelist = new ArrayList<>(); List extralist = new ArrayList<>(); allList.forEach(item -> { if(Constants.equalsInteger(item.getObjType(),Constants.MultiFile.BUSINESS_HC.getKey())){ filelist.add(item);//服务资料 }else if(Constants.equalsInteger(item.getObjType(),Constants.MultiFile.BUSINESS_HC_EXTRA.getKey())){ extralist.add(item);//补充资料 } }); table.setFileDiagnosisList(filelist); table.setFileExtraList(extralist); dsZHList.add(table); } }); //获取专家评分数据 initExpertScoreRecode(dsv,declares,user); dsv.setDsServiceList(dsServiceList); if(Constants.equalsInteger(user.getType(),Constants.UserType.SJ.getKey()) ||Constants.equalsInteger(user.getType(),Constants.UserType.SJ_CHILD.getKey()) || Constants.equalsInteger(user.getType(),Constants.UserType.SD_ADMIN.getKey()) || Constants.equalsInteger(user.getType(),Constants.UserType.SD_CHILD.getKey()) || Constants.equalsInteger(user.getType(),Constants.UserType.COMPANY.getKey())){ //市局、综合服务单位查看核查资料 dsv.setDsZHList(dsZHList); } return dsv; } /** * 获取专家评分数据 */ private void initExpertScoreRecode(DeclareServiceVo dsv, Declares declares, LoginUserInfo user) { if(Constants.equalsInteger(user.getType(),Constants.UserType.SJ.getKey()) ||Constants.equalsInteger(user.getType(),Constants.UserType.SJ_CHILD.getKey()) || Constants.equalsInteger(user.getType(),Constants.UserType.SO_ADMIN.getKey()) || Constants.equalsInteger(user.getType(),Constants.UserType.SO_ADMIN.getKey()) || Constants.equalsInteger(user.getType(),Constants.UserType.EXPERT.getKey()) || Constants.equalsInteger(user.getType(),Constants.UserType.SD_ADMIN.getKey()) || Constants.equalsInteger(user.getType(),Constants.UserType.SD_CHILD.getKey())){ //服务机构、专家、市局、综合服务单位查看专家评分数据 DeclareExpert declareExpert=new DeclareExpert(); declareExpert.setIsdeleted(Constants.ZERO); declareExpert.setDeclareId(declares.getId()); DeclareExpert de= declareExpertMapper.selectOne(new QueryWrapper<>(declareExpert) .select("declare_expert.* ,(select s.REALNAME from system_user s where s.id = declare_expert.EXPERT_ID and s.DELETED=0) as realZJName ") .last("limit 1")); if(de != null){ dsv.setDeclareExpert(de); Multifile f = new Multifile(); f.setObjId(de.getId()); f.setObjType(Constants.MultiFile.BUSINESS_EXPERT.getKey()); dsv.setDeclareExpertFiles(getMultiFileList(f)); } } } public List getMultiFileList(Multifile multifile){ multifile.setIsdeleted(Constants.ZERO); List filelist = multifileService.findList(multifile); if(filelist!=null && filelist.size()>0){ String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode(); path += systemDictDataBiz.queryByCode(Constants.OSS,Constants.PROJECT_FILE).getCode(); for(Multifile f : filelist){ if(StringUtils.isNoneBlank(f.getFileurl())){ f.setFileurlfull(path + f.getFileurl()); } } } return filelist; } public List getFinishServiceData(DeclareServiceVo dsv ){ DeclareDone d = new DeclareDone(); d.setDeclareId(dsv.getDeclareId()); d.setIsdeleted(Constants.ZERO); //查询完成服务数据 List list = declareDoneMapper.selectList(new QueryWrapper<>(d).lambda().orderByAsc(DeclareDone::getCreateDate)); if(list.size()>0){ Multifile mf = new Multifile(); mf.setIsdeleted(Constants.ZERO); for(DeclareDone model :list){ mf.setObjId(model.getId()); //完成服务资料 企业评分 // mf.setObjType(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); mf.setTypeList(new ArrayList<>()); mf.getTypeList().add(Constants.MultiFile.BUSINESS_SCORE.getKey()); mf.getTypeList().add(Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey()); mf.getTypeList().add(Constants.MultiFile.BUSINESS_DIAGNOSIS_EXTRA.getKey()); List allFileList =getMultiFileList(mf); List fileList =new ArrayList<>(); List extraList =new ArrayList<>(); List scoreList =new ArrayList<>(); if(allFileList!=null){ for(Multifile f :allFileList){ if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.BUSINESS_DIAGNOSIS.getKey())){ fileList.add(f); }else if(Constants.equalsInteger(f.getObjType(),Constants.MultiFile.BUSINESS_SCORE.getKey())){ scoreList.add(f); }else{ //补充资料 extraList.add(f); } } } model.setFileDiagnosisList(fileList); model.setFileScoreList(scoreList); model.setFileExtraList(extraList); //诊断填写信息 DeclareDiagnose dd=new DeclareDiagnose(); dd.setIsdeleted(Constants.ZERO); dd.setDeclareId(model.getId()); List ddList= declareDiagnoseService.findList(dd); model.setDeclareDiagnoseList(ddList); mf.setObjId(model.getId()); } } dsv.setDeclareDoneList(list); return list; } }