From cdd6551b190b981b807a3b95e9635c559ccc769d Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期一, 19 五月 2025 09:45:07 +0800 Subject: [PATCH] git ch --- server/service/src/main/java/com/doumee/service/business/impl/InsuranceServiceImpl.java | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 201 insertions(+), 18 deletions(-) diff --git a/server/service/src/main/java/com/doumee/service/business/impl/InsuranceServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/InsuranceServiceImpl.java index 2bc2611..8d8d616 100644 --- a/server/service/src/main/java/com/doumee/service/business/impl/InsuranceServiceImpl.java +++ b/server/service/src/main/java/com/doumee/service/business/impl/InsuranceServiceImpl.java @@ -1,5 +1,6 @@ package com.doumee.service.business.impl; +import com.doumee.biz.system.SystemDictDataBiz; import com.doumee.core.constants.ResponseStatus; import com.doumee.core.exception.BusinessException; import com.doumee.core.model.LoginUserInfo; @@ -9,7 +10,10 @@ import com.doumee.core.utils.Utils; import com.doumee.dao.business.InsuranceMapper; import com.doumee.dao.business.WorktypeMapper; +import com.doumee.dao.business.join.DuWorkTypeJoinMapper; +import com.doumee.dao.business.join.WorktypeJoinMapper; import com.doumee.dao.business.model.Insurance; +import com.doumee.dao.business.model.Solutions; import com.doumee.dao.business.model.Worktype; import com.doumee.dao.system.model.SystemUser; import com.doumee.service.business.InsuranceService; @@ -17,18 +21,18 @@ 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.sun.corba.se.spi.orbutil.threadpool.Work; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.UUID; +import java.util.*; +import java.util.stream.Collectors; /** * 淇濋櫓鍏徃淇℃伅琛⊿ervice瀹炵幇 @@ -42,6 +46,10 @@ private InsuranceMapper insuranceMapper; @Autowired private WorktypeMapper worktypeMapper; + @Autowired + private WorktypeJoinMapper worktypeJoinMapper; + @Autowired + private SystemDictDataBiz systemDictDataBiz; @Override @Transactional @@ -49,6 +57,13 @@ LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); initCreateParam(insurance);//宸ョ鏁版嵁鏈夋晥鎬ф楠岋紝鍘婚櫎绌虹櫧琛屾暟鎹� + + if(insuranceMapper.selectCount(new QueryWrapper<Insurance>().lambda().eq(Insurance::getName,insurance.getName()) + .eq(Insurance::getIsdeleted,Constants.ZERO) + .eq(Insurance::getDataType,Constants.ZERO) + )>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"淇濋櫓鍏徃鍚嶇О宸插瓨鍦�"); + } insurance.setIsdeleted(Constants.ZERO); insurance.setCreator(user.getId()); @@ -72,28 +87,54 @@ } private void dealWorkTypeData(Insurance insurance, Insurance newModel, List<Worktype> worktypeList,boolean isNew) { int num=0; + List<String> workTypeName = worktypeList.stream().map(m->m.getName()).collect(Collectors.toList()); + Set<String> set = new HashSet<>(workTypeName); + if(workTypeName.size() != set.size()){ + throw new BusinessException(ResponseStatus.DATA_ERRO.getCode(),"瀵逛笉璧凤紝宸ョ褰曞叆鏁版嵁瀛樺湪鐩稿悓鏁版嵁锛�"); + } + List<Worktype> saveList = new ArrayList<>(); + for(Worktype w : worktypeList) { + if(!isNew){ + //鏌ヨ淇濋櫓鍏徃涓嬫槸鍚﹀凡瀛樺湪璇ュ伐绉� + if(worktypeMapper.selectCount(new QueryWrapper<Worktype>().lambda().eq(Worktype::getInsuranceId,insurance.getId()) + .eq(Worktype::getIsdeleted,Constants.ZERO) + .eq(Worktype::getDataType,Constants.ZERO) + .eq(Worktype::getName,w.getName()) + )>Constants.ZERO){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"褰撳墠淇濋櫓鍏徃涓嬪瓨鍦ㄣ��"+w.getName()+"銆戣宸ョ淇℃伅"); + } + } //鍩虹鐗堟湰 w.setInsuranceId(insurance.getId()); w.setIsdeleted(Constants.ZERO); w.setCreator(newModel.getCreator()); - w.setCreateDate(insurance.getCreateDate()); + w.setCreateDate(new Date()); w.setDataType(insurance.getDataType()); w.setStatus(Constants.ZERO); w.setVersion(insurance.getVersion()); w.setSortnum(num++); - worktypeMapper.insert(w); + saveList.add(w); +// worktypeMapper.insert(w); + //鍘嗗彶鐗堟湰鐨勫伐绉嶄俊鎭� Worktype newType = new Worktype(); BeanUtils.copyProperties(w, newType); newType.setInsuranceId(newModel.getId()); newType.setBaseId(w.getId()); - newType.setDataType(Constants.ONE); + newType.setDataType(Constants.TWO); newType.setVersion(newModel.getVersion()); w.setSortnum(num++); - worktypeMapper.insert(newType); + saveList.add(newType); +// worktypeMapper.insert(newType); } + + if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(saveList)){ + worktypeJoinMapper.insertBatchSomeColumn(saveList); + } + + } private void initCreateParam(Insurance insurance) { @@ -110,6 +151,15 @@ } if(worktypeList.size()==0){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝宸ョ涓嶈兘涓虹┖锛�"); + } + if(StringUtils.isNotBlank(insurance.getEnglishName()) && insurance.getEnglishName().length()>100){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝鑻辨枃鍚嶈秴闀匡紒"); + } + if(StringUtils.isNotBlank(insurance.getLinkName()) && insurance.getLinkName().length()>10){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝鑱旂郴浜哄悕绉拌秴闀匡紒"); + } + if(StringUtils.isNotBlank(insurance.getLinkPhone()) && insurance.getLinkPhone().length()!=11){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇疯緭鍏ユ纭殑鎵嬫満鍙凤紒"); } insurance.setWorktypeList(worktypeList); } @@ -160,7 +210,7 @@ insuranceMapper.deleteBatchIds(ids); } - @Override + /*@Override public void updateById(Insurance insurance) { Insurance model = findById(insurance.getId()); if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) @@ -169,6 +219,14 @@ } //鏁版嵁鏈夋晥鎬ф牎楠� initCreateParam(insurance); + if(insuranceMapper.selectCount(new QueryWrapper<Insurance>().lambda().eq(Insurance::getName,insurance.getName()) + .eq(Insurance::getIsdeleted,Constants.ZERO) + .eq(Insurance::getDataType,Constants.ZERO) + .ne(Insurance::getId,insurance.getId()) + )>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"淇濋櫓鍏徃鍚嶇О宸插瓨鍦�"); + } + LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); Insurance updateModel = new Insurance(); updateModel.setEditor(user.getId()); @@ -178,6 +236,112 @@ updateModel.setEditDate(new Date()); updateModel.setRemark(insurance.getRemark()); updateModel.setSortnum(insurance.getSortnum()); + updateModel.setLogo(insurance.getLogo()); + updateModel.setEnglishName(insurance.getEnglishName()); + updateModel.setLinkName(insurance.getLinkName()); + updateModel.setLinkPhone(insurance.getLinkPhone()); + updateModel.setPolicy(insurance.getPolicy()); + updateModel.setAgreement(insurance.getAgreement()); + updateModel.setClaimsInformation(insurance.getClaimsInformation()); + insuranceMapper.updateById(updateModel); + + //濡傛灉淇敼锛屽垯浜х敓涓�涓柊鐨勫巻鍙茬増鏈� ~ +// Insurance newModel = new Insurance(); +// BeanUtils.copyProperties(model,newModel); +// newModel.setId(null); +// newModel.setVersion(updateModel.getVersion()); +// newModel.setCreateDate(new Date()); +// newModel.setName(updateModel.getName()); +// newModel.setBaseId(insurance.getId()); +// newModel.setDataType(Constants.TWO); +// newModel.setLogo(insurance.getLogo()); +// newModel.setEnglishName(insurance.getEnglishName()); +// newModel.setLinkName(insurance.getLinkName()); +// newModel.setLinkPhone(insurance.getLinkPhone()); +// newModel.setPolicy(insurance.getPolicy()); +// newModel.setAgreement(insurance.getAgreement()); +// newModel.setClaimsInformation(insurance.getClaimsInformation()); +// insuranceMapper.insert(newModel); + + Insurance useVersion = insuranceMapper.selectOne(new QueryWrapper<Insurance>().lambda() + .eq(Insurance::getBaseId,insurance.getId()) + .eq(Insurance::getDataType,Constants.TWO) + .last(" limit 1") + ); + + Insurance updateUsrModel = new Insurance(); + updateUsrModel.setEditor(user.getId()); + updateUsrModel.setName(insurance.getName()); + updateUsrModel.setId(useVersion.getId()); + updateUsrModel.setVersion(UUID.randomUUID().toString()); + updateUsrModel.setEditDate(new Date()); + updateUsrModel.setRemark(insurance.getRemark()); + updateUsrModel.setSortnum(insurance.getSortnum()); + updateUsrModel.setLogo(insurance.getLogo()); + updateUsrModel.setEnglishName(insurance.getEnglishName()); + updateUsrModel.setLinkName(insurance.getLinkName()); + updateUsrModel.setLinkPhone(insurance.getLinkPhone()); + updateUsrModel.setPolicy(insurance.getPolicy()); + updateUsrModel.setAgreement(insurance.getAgreement()); + updateUsrModel.setClaimsInformation(insurance.getClaimsInformation()); + + //鍒犻櫎鎵�鏈夊伐绉嶆暟鎹� + worktypeMapper.delete(new UpdateWrapper<Worktype>() + .lambda() + .in(Worktype::getInsuranceId,insurance.getId()) + ); +// insuranceMapper.update(null,new UpdateWrapper<Insurance>() +// .lambda() +// .eq(Insurance::getBaseId,insurance.getId()) +// .eq(Insurance::getDataType,Constants.TWO) +// .ne(Insurance::getId,newModel.getId()) +// .set(Insurance::getDataType,Constants.ONE) +// ); + worktypeMapper.update(null,new UpdateWrapper<Worktype>() + .lambda() + .eq(Worktype::getInsuranceId,useVersion.getId()) + .eq(Worktype::getDataType,Constants.TWO) + .set(Worktype::getDataType,Constants.ONE) + ); + + //澶勭悊宸ヤ綔淇℃伅锛屾柊澧炴渶鏂扮殑锛屽悓鏃朵骇鐢熷巻鍙茬増鏈� + dealWorkTypeData(updateModel,useVersion,insurance.getWorktypeList(),false); + }*/ + + + @Override + public void updateById(Insurance insurance) { + Insurance model = findById(insurance.getId()); + if(model == null || !Constants.equalsInteger(model.getIsdeleted(),Constants.ZERO) + || !Constants.equalsInteger(model.getDataType(),Constants.ZERO)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY ); + } + //鏁版嵁鏈夋晥鎬ф牎楠� + initCreateParam(insurance); + if(insuranceMapper.selectCount(new QueryWrapper<Insurance>().lambda().eq(Insurance::getName,insurance.getName()) + .eq(Insurance::getIsdeleted,Constants.ZERO) + .eq(Insurance::getDataType,Constants.ZERO) + .ne(Insurance::getId,insurance.getId()) + )>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"淇濋櫓鍏徃鍚嶇О宸插瓨鍦�"); + } + + LoginUserInfo user= (LoginUserInfo)SecurityUtils.getSubject().getPrincipal(); + Insurance updateModel = new Insurance(); + updateModel.setEditor(user.getId()); + updateModel.setName(insurance.getName()); + updateModel.setId(model.getId()); + updateModel.setVersion(UUID.randomUUID().toString()); + updateModel.setEditDate(new Date()); + updateModel.setRemark(insurance.getRemark()); + updateModel.setSortnum(insurance.getSortnum()); + updateModel.setLogo(insurance.getLogo()); + updateModel.setEnglishName(insurance.getEnglishName()); + updateModel.setLinkName(insurance.getLinkName()); + updateModel.setLinkPhone(insurance.getLinkPhone()); + updateModel.setPolicy(insurance.getPolicy()); + updateModel.setAgreement(insurance.getAgreement()); + updateModel.setClaimsInformation(insurance.getClaimsInformation()); insuranceMapper.updateById(updateModel); //濡傛灉淇敼锛屽垯浜х敓涓�涓柊鐨勫巻鍙茬増鏈� ~ @@ -186,8 +350,16 @@ newModel.setId(null); newModel.setVersion(updateModel.getVersion()); newModel.setCreateDate(new Date()); + newModel.setName(updateModel.getName()); newModel.setBaseId(insurance.getId()); newModel.setDataType(Constants.TWO); + newModel.setLogo(insurance.getLogo()); + newModel.setEnglishName(insurance.getEnglishName()); + newModel.setLinkName(insurance.getLinkName()); + newModel.setLinkPhone(insurance.getLinkPhone()); + newModel.setPolicy(insurance.getPolicy()); + newModel.setAgreement(insurance.getAgreement()); + newModel.setClaimsInformation(insurance.getClaimsInformation()); insuranceMapper.insert(newModel); //鍒犻櫎鎵�鏈夊伐绉嶆暟鎹� @@ -199,8 +371,16 @@ .lambda() .eq(Insurance::getBaseId,insurance.getId()) .eq(Insurance::getDataType,Constants.TWO) + .ne(Insurance::getId,newModel.getId()) .set(Insurance::getDataType,Constants.ONE) ); + worktypeMapper.update(null,new UpdateWrapper<Worktype>() + .lambda() + .eq(Worktype::getBaseId,insurance.getId()) + .eq(Worktype::getDataType,Constants.TWO) + .set(Worktype::getDataType,Constants.ONE) + ); + //澶勭悊宸ヤ綔淇℃伅锛屾柊澧炴渶鏂扮殑锛屽悓鏃朵骇鐢熷巻鍙茬増鏈� dealWorkTypeData(updateModel,newModel,insurance.getWorktypeList(),false); } @@ -316,16 +496,19 @@ if (pageWrap.getModel().getBaseId() != null) { queryWrapper.lambda().eq(Insurance::getBaseId, pageWrap.getModel().getBaseId()); } - /* for(PageWrap.SortData sortData: pageWrap.getSorts()) { - if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { - queryWrapper.orderByDesc(sortData.getProperty()); - } else { - queryWrapper.orderByAsc(sortData.getProperty()); - } - - }*/ queryWrapper.lambda().orderByAsc(Insurance::getSortnum); - return PageData.from(insuranceMapper.selectPage(page, queryWrapper)); + PageData<Insurance> pageData = PageData.from(insuranceMapper.selectPage(page, queryWrapper)); + if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(pageData.getRecords())){ + String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode() + +systemDictDataBiz.queryByCode(Constants.OSS,Constants.INSURANCE).getCode(); + for (Insurance insurance:pageData.getRecords()) { + if (StringUtils.isNotBlank(insurance.getLogo())) { + insurance.setLogoFullUrl(path + insurance.getLogo() ); + } + } + } + + return pageData; } @Override -- Gitblit v1.9.3