| | |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.excel.ExcelReplaceCommon; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.dto.YwSmsEmailBillCallDTO; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.business.vo.YwContractBillCallDataVO; |
| | | import com.doumee.dao.business.vo.YwContractBillDataVO; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import lombok.extern.java.Log; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.checkerframework.checker.units.qual.C; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.Charset; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private YwTempConfigMapper ywTempConfigMapper; |
| | | |
| | | |
| | | @Override |
| | |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"è´¦åæ°æ®é误ï¼è¯·å·æ°éè¯"); |
| | | } |
| | | this.dealRoomDetail(ywContractBillList); |
| | | for (YwContractBill ywContractBill:ywContractBillList) { |
| | | YwContractBillCallDataVO ywContractBillCallDataVO = new YwContractBillCallDataVO(); |
| | | ywContractBillCallDataVO.setBillId(ywContractBill.getId()); |
| | |
| | | } |
| | | |
| | | |
| | | public void downloadCallFeeDoc(List<Integer> billIds){ |
| | | List<YwContractBill> ywContractBillList = ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>() |
| | | .selectAll(YwContractBill.class) |
| | | .selectAs(YwCustomer::getName,YwContractBill::getCustomerName) |
| | | .selectAs(YwCustomer::getUserId,YwContractBill::getCustomerUserId) |
| | | .selectAs(YwCustomer::getId,YwContractBill::getCustomerId) |
| | | .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId) |
| | | .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId) |
| | | .in(YwContractBill::getId,billIds) |
| | | ); |
| | | @Override |
| | | public void downloadCallFeeDoc(List<Integer> billIds, LoginUserInfo loginUserInfo,HttpServletResponse response){ |
| | | try { |
| | | List<YwContractBill> ywContractBillList = ywContractBillMapper.selectJoinList(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>() |
| | | .selectAll(YwContractBill.class) |
| | | .selectAs(YwCustomer::getName,YwContractBill::getCustomerName) |
| | | .selectAs(YwCustomer::getUserId,YwContractBill::getCustomerUserId) |
| | | .selectAs(YwCustomer::getId,YwContractBill::getCustomerId) |
| | | .selectAs(YwContractDetail::getPrice,YwContractBill::getPrice) |
| | | .selectAs(YwContract::getCompanyId,YwContractBill::getCompanyId) |
| | | .selectAs(YwContractDetail::getCircleType,YwContractBill::getCircleType) |
| | | .selectAs(YwContractDetail::getType,YwContractBill::getDetailType) |
| | | .selectAs(YwContract::getZlPayType,YwContractBill::getZlPayType) |
| | | .selectAs(YwContract::getWyPayType,YwContractBill::getWyPayType) |
| | | .select(" ( select ifnull(sum(r.rent_area),0) from yw_room y left join yw_contract_room yr on y.id = yr.room_id where yr.contract_id = t.contract_id and y.IS_INVESTMENT = 0 and yr.type = 0 ) " , YwContractBill::getTotalArea) |
| | | .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId) |
| | | .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId) |
| | | .leftJoin(YwContractDetail.class,YwContractDetail::getId,YwContractBill::getDetailId) |
| | | .in(YwContractBill::getId,billIds) |
| | | ); |
| | | List<YwTempConfig> ywTempConfigList = ywTempConfigMapper.selectList(new QueryWrapper<YwTempConfig>().lambda().eq(YwTempConfig::getIsdeleted,Constants.ZERO)); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywTempConfigList)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"æªæ¥è¯¢å°æ¨¡æ¿é
置项,请è系管çå"); |
| | | } |
| | | List<YwTempConfig> tempList = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.FOUR)|| |
| | | Constants.equalsInteger(i.getType(),Constants.FIVE)|| |
| | | Constants.equalsInteger(i.getType(),Constants.SIX)).collect(Collectors.toList()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(tempList)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"æªæ¥è¯¢å°æ¨¡æ¿é
置项,请è系管çå"); |
| | | } |
| | | List<File> fileList = new ArrayList<>(); |
| | | for (YwContractBill ywContractBill:ywContractBillList) { |
| | | this.dealTempData(tempList,ywContractBill,loginUserInfo); |
| | | String fileName = "å¬è´¹éç¥å_" +ywContractBill.getCode() +"_" + System.currentTimeMillis()+".docx"; |
| | | YwTempConfig ywTempConfig = new YwTempConfig(); |
| | | if(Constants.equalsInteger(ywContractBill.getType(),Constants.ZERO)){ |
| | | Optional<YwTempConfig> optional = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.TWO)).findAny(); |
| | | if (optional.isPresent()) { |
| | | ywTempConfig = optional.get(); |
| | | } |
| | | }else{ |
| | | Optional<YwTempConfig> optional = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.THREE)).findAny(); |
| | | if (optional.isPresent()) { |
| | | ywTempConfig = optional.get(); |
| | | } |
| | | } |
| | | if(Objects.isNull(ywTempConfig)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"模æ¿ä¿¡æ¯å¼å¸¸,请è系管çå"); |
| | | } |
| | | String path = ExcelReplaceCommon.modifyWordTemplate(ywTempConfig.getUrl(),tempList,fileName); |
| | | File f = new File(path); |
| | | if(f !=null && f.isFile()){ |
| | | fileList.add(f); |
| | | } |
| | | if(fileList == null || fileList.size() == 0){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | } |
| | | String fileName = "å¬è´¹éç¥å-" +System.currentTimeMillis(); |
| | | String encodeFileName = URLEncoder.encode(fileName, Charset.forName("UTF-8").toString())+".zip"; |
| | | response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName); |
| | | response.setContentType("application/octet-stream"); |
| | | response.setHeader("eva-opera-type", "download"); |
| | | response.setHeader("eva-download-filename", encodeFileName); |
| | | Constants.packFilesToZip(fileList,response.getOutputStream()); |
| | | } catch (Exception e) { |
| | | throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void dealTempData(List<YwTempConfig> ywTempConfigList , YwContractBill ywContractBill, LoginUserInfo loginUserInfo){ |
| | | //æ¥è¯¢æ¶æ¯è´¦å·æ°æ® |
| | | |
| | | for (YwTempConfig y:ywTempConfigList) { |
| | | if(y.getTitle().equals("${è´¹ç¨åç§°}")&&Objects.nonNull(ywContractBill.getCostType())){ |
| | | //è´¹ç¨ç±»åï¼0=ç§èµè´¹ï¼1=ç©ä¸è´¹ï¼2=ç§èµæ¼éï¼3=ç©ä¸æ¼éï¼4=æ°´çµè´¹ï¼5=æé¡¹è´¹ï¼6=å
¶ä»; 7=ä¿è¯é |
| | | if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.ZERO)){ |
| | | y.setUrl("ç§èµè´¹"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.ONE)){ |
| | | y.setUrl("ç©ä¸è´¹"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.TWO)){ |
| | | y.setUrl("ç§èµæ¼é"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.THREE)){ |
| | | y.setUrl("ç©ä¸æ¼é"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.FOUR)){ |
| | | y.setUrl("æ°´çµè´¹"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.FIVE)){ |
| | | y.setUrl("æé¡¹è´¹"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.SIX)){ |
| | | y.setUrl("å
¶ä»"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getCostType(),Constants.SEVEN)){ |
| | | y.setUrl("ä¿è¯é"); |
| | | } |
| | | }else if(y.getTitle().equals("${è®¡è´¹å¨æ}")&&Objects.nonNull(ywContractBill.getDetailType())){ |
| | | if(Constants.equalsInteger(ywContractBill.getDetailType(),Constants.ZERO)){ |
| | | //ç§èµæ¯ä»æ¹å¼ 0=䏿¬¡æ§ä»æ¬¾ï¼1=æ¯ä¸ä¸ªæä¸ä»ï¼2=å
个æä¸ä»ï¼3=ä¸å¹´ä¸ä» |
| | | if(Objects.nonNull(ywContractBill.getZlPayType())){ |
| | | if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.ZERO)){ |
| | | y.setUrl("䏿¬¡æ§ä»æ¬¾"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.ONE)){ |
| | | y.setUrl("æ¯ä¸ä¸ªæä¸ä»"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.TWO)){ |
| | | y.setUrl("å
个æä¸ä»"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getZlPayType(),Constants.THREE)){ |
| | | y.setUrl("ä¸å¹´ä¸ä»"); |
| | | } |
| | | } |
| | | }else{ |
| | | //ç©ä¸æ¯ä»æ¹å¼ 0=䏿¬¡æ§ä»æ¬¾ï¼1=æ¯ä¸ä¸ªæä¸ä»ï¼2=å
个æä¸ä»ï¼3=ä¸å¹´ä¸ä» |
| | | if(Objects.nonNull(ywContractBill.getWyPayType())){ |
| | | if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.ZERO)){ |
| | | y.setUrl("䏿¬¡æ§ä»æ¬¾"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.ONE)){ |
| | | y.setUrl("æ¯ä¸ä¸ªæä¸ä»"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.TWO)){ |
| | | y.setUrl("å
个æä¸ä»"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getWyPayType(),Constants.THREE)){ |
| | | y.setUrl("ä¸å¹´ä¸ä»"); |
| | | } |
| | | } |
| | | } |
| | | }else if(y.getTitle().equals("${åä»·}")&&Objects.nonNull(ywContractBill.getPrice())){ |
| | | y.setUrl(ywContractBill.getPrice().toString()); |
| | | }else if(y.getTitle().equals("${åä½}")&&Objects.nonNull(ywContractBill.getCircleType())){ |
| | | //仿¬¾å¨æç±»å 0=å
æ¯å¹³ç±³å¤©;1=å
æ¯å¹³ç±³æ;2=å
æ¯å¹³ç±³å¹´;3=å
æ¯å¤©;4=å
æ¯æ;5=å
æ¯å¹´;6=å
æ¯åº; |
| | | if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ZERO)){ |
| | | y.setUrl("å
æ¯å¹³ç±³å¤©"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){ |
| | | y.setUrl("å
æ¯å¹³ç±³æ"); |
| | | }else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){ |
| | | y.setUrl("å
æ¯å¹³ç±³å¹´"); |
| | | } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){ |
| | | y.setUrl("å
æ¯å¤©"); |
| | | } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){ |
| | | y.setUrl("å
æ¯æ"); |
| | | } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){ |
| | | y.setUrl("å
æ¯å¹´"); |
| | | } else if(Constants.equalsInteger(ywContractBill.getCircleType(),Constants.ONE)){ |
| | | y.setUrl("å
æ¯åº"); |
| | | } |
| | | }else if(y.getTitle().equals("${åºæ¶æ¥æ}")&&Objects.nonNull(ywContractBill.getPlanPayDate())){ |
| | | y.setUrl(DateUtil.formatDate(ywContractBill.getPlanPayDate(),"yyyy-MM-dd")); |
| | | }else if(y.getTitle().equals("${åºæ¶éé¢}")&&Objects.nonNull(ywContractBill.getReceivableFee())){ |
| | | y.setUrl(ywContractBill.getReceivableFee().toString()); |
| | | }else if(y.getTitle().equals("${è´¦å夿³¨}")){ |
| | | if(StringUtils.isNotBlank(ywContractBill.getRemark())){ |
| | | y.setUrl(ywContractBill.getRemark()); |
| | | }else{ |
| | | y.setUrl(""); |
| | | } |
| | | }else if(y.getTitle().equals("${ç§å®¢åç§°}")&&StringUtils.isNotBlank(ywContractBill.getCustomerName())){ |
| | | y.setUrl(ywContractBill.getCustomerName()); |
| | | }else if(y.getTitle().equals("${楼å®/楼å±/æ¿æº}")){ |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywContractBill.getYwContractRoomList())){ |
| | | StringBuilder roomPathName = new StringBuilder(); |
| | | for (YwContractRoom ywContractRoom:ywContractBill.getYwContractRoomList()) { |
| | | if(StringUtils.isNotBlank(ywContractRoom.getProjectName())){ |
| | | roomPathName.append(ywContractRoom.getProjectName()+"/"); |
| | | } |
| | | if(StringUtils.isNotBlank(ywContractRoom.getBuildingName())){ |
| | | roomPathName.append(ywContractRoom.getBuildingName()+"/"); |
| | | } |
| | | if(StringUtils.isNotBlank(ywContractRoom.getFloorName())){ |
| | | roomPathName.append(ywContractRoom.getFloorName()+"/"); |
| | | } |
| | | if(StringUtils.isNotBlank(ywContractRoom.getRoomName())){ |
| | | roomPathName.append(ywContractRoom.getRoomName()); |
| | | } |
| | | if(StringUtils.isNotBlank(roomPathName)){ |
| | | roomPathName.append(";"); |
| | | } |
| | | } |
| | | y.setUrl(roomPathName.toString()); |
| | | } |
| | | }else if(y.getTitle().equals("${ç§èµé¢ç§¯}")&&Objects.nonNull(ywContractBill.getTotalArea())){ |
| | | y.setUrl(ywContractBill.getTotalArea().toString()); |
| | | }else if(y.getTitle().equals("${æå±å
¬å¸è´¦æ·åç§°}")){ |
| | | y.setUrl("æå±å
¬å¸è´¦æ·åç§°"); |
| | | }else if(y.getTitle().equals("${æå±å
¬å¸é¶è¡è´¦å·}")){ |
| | | y.setUrl("æå±å
¬å¸é¶è¡è´¦å·"); |
| | | }else if(y.getTitle().equals("${æå±å
¬å¸å¼æ·é¶è¡}")){ |
| | | y.setUrl("æå±å
¬å¸å¼æ·é¶è¡"); |
| | | }else if(y.getTitle().equals("${éç¥åçææ¥æ}")){ |
| | | y.setUrl(DateUtil.formatDate(new Date(),"yyyy-MM-dd")); |
| | | }else if(y.getTitle().equals("${å½åç¨æ·å§å}")){ |
| | | y.setUrl(loginUserInfo.getRealname()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public void sendSmsEmail(List<YwSmsEmailBillCallDTO> ywSmsEmailBillCallDTOList,LoginUserInfo loginUserInfo){ |
| | | if(CollectionUtils.isEmpty(ywSmsEmailBillCallDTOList)){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | List<YwTempConfig> ywTempConfigList = ywTempConfigMapper.selectList(new QueryWrapper<YwTempConfig>().lambda().eq(YwTempConfig::getIsdeleted,Constants.ZERO)); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywTempConfigList)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"æªæ¥è¯¢å°æ¨¡æ¿é
置项,请è系管çå"); |
| | | } |
| | | List<YwTempConfig> tempList = ywTempConfigList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.FOUR)|| |
| | | Constants.equalsInteger(i.getType(),Constants.FIVE)|| |
| | | Constants.equalsInteger(i.getType(),Constants.SIX)).collect(Collectors.toList()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(tempList)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"æªæ¥è¯¢å°æ¨¡æ¿é
置项,请è系管çå"); |
| | | } |
| | | for (YwSmsEmailBillCallDTO ywSmsEmailBillCallDTO:ywSmsEmailBillCallDTOList) { |
| | | if(Objects.isNull(ywSmsEmailBillCallDTO) |
| | | || Objects.isNull(ywSmsEmailBillCallDTO.getBillId()) |
| | | || Objects.isNull(ywSmsEmailBillCallDTO.getUserId()) |
| | | ||Objects.isNull(ywSmsEmailBillCallDTO.getSendEmail()) |
| | | || Objects.isNull(ywSmsEmailBillCallDTO.getSendSms())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | |
| | | YwContractBill ywContractBill = ywContractBillMapper.selectJoinOne(YwContractBill.class,new MPJLambdaWrapper<YwContractBill>() |
| | | .selectAll(YwContractBill.class) |
| | | .selectAs(YwCustomer::getName,YwContractBill::getCustomerName) |
| | | .selectAs(YwCustomer::getUserId,YwContractBill::getCustomerUserId) |
| | | .selectAs(YwCustomer::getId,YwContractBill::getCustomerId) |
| | | .selectAs(YwContractDetail::getPrice,YwContractBill::getPrice) |
| | | .selectAs(YwContract::getCompanyId,YwContractBill::getCompanyId) |
| | | .selectAs(YwContractDetail::getCircleType,YwContractBill::getCircleType) |
| | | .selectAs(YwContractDetail::getType,YwContractBill::getDetailType) |
| | | .selectAs(YwContract::getZlPayType,YwContractBill::getZlPayType) |
| | | .selectAs(YwContract::getWyPayType,YwContractBill::getWyPayType) |
| | | .select(" ( select ifnull(sum(r.rent_area),0) from yw_room y left join yw_contract_room yr on y.id = yr.room_id where yr.contract_id = t.contract_id and y.IS_INVESTMENT = 0 and yr.type = 0 ) " , YwContractBill::getTotalArea) |
| | | .leftJoin(YwContract.class,YwContract::getId,YwContractBill::getContractId) |
| | | .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId) |
| | | .leftJoin(YwContractDetail.class,YwContractDetail::getId,YwContractBill::getDetailId) |
| | | .eq(YwContractBill::getId,ywSmsEmailBillCallDTO.getBillId()) |
| | | .last( "limit 1" ) |
| | | ); |
| | | this.dealTempData(tempList,ywContractBill,loginUserInfo); |
| | | Member member = memberMapper.selectById(ywSmsEmailBillCallDTO.getUserId()); |
| | | if(Objects.isNull(member)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"å卿ªæ¥è¯¢å°ç人åä¿¡æ¯"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | for (YwSmsEmailBillCallDTO ywSmsEmailBillCallDTO:ywSmsEmailBillCallDTOList) { |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |