From 50fb58286ed3b718c39a97e0987ee7561a295651 Mon Sep 17 00:00:00 2001 From: k94314517 <8417338+k94314517@user.noreply.gitee.com> Date: 星期五, 04 七月 2025 17:56:41 +0800 Subject: [PATCH] git ch --- server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java | 286 +++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 188 insertions(+), 98 deletions(-) diff --git a/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java index f9fbdd0..17d9b02 100644 --- a/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java +++ b/server/service/src/main/java/com/doumee/service/business/impl/MemberServiceImpl.java @@ -21,6 +21,7 @@ import com.doumee.dao.business.join.ApplyDetailJoinMapper; import com.doumee.dao.business.join.DispatchUnitJoinMapper; import com.doumee.dao.business.join.MemberJoinMapper; +import com.doumee.dao.business.join.SolutionWorktypeJoinMapper; import com.doumee.dao.business.model.*; import com.doumee.service.business.MemberService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -39,6 +40,8 @@ import java.math.BigDecimal; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -67,6 +70,8 @@ private SolutionsMapper solutionsMapper; @Autowired private InsuranceApplyMapper insuranceApplyMapper; + @Autowired + private SolutionWorktypeJoinMapper solutionWorktypeJoinMapper; @Override public Integer create(Member member) { @@ -225,6 +230,13 @@ //浼佷笟浜哄憳鏌ョ湅鏈紒涓氭暟鎹� if(loginUserInfo.getType().equals(Constants.ONE)){ queryWrapper.eq(InsuranceApply::getCompanyId, loginUserInfo.getCompanyId()); +// .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id where a.member_id = t.id and b.company_id = "+loginUserInfo.getCompanyId()+" and b.status in (" + +// " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " + +// " and a.end_time >= now() ) ", Member::getValidNum ) +// +// .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id where a.member_id = t.id and b.company_id = "+loginUserInfo.getCompanyId()+" and b.status in (" + +// " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " + +// " and a.end_time < now() ) ", Member::getInvalidNum ); }else{ if(loginUserInfo.getCompanyIdList()!=null && loginUserInfo.getCompanyIdList().size()>0){ queryWrapper.in(InsuranceApply::getCompanyId, loginUserInfo.getCompanyIdList()); @@ -232,44 +244,31 @@ queryWrapper.eq(InsuranceApply::getCompanyId, -1); } queryWrapper.eq(pageWrap.getModel().getCompanyId()!=null,InsuranceApply::getCompanyId, pageWrap.getModel().getCompanyId()); +// .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id where a.member_id = t.id and b.status in (" + +// " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " + +// " and a.end_time >= now() ) ", Member::getValidNum ) +// .select( " ( select count(1) from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id where a.member_id = t.id and b.status in (" + +// " "+Constants.InsuranceApplyStatus.WTB_DONE.getKey()+","+Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()+" ) " + +// " and a.end_time < now() ) ", Member::getInvalidNum ); } queryWrapper.selectAll(Member.class) - .selectAs(DispatchUnit::getName,Member::getDuName) - .selectAs(Worktype::getName,Member::getWorkTypeName) - .selectAs(Solutions::getName,Member::getSolutionName) - .selectAs(Company::getName,Member::getCompanyName) - .select(" case when now() between t.start_time and t.end_time then 1 else 2 end solutionsStatus ") - .leftJoin(InsuranceApply.class,InsuranceApply::getId,Member::getApplyId) - .leftJoin(Solutions.class,Solutions::getId,InsuranceApply::getSolutionId) - .leftJoin(DispatchUnit.class,DispatchUnit::getId,Member::getDuId) - .leftJoin(Worktype.class,Worktype::getId,Member::getWorktypeId) - .leftJoin(Company.class,Company::getId,Member::getCompanyId) .and(StringUtils.isNotBlank(memberQueryDTO.getKeywords()), i->i.like(Member::getName, memberQueryDTO.getKeywords()).or().like( Member::getIdcardNo,memberQueryDTO.getKeywords() )) .eq(Member::getIsdeleted, Constants.ZERO) -// .eq(Member::getCompanyId, memberQueryDTO.getCompanyId()) .like(StringUtils.isNotBlank(memberQueryDTO.getName()),Member::getName, memberQueryDTO.getName()) .like(StringUtils.isNotBlank(memberQueryDTO.getIdCard()),Member::getIdcardNo, memberQueryDTO.getIdCard()) .like(StringUtils.isNotBlank(memberQueryDTO.getIdcardNo()),Member::getIdcardNo, memberQueryDTO.getIdcardNo()) - .like(StringUtils.isNotBlank(memberQueryDTO.getDuName()),DispatchUnit::getName, memberQueryDTO.getDuName()) - .eq(!Objects.isNull(memberQueryDTO.getDuId()),Member::getDuId, memberQueryDTO.getDuId()) - .eq(!Objects.isNull(memberQueryDTO.getSolutionsId()),Solutions::getBaseId, memberQueryDTO.getSolutionsId()) - .apply(!Objects.isNull(memberQueryDTO.getSolutionsStatus())&&memberQueryDTO.getSolutionsStatus().equals(Constants.ONE),"now() between t.start_time and t.end_time") - .apply(!Objects.isNull(memberQueryDTO.getSolutionsStatus())&&memberQueryDTO.getSolutionsStatus().equals(Constants.TWO),"now() > t.end_time") + + .apply(!Objects.isNull(memberQueryDTO.getSolutionsId())," t.id in( select a.member_id from apply_detail a inner join insurance_apply b on a.APPLY_ID = b.id " + + "inner join solutions s on b.solution_id = s.id where s.base_id = '"+memberQueryDTO.getSolutionsId()+"' ) ") ; queryWrapper.orderByAsc(DispatchUnit::getName); queryWrapper.orderByAsc(Member::getName); -// for(PageWrap.SortData sortData: pageWrap.getSorts()) { -// if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { -// queryWrapper.orderByDesc(sortData.getProperty()); -// } else { -// queryWrapper.orderByAsc(sortData.getProperty()); -// } -// } PageData<Member> pageData = PageData.from(memberJoinMapper.selectJoinPage(page,Member.class, queryWrapper)); + this.getValidNum(pageData,loginUserInfo); Integer sn = 0; for (Member member:pageData.getRecords()) { sn = sn + 1; @@ -277,9 +276,40 @@ if(StringUtils.isNotBlank(member.getIdcardNo())){ member.setAge(Constants.getAgeByIdCard(member.getIdcardNo())); } + member.setTotalNum(member.getInvalidNum()+member.getValidNum()); } return pageData; } + + public void getValidNum(PageData<Member> pageData,LoginUserInfo loginUserInfo){ + List<Integer> listId = pageData.getRecords().stream().map(i->i.getId()).collect(Collectors.toList()); + if(CollectionUtils.isNotEmpty(listId)){ + Integer companyId = null; + if(Objects.nonNull(loginUserInfo.getType())&&Constants.equalsInteger(loginUserInfo.getType(),Constants.ONE)){ + companyId = loginUserInfo.getShowCompany().getId(); + } + List<ApplyDetail> applyDetailList = applyDetailJoinMapper.selectJoinList(ApplyDetail.class, + new MPJLambdaWrapper<ApplyDetail>() + .select(ApplyDetail::getMemberId,ApplyDetail::getStartTime,ApplyDetail::getEndTime,ApplyDetail::getId) + .leftJoin(InsuranceApply.class,InsuranceApply::getId,ApplyDetail::getApplyId) + .in(InsuranceApply::getStatus,Constants.InsuranceApplyStatus.WTB_DONE.getKey(),Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()) + .in(ApplyDetail::getMemberId,listId) + .eq(Objects.nonNull(companyId) + ,InsuranceApply::getCompanyId,companyId) + ); + + if(CollectionUtils.isNotEmpty(applyDetailList)){ + for (Member member:pageData.getRecords()) { + member.setInvalidNum(applyDetailList.stream().filter(i->Constants.equalsInteger(i.getMemberId(),member.getId())&&i.getEndTime().getTime()<System.currentTimeMillis()).collect(Collectors.toList()).size()); + member.setValidNum( + applyDetailList.stream().filter(i->Constants.equalsInteger(i.getMemberId(),member.getId())&&i.getEndTime().getTime()>=System.currentTimeMillis()).collect(Collectors.toList()).size() + ); + } + } + } + } + + @Override public long count(Member member) { @@ -312,6 +342,9 @@ " and ad.END_TIME >= '"+DateUtil.DateToStr(memberQueryDTO.getValidTime(),"yyyy-MM-dd HH:mm:ss.SSS")+"' and ad.START_TIME <= '"+DateUtil.DateToStr(memberQueryDTO.getValidTime(),"yyyy-MM-dd HH:mm:ss.SSS")+"' and ad.isdeleted = 0 " + " and ad.member_id = t.id ") ; if(!Objects.isNull(memberQueryDTO.getInsuranceApplyId())){ + if(Objects.isNull(memberQueryDTO.getValidTime())){ + memberQueryDTO.setValidTime(new Date()); + } lambdaWrapper = new MPJLambdaWrapper<Member>() .select(Member::getId,Member::getName,Member::getIdcardNo) .selectAs(Worktype::getId,Member::getWorktypeId) @@ -334,29 +367,38 @@ .eq(InsuranceApply::getId,memberQueryDTO.getInsuranceApplyId()) .and(StringUtils.isNotBlank(memberQueryDTO.getName()),i->i.like(Member::getName,memberQueryDTO.getName()) .or().like(Member::getIdcardNo,memberQueryDTO.getName())) - .le(!Objects.isNull(memberQueryDTO.getValidTime()),ApplyDetail::getStartTime,memberQueryDTO.getValidTime()) +// .le(!Objects.isNull(memberQueryDTO.getValidTime()),ApplyDetail::getStartTime,memberQueryDTO.getValidTime()) .ge(!Objects.isNull(memberQueryDTO.getValidTime()),ApplyDetail::getEndTime,memberQueryDTO.getValidTime()) .in(CollectionUtils.isNotEmpty(memberQueryDTO.getSubtractMemberIds()),Member::getId,memberQueryDTO.getSubtractMemberIds()) .exists(!Objects.isNull(memberQueryDTO.getInsuranceApplyId())&&!Objects.isNull(memberQueryDTO.getValidTime()), " select 1 from apply_detail ad where ad.apply_id = "+memberQueryDTO.getInsuranceApplyId()+"" + - " and ad.END_TIME >= '"+DateUtil.DateToStr(memberQueryDTO.getValidTime(),"yyyy-MM-dd HH:mm:ss.SSS")+"' and ad.START_TIME <= '"+DateUtil.DateToStr(memberQueryDTO.getValidTime(),"yyyy-MM-dd HH:mm:ss.SSS")+"' and ad.isdeleted = 0 " + + " and ad.END_TIME >= '"+DateUtil.DateToStr(memberQueryDTO.getValidTime(),"yyyy-MM-dd HH:mm:ss.SSS")+"'" + +// " and ad.START_TIME <= '"+DateUtil.DateToStr(memberQueryDTO.getValidTime(),"yyyy-MM-dd HH:mm:ss.SSS")+"'" + + " and ad.isdeleted = 0 " + " and ad.member_id = t.id "); } List<Member> memberList = memberJoinMapper.selectJoinList(Member.class,lambdaWrapper); - if(!Objects.isNull(memberQueryDTO.getInsuranceApplyId())&&Objects.isNull(memberQueryDTO.getValidTime())){ + if(!Objects.isNull(memberQueryDTO.getInsuranceApplyId())&&Objects.nonNull(memberQueryDTO.getValidTime())){ if(CollectionUtils.isNotEmpty(memberList)){ Solutions solutions = solutionsMapper.selectById(memberList.get(Constants.ZERO).getSolutionId()); - Date reduceEndTime = DateUtil.getMontageDate( - DateUtil.afterDateByType(new Date(),0,solutions.getDelValidDays()),3); - memberList = memberList.stream().filter(member->member.getDetailStartTime().getTime()<=reduceEndTime.getTime() - &&member.getDetailEndTime().getTime()>=reduceEndTime.getTime()).collect(Collectors.toList()); +// Date reduceEndTime = DateUtil.getMontageDate( +// DateUtil.afterDateByType(new Date(),0,solutions.getDelValidDays()),3); +// Date reduceEndTime = DateUtil.getMontageDate(new Date(),3); for (Member member:memberList) { - //鍑忎繚涓氬姟 浣跨敤 閫夋嫨浜哄憳 鏍规嵁鏃ユ湡瀹炴椂鏌ヨ - member.setFee( - Constants.reduceFee(solutions, - Objects.isNull(member.getDetailServerCost())? - solutions.getPrice():solutions.getPrice().add(member.getDetailServerCost()),member.getStartTime(),member.getEndTime(),member.getDetailStartTime(), - reduceEndTime).subtract(member.getFee())); + //濡傛灉褰撳墠鏃ユ湡 灏忎簬 浜哄憳淇濆崟鏄庣粏璁板綍鐨勫紑濮嬫椂闂� 鍒欎娇鐢ㄥ紑濮嬫棩鏈� 寮�濮嬫棩鏈� = 缁撴潫鏃ユ湡 涓� 璐圭敤鍏ㄩ儴閫�鍥� +// if(System.currentTimeMillis()<=member.getStartTime().getTime()){ +// member.setFee(solutions.getPrice().multiply(new BigDecimal(-1))); + if(System.currentTimeMillis()<=member.getDetailStartTime().getTime()){ + member.setFee(member.getFee().multiply(new BigDecimal(-1))); + }else{ + Date reduceEndTime = DateUtil.getMontageDate( + DateUtil.afterDateByType(new Date(),0,solutions.getDelValidDays()),3); + member.setFee( + Constants.reduceFee(solutions, + Objects.isNull(member.getDetailServerCost())? + solutions.getPrice():solutions.getPrice().add(member.getDetailServerCost()),member.getStartTime(),member.getEndTime(),member.getDetailStartTime(), + reduceEndTime).subtract(member.getFee())); + } } } @@ -372,9 +414,9 @@ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇烽�夋嫨鏈夋晥鐨勬柟妗堝啀杩涜鎿嶄綔锛�"); } LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); - if(!loginUserInfo.getType().equals(Constants.ONE)){ - throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氫汉鍛樻棤娉曡繘琛岃鎿嶄綔"); - } +// if(!loginUserInfo.getType().equals(Constants.ONE)){ +// throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氫汉鍛樻棤娉曡繘琛岃鎿嶄綔"); +// } ExcelImporter ie = null; List<MemberReduceImport> dataList =null; try { @@ -388,9 +430,9 @@ } InsuranceApply insuranceApply = insuranceApplyMapper.selectById(applyId); - if (Objects.isNull(insuranceApply) || !Constants.equalsInteger(insuranceApply.getCompanyId(),loginUserInfo.getCompanyId())) { - throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝淇濆崟淇℃伅涓嶅瓨鍦紝璇峰埛鏂伴〉闈㈤噸璇曪紒"); - } +// if (Objects.isNull(insuranceApply) || !Constants.equalsInteger(insuranceApply.getCompanyId(),loginUserInfo.getCompanyId())) { +// throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"瀵逛笉璧凤紝淇濆崟淇℃伅涓嶅瓨鍦紝璇峰埛鏂伴〉闈㈤噸璇曪紒"); +// } if (!(Constants.equalsInteger(insuranceApply.getStatus(), Constants.InsuranceApplyStatus.UPLOAD_INSURANCE.getKey()) ||Constants.equalsInteger(insuranceApply.getStatus(), Constants.InsuranceApplyStatus.WTB_DONE.getKey()) )) { @@ -399,14 +441,14 @@ if (DateUtil.compareDate(insuranceApply.getEndTime(),new Date()) >= Constants.ZERO ) { throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "淇濆崟宸茶繃淇濓紝涓嶆敮鎸佽鎿嶄綔"); } - if (DateUtil.compareDate(insuranceApply.getEndTime(),new Date()) >= Constants.ZERO ) { - throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "淇濆崟宸茶繃淇濓紝涓嶆敮鎸佽鎿嶄綔"); - } - Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId()); if(Objects.isNull(solutions)){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌淇濋櫓鏂规"); } +// Date reduceEndTime = DateUtil.getMontageDate( +// DateUtil.afterDateByType(new Date(),0,solutions.getDelValidDays()),3); + +// Date reduceEndTime = DateUtil.getMontageDate(new Date(),3); int index = Constants.TWO; Map<String,String> idCardMap = new HashMap<>(); for(MemberReduceImport model : dataList){ @@ -420,8 +462,8 @@ .selectAll(ApplyDetail.class) .selectAs(Worktype::getName,ApplyDetail::getWorkTypeName) .selectAs(DispatchUnit::getName,ApplyDetail::getDuName) - .selectAs(InsuranceApply::getStartTime,ApplyDetail::getStartTime) - .selectAs(InsuranceApply::getFinalEndTime,ApplyDetail::getEndTime) +// .selectAs(InsuranceApply::getStartTime,ApplyDetail::getStartTime) +// .selectAs(InsuranceApply::getEndTime,ApplyDetail::getEndTime) .selectAs(InsuranceApply::getServerCost,ApplyDetail::getDetailServerCost) .leftJoin(Worktype.class,Worktype::getId,ApplyDetail::getWorktypeId) .leftJoin(DispatchUnit.class,DispatchUnit::getId,ApplyDetail::getDuId) @@ -429,8 +471,11 @@ .eq(ApplyDetail::getApplyId,insuranceApply.getId()) .eq(ApplyDetail::getApplyId,insuranceApply.getId()) .eq(ApplyDetail::getIdcardNo,model.getIdCard()) - .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(new Date(),1)) - .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(new Date(),3))); + /* .le(ApplyDetail::getStartTime,DateUtil.getMontageDate(new Date(),1))*/ + .ge(ApplyDetail::getEndTime,DateUtil.getMontageDate(new Date(),3)) + .orderByAsc(ApplyDetail::getEndTime) + .last(" limit 1 ") + ); if(detail == null){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "褰撳墠淇濆崟涓嬶紝鍛樺伐銆�" + model.getName()+model.getIdCard() + "銆戦潪鍦ㄤ繚浜哄憳锛屾棤娉曡繘琛岃鎿嶄綔"); } @@ -443,12 +488,22 @@ model.setDuId(detail.getDuId()); model.setDuName(detail.getDuName()); model.setWorktypeId(detail.getWorktypeId()); + model.setMemberId(detail.getMemberId()); model.setWorkTypeName(detail.getWorkTypeName()); - model.setFee( - Constants.reduceFee(solutions, - Objects.isNull(detail.getDetailServerCost())? - solutions.getPrice():solutions.getPrice().add(detail.getDetailServerCost()),detail.getParentStartTime(),detail.getParentEndTime(),detail.getStartTime(), - detail.getEndTime()).subtract(detail.getFee())); + //濡傛灉褰撳墠鏃ユ湡 灏忎簬 浜哄憳淇濆崟鏄庣粏璁板綍鐨勫紑濮嬫椂闂� 鍒欎娇鐢ㄥ紑濮嬫棩鏈� 寮�濮嬫棩鏈� = 缁撴潫鏃ユ湡 涓� 璐圭敤鍏ㄩ儴閫�鍥� + if(System.currentTimeMillis()<=detail.getStartTime().getTime()){ + model.setFee(solutions.getPrice().multiply(new BigDecimal(-1))); + }else{ + Date reduceEndTime = DateUtil.getMontageDate( + DateUtil.afterDateByType(new Date(),0,solutions.getDelValidDays()),3); + model.setFee( + Constants.reduceFee(solutions, + Objects.isNull(detail.getDetailServerCost())?solutions.getPrice():solutions.getPrice().add(detail.getDetailServerCost()), + insuranceApply.getStartTime(), + insuranceApply.getEndTime(), + detail.getStartTime(), + reduceEndTime).subtract(detail.getFee())); + } index += 1; } return dataList; @@ -478,8 +533,15 @@ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇烽�夋嫨鏈夋晥鐨勬柟妗堝啀杩涜鎿嶄綔锛�"); } LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); - if(!loginUserInfo.getType().equals(Constants.ONE)){ - throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氫汉鍛樻棤娉曡繘琛岃鎿嶄綔"); +// if(!loginUserInfo.getType().equals(Constants.ONE)){ +// throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰紒涓氫汉鍛樻棤娉曡繘琛岃鎿嶄綔"); +// } + if(Objects.isNull(solutionId)){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍙傛暟閿欒 - 鏂规淇℃伅"); + } + Solutions solutions = solutionsMapper.selectById(solutionId); + if(Objects.isNull(solutions)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鏂规淇℃伅"); } ExcelImporter ie = null; List<MemberImport> dataList =null; @@ -496,83 +558,111 @@ Map<String,String> idCardMap = new HashMap<>(); for(MemberImport model : dataList){ //鏍¢獙鍙傛暟鏄惁鍚堟硶 - validImportParam(model,idCardMap,dataList,index,solutionId); + validImportParam(model,idCardMap,dataList,index,solutions); index += 1; } - List<DispatchUnit> dispatchUnitList = dispatchUnitJoinMapper.selectJoinList(DispatchUnit.class, + List<DispatchUnit> dispatchUnitList = new ArrayList<>(); + List<SolutionWorktype> solutionWorktypeList = new ArrayList<>(); + //2024骞�11鏈�6鏃�15:39:10 鍔犲叆 鏍规嵁鏂规鏄惁鏈変繚闄╂柟妗堣繘琛屽垽鏂� + if(Constants.equalsInteger(solutions.getHasDispatchUnit(),Constants.ZERO)){ + dispatchUnitList = dispatchUnitJoinMapper.selectJoinList(DispatchUnit.class, new MPJLambdaWrapper<DispatchUnit>() .selectAll(DispatchUnit.class) - .select("(select b.id from du_solution b where b.isdeleted=0 and b.dispatch_unit_id=t.id and b.solution_id="+solutionId+" limit 1) as du_solution_id" ) + .select("(select b.id from du_solution b where b.isdeleted=0 and b.dispatch_unit_id=t.id and b.solution_id="+solutionId+" order by b.CHECK_DATE desc limit 1) as du_solution_id" ) .eq(DispatchUnit::getIsdeleted,Constants.ZERO) .eq(DispatchUnit::getStatus,Constants.ZERO) .eq(DispatchUnit::getDataType,Constants.TWO) .eq(loginUserInfo.getType().equals(Constants.ONE),DispatchUnit::getCompanyId,loginUserInfo.getCompanyId()) .exists("select b.id from du_solution b where b.isdeleted=0 and b.dispatch_unit_id=t.id and b.status = 1 and b.solution_id="+solutionId ) ); - if(CollectionUtils.isNotEmpty(dispatchUnitList)){ - for (DispatchUnit dispatchUnit:dispatchUnitList) { - List<Worktype> worktypeList = worktypeMapper.selectList(new QueryWrapper<Worktype>().lambda() - .eq(Worktype::getIsdeleted,Constants.ZERO) - .eq(Worktype::getDataType,Constants.TWO) - .eq(Worktype::getStatus,Constants.ZERO) - .apply("id in ( select dw.work_type_id from du_worktype dw where dw.status = 1" + - " and dw.du_solution_id = "+dispatchUnit.getDuSolutionId()+" )") - ); - dispatchUnit.setWorktypeList(worktypeList); + if(CollectionUtils.isNotEmpty(dispatchUnitList)){ + for (DispatchUnit dispatchUnit:dispatchUnitList) { + List<Worktype> worktypeList = worktypeMapper.selectList(new QueryWrapper<Worktype>().lambda() + .eq(Worktype::getIsdeleted,Constants.ZERO) + .eq(Worktype::getDataType,Constants.TWO) + .eq(Worktype::getStatus,Constants.ZERO) + .apply("id in ( select dw.work_type_id from du_worktype dw where dw.status = 1" + + " and dw.du_solution_id = "+dispatchUnit.getDuSolutionId()+" )") + ); + dispatchUnit.setWorktypeList(worktypeList); + } + } + }else{ + //鏂规涓嶉�夋嫨娲鹃仯鍗曚綅鎯呭喌涓嬬殑涓氬姟 + solutionWorktypeList = solutionWorktypeJoinMapper.selectJoinList(SolutionWorktype.class, + new MPJLambdaWrapper<SolutionWorktype>() + .selectAll(SolutionWorktype.class) + .selectAs(Worktype::getName,SolutionWorktype::getWorktypeName) + .leftJoin(Worktype.class,Worktype::getId,SolutionWorktype::getWorktypeId) + .eq(SolutionWorktype::getSolutionId,solutions.getId()) + ); + if(CollectionUtils.isEmpty(solutionWorktypeList)){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝淇濋櫓鏂规涓嬫湭鏌ヨ鍒板伐绉嶄俊鎭�"); } } + //String pattern = "^[\\u4e00-\\u9fa5\\d路]+$"; + String pattern = "^[\\u4e00-\\u9fa5路]*$"; + Pattern r = Pattern.compile(pattern); index = Constants.TWO; for(MemberImport model : dataList){ - //鏍¢獙浜哄憳鏄惁宸茬粡鍦ㄥ弬淇濅腑 - isMemberValidForSolution(model,index,solutionId); + Matcher m = r.matcher(model.getName()); + if (!m.matches()) { + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝"+model.getName() + "濮撳悕鏃犳晥锛岃妫�鏌ュ悗閲嶈瘯"); + } //妫�鏌ユ淳閬e崟浣嶅拰宸ョ鏈夋晥鎬� - dealDuAndWorktype(model,index,dispatchUnitList); + dealDuAndWorktype(model,index,dispatchUnitList,solutions,solutionWorktypeList); index += 1; + model.setSex(Constants.getSexByIdCard(model.getIdCard())); } return dataList; } - private void isMemberValidForSolution(MemberImport model, int index, Integer solutionId) { - /* ApplyDetail detail = applyDetailJoinMapper.selectJoinOne(ApplyDetail.class,new MPJLambdaWrapper<ApplyDetail>() - .last("limit 1")); - if(detail!=null){ - throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+index+"琛岃韩浠借瘉涓恒��"+model.getIdCard()+"銆戜汉鍛樺凡缁忓湪璇ユ柟妗堜笅瀛樺湪鎶曚繚璁板綍锛�"); - }*/ - } - private void dealDuAndWorktype(MemberImport model, int index, List<DispatchUnit> dispatchUnitList ) { - - if(CollectionUtils.isNotEmpty(dispatchUnitList)){ - Optional<DispatchUnit> dispatchUnitOptional= dispatchUnitList.stream().filter(m->m.getName().equals(model.getDuName())).findFirst(); - if(dispatchUnitOptional.isPresent()){ - DispatchUnit dispatchUnit = dispatchUnitOptional.get(); - model.setDuId(dispatchUnit.getId()); - if(StringUtils.isNotBlank(model.getWorkTypeName())&&CollectionUtils.isNotEmpty(dispatchUnit.getWorktypeList())){ - Optional<Worktype> worktypeOptional= dispatchUnit.getWorktypeList().stream().filter(m->m.getName().equals(model.getWorkTypeName())).findFirst(); - if(worktypeOptional.isPresent()){ - Worktype worktype = worktypeOptional.get(); - model.setWorktypeId(worktype.getId()); + private void dealDuAndWorktype(MemberImport model, int index, List<DispatchUnit> dispatchUnitList , Solutions solutions,List<SolutionWorktype> solutionWorktypeList) { + //2024骞�11鏈�6鏃�15:39:10 鍔犲叆 鏍规嵁鏂规鏄惁鏈変繚闄╂柟妗堣繘琛屽垽鏂� + if(Constants.equalsInteger(solutions.getHasDispatchUnit(),Constants.ZERO)){ + if(CollectionUtils.isNotEmpty(dispatchUnitList)){ + Optional<DispatchUnit> dispatchUnitOptional= dispatchUnitList.stream().filter(m->m.getName().equals(model.getDuName())).findFirst(); + if(dispatchUnitOptional.isPresent()){ + DispatchUnit dispatchUnit = dispatchUnitOptional.get(); + model.setDuId(dispatchUnit.getId()); + if(StringUtils.isNotBlank(model.getWorkTypeName())&&CollectionUtils.isNotEmpty(dispatchUnit.getWorktypeList())){ + Optional<Worktype> worktypeOptional= dispatchUnit.getWorktypeList().stream().filter(m->m.getName().replaceAll(" ","").equals(model.getWorkTypeName().replaceAll(" ",""))).findFirst(); + if(worktypeOptional.isPresent()){ + Worktype worktype = worktypeOptional.get(); + model.setWorktypeId(worktype.getId()); + } } } } - } - if(Objects.isNull(model.getDuId())){ - throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+index+"琛屾暟鎹淳閬e崟浣嶃��"+model.getDuName()+"銆戜笉姝g‘锛�"); + if(Objects.isNull(model.getDuId())){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+index+"琛屾暟鎹淳閬e崟浣嶃��"+model.getDuName()+"銆戜笉姝g‘锛�"); + } + }else{ + Optional<SolutionWorktype> worktypeOptional= solutionWorktypeList.stream().filter(m->m.getWorktypeName().replaceAll(" ","") + .equals(model.getWorkTypeName().replaceAll(" ",""))).findFirst(); + if(worktypeOptional.isPresent()){ + SolutionWorktype worktype = worktypeOptional.get(); + model.setWorktypeId(worktype.getId()); + } } if(Objects.isNull(model.getWorktypeId())){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+index+"琛屾暟鎹伐绉嶃��"+model.getWorkTypeName()+"銆戜笉姝g‘锛�"); } } - private void validImportParam(MemberImport model, Map<String, String> idCardMap, List<MemberImport> dataList,int index,Integer solutionId) { + private void validImportParam(MemberImport model, Map<String, String> idCardMap, List<MemberImport> dataList,int index,Solutions solutions) { if(StringUtils.isBlank(model.getName())){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+index+"琛屾暟鎹鍚嶄笉鑳戒负绌猴紒"); } if(StringUtils.isBlank(model.getIdCard())){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+index+"琛屾暟鎹韩浠借瘉鍙蜂笉鑳戒负绌猴紒"); } - if(StringUtils.isBlank(model.getDuName())){ - throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+index+"琛屾暟鎹淳閬e崟浣嶄笉鑳戒负绌猴紒"); + //2024骞�11鏈�6鏃�15:39:10 鍔犲叆 鏍规嵁鏂规鏄惁鏈変繚闄╂柟妗堣繘琛屽垽鏂� + if(Constants.equalsInteger(solutions.getHasDispatchUnit(),Constants.ZERO)){ + if(StringUtils.isBlank(model.getDuName())){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+index+"琛屾暟鎹淳閬e崟浣嶄笉鑳戒负绌猴紒"); + } } if(StringUtils.isBlank(model.getWorkTypeName())){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗�"+index+"琛屾暟鎹伐绉嶄笉鑳戒负绌猴紒"); -- Gitblit v1.9.3