java110-bean/src/main/java/com/java110/po/car/CarInoutFeeHistoryPo.java
@@ -31,6 +31,26 @@ private String primeRateName; private String transferorName; private String remark; public String getTransferorName() { return transferorName; } public void setTransferorName(String transferorName) { this.transferorName = transferorName; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } public String getPrimeRateName() { return primeRateName; } java110-bean/src/main/java/com/java110/vo/FeeQueryParams.java
@@ -11,6 +11,26 @@ private Integer endYear; private List<PayFeePo> payFeePos; private BigDecimal[][] reports; private Integer row; private Integer page; public Integer getRow() { return row; } public void setRow(Integer row) { this.row = row; } public Integer getPage() { return page; } public void setPage(Integer page) { this.page = page; } // getters and setters public String getCommunityId() { java110-db/src/main/resources/mapper/common/CarInoutFeeHistoryServiceDaoImplMapper.xml
@@ -4,8 +4,8 @@ <mapper namespace="carInoutFeeHistoryDaoImpl"> <insert id="saveCarInoutFeeHistory" parameterType="Map"> insert into car_inout_fee_history(id,inout_id,receipt_no,invoice_no,pay_amount,payer_name,prime_rate,pay_time) values (#{id}, #{inoutId}, #{receiptNo}, #{invoiceNo}, #{payAmount}, #{payerName}, #{primeRate}, #{payTime}) insert into car_inout_fee_history(id,inout_id,receipt_no,invoice_no,pay_amount,payer_name,prime_rate,pay_time,transferor_name,remark) values (#{id}, #{inoutId}, #{receiptNo}, #{invoiceNo}, #{payAmount}, #{payerName}, #{primeRate}, #{payTime}, #{transferorName}, #{remark}) </insert> <select id="getCarInoutFeeHistory" parameterType="Map" resultType="Map"> @@ -18,7 +18,9 @@ t.payer_name as payerName, t.prime_rate as primeRate, t.pay_time as payTime, td.`name` as primeRateName td.`name` as primeRateName, t.transferor_name as transferorName, t.remark as remark from car_inout_fee_history t left join t_dict td on t.prime_rate = td.status_cd and td.table_name = 'pay_fee_detail' and td.table_columns = 'prime_rate' where 1 =1 java110-db/src/main/resources/mapper/common/CarInoutServiceDaoImplMapper.xml
@@ -82,32 +82,25 @@ t.car_num AS carNum, t.status_cd, t.status_cd AS statusCd, COALESCE(out_rec.state, t.state) AS state, COALESCE(t.state, t.state) AS state, t.community_id, t.community_id AS communityId, t.b_id, t.b_id AS bId, out_rec.out_time, out_rec.out_time AS outTime, td1.name AS stateName, out_rec.payment_amount AS money, t.out_time AS outTime, COALESCE(td1.name, '未支付') AS stateName, t.payment_amount AS money, t.create_time -- 新增排序字段到SELECT列表 FROM car_inout t -- 先左连接出场记录,确保out_rec表在前面定义 LEFT JOIN car_inout out_rec ON t.car_num = out_rec.car_num AND t.b_id = out_rec.b_id AND t.in_time = out_rec.in_time AND t.direction = 'entry' AND out_rec.direction = 'exit' -- 再关联字典表,此时out_rec表已被定义,可以正常引用 INNER JOIN t_dict td1 ON COALESCE(out_rec.state, t.state) = td1.status_cd left JOIN t_dict td1 ON COALESCE(t.state, t.state) = td1.status_cd AND td1.table_name = 'car_inout' AND td1.table_columns = 'state' WHERE t.direction = 'entry' <if test="inTime !=null "> and t.in_time= #{inTime} </if> java110-db/src/main/resources/mapper/community/RoomServiceDaoImplMapper.xml
@@ -976,4 +976,13 @@ limit #{page},#{row} </if> </select> <select id="queryRoomsAsReport" parameterType="Map" resultType="Map"> select br.property_type,bf.floor_num,bu.unit_num,br.room_num,br.door_room_num,br.property_address,br.room_area,bo.`name`,br.room_id from building_room br left join building_unit bu on br.unit_id = bu.unit_id inner join f_floor bf on bu.floor_id = bf.floor_id left join building_owner_room_rel borr on borr.room_id = br.room_id left join building_owner bo on bo.owner_id = borr.owner_id limit 1,10 </select> </mapper> java110-db/src/main/resources/mapper/community/UnitServiceDaoImplMapper.xml
@@ -92,7 +92,7 @@ <select id="getUnitInfo" parameterType="Map" resultType="Map"> select t.floor_id,t.floor_id floorId,t.layer_count,t.layer_count layerCount,t.unit_id,t.unit_id unitId,t.unit_num,t.unit_num unitNum,t.lift,t.status_cd,t.status_cd statusCd,t.remark,t.b_id,t.b_id bId,t.user_id,t.user_id userId,t.unit_area,t.unit_area unitArea,ff.floor_num floorNum bId,t.user_id,t.user_id userId,t.unit_area,t.unit_area unitArea,ff.floor_num floorNum,t.unit_name,t.unit_name unitName from building_unit t left join f_floor ff on t.`floor_id` = ff.`floor_id` and ff.status_cd = '0' where 1 =1 java110-db/src/main/resources/mapper/community/UnitV1ServiceDaoImplMapper.xml
@@ -19,7 +19,7 @@ <select id="getUnitInfo" parameterType="Map" resultType="Map"> select t.floor_id,t.floor_id floorId,t.layer_count,t.layer_count layerCount,t.unit_area,t.unit_area unitArea,t.unit_id,t.unit_id unitId,t.unit_num,t.unit_num unitNum,t.lift,t.remark,t.status_cd,t.status_cd statusCd,t.user_id,t.user_id userId statusCd,t.user_id,t.user_id userId,t.unit_name,t.unit_name unitName from building_unit t where 1 =1 <if test="floorId !=null and floorId != ''"> java110-db/src/main/resources/mapper/fee/ReportFeeServiceDaoImplMapper.xml
@@ -49,6 +49,147 @@ fee_type_cd, detail_year WITH ROLLUP; </select> <select id="repostPaidInFeeByWhiteOrder" resultType="java.util.Map"> WITH RECURSIVE year_ranges AS ( -- 基础查询:获取所有需要的字段并计算起始年份和结束年份 SELECT ROW_NUMBER() OVER () AS row1, bc.`name` AS row2, ROW_NUMBER() OVER () AS row3, pfd.create_time AS row4, pw.invoice_receipt_no AS row5, br.property_address AS row6, br.door_room_num AS row7, CONCAT(pfd.start_time, ' 至 ', pfd.end_time) AS row8, YEAR(pfd.start_time) AS row9, -- 起始年份 YEAR(pfd.end_time) AS row10, -- 结束年份 pfc.fee_name AS row11, pfd.received_amount AS row12, pfd.cashier_name AS row13, pw.bank_deposit_date AS row14, pw.bank_depositor AS row15, pw.bank_deposit_amount AS row16, pw.split_bank_deposit_amount AS row17, pw.check_amount AS row18, pw.white_list_archive_no AS row19, pw.sheet_count AS row20, pw.financial_receiver AS row21, pw.input_time AS row22, pw.input_person AS row23, pw.input_time AS row24, YEAR(pw.input_time) AS row25, pw.license_plate AS row26, pw.category_22 AS row27, -- 额外增加用于递归的当前年份字段 YEAR(pfd.start_time) AS current_year, YEAR(pfd.end_time) AS end_year, -- 保留原始的start_time和end_time用于后续计算 pfd.start_time AS original_start, pfd.end_time AS original_end FROM pay_fee_detail pfd LEFT JOIN s_community bc ON bc.community_id = pfd.community_id LEFT JOIN pay_fee pf ON pf.fee_id = pfd.fee_id LEFT JOIN building_room br ON br.room_id = pf.payer_obj_id LEFT JOIN pay_fee_config pfc ON pf.config_id = pfc.config_id LEFT JOIN property_white_list_flow pw ON pfd.create_time = pw.input_time AND pfd.start_time = pw.charge_start AND pfd.cashier_name = pw.charger WHERE pfd.state = 1400 <if test="communityId != null"> and pfd.community_id = #{communityId} </if> UNION ALL -- 递归查询:生成中间年份记录,保持所有字段一致 SELECT row1, row2, row3, row4, row5, row6, row7, row8, row9, row10, row11, row12, row13, row14, row15, row16, row17, row18, row19, row20, row21, row22, row23, row24, row25, row26, row27, current_year + 1 AS current_year, -- 年份递增 end_year, original_start, original_end FROM year_ranges WHERE current_year + 1 <= end_year -- 递归终止条件 ) -- 最终查询:拆分时间区间并展示结果 SELECT ROW_NUMBER() OVER () as row1, row2, ROW_NUMBER() OVER () as row3, row4, row5, row6, row7, -- 显示当年的时间范围 CONCAT( CASE WHEN current_year = YEAR(original_start) THEN original_start ELSE STR_TO_DATE(CONCAT(current_year, '-01-01'), '%Y-%m-%d') END, ' 至 ', CASE WHEN current_year = YEAR(original_end) THEN original_end ELSE STR_TO_DATE(CONCAT(current_year, '-12-31'), '%Y-%m-%d') END ) AS row9, current_year AS row8, -- 替换为当前年份 row10 as row9, row11 as row10, row12 as row11, row13 as row12, row14 as row13, row15 as row14, row16 as row15, row17 as row16, row18 as row17, row19 as row18, row20 as row19, row21 as row20, row22 as row21, row23 as row22, row24 as row23, row25 as row24, row26 as row25, null as row26; null as row27; row27 as row28, null as row29, null as row30 FROM year_ranges ORDER BY row3, current_year -- 按原始记录顺序和年份排序 <if test="page != -1 and page != null "> limit #{page}, #{row} </if>; </select> <insert id="saveReport" parameterType="Map"> INSERT INTO report_query_record ( id, @@ -97,6 +238,9 @@ <if test="endYear != null and endYear != ''"> AND end_year = #{endYear} </if> <if test="operator != null and operator != ''"> AND operator = #{operator} </if> <if test="queryStatus != null and queryStatus != ''"> AND query_status = #{queryStatus} </if> java110-interface/src/main/java/com/java110/intf/community/IRoomInnerServiceSMO.java
@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import java.util.List; import java.util.Map; /** * @ClassName IRoomInnerServiceSMO @@ -113,4 +114,6 @@ */ @RequestMapping(value = "/freshRoomIdsByImportCustomCreateFee", method = RequestMethod.POST) List<ImportCustomCreateFeeDto> freshRoomIdsByImportCustomCreateFee(@RequestBody List<ImportCustomCreateFeeDto> importCustomCreateFeeDtos); List<Map> queryRoomsAsReport(RoomDto roomDto); } java110-interface/src/main/java/com/java110/intf/fee/IReportFeeInnerServiceSMO.java
@@ -19,4 +19,6 @@ int saveReport(Map map); List<ReportQueryRecord> queryReport(Map map); List<Map> repostPaidInFeeByWhiteOrder(FeeQueryParams feeQueryParams); } service-common/src/main/java/com/java110/common/cmd/carInout/SaveCarInoutFeeHistoryCmd.java
@@ -32,6 +32,7 @@ import com.java110.vo.ResultVo; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import java.util.Date; @@ -62,6 +63,14 @@ Assert.hasKeyAndValue(reqJson, "payAmount", "缴费金额不能为空"); Assert.hasKeyAndValue(reqJson, "primeRate", "缴费方式不能为空"); Assert.hasKeyAndValue(reqJson, "payTime", "缴费时间不能为空"); //当支付方式为转账时,需要校验转账人是否为空 String primeRate = reqJson.getString("primeRate"); if(!StringUtils.isEmpty(primeRate) && primeRate.equals("7")){ String transferorName = reqJson.getString("transferorName"); if(StringUtils.isEmpty(transferorName)){ Assert.hasLength(reqJson.getString("transferorName"), "支付方式为转账时,转账人不能为空"); } } } @Override service-community/src/main/java/com/java110/community/dao/IRoomServiceDao.java
@@ -139,4 +139,5 @@ public List<Map> getRoomInfos(Map info); List<Map> queryRoomsAsReport(Map map); } service-community/src/main/java/com/java110/community/dao/impl/RoomServiceDaoImpl.java
@@ -209,6 +209,11 @@ return infos; } @Override public List<Map> queryRoomsAsReport(Map info) { List<Map> infos = sqlSessionTemplate.selectList("roomServiceDaoImpl.queryRoomsAsReport", info); return infos; } } service-community/src/main/java/com/java110/community/smo/impl/RoomInnerServiceSMOImpl.java
@@ -351,6 +351,11 @@ return importCustomCreateFeeDtos; } @Override public List<Map> queryRoomsAsReport(RoomDto roomDto) { return roomServiceDaoImpl.queryRoomsAsReport(BeanConvertUtil.beanCovertMap(roomDto)); } public IRoomServiceDao getRoomServiceDaoImpl() { return roomServiceDaoImpl; } service-fee/src/main/java/com/java110/fee/cmd/fee/ReportFeeCmd.java
@@ -67,6 +67,7 @@ reportQueryRecord.setCommunityId(reqJson.getString("communityId")); reportQueryRecord.setQueryStatus("0"); reportQueryRecord.setEndYear(currentYear+""); reportQueryRecord.setOperator("白单流水汇总表"); List<ReportQueryRecord> reportQueryRecords = reportFeeInnerServiceSMOImpl.queryReport(BeanConvertUtil.beanCovertMap(reportQueryRecord)); if(reportQueryRecords.size()>0 && !reqJson.containsKey("reload")){ @@ -99,6 +100,8 @@ reportQueryRecord.setQueryStatus("0"); reportQueryRecord.setEndYear(currentYear+""); reportQueryRecord.setReportContent(JSONObject.toJSONString(feeDto)); reportQueryRecord.setOperator("白单流水汇总表"); int i = reportFeeInnerServiceSMOImpl.saveReport(BeanConvertUtil.beanCovertMap(reportQueryRecord)); @@ -216,11 +219,11 @@ if(i == 3){ if (doubles[i] != 0){ col1Fee[i] = (doubles[i]+col1Fee[i])/2; col2Fee[i] = (doubles[i]+col2Fee[i])/2; // col2Fee[i] = (doubles[i]+col2Fee[i])/2; } }else{ col1Fee[i] += doubleUse(doubles[i]); col2Fee[i] += doubleUse(doubles[i]); // col2Fee[i] += doubleUse(doubles[i]); } } }else{ @@ -228,11 +231,11 @@ if(i == 3){ if (doubles[i] != 0){ col1Fee[i] = (doubles[i]+col1Fee[i])/2; col2Fee[i] = (doubles[i]+col2Fee[i])/2; // col2Fee[i] = (doubles[i]+col2Fee[i])/2; } }else{ col1Fee[i] += doubleUse(doubles[i]); col2Fee[i] += doubleUse(doubles[i]); // col2Fee[i] += doubleUse(doubles[i]); } } } service-fee/src/main/java/com/java110/fee/cmd/fee/ReportFeePropertyCmd.java
New file @@ -0,0 +1,108 @@ package com.java110.fee.cmd.fee; import com.alibaba.fastjson.JSONObject; import com.java110.core.annotation.Java110Cmd; import com.java110.core.context.ICmdDataFlowContext; import com.java110.core.event.cmd.Cmd; import com.java110.core.event.cmd.CmdEvent; import com.java110.dto.community.CommunityDto; import com.java110.dto.dict.DictDto; import com.java110.dto.fee.FeeDto; import com.java110.dto.report.ReportQueryRecord; import com.java110.dto.room.RoomDto; import com.java110.intf.community.ICommunityInnerServiceSMO; import com.java110.intf.community.IRoomInnerServiceSMO; import com.java110.intf.dev.IDictV1InnerServiceSMO; import com.java110.intf.fee.IReportFeeInnerServiceSMO; import com.java110.utils.exception.CmdException; import com.java110.utils.util.Assert; import com.java110.utils.util.BeanConvertUtil; import com.java110.vo.FeeQueryParams; import com.java110.vo.ResultVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import java.math.BigDecimal; import java.text.ParseException; import java.util.LinkedList; import java.util.List; import java.util.Map; @Java110Cmd(serviceCode = "fee.reportPropertyFeeCmd") public class ReportFeePropertyCmd extends Cmd { @Autowired private IReportFeeInnerServiceSMO reportFeeInnerServiceSMOImpl; @Autowired private ICommunityInnerServiceSMO communityInnerServiceSMOImpl; @Autowired private IDictV1InnerServiceSMO dictV1InnerServiceSMOImpl; @Autowired private IRoomInnerServiceSMO roomInnerServiceSMOImpl; @Override public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { Assert.hasKey(reqJson, "communityId", "请求报文中未包含小区编号"); } @Override public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { int startYear = 2020; CommunityDto communityDto = new CommunityDto(); communityDto.setCommunityId(reqJson.getString("communityId")); List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto); FeeQueryParams feeQueryParams = new FeeQueryParams(); feeQueryParams.setCommunityId(reqJson.getString("communityId")); feeQueryParams.setStartYear(startYear); int currentYear = java.time.Year.now().getValue(); feeQueryParams.setEndYear(currentYear + 2); if(reqJson.containsKey("endYear") && !reqJson.get("endYear").equals("") && reqJson.get("endYear") != null) { currentYear=Integer.parseInt(reqJson.get("endYear")+""); feeQueryParams.setEndYear(Integer.parseInt(reqJson.get("endYear")+"")+2); } int endYear = feeQueryParams.getEndYear(); int doYear = endYear - startYear; ReportQueryRecord reportQueryRecord = new ReportQueryRecord(); reportQueryRecord.setCommunityId(reqJson.getString("communityId")); reportQueryRecord.setQueryStatus("0"); reportQueryRecord.setEndYear(currentYear+""); reportQueryRecord.setOperator("白单流水物业表"); List<ReportQueryRecord> reportQueryRecords = reportFeeInnerServiceSMOImpl.queryReport(BeanConvertUtil.beanCovertMap(reportQueryRecord)); if(reportQueryRecords.size()>0 && !reqJson.containsKey("reload")){ ResultVo resultVo = new ResultVo(JSONObject.parse(reportQueryRecords.get(reportQueryRecords.size()-1).getReportContent())); ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); context.setResponseEntity(responseEntity); } else{ RoomDto roomDto = new RoomDto(); roomDto.setRoomId(reqJson.getString("communityId")); List<Map> rooms = roomInnerServiceSMOImpl.queryRoomsAsReport(roomDto); reportQueryRecord.setCommunityId(reqJson.getString("communityId")); reportQueryRecord.setQueryStatus("0"); reportQueryRecord.setEndYear(currentYear+""); // reportQueryRecord.setReportContent(JSONObject.toJSONString()); reportQueryRecord.setOperator("白单流水物业表"); // int i = reportFeeInnerServiceSMOImpl.saveReport(BeanConvertUtil.beanCovertMap(reportQueryRecord)); ResultVo resultVo = new ResultVo(); ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); context.setResponseEntity(responseEntity); } } } service-fee/src/main/java/com/java110/fee/cmd/fee/ReportFeeWriteOrderCmd.java
New file @@ -0,0 +1,112 @@ package com.java110.fee.cmd.fee; import com.alibaba.fastjson.JSONObject; import com.java110.core.annotation.Java110Cmd; import com.java110.core.context.ICmdDataFlowContext; import com.java110.core.event.cmd.Cmd; import com.java110.core.event.cmd.CmdEvent; import com.java110.dto.community.CommunityDto; import com.java110.dto.dict.DictDto; import com.java110.dto.fee.FeeDto; import com.java110.dto.report.ReportQueryRecord; import com.java110.intf.community.ICommunityInnerServiceSMO; import com.java110.intf.dev.IDictV1InnerServiceSMO; import com.java110.intf.fee.IReportFeeInnerServiceSMO; import com.java110.utils.exception.CmdException; import com.java110.utils.util.Assert; import com.java110.utils.util.BeanConvertUtil; import com.java110.vo.FeeQueryParams; import com.java110.vo.ResultVo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import java.math.BigDecimal; import java.text.ParseException; import java.util.LinkedList; import java.util.List; import java.util.Map; @Java110Cmd(serviceCode = "fee.whiteOrderReportFeeCmd") public class ReportFeeWriteOrderCmd extends Cmd { @Autowired private IReportFeeInnerServiceSMO reportFeeInnerServiceSMOImpl; @Autowired private ICommunityInnerServiceSMO communityInnerServiceSMOImpl; @Autowired private IDictV1InnerServiceSMO dictV1InnerServiceSMOImpl; @Override public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { Assert.hasKey(reqJson, "communityId", "请求报文中未包含小区编号"); } @Override public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException { // int startYear = 2020; // CommunityDto communityDto = new CommunityDto(); // communityDto.setCommunityId(reqJson.getString("communityId")); // List<CommunityDto> communityDtos = communityInnerServiceSMOImpl.queryCommunitys(communityDto); // FeeQueryParams feeQueryParams = new FeeQueryParams(); // feeQueryParams.setCommunityId(reqJson.getString("communityId")); // feeQueryParams.setStartYear(startYear); // int currentYear = java.time.Year.now().getValue(); // feeQueryParams.setEndYear(currentYear + 2); // if(reqJson.containsKey("endYear") && !reqJson.get("endYear").equals("") && reqJson.get("endYear") != null) { // currentYear=Integer.parseInt(reqJson.get("endYear")+""); // feeQueryParams.setEndYear(Integer.parseInt(reqJson.get("endYear")+"")+2); // } // int endYear = feeQueryParams.getEndYear(); // int doYear = endYear - startYear; // ReportQueryRecord reportQueryRecord = new ReportQueryRecord(); reportQueryRecord.setCommunityId(reqJson.getString("communityId")); reportQueryRecord.setQueryStatus("0"); reportQueryRecord.setOperator("白单流水表"); List<ReportQueryRecord> reportQueryRecords = reportFeeInnerServiceSMOImpl.queryReport(BeanConvertUtil.beanCovertMap(reportQueryRecord)); if(reportQueryRecords.size()>0 && !reqJson.containsKey("reload")){ ResultVo resultVo = new ResultVo(JSONObject.parse(reportQueryRecords.get(reportQueryRecords.size()-1).getReportContent())); ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); context.setResponseEntity(responseEntity); } else{ FeeQueryParams feeQueryParams = new FeeQueryParams(); feeQueryParams.setCommunityId(reqJson.getString("communityId")); feeQueryParams.setRow(reqJson.containsKey("row") ? Integer.valueOf(reqJson.getString("row")) : 20); feeQueryParams.setPage(reqJson.containsKey("page")? Integer.valueOf(reqJson.get("page").toString()) :1); List<Map> result = reportFeeInnerServiceSMOImpl.repostPaidInFeeByWhiteOrder(feeQueryParams); String[][] reportList = new String[feeQueryParams.getRow()][]; for (int i = 0; i < result.size(); i++) { Map map = result.get(i); String[] strings = new String[29]; for (int j = 1; j <= 27; j++) { strings[j-1] = map.get("row"+j).toString(); } reportList[i] = strings; } reportQueryRecord.setEndYear("2025"); reportQueryRecord.setCommunityId(reqJson.getString("communityId")); reportQueryRecord.setQueryStatus("0"); reportQueryRecord.setReportContent(JSONObject.toJSONString(reportList)); reportQueryRecord.setOperator("白单流水表"); int i = reportFeeInnerServiceSMOImpl.saveReport(BeanConvertUtil.beanCovertMap(reportQueryRecord)); ResultVo resultVo = new ResultVo(reportList); ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK); context.setResponseEntity(responseEntity); } } } service-fee/src/main/java/com/java110/fee/dao/IReportFeeServiceDao.java
@@ -15,4 +15,6 @@ int saveReport(Map map); List<ReportQueryRecord> queryReport(Map map); List<Map> repostPaidInFeeByWhiteOrder(Map map); } service-fee/src/main/java/com/java110/fee/dao/impl/IReportFeeServiceDaoImpl.java
@@ -68,4 +68,9 @@ public List<ReportQueryRecord> queryReport(Map map) { return BeanConvertUtil.covertBeanList(sqlSessionTemplate.selectList("reportFeeServiceDaoImpl.queryReport", map), ReportQueryRecord.class); } @Override public List<Map> repostPaidInFeeByWhiteOrder(Map map) { return sqlSessionTemplate.selectList("reportFeeServiceDaoImpl.repostPaidInFeeByWhiteOrder", map); } } service-fee/src/main/java/com/java110/fee/smo/impl/ReportFeeInnerServiceSMOImpl.java
@@ -4,10 +4,12 @@ import com.java110.dto.report.ReportQueryRecord; import com.java110.fee.dao.IReportFeeServiceDao; import com.java110.intf.fee.IReportFeeInnerServiceSMO; import com.java110.utils.util.BeanConvertUtil; import com.java110.vo.FeeQueryParams; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RestController; import java.util.Collections; import java.util.List; import java.util.Map; @@ -36,4 +38,9 @@ return iReportFeeServiceDao.queryReport(map); } @Override public List<Map> repostPaidInFeeByWhiteOrder(FeeQueryParams feeQueryParams) { return iReportFeeServiceDao.repostPaidInFeeByWhiteOrder(BeanConvertUtil.beanCovertMap(feeQueryParams)); } } service-job/src/main/java/com/java110/job/cmd/export/ExportDataCmd.java
@@ -16,9 +16,11 @@ import com.java110.utils.exception.CmdException; import com.java110.utils.util.Assert; import com.java110.utils.util.DateUtil; import com.java110.utils.util.StringUtil; import com.java110.vo.ResultVo; import org.springframework.beans.factory.annotation.Autowired; import java.util.Arrays; import java.util.List; /** @@ -60,12 +62,33 @@ reqJson.put("userId",userId); reqJson.put("storeId",storeId); if ("dataFeeManualCollection".equals(reqJson.getString("pagePath"))) { // 物业费催缴单 List<String> configIds = Arrays.asList(reqJson.getString("configIds").split(",")); List<String> roomIds = Arrays.asList(reqJson.getString("roomIds").split(",")); for (String configId : configIds) { reqJson.put("configId", configId); for (String roomId : roomIds) { reqJson.put("roomId", roomId); this.create(userId, userDtos, reqJson); } } } else { this.create(userId, userDtos, reqJson); } context.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_OK,"文件正在生成,请到文件下载页面下载")); } private void create(String userId, List<UserDto> userDtos, JSONObject reqJson) { ExportDataDto exportDataDto = new ExportDataDto(); exportDataDto.setBusinessAdapt(reqJson.getString("pagePath")); exportDataDto.setReqJson(reqJson); String fileName = GenerateCodeFactory.getUUID() + ".xlsx"; String fileName = ""; if ("dataFeeManualCollection".equals(reqJson.getString("pagePath"))) { fileName = GenerateCodeFactory.getUUID() + ".docx"; } else { fileName = GenerateCodeFactory.getUUID() + ".xlsx"; } exportDataDto.setFileName(EXPORT_DATA_PRE + reqJson.getString("pagePath") + "/" @@ -86,12 +109,7 @@ if (flag < 1) { throw new CmdException("下载文件失败"); } exportDataDto.setDownloadId(userDownloadFilePo.getDownloadId()); ExportDataQueue.addMsg(exportDataDto); context.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_OK,"文件正在生成,请到文件下载页面下载")); } } service-job/src/main/java/com/java110/job/export/ExportDataExecutor.java
@@ -10,10 +10,12 @@ import com.java110.utils.util.ExceptionUtil; import com.java110.utils.util.StringUtil; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.slf4j.Logger; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -66,7 +68,7 @@ ByteArrayInputStream inputStream = null; ByteArrayOutputStream os = null; SXSSFWorkbook workbook = null; Object document = null; String fileName = ""; if (exportDataDto == null) { @@ -81,26 +83,46 @@ return; } updateUserDownloadFile(exportDataDto, UserDownloadFileDto.STATE_DOING,"", "开始下载"); try { workbook = exportDataAdaptImpl.exportData(exportDataDto); document = exportDataAdaptImpl.exportData(exportDataDto); //保存文件路径到 文件下载表 // os = new ByteArrayOutputStream(); // workbook.write(os); // inputStream = new ByteArrayInputStream(os.toByteArray()); // // fileName = fileUploadTemplate.saveFile(inputStream, exportDataDto.getFileName()); // // // updateUserDownloadFile(exportDataDto, UserDownloadFileDto.STATE_FINISH,fileName, "下载完成"); // 根据文档类型,写入流 os = new ByteArrayOutputStream(); workbook.write(os); if (document instanceof SXSSFWorkbook) { ((SXSSFWorkbook) document).write(os); } else if (document instanceof XWPFDocument) { ((XWPFDocument) document).write(os); } inputStream = new ByteArrayInputStream(os.toByteArray()); fileName = fileUploadTemplate.saveFile(inputStream, exportDataDto.getFileName()); fileName = fileUploadTemplate.saveFile(inputStream, exportDataDto.getFileName() + "." + exportDataAdaptImpl.getFileType()); updateUserDownloadFile(exportDataDto, UserDownloadFileDto.STATE_FINISH,fileName, "下载完成"); } catch (Throwable e) { e.printStackTrace(); updateUserDownloadFile(exportDataDto, UserDownloadFileDto.STATE_FAIL, "","下载失败" + ExceptionUtil.getStackTrace(e)); } finally { // 关闭文档对象(针对不同类型的文档进行资源释放) if (document != null) { try { workbook.close(); } catch (Exception e) { if (document instanceof SXSSFWorkbook) { ((SXSSFWorkbook) document).close(); } else if (document instanceof XWPFDocument) { ((XWPFDocument) document).close(); } else if (document instanceof ByteArrayInputStream) { ((ByteArrayInputStream) document).close(); } } catch (IOException e) { log.error("关闭文档对象失败", e); } } try { inputStream.close(); @@ -112,7 +134,6 @@ } catch (Exception e) { } } } service-job/src/main/java/com/java110/job/export/IExportDataAdapt.java
@@ -1,7 +1,6 @@ package com.java110.job.export; import com.java110.dto.data.ExportDataDto; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import java.text.ParseException; @@ -14,5 +13,13 @@ * 导出数据 excel * @param exportDataDto */ SXSSFWorkbook exportData(ExportDataDto exportDataDto) throws ParseException; Object exportData(ExportDataDto exportDataDto) throws ParseException; /** * 获取导出文件类型(如 "xlsx", "docx" ) * 用于后续生成文件名和处理流 */ default String getFileType() { return "xlsx"; } } service-job/src/main/java/com/java110/job/export/adapt/DataFeeManualCollectionAdapt.java
@@ -1,36 +1,32 @@ package com.java110.job.export.adapt; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.core.smo.IComputeFeeSMO; import com.java110.dto.community.CommunityDto; import com.java110.dto.data.ExportDataDto; import com.java110.dto.fee.FeeDto; import com.java110.dto.fee.FeePrintSpecDto; import com.java110.dto.reportFee.ReportOweFeeDto; import com.java110.dto.room.RoomDto; import com.java110.intf.community.ICommunityV1InnerServiceSMO; import com.java110.intf.community.IRoomInnerServiceSMO; import com.java110.intf.community.IRoomV1InnerServiceSMO; import com.java110.intf.fee.IFeeInnerServiceSMO; import com.java110.intf.fee.IFeePrintSpecInnerServiceSMO; import com.java110.intf.report.IReportOweFeeInnerServiceSMO; import com.java110.job.export.IExportDataAdapt; import com.java110.utils.util.*; import com.java110.utils.util.DateUtil; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFClientAnchor; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRun; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import java.awt.image.ImagingOpException; import java.io.IOException; import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.io.InputStream; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; /** @@ -54,352 +50,576 @@ @Autowired private IRoomV1InnerServiceSMO roomV1InnerServiceSMOImpl; @Autowired private ICommunityV1InnerServiceSMO communityV1InnerServiceSMO; private static final int MAX_ROW = 100; // 模板文件路径(放在resources目录下) private static final String DOCX_TEMPLATE_PATH = "templates/fee_reminder_template.docx"; // // @Override // public SXSSFWorkbook exportData(ExportDataDto exportDataDto) { // // JSONObject reqJson = exportDataDto.getReqJson(); // Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区"); // Assert.hasKeyAndValue(reqJson, "configIds", "未包含费用"); // Assert.hasKeyAndValue(reqJson, "roomIds", "未包含房屋"); // // String configIds = reqJson.getString("configIds"); // // String roomIds = reqJson.getString("roomIds"); // // // SXSSFWorkbook workbook = null; //工作簿 // workbook = new SXSSFWorkbook(); // workbook.setCompressTempFiles(false); // // Sheet sheet = workbook.createSheet("催缴单"); // Drawing patriarch = sheet.createDrawingPatriarch(); // // FeePrintSpecDto feePrintSpecDto = new FeePrintSpecDto(); // feePrintSpecDto.setCommunityId(reqJson.getString("communityId")); // feePrintSpecDto.setSpecCd("1010"); // feePrintSpecDto.setPage(1); // feePrintSpecDto.setRow(1); // List<FeePrintSpecDto> feePrintSpecDtos = feePrintSpecInnerServiceSMOImpl.queryFeePrintSpecs(feePrintSpecDto); // // if (ListUtil.isNull(feePrintSpecDtos)) { // feePrintSpecDto = null; // } else { // feePrintSpecDto = feePrintSpecDtos.get(0); // } // int line = 0; // double totalPageHeight = 0; // // RoomDto roomDto = new RoomDto(); // roomDto.setRoomIds(roomIds.split(",")); // roomDto.setCommunityId(reqJson.getString("communityId")); // List<RoomDto> roomDtos = roomV1InnerServiceSMOImpl.queryRooms(roomDto); // // if (ListUtil.isNull(roomDtos)) { // throw new IllegalArgumentException("未包含房屋"); // } // // for (RoomDto roomDto1 : roomDtos) { // getTmpRoomDtos(roomDto1, configIds, reqJson); // } // for (int roomIndex = 0; roomIndex < roomDtos.size(); roomIndex++) { // //todo 有可能房屋下没有欠费 // if (ListUtil.isNull(roomDtos.get(roomIndex).getFees())) { // continue; // } // Map<String, Object> info = generatorRoomOweFee(sheet, workbook, roomDtos.get(roomIndex), line, totalPageHeight, patriarch, feePrintSpecDto); // line = Integer.parseInt(info.get("line").toString()) + 1; // totalPageHeight = Double.parseDouble(info.get("totalPageHeight").toString()); // } // // // return workbook; // } // // private Map<String, Object> generatorRoomOweFee(Sheet sheet, SXSSFWorkbook workbook, RoomDto roomDto, int line, // double totalPageHeight, Drawing patriarch, FeePrintSpecDto feePrintSpecDto // ) { // List<FeeDto> fees = roomDto.getFees(); // String[] feePrintRemarks = null; // if (feePrintSpecDto != null) { // feePrintRemarks = feePrintSpecDto.getContent().toLowerCase().replace("</br>", "").split("\n"); // } else { // feePrintRemarks = new String[]{""}; // } // int defaultRowHeight = 280; // //计算当前单子的高度 // int titleHeight = defaultRowHeight * 3; // int subTitleHeight = defaultRowHeight * 5; // int totalHeight = titleHeight + subTitleHeight + defaultRowHeight * 3 + fees.size() * defaultRowHeight; // //备注,加上打印配置内容 // if (feePrintRemarks != null && feePrintRemarks.length > 0) { // totalHeight += (feePrintRemarks.length * defaultRowHeight); // } // double A4_lengthways_pageSize = defaultRowHeight * 57;//15960 // // //当前页 已经占用的高度 // double curPageHeight = totalPageHeight % A4_lengthways_pageSize; // //当前页空闲高度 // double freePageHeight = A4_lengthways_pageSize - curPageHeight; // if (freePageHeight < totalHeight && curPageHeight != 0) { // line += Math.ceil(freePageHeight / defaultRowHeight); // totalPageHeight += freePageHeight; // } // // totalPageHeight += totalHeight; // // // sheet.setColumnWidth(0, 8 * 256 * 2); // sheet.setColumnWidth(1, 8 * 256 * 1); // sheet.setColumnWidth(2, 8 * 256 * 1); // sheet.setColumnWidth(3, 8 * 256 * 3); // sheet.setColumnWidth(4, 8 * 256 * 1); // sheet.setColumnWidth(5, 8 * 256 * 1); // sheet.setColumnWidth(6, 8 * 256 * 1); // // //通用样式 // CellStyle cellStyle = workbook.createCellStyle(); ////设置样式对象,这里仅设置了边框属性 // cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 // cellStyle.setBorderLeft(BorderStyle.THIN);//左边框 // cellStyle.setBorderTop(BorderStyle.THIN);//上边框 // cellStyle.setBorderRight(BorderStyle.THIN);//右边框 // cellStyle.setAlignment(HorizontalAlignment.CENTER); // // // 标题 // Row row = sheet.createRow(0 + line); // Cell cell0 = row.createCell(0); // //cell0.setCellValue("缴费通知单totalHeight:" + totalHeight + "-totalPageHeight:" + totalPageHeight + "-curPageHeight:" + curPageHeight + "-freePageHeight:" + freePageHeight + "-line:" + line); // if (feePrintSpecDto != null) { // cell0.setCellValue(feePrintSpecDto.getPrintName() + "缴费通知单"); // } else { // cell0.setCellValue("缴费通知单"); // } // //标题设置字体 // Font font = workbook.createFont(); // font.setFontName("黑体"); // font.setFontHeightInPoints((short) 26); // CellStyle titleCellStyle = workbook.createCellStyle(); // titleCellStyle.setFont(font); // titleCellStyle.setAlignment(HorizontalAlignment.CENTER); // cell0.setCellStyle(titleCellStyle); // row.setHeight((short) (titleHeight)); // // //合并标题 // CellRangeAddress region = new CellRangeAddress(0 + line, 0 + line, 0, 6); // sheet.addMergedRegion(region); // // // //子标题 // if (feePrintSpecDto != null) { // XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) 0, 1 + line, (short) 1, 1 + line + 1); // anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);//设置图片随单元移动调整大小 // try { // String qrImg = ImageUtils.getBase64ByImgUrl(feePrintSpecDto.getQrImg()).replace("data:image/webp;base64,", "") // .replace("data:image/png;base64,", "") // .replace("data:image/jpeg;base64,", ""); // patriarch.createPicture(anchor, workbook.addPicture(Base64Convert.base64ToByte(qrImg), XSSFWorkbook.PICTURE_TYPE_JPEG)); // } catch (IOException e) { // e.printStackTrace(); // } // } // CellStyle subTitleCellStyle = workbook.createCellStyle(); // subTitleCellStyle.setAlignment(HorizontalAlignment.CENTER); // subTitleCellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM); // row = sheet.createRow(1 + line); // Cell cell1 = row.createCell(1); // if (!ListUtil.isNull(fees)) { // cell1.setCellValue("业主:" + fees.get(0).getOwnerName()); // } else { // cell1.setCellValue("业主:无"); // } // cell1.setCellStyle(subTitleCellStyle); // // Cell cell2 = row.createCell(2); // cell2.setCellValue("房号:" + roomDto.getFloorNum() // + "-" + roomDto.getUnitNum() // + "-" + roomDto.getRoomNum()); // cell2.setCellStyle(subTitleCellStyle); // // row.createCell(3).setCellValue(""); // row.createCell(4).setCellValue(""); // Cell cell5 = row.createCell(5); // cell5.setCellValue(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B)); // cell5.setCellStyle(subTitleCellStyle); // CellStyle rowCellStyle = workbook.createCellStyle(); // rowCellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM); // row.setRowStyle(rowCellStyle); // // //设置表头之上 // region = new CellRangeAddress(1 + line, 1 + line, 2, 3); // sheet.addMergedRegion(region); // region = new CellRangeAddress(1 + line, 1 + line, 5, 6); // sheet.addMergedRegion(region); // //子标题高度 // row.setHeight((short) (subTitleHeight)); // // // row = sheet.createRow(2 + line); // cell0 = row.createCell(0); // cell0.setCellValue("收费名称"); // cell0.setCellStyle(cellStyle); // cell1 = row.createCell(1); // cell1.setCellValue("收费标准"); // cell1.setCellStyle(cellStyle); // cell2 = row.createCell(2); // cell2.setCellValue("数量/面积"); // cell2.setCellStyle(cellStyle); // Cell cell3 = row.createCell(3); // cell3.setCellValue("欠费时间"); // cell3.setCellStyle(cellStyle); // Cell cell4 = row.createCell(4); // cell4.setCellValue("应缴金额(元)"); // cell4.setCellStyle(cellStyle); // cell5 = row.createCell(5); // cell5.setCellValue("违约金(元)"); // cell5.setCellStyle(cellStyle); // Cell cell6 = row.createCell(6); // cell6.setCellValue("备注"); // cell6.setCellStyle(cellStyle); // row.setHeight((short) (defaultRowHeight)); // // // BigDecimal totalPrice = new BigDecimal(0); // String startTime = ""; // String endTime = ""; // String squarePrice = ""; // for (int feeIndex = 0; feeIndex < fees.size(); feeIndex++) { // JSONObject feeObj = BeanConvertUtil.beanCovertJson(fees.get(feeIndex)); // row = sheet.createRow(line + feeIndex + 3); // startTime = DateUtil.getFormatTimeStringB(feeObj.getDate("endTime")); // endTime = DateUtil.getFormatTimeStringB(feeObj.getDate("deadlineTime")); // squarePrice = feeObj.getString("squarePrice"); // // //动态费用单价就去动态单价 // if (feeObj.containsKey("computingFormula") && "9009".equals(feeObj.getString("computingFormula"))) { // squarePrice = feeObj.getString("mwPrice"); // } // // cell0 = row.createCell(0); // cell0.setCellValue(feeObj.getString("feeName")); // cell0.setCellStyle(cellStyle); // cell1 = row.createCell(1); // cell1.setCellValue(squarePrice); // cell1.setCellStyle(cellStyle); // cell2 = row.createCell(2); // //todo 不能只展示面积 // cell2.setCellValue(roomDto.getBuiltUpArea()); // if (!StringUtil.isEmpty(feeObj.getString("curDegrees"))) { // BigDecimal degrees = new BigDecimal(feeObj.getString("curDegrees")) // .subtract(new BigDecimal(feeObj.getString("preDegrees"))); // cell2.setCellValue(degrees.doubleValue()); // } // // cell2.setCellStyle(cellStyle); // cell3 = row.createCell(3); // if (feeObj.containsKey("curDegrees")) { // cell3.setCellValue(startTime + "至" + endTime + " " + feeObj.getString("preDegrees") + "至" + feeObj.getString("curDegrees")); // } else { // cell3.setCellValue(startTime + "至" + endTime); // } // cell3.setCellStyle(cellStyle); // cell4 = row.createCell(4); // cell4.setCellValue(feeObj.getString("feeTotalPrice")); // cell4.setCellStyle(cellStyle); // cell5 = row.createCell(5); // cell5.setCellValue("0"); // cell5.setCellStyle(cellStyle); // cell6 = row.createCell(6); // cell6.setCellValue(""); // cell6.setCellStyle(cellStyle); // row.setHeight((short) (defaultRowHeight)); // totalPrice = totalPrice.add(new BigDecimal(feeObj.getString("feeTotalPrice"))); // } // // row = sheet.createRow(line + fees.size() + 3); // // cell0 = row.createCell(0); // cell0.setCellValue("合计(大写)"); // cell0.setCellStyle(cellStyle); // cell1 = row.createCell(1); // cell1.setCellValue(Money2ChineseUtil.toChineseChar(totalPrice.doubleValue())); // cell1.setCellStyle(cellStyle); // cell2 = row.createCell(2); // cell2.setCellValue(""); // cell2.setCellStyle(cellStyle); // cell3 = row.createCell(3); // cell3.setCellValue(""); // cell3.setCellStyle(cellStyle); // cell4 = row.createCell(4); // cell4.setCellValue(totalPrice.doubleValue()); // cell4.setCellStyle(cellStyle); // cell5 = row.createCell(5); // cell5.setCellValue(""); // cell5.setCellStyle(cellStyle); // cell6 = row.createCell(6); // cell6.setCellValue(""); // cell6.setCellStyle(cellStyle); // row.setHeight((short) (defaultRowHeight)); // // // //合计 合并 // region = new CellRangeAddress(line + fees.size() + 3, line + fees.size() + 3, 1, 3); // sheet.addMergedRegion(region); // // if (feePrintRemarks != null && feePrintRemarks.length > 0) { // for (int remarkIndex = 0; remarkIndex < feePrintRemarks.length; remarkIndex++) { // row = sheet.createRow(line + fees.size() + 4 + remarkIndex); // row.createCell(0).setCellValue(feePrintRemarks[remarkIndex]); // row.setHeight((short) (defaultRowHeight)); // } // } // row = sheet.createRow(line + fees.size() + 4 + feePrintRemarks.length); // row.createCell(0).setCellValue(""); // row.setHeight((short) (defaultRowHeight)); // Map info = new HashMap(); // info.put("line", line + fees.size() + 4 + feePrintRemarks.length); // info.put("totalPageHeight", totalPageHeight); // return info; // } // // private RoomDto getTmpRoomDtos(RoomDto tmpRoomDto, String configIds, JSONObject reqJson) { // FeeDto tmpFeeDto = null; // tmpFeeDto = new FeeDto(); // // tmpFeeDto.setArrearsEndTime(DateUtil.getCurrentDate()); // tmpFeeDto.setState(FeeDto.STATE_DOING); // tmpFeeDto.setPayerObjId(tmpRoomDto.getRoomId()); // tmpFeeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_ROOM); // tmpFeeDto.setConfigIds(configIds.split(",")); // List<FeeDto> feeDtos = feeInnerServiceSMOImpl.querySimpleFees(tmpFeeDto); // // if (ListUtil.isNull(feeDtos)) { // return null; // } // // List<FeeDto> tmpFeeDtos = new ArrayList<>(); // for (FeeDto tempFeeDto : feeDtos) { // // computeFeeSMOImpl.computeEveryOweFee(tempFeeDto, tmpRoomDto);//计算欠费金额 // //如果金额为0 就排除 // //if (tempFeeDto.getFeePrice() > 0 && tempFeeDto.getEndTime().getTime() <= DateUtil.getCurrentDate().getTime()) { // // todo 校验 时间范围 // if (!hasInTime(tempFeeDto, reqJson)) { // continue; // } // if (tempFeeDto.getFeeTotalPrice() != 0) { // tmpFeeDtos.add(tempFeeDto); // } // } // // if (tmpFeeDtos.size() < 1) { // return null; // } // tmpRoomDto.setFees(tmpFeeDtos); // return tmpRoomDto; // } // // private boolean hasInTime(FeeDto tempFeeDto, JSONObject reqJson) { // if (!reqJson.containsKey("startTime") || !reqJson.containsKey("endTime")) { // return true; // } // // String startTime = reqJson.getString("startTime"); // String endTime = reqJson.getString("endTime"); // // if (StringUtil.isEmpty(startTime) || StringUtil.isEmpty(endTime)) { // return true; // } // if (tempFeeDto.getDeadlineTime() == null) { // return true; // } // // if (tempFeeDto.getEndTime().before(DateUtil.getDateFromStringB(startTime)) // && tempFeeDto.getDeadlineTime().after(DateUtil.getDateFromStringB(endTime)) // ) { // return true; // } // // return false; // } @Override public SXSSFWorkbook exportData(ExportDataDto exportDataDto) { public Object exportData(ExportDataDto exportDataDto) throws ParseException { try { // 1. 获取请求数据 JSONObject reqJson = exportDataDto.getReqJson(); validateParams(reqJson); // 验证必要参数 String configId = reqJson.getString("configId"); String roomId = reqJson.getString("roomId"); // 2. 查询房屋信息 RoomDto roomDto = getRoomInfo(roomId, reqJson.getString("communityId")); if (roomDto == null) { throw new IllegalArgumentException("未找到房屋数据"); } // 3. 处理费用数据 getTmpRoomDtos(roomDto, configId, reqJson); if (ListUtil.isNull(roomDto.getFees())) { throw new IllegalArgumentException("未找到该房屋的费用数据"); } // 准备替换的占位符数据 Map<String, String> placeholders = preparePlaceholders(roomDto, reqJson); // 读取Docx模板并替换占位符 XWPFDocument doc = renderDocxTemplate(placeholders); return doc; } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("生成催款通知失败: " + e.getMessage()); } } /** * 验证必要参数 */ private void validateParams(JSONObject reqJson) { Assert.hasKeyAndValue(reqJson, "communityId", "未包含小区"); Assert.hasKeyAndValue(reqJson, "configIds", "未包含费用"); Assert.hasKeyAndValue(reqJson, "roomIds", "未包含房屋"); String configIds = reqJson.getString("configIds"); String roomIds = reqJson.getString("roomIds"); SXSSFWorkbook workbook = null; //工作簿 workbook = new SXSSFWorkbook(); workbook.setCompressTempFiles(false); Sheet sheet = workbook.createSheet("催缴单"); Drawing patriarch = sheet.createDrawingPatriarch(); FeePrintSpecDto feePrintSpecDto = new FeePrintSpecDto(); feePrintSpecDto.setCommunityId(reqJson.getString("communityId")); feePrintSpecDto.setSpecCd("1010"); feePrintSpecDto.setPage(1); feePrintSpecDto.setRow(1); List<FeePrintSpecDto> feePrintSpecDtos = feePrintSpecInnerServiceSMOImpl.queryFeePrintSpecs(feePrintSpecDto); if (ListUtil.isNull(feePrintSpecDtos)) { feePrintSpecDto = null; } else { feePrintSpecDto = feePrintSpecDtos.get(0); Assert.hasKeyAndValue(reqJson, "roomId", "未包含房屋"); } int line = 0; double totalPageHeight = 0; /** * 获取房屋信息 */ private RoomDto getRoomInfo(String roomId, String communityId) { RoomDto roomDto = new RoomDto(); roomDto.setRoomIds(roomIds.split(",")); roomDto.setCommunityId(reqJson.getString("communityId")); roomDto.setRoomIds(roomId.split(",")); roomDto.setCommunityId(communityId); List<RoomDto> roomDtos = roomV1InnerServiceSMOImpl.queryRooms(roomDto); if (ListUtil.isNull(roomDtos)) { throw new IllegalArgumentException("未包含房屋"); return ListUtil.isNull(roomDtos) ? null : roomDtos.get(0); } for (RoomDto roomDto1 : roomDtos) { getTmpRoomDtos(roomDto1, configIds, reqJson); /** * 准备占位符数据(文本替换) */ private Map<String, String> preparePlaceholders(RoomDto roomDto, JSONObject reqJson) { Map<String, String> placeholders = new HashMap<>(); CommunityDto communityDto = new CommunityDto(); communityDto.setCommunityId(roomDto.getCommunityId()); List<CommunityDto> communityDtos = communityV1InnerServiceSMO.queryCommunitys(communityDto); placeholders.put("area", communityDtos.get(0).getNearbyLandmarks()); // 房屋信息 placeholders.put("buildingNum", roomDto.getUnitNum() != null ? roomDto.getUnitNum() : ""); placeholders.put("roomNum", roomDto.getRoomNum() != null ? roomDto.getRoomNum() : ""); // 业主与费用信息 FeeDto fee = roomDto.getFees().get(0); placeholders.put("ownerName", fee.getOwnerName() != null ? fee.getOwnerName() : ""); placeholders.put("price", String.valueOf(fee.getFeeTotalPrice())); JSONObject feeObj = BeanConvertUtil.beanCovertJson(fee); String startTime = DateUtil.getFormatTimeStringB(feeObj.getDate("endTime")); String endTime = DateUtil.getFormatTimeStringB(feeObj.getDate("deadlineTime")); LocalDate startDate = LocalDate.parse(startTime, DateTimeFormatter.ISO_LOCAL_DATE); LocalDate endDate = LocalDate.parse(endTime, DateTimeFormatter.ISO_LOCAL_DATE); // 时间信息 placeholders.put("startYear", String.valueOf(startDate.getYear())); placeholders.put("startMonth", startDate.getMonthValue() >= 10 ? String.valueOf(startDate.getMonthValue()) : ("0" + startDate.getMonthValue())); placeholders.put("endYear", String.valueOf(endDate.getYear())); placeholders.put("endMonth", endDate.getMonthValue() >= 10 ? String.valueOf(endDate.getMonthValue()) : ("0" + endDate.getMonthValue())); // 当前日期 Date currentDate = new Date(); SimpleDateFormat yearFormat = new SimpleDateFormat("yyyy"); SimpleDateFormat monthFormat = new SimpleDateFormat("MM"); SimpleDateFormat dayFormat = new SimpleDateFormat("dd"); placeholders.put("a", yearFormat.format(currentDate)); placeholders.put("b", monthFormat.format(currentDate)); placeholders.put("c", dayFormat.format(currentDate)); return placeholders; } for (int roomIndex = 0; roomIndex < roomDtos.size(); roomIndex++) { //todo 有可能房屋下没有欠费 if (ListUtil.isNull(roomDtos.get(roomIndex).getFees())) { /** * 读取Docx模板并替换占位符 */ private XWPFDocument renderDocxTemplate(Map<String, String> placeholders) throws IOException { // 1. 读取模板文件 ClassPathResource resource = new ClassPathResource(DOCX_TEMPLATE_PATH); try (InputStream is = resource.getInputStream()) { XWPFDocument doc = new XWPFDocument(is); // 2. 替换文本占位符 replaceTextPlaceholders(doc, placeholders); return doc; } } /** * 替换文本占位符(如 ${ownerName}) */ private void replaceTextPlaceholders(XWPFDocument doc, Map<String, String> placeholders) { // 处理段落中的占位符 for (XWPFParagraph para : doc.getParagraphs()) { for (XWPFRun run : para.getRuns()) { String text = run.getText(0); if (text == null) { // 文本本身为null时跳过 continue; } Map<String, Object> info = generatorRoomOweFee(sheet, workbook, roomDtos.get(roomIndex), line, totalPageHeight, patriarch, feePrintSpecDto); line = Integer.parseInt(info.get("line").toString()) + 1; totalPageHeight = Double.parseDouble(info.get("totalPageHeight").toString()); } return workbook; } private Map<String, Object> generatorRoomOweFee(Sheet sheet, SXSSFWorkbook workbook, RoomDto roomDto, int line, double totalPageHeight, Drawing patriarch, FeePrintSpecDto feePrintSpecDto ) { List<FeeDto> fees = roomDto.getFees(); String[] feePrintRemarks = null; if (feePrintSpecDto != null) { feePrintRemarks = feePrintSpecDto.getContent().toLowerCase().replace("</br>", "").split("\n"); } else { feePrintRemarks = new String[]{""}; } int defaultRowHeight = 280; //计算当前单子的高度 int titleHeight = defaultRowHeight * 3; int subTitleHeight = defaultRowHeight * 5; int totalHeight = titleHeight + subTitleHeight + defaultRowHeight * 3 + fees.size() * defaultRowHeight; //备注,加上打印配置内容 if (feePrintRemarks != null && feePrintRemarks.length > 0) { totalHeight += (feePrintRemarks.length * defaultRowHeight); } double A4_lengthways_pageSize = defaultRowHeight * 57;//15960 //当前页 已经占用的高度 double curPageHeight = totalPageHeight % A4_lengthways_pageSize; //当前页空闲高度 double freePageHeight = A4_lengthways_pageSize - curPageHeight; if (freePageHeight < totalHeight && curPageHeight != 0) { line += Math.ceil(freePageHeight / defaultRowHeight); totalPageHeight += freePageHeight; } totalPageHeight += totalHeight; sheet.setColumnWidth(0, 8 * 256 * 2); sheet.setColumnWidth(1, 8 * 256 * 1); sheet.setColumnWidth(2, 8 * 256 * 1); sheet.setColumnWidth(3, 8 * 256 * 3); sheet.setColumnWidth(4, 8 * 256 * 1); sheet.setColumnWidth(5, 8 * 256 * 1); sheet.setColumnWidth(6, 8 * 256 * 1); //通用样式 CellStyle cellStyle = workbook.createCellStyle(); //设置样式对象,这里仅设置了边框属性 cellStyle.setBorderBottom(BorderStyle.THIN); //下边框 cellStyle.setBorderLeft(BorderStyle.THIN);//左边框 cellStyle.setBorderTop(BorderStyle.THIN);//上边框 cellStyle.setBorderRight(BorderStyle.THIN);//右边框 cellStyle.setAlignment(HorizontalAlignment.CENTER); // 标题 Row row = sheet.createRow(0 + line); Cell cell0 = row.createCell(0); //cell0.setCellValue("缴费通知单totalHeight:" + totalHeight + "-totalPageHeight:" + totalPageHeight + "-curPageHeight:" + curPageHeight + "-freePageHeight:" + freePageHeight + "-line:" + line); if (feePrintSpecDto != null) { cell0.setCellValue(feePrintSpecDto.getPrintName() + "缴费通知单"); } else { cell0.setCellValue("缴费通知单"); } //标题设置字体 Font font = workbook.createFont(); font.setFontName("黑体"); font.setFontHeightInPoints((short) 26); CellStyle titleCellStyle = workbook.createCellStyle(); titleCellStyle.setFont(font); titleCellStyle.setAlignment(HorizontalAlignment.CENTER); cell0.setCellStyle(titleCellStyle); row.setHeight((short) (titleHeight)); //合并标题 CellRangeAddress region = new CellRangeAddress(0 + line, 0 + line, 0, 6); sheet.addMergedRegion(region); //子标题 if (feePrintSpecDto != null) { XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) 0, 1 + line, (short) 1, 1 + line + 1); anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);//设置图片随单元移动调整大小 try { String qrImg = ImageUtils.getBase64ByImgUrl(feePrintSpecDto.getQrImg()).replace("data:image/webp;base64,", "") .replace("data:image/png;base64,", "") .replace("data:image/jpeg;base64,", ""); patriarch.createPicture(anchor, workbook.addPicture(Base64Convert.base64ToByte(qrImg), XSSFWorkbook.PICTURE_TYPE_JPEG)); } catch (IOException e) { e.printStackTrace(); String replacedText = text; // 临时存储替换后的文本 for (Map.Entry<String, String> entry : placeholders.entrySet()) { String placeholder = "${" + entry.getKey() + "}"; // 关键修复:如果替换值为null,用空字符串替代 String replacement = entry.getValue() != null ? entry.getValue() : ""; // 替换占位符 if (replacedText.contains(placeholder)) { replacedText = replacedText.replace(placeholder, replacement); } } CellStyle subTitleCellStyle = workbook.createCellStyle(); subTitleCellStyle.setAlignment(HorizontalAlignment.CENTER); subTitleCellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM); row = sheet.createRow(1 + line); Cell cell1 = row.createCell(1); if (!ListUtil.isNull(fees)) { cell1.setCellValue("业主:" + fees.get(0).getOwnerName()); } else { cell1.setCellValue("业主:无"); } cell1.setCellStyle(subTitleCellStyle); Cell cell2 = row.createCell(2); cell2.setCellValue("房号:" + roomDto.getFloorNum() + "-" + roomDto.getUnitNum() + "-" + roomDto.getRoomNum()); cell2.setCellStyle(subTitleCellStyle); row.createCell(3).setCellValue(""); row.createCell(4).setCellValue(""); Cell cell5 = row.createCell(5); cell5.setCellValue(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B)); cell5.setCellStyle(subTitleCellStyle); CellStyle rowCellStyle = workbook.createCellStyle(); rowCellStyle.setVerticalAlignment(VerticalAlignment.BOTTOM); row.setRowStyle(rowCellStyle); //设置表头之上 region = new CellRangeAddress(1 + line, 1 + line, 2, 3); sheet.addMergedRegion(region); region = new CellRangeAddress(1 + line, 1 + line, 5, 6); sheet.addMergedRegion(region); //子标题高度 row.setHeight((short) (subTitleHeight)); row = sheet.createRow(2 + line); cell0 = row.createCell(0); cell0.setCellValue("收费名称"); cell0.setCellStyle(cellStyle); cell1 = row.createCell(1); cell1.setCellValue("收费标准"); cell1.setCellStyle(cellStyle); cell2 = row.createCell(2); cell2.setCellValue("数量/面积"); cell2.setCellStyle(cellStyle); Cell cell3 = row.createCell(3); cell3.setCellValue("欠费时间"); cell3.setCellStyle(cellStyle); Cell cell4 = row.createCell(4); cell4.setCellValue("应缴金额(元)"); cell4.setCellStyle(cellStyle); cell5 = row.createCell(5); cell5.setCellValue("违约金(元)"); cell5.setCellStyle(cellStyle); Cell cell6 = row.createCell(6); cell6.setCellValue("备注"); cell6.setCellStyle(cellStyle); row.setHeight((short) (defaultRowHeight)); BigDecimal totalPrice = new BigDecimal(0); String startTime = ""; String endTime = ""; String squarePrice = ""; for (int feeIndex = 0; feeIndex < fees.size(); feeIndex++) { JSONObject feeObj = BeanConvertUtil.beanCovertJson(fees.get(feeIndex)); row = sheet.createRow(line + feeIndex + 3); startTime = DateUtil.getFormatTimeStringB(feeObj.getDate("endTime")); endTime = DateUtil.getFormatTimeStringB(feeObj.getDate("deadlineTime")); squarePrice = feeObj.getString("squarePrice"); //动态费用单价就去动态单价 if (feeObj.containsKey("computingFormula") && "9009".equals(feeObj.getString("computingFormula"))) { squarePrice = feeObj.getString("mwPrice"); } cell0 = row.createCell(0); cell0.setCellValue(feeObj.getString("feeName")); cell0.setCellStyle(cellStyle); cell1 = row.createCell(1); cell1.setCellValue(squarePrice); cell1.setCellStyle(cellStyle); cell2 = row.createCell(2); //todo 不能只展示面积 cell2.setCellValue(roomDto.getBuiltUpArea()); if (!StringUtil.isEmpty(feeObj.getString("curDegrees"))) { BigDecimal degrees = new BigDecimal(feeObj.getString("curDegrees")) .subtract(new BigDecimal(feeObj.getString("preDegrees"))); cell2.setCellValue(degrees.doubleValue()); } cell2.setCellStyle(cellStyle); cell3 = row.createCell(3); if (feeObj.containsKey("curDegrees")) { cell3.setCellValue(startTime + "至" + endTime + " " + feeObj.getString("preDegrees") + "至" + feeObj.getString("curDegrees")); } else { cell3.setCellValue(startTime + "至" + endTime); } cell3.setCellStyle(cellStyle); cell4 = row.createCell(4); cell4.setCellValue(feeObj.getString("feeTotalPrice")); cell4.setCellStyle(cellStyle); cell5 = row.createCell(5); cell5.setCellValue("0"); cell5.setCellStyle(cellStyle); cell6 = row.createCell(6); cell6.setCellValue(""); cell6.setCellStyle(cellStyle); row.setHeight((short) (defaultRowHeight)); totalPrice = totalPrice.add(new BigDecimal(feeObj.getString("feeTotalPrice"))); } row = sheet.createRow(line + fees.size() + 3); cell0 = row.createCell(0); cell0.setCellValue("合计(大写)"); cell0.setCellStyle(cellStyle); cell1 = row.createCell(1); cell1.setCellValue(Money2ChineseUtil.toChineseChar(totalPrice.doubleValue())); cell1.setCellStyle(cellStyle); cell2 = row.createCell(2); cell2.setCellValue(""); cell2.setCellStyle(cellStyle); cell3 = row.createCell(3); cell3.setCellValue(""); cell3.setCellStyle(cellStyle); cell4 = row.createCell(4); cell4.setCellValue(totalPrice.doubleValue()); cell4.setCellStyle(cellStyle); cell5 = row.createCell(5); cell5.setCellValue(""); cell5.setCellStyle(cellStyle); cell6 = row.createCell(6); cell6.setCellValue(""); cell6.setCellStyle(cellStyle); row.setHeight((short) (defaultRowHeight)); //合计 合并 region = new CellRangeAddress(line + fees.size() + 3, line + fees.size() + 3, 1, 3); sheet.addMergedRegion(region); if (feePrintRemarks != null && feePrintRemarks.length > 0) { for (int remarkIndex = 0; remarkIndex < feePrintRemarks.length; remarkIndex++) { row = sheet.createRow(line + fees.size() + 4 + remarkIndex); row.createCell(0).setCellValue(feePrintRemarks[remarkIndex]); row.setHeight((short) (defaultRowHeight)); // 只有文本变化时才更新,避免无效操作 if (!replacedText.equals(text)) { run.setText(replacedText, 0); } } row = sheet.createRow(line + fees.size() + 4 + feePrintRemarks.length); row.createCell(0).setCellValue(""); row.setHeight((short) (defaultRowHeight)); Map info = new HashMap(); info.put("line", line + fees.size() + 4 + feePrintRemarks.length); info.put("totalPageHeight", totalPageHeight); return info; } private RoomDto getTmpRoomDtos(RoomDto tmpRoomDto, String configIds, JSONObject reqJson) { FeeDto tmpFeeDto = null; tmpFeeDto = new FeeDto(); // tmpFeeDto.setArrearsEndTime(DateUtil.getCurrentDate()); // 处理表格中的占位符(同样处理null值) doc.getTables().forEach(table -> { table.getRows().forEach(row -> { row.getTableCells().forEach(cell -> { cell.getParagraphs().forEach(para -> { para.getRuns().forEach(run -> { String text = run.getText(0); if (text == null) { return; } String replacedText = text; for (Map.Entry<String, String> entry : placeholders.entrySet()) { String placeholder = "${" + entry.getKey() + "}"; String replacement = entry.getValue() != null ? entry.getValue() : ""; // 处理null if (replacedText.contains(placeholder)) { replacedText = replacedText.replace(placeholder, replacement); } } if (!replacedText.equals(text)) { run.setText(replacedText, 0); } }); }); }); }); }); } /** * 处理房屋费用数据 */ private RoomDto getTmpRoomDtos(RoomDto tmpRoomDto, String configId, JSONObject reqJson) { FeeDto tmpFeeDto = new FeeDto(); tmpFeeDto.setState(FeeDto.STATE_DOING); tmpFeeDto.setPayerObjId(tmpRoomDto.getRoomId()); tmpFeeDto.setPayerObjType(FeeDto.PAYER_OBJ_TYPE_ROOM); tmpFeeDto.setConfigIds(configIds.split(",")); tmpFeeDto.setConfigId(configId); List<FeeDto> feeDtos = feeInnerServiceSMOImpl.querySimpleFees(tmpFeeDto); if (ListUtil.isNull(feeDtos)) { return null; } List<FeeDto> tmpFeeDtos = new ArrayList<>(); if (!ListUtil.isNull(feeDtos)) { for (FeeDto tempFeeDto : feeDtos) { computeFeeSMOImpl.computeEveryOweFee(tempFeeDto, tmpRoomDto);//计算欠费金额 //如果金额为0 就排除 //if (tempFeeDto.getFeePrice() > 0 && tempFeeDto.getEndTime().getTime() <= DateUtil.getCurrentDate().getTime()) { // todo 校验 时间范围 if (!hasInTime(tempFeeDto, reqJson)) { continue; } if (tempFeeDto.getFeeTotalPrice() != 0) { computeFeeSMOImpl.computeEveryOweFee(tempFeeDto, tmpRoomDto); if (hasInTime(tempFeeDto, reqJson) && tempFeeDto.getFeeTotalPrice() != 0) { tmpFeeDtos.add(tempFeeDto); } } if (tmpFeeDtos.size() < 1) { return null; } tmpRoomDto.setFees(tmpFeeDtos); return tmpRoomDto; } /** * 验证费用是否在时间范围内 */ private boolean hasInTime(FeeDto tempFeeDto, JSONObject reqJson) { if (!reqJson.containsKey("startTime") || !reqJson.containsKey("endTime")) { return true; @@ -411,16 +631,23 @@ if (StringUtil.isEmpty(startTime) || StringUtil.isEmpty(endTime)) { return true; } if (tempFeeDto.getDeadlineTime() == null) { return true; } if (tempFeeDto.getEndTime().before(DateUtil.getDateFromStringB(startTime)) && tempFeeDto.getDeadlineTime().after(DateUtil.getDateFromStringB(endTime)) ) { return true; try { Date startDate = DateUtil.getDateFromStringB(startTime); Date endDate = DateUtil.getDateFromStringB(endTime); return tempFeeDto.getEndTime().before(startDate) && tempFeeDto.getDeadlineTime().after(endDate); } catch (Exception e) { e.printStackTrace(); return false; } } return false; @Override public String getFileType() { return "docx"; // 明确生成docx格式 } } service-job/src/main/java/com/java110/job/importData/adapt/ImportCarHistoryFeeDetailQueueDataAdapt.java
@@ -10,6 +10,7 @@ import com.java110.dto.importData.ImportRoomFee; import com.java110.dto.log.AssetImportLogDetailDto; import com.java110.dto.owner.OwnerRoomRelDto; import com.java110.dto.room.RoomDto; import com.java110.fee.api.FeeDiscountApi; import com.java110.intf.community.IRoomInnerServiceSMO; import com.java110.intf.fee.*; @@ -43,6 +44,8 @@ @Service("importCarHistoryFeeDetailQueueData") public class ImportCarHistoryFeeDetailQueueDataAdapt extends DefaultImportData implements IImportDataAdapt { @Autowired private IRoomInnerServiceSMO iRoomInnerServiceSMOImpl; @Autowired private IPayFeeDetailDiscountNewV1InnerServiceSMO payFeeDetailDiscountNewV1InnerServiceSMOImpl; @@ -119,6 +122,16 @@ */ private void importCarFeeDetail(ImportRoomFee importRoomFee, String storeId, String userId, String batchId) { RoomDto roomDto = new RoomDto(); roomDto.setDoorRoomNum(importRoomFee.getDoorRoomNum()); roomDto.setCommunityId(importRoomFee.getCommunityId()); List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); try { importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); }catch (Exception e){ updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); } PayFeeDetailPo payFeeDetailPo = new PayFeeDetailPo(); payFeeDetailPo.setPayOrderId(importRoomFee.getRoomId()); payFeeDetailPo.setCycles(importRoomFee.getCycle()); service-job/src/main/java/com/java110/job/importData/adapt/ImportHistoryFeeDetailQueueDataAdapt.java
@@ -107,9 +107,6 @@ String communityId = assetImportLogDetailDto.getCommunityId(); JSONObject data = JSONObject.parseObject(assetImportLogDetailDto.getContent()); ImportRoomFee importRoomFee = BeanConvertUtil.covertBean(data, ImportRoomFee.class); RoomDto roomDto = new RoomDto(); roomDto.setDoorRoomNum(importRoomFee.getDoorRoomNum()); roomDto.setCommunityId(communityId); // List<String> roomTypes = Arrays.asList("住宅物业费","商铺物业费","维修收入","维修基金收入","电费及管理费","代收水费","各类押金","租金收入"); List<String> carTypes = Arrays.asList("临时停车费", "业主产权过道停车费", "小业主产权车辆管理费","地下停车费","地面停车费"); List<String> contractTypes = Arrays.asList("垃圾清运费","其他收入","补贴费用","场地使用费","电梯广告(业委会)","快递柜","电梯广告(联讯)","房产中介","非机动车管理费","其他广告"); @@ -163,22 +160,9 @@ updateImportLogDetailState(importRoomFee.getDetailId()); } else if(contractTypes.contains(importRoomFee.getSecondaryFeeTypeCd())){ List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); try { importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); }catch (Exception e){ throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); } importRoomFee.setFeeName(data.getString("secondaryFeeTypeCd")); FeeDto feeDto = new FeeDto(); feeDto.setFeeName(importRoomFee.getFeeName()); List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); if(feeDtos.size() == 0){ updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); throw new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在"); } importRoomFee.setCommunityId(communityId); importRoomFee.setDetailId(assetImportLogDetailDto.getDetailId()); importRoomFee.setStartTime(data.getString("chargeStart")); importRoomFee.setEndTime(data.getString("chargeEnd").split(" ")[0]+" 23:59:59"); @@ -196,13 +180,7 @@ importCarFees.add(importRoomFee); } else if(carTypes.contains(JSONObject.parseObject(infos.get(0).getContent()).get("category22"))){ List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); try { importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); }catch (Exception e){ updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); } importRoomFee.setCommunityId(communityId); importRoomFee.setFeeName(data.getString("secondaryFeeTypeCd")); importRoomFee.setDetailId(assetImportLogDetailDto.getDetailId()); importRoomFee.setStartTime(data.getString("chargeStart")); @@ -221,13 +199,7 @@ importCarFees.add(importRoomFee); } else{ List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); try { importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); }catch (Exception e){ updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); } importRoomFee.setCommunityId(communityId); importRoomFee.setFeeName(data.getString("secondaryFeeTypeCd")); importRoomFee.setDetailId(assetImportLogDetailDto.getDetailId()); importRoomFee.setStartTime(data.getString("chargeStart")); @@ -296,13 +268,30 @@ */ private void importFeeDetail(ImportRoomFee importRoomFee, String storeId, String userId, String batchId) { RoomDto roomDto = new RoomDto(); roomDto.setDoorRoomNum(importRoomFee.getDoorRoomNum()); roomDto.setCommunityId(importRoomFee.getCommunityId()); List<RoomDto> roomDtos = iRoomInnerServiceSMOImpl.queryRooms(roomDto); try { importRoomFee.setRoomId(roomDtos.get(0).getRoomId()); }catch (Exception e){ throw new IllegalArgumentException("门室号"+importRoomFee.getDoorRoomNum()+"未查询到房屋"); } FeeDto feeDto2 = new FeeDto(); feeDto2.setFeeName(importRoomFee.getFeeName()); List<FeeDto> feeDtos2 = feeInnerServiceSMOImpl.queryFees(feeDto2); if(feeDtos2.size() == 0){ updateImportLogDetailState(importRoomFee.getDetailId(),new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在")); throw new IllegalArgumentException("费用项"+importRoomFee.getFeeName()+"不存在"); } FeeConfigDto feeConfigDto = new FeeConfigDto(); feeConfigDto.setFeeNameEq(importRoomFee.getFeeName().trim()); feeConfigDto.setFeeName(importRoomFee.getFeeName().trim()); feeConfigDto.setCommunityId(importRoomFee.getCommunityId()); List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); if (ListUtil.isNull(feeConfigDtos)) { throw new IllegalArgumentException("收费项不存在"); throw new IllegalArgumentException("收费项"+feeConfigDto.getFeeName()+"不存在"); } FeeConfigDto tmpFeeConfigDto = feeConfigDtos.get(0);