java110-db/src/main/resources/mapper/user/OwnerServiceDaoImplMapper.xml
@@ -527,6 +527,7 @@ <if test="communityId !=null and communityId != ''"> and t.community_id= #{communityId} </if> and t.owner_type_cd = '1001' AND r.`status_cd` = '0' AND orr.`status_cd` = '0' AND t.`status_cd` = '0' java110-utils/src/main/java/com/java110/utils/util/Assert.java
@@ -16,6 +16,13 @@ */ public class Assert extends org.springframework.util.Assert { public static void hasValue(Object value,String msg){ Assert.notNull(value, msg); Assert.hasLength(value.toString(), msg); } /** * 判断 jsonObject 是否为空 * service-front/src/main/java/com/java110/front/components/assetImport/ImportRoomFeeComponent.java
@@ -3,6 +3,7 @@ import com.java110.core.context.IPageData; import com.java110.front.controller.CallComponentController; import com.java110.front.smo.assetExport.IAssetExportSMO; import com.java110.front.smo.assetExport.IExportRoomSMO; import com.java110.front.smo.assetImport.IImportRoomFeeSMO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,7 +25,7 @@ private IImportRoomFeeSMO importRoomFeeSMOImpl; @Autowired private IAssetExportSMO assetExportSMOImpl; private IExportRoomSMO exportRoomSMOImpl; /** * 添加应用数据 @@ -45,26 +46,8 @@ */ public ResponseEntity<Object> exportData(IPageData pd) throws Exception { return assetExportSMOImpl.exportExcelData(pd); } /** * 资产导出 * * @param pd * @return * @throws Exception */ public ResponseEntity<Object> exitCommunityData(IPageData pd) throws Exception { return assetExportSMOImpl.exportExcelData(pd); return exportRoomSMOImpl.exportExcelData(pd); } public IAssetExportSMO getAssetExportSMOImpl() { return assetExportSMOImpl; } public void setAssetExportSMOImpl(IAssetExportSMO assetExportSMOImpl) { this.assetExportSMOImpl = assetExportSMOImpl; } } service-front/src/main/java/com/java110/front/smo/assetExport/IExportRoomSMO.java
New file @@ -0,0 +1,22 @@ package com.java110.front.smo.assetExport; import com.java110.core.context.IPageData; import org.springframework.http.ResponseEntity; /** * @ClassName IAssetImportSMO * @Description TODO * @Author wuxw * @Date 2019/9/23 23:13 * @Version 1.0 * add by wuxw 2019/9/23 **/ public interface IExportRoomSMO { /** * 导入excel数据 * @param pd 前台数据封装 * @return ResponseEntity */ public ResponseEntity<Object> exportExcelData(IPageData pd) throws Exception; } service-front/src/main/java/com/java110/front/smo/assetExport/impl/ExportRoomSMOImpl.java
New file @@ -0,0 +1,227 @@ package com.java110.front.smo.assetExport.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.java110.core.component.BaseComponentSMO; import com.java110.core.context.IPageData; import com.java110.entity.component.ComponentValidateResult; import com.java110.front.smo.assetExport.IExportRoomSMO; import com.java110.utils.constant.ServiceConstant; import com.java110.utils.util.Assert; import com.java110.utils.util.DateUtil; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; import java.io.ByteArrayOutputStream; import java.io.IOException; /** * @ClassName AssetImportSmoImpl * @Description TODO * @Author wuxw * @Date 2019/9/23 23:14 * @Version 1.0 * add by wuxw 2019/9/23 **/ @Service("exportRoomSMOImpl") public class ExportRoomSMOImpl extends BaseComponentSMO implements IExportRoomSMO { private final static Logger logger = LoggerFactory.getLogger(ExportRoomSMOImpl.class); @Autowired private RestTemplate restTemplate; @Override public ResponseEntity<Object> exportExcelData(IPageData pd) throws Exception { ComponentValidateResult result = this.validateStoreStaffCommunityRelationship(pd, restTemplate); Assert.hasKeyAndValue(JSONObject.parseObject(pd.getReqData()), "communityId", "请求中未包含小区"); Workbook workbook = null; //工作簿 //工作表 workbook = new HSSFWorkbook(); //获取楼信息 getRooms(pd, result, workbook); ByteArrayOutputStream os = new ByteArrayOutputStream(); MultiValueMap headers = new HttpHeaders(); headers.add("content-type", "application/octet-stream;charset=UTF-8"); headers.add("Content-Disposition", "attachment;filename=" + DateUtil.getyyyyMMddhhmmssDateString() + ".xls"); headers.add("Pargam", "no-cache"); headers.add("Cache-Control", "no-cache"); //headers.add("Content-Disposition", "attachment; filename=" + outParam.getString("fileName")); headers.add("Accept-Ranges", "bytes"); byte[] context = null; try { workbook.write(os); context = os.toByteArray(); os.close(); workbook.close(); } catch (IOException e) { e.printStackTrace(); // 保存数据 return new ResponseEntity<Object>("导出失败", HttpStatus.INTERNAL_SERVER_ERROR); } // 保存数据 return new ResponseEntity<Object>(context, headers, HttpStatus.OK); } /** * 查询存在的房屋信息 * room.queryRooms * * @param pd * @param result * @return */ private JSONArray getExistsRoom(IPageData pd, ComponentValidateResult result) { String apiUrl = ""; ResponseEntity<String> responseEntity = null; apiUrl = ServiceConstant.SERVICE_API_URL + "/api/room.queryRooms?page=1&row=10000&communityId=" + result.getCommunityId(); responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 return null; } JSONObject savedRoomInfoResults = JSONObject.parseObject(responseEntity.getBody()); if (!savedRoomInfoResults.containsKey("rooms")) { return null; } return savedRoomInfoResults.getJSONArray("rooms"); } private JSONArray getExistsUnit(IPageData pd, ComponentValidateResult result, String floorId) { String apiUrl = ""; ResponseEntity<String> responseEntity = null; apiUrl = ServiceConstant.SERVICE_API_URL + "/api/unit.queryUnits?communityId=" + result.getCommunityId() + "&floorId=" + floorId; responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 return null; } JSONArray savedFloorInfoResults = JSONArray.parseArray(responseEntity.getBody()); return savedFloorInfoResults; } private JSONArray getExistsFloor(IPageData pd, ComponentValidateResult result) { String apiUrl = ""; ResponseEntity<String> responseEntity = null; apiUrl = ServiceConstant.SERVICE_API_URL + "/api/floor.queryFloors?page=1&row=100&communityId=" + result.getCommunityId(); responseEntity = this.callCenterService(restTemplate, pd, "", apiUrl, HttpMethod.GET); if (responseEntity.getStatusCode() != HttpStatus.OK) { //跳过 保存单元信息 return null; } JSONObject savedFloorInfoResult = JSONObject.parseObject(responseEntity.getBody()); if (!savedFloorInfoResult.containsKey("apiFloorDataVoList")) { return null; } return savedFloorInfoResult.getJSONArray("apiFloorDataVoList"); } /** * 获取 房屋信息 * * @param componentValidateResult * @param workbook */ private void getRooms(IPageData pd, ComponentValidateResult componentValidateResult, Workbook workbook) { Sheet sheet = workbook.createSheet("房屋信息"); Row row = sheet.createRow(0); row.createCell(0).setCellValue("楼栋编号"); row.createCell(1).setCellValue("单元编号"); row.createCell(2).setCellValue("房屋编码"); row.createCell(3).setCellValue("费用名称"); row.createCell(4).setCellValue("开始时间"); row.createCell(5).setCellValue("结束时间"); row.createCell(6).setCellValue("收费金额"); //查询楼栋信息 JSONArray rooms = this.getExistsRoom(pd, componentValidateResult); if (rooms == null) { return; } for (int roomIndex = 0; roomIndex < rooms.size(); roomIndex++) { row = sheet.createRow(roomIndex + 1); row.createCell(0).setCellValue(rooms.getJSONObject(roomIndex).getString("roomNum")); row.createCell(1).setCellValue(rooms.getJSONObject(roomIndex).getString("floorNum")); row.createCell(2).setCellValue(rooms.getJSONObject(roomIndex).getString("unitNum")); row.createCell(3).setCellValue(""); row.createCell(4).setCellValue(""); row.createCell(5).setCellValue(""); row.createCell(6).setCellValue(""); } } /** * 获取小区 * * @param workbook */ private void getFloors(IPageData pd, ComponentValidateResult componentValidateResult, Workbook workbook) { Sheet sheet = workbook.createSheet("楼栋单元"); Row row = sheet.createRow(0); row.createCell(0).setCellValue("楼栋号"); row.createCell(1).setCellValue("单元编号"); row.createCell(2).setCellValue("总层数"); row.createCell(3).setCellValue("是否有电梯"); //查询楼栋信息 JSONArray floors = this.getExistsFloor(pd, componentValidateResult); if (floors == null) { return; } for (int floorIndex = 0; floorIndex < floors.size(); floorIndex++) { JSONArray units = this.getExistsUnit(pd, componentValidateResult, floors.getJSONObject(floorIndex).getString("floorId")); for (int unitIndex = 0; unitIndex < units.size(); unitIndex++) { row = sheet.createRow(floorIndex + 1); row.createCell(0).setCellValue(floors.getJSONObject(floorIndex).getString("floorNum")); row.createCell(1).setCellValue(units.getJSONObject(unitIndex).getString("unitNum")); row.createCell(2).setCellValue(units.getJSONObject(unitIndex).getString("layerCount")); row.createCell(3).setCellValue("1010".equals(units.getJSONObject(unitIndex).getString("lift")) ? "有" : "无"); } } } public RestTemplate getRestTemplate() { return restTemplate; } public void setRestTemplate(RestTemplate restTemplate) { this.restTemplate = restTemplate; } } service-front/src/main/java/com/java110/front/smo/assetImport/impl/AssetImportSMOImpl.java
@@ -713,10 +713,10 @@ if (StringUtil.isNullOrNone(os[0])) { continue; } Assert.hasLength(os[0].toString(), "车位信息选项中" + (osIndex + 1) + "行停车场编号为空"); Assert.hasLength(os[1].toString(), "车位信息选项中" + (osIndex + 1) + "行车位编码为空"); Assert.hasLength(os[2].toString(), "车位信息选项中" + (osIndex + 1) + "行停车场类型为空"); Assert.hasLength(os[3].toString(), "车位信息选项中" + (osIndex + 1) + "行面积为空,没有请填写规定值 如10"); Assert.hasValue(os[0], "车位信息选项中" + (osIndex + 1) + "行停车场编号为空"); Assert.hasValue(os[1], "车位信息选项中" + (osIndex + 1) + "行车位编码为空"); Assert.hasValue(os[2], "车位信息选项中" + (osIndex + 1) + "行停车场类型为空"); Assert.hasValue(os[3], "车位信息选项中" + (osIndex + 1) + "行面积为空,没有请填写规定值 如10"); importParkingSpace = new ImportParkingSpace(); importParkingSpace.setPaNum(os[0].toString()); importParkingSpace.setPsNum(os[1].toString()); @@ -760,14 +760,14 @@ if (StringUtil.isNullOrNone(os[0])) { continue; } Assert.hasLength(os[1].toString(), "房屋信息选项中" + (osIndex + 1) + "行楼栋编号为空"); Assert.hasLength(os[2].toString(), "房屋信息选项中" + (osIndex + 1) + "行单元编号为空"); Assert.hasLength(os[3].toString(), "房屋信息选项中" + (osIndex + 1) + "行房屋楼层为空"); Assert.hasLength(os[4].toString(), "房屋信息选项中" + (osIndex + 1) + "行房屋户型为空"); Assert.hasLength(os[5].toString(), "房屋信息选项中" + (osIndex + 1) + "行建筑面积为空"); Assert.hasValue(os[1], "房屋信息选项中" + (osIndex + 1) + "行楼栋编号为空"); Assert.hasValue(os[2], "房屋信息选项中" + (osIndex + 1) + "行单元编号为空"); Assert.hasValue(os[3], "房屋信息选项中" + (osIndex + 1) + "行房屋楼层为空"); Assert.hasValue(os[4], "房屋信息选项中" + (osIndex + 1) + "行房屋户型为空"); Assert.hasValue(os[5], "房屋信息选项中" + (osIndex + 1) + "行建筑面积为空"); if (!StringUtil.isNullOrNone(os[6])) { Assert.hasLength(os[7].toString(), "房屋信息选项中" + (osIndex + 1) + "行房屋费用为空"); Assert.hasLength(os[8].toString(), "房屋信息选项中" + (osIndex + 1) + "行费用到期时间为空"); Assert.hasValue(os[7], "房屋信息选项中" + (osIndex + 1) + "行房屋费用为空"); Assert.hasValue(os[8], "房屋信息选项中" + (osIndex + 1) + "行费用到期时间为空"); } importRoom = new ImportRoom(); importRoom.setRoomNum(os[0].toString()); @@ -808,22 +808,22 @@ if (StringUtil.isNullOrNone(os[0])) { continue; } Assert.hasLength(os[0].toString(), "费用设置选项中" + (osIndex + 1) + "行费用编号为空"); Assert.hasLength(os[1].toString(), "费用设置选项中" + (osIndex + 1) + "行费用类型为空"); Assert.hasLength(os[2].toString(), "费用设置选项中" + (osIndex + 1) + "行收费项目为空"); Assert.hasLength(os[3].toString(), "费用设置选项中" + (osIndex + 1) + "行费用标识为空"); Assert.hasLength(os[4].toString(), "费用设置选项中" + (osIndex + 1) + "行费用类型为空"); Assert.hasLength(os[5].toString(), "费用设置选项中" + (osIndex + 1) + "行缴费周期为空"); Assert.hasValue(os[0], "费用设置选项中" + (osIndex + 1) + "行费用编号为空"); Assert.hasValue(os[1], "费用设置选项中" + (osIndex + 1) + "行费用类型为空"); Assert.hasValue(os[2], "费用设置选项中" + (osIndex + 1) + "行收费项目为空"); Assert.hasValue(os[3], "费用设置选项中" + (osIndex + 1) + "行费用标识为空"); Assert.hasValue(os[4], "费用设置选项中" + (osIndex + 1) + "行费用类型为空"); Assert.hasValue(os[5], "费用设置选项中" + (osIndex + 1) + "行缴费周期为空"); Assert.isInteger(os[5].toString(), "费用设置选项中" + (osIndex + 1) + "行缴费周期不是正整数"); Assert.hasLength(os[6].toString(), "费用设置选项中" + (osIndex + 1) + "行出账类型为空"); Assert.hasValue(os[6], "费用设置选项中" + (osIndex + 1) + "行出账类型为空"); Assert.isDate(os[7].toString(), DateUtil.DATE_FORMATE_STRING_B, "费用设置选项中" + (osIndex + 1) + "行计费起始时间不是有效时间格式 请输入类似2020-06-01"); Assert.isDate(os[8].toString(), DateUtil.DATE_FORMATE_STRING_B, "费用设置选项中" + (osIndex + 1) + "行计费终止时间不是有效时间格式 请输入类似2037-01-01"); Assert.hasLength(os[9].toString(), "费用设置选项中" + (osIndex + 1) + "行计算公式为空"); Assert.hasValue(os[9], "费用设置选项中" + (osIndex + 1) + "行计算公式为空"); if (!"1001".equals(os[9].toString()) && !"2002".equals(os[9].toString())) { throw new IllegalArgumentException("费用设置选项中" + (osIndex + 1) + "行计算公式错误 请填写1001 或者2002"); } Assert.hasLength(os[10].toString(), "费用设置选项中" + (osIndex + 1) + "行计费单价为空"); Assert.hasLength(os[11].toString(), "费用设置选项中" + (osIndex + 1) + "行固定费用为空"); Assert.hasValue(os[10], "费用设置选项中" + (osIndex + 1) + "行计费单价为空"); Assert.hasValue(os[11], "费用设置选项中" + (osIndex + 1) + "行固定费用为空"); importFee = new ImportFee(); importFee.setId(os[0].toString()); importFee.setFeeTypeCd("物业费".equals(os[1]) ? "888800010001" : "888800010002"); @@ -904,9 +904,9 @@ if (StringUtil.isNullOrNone(os[0])) { continue; } Assert.hasLength(os[0].toString(), "业主信息选项中" + (osIndex + 1) + "行业主编号为空"); Assert.hasLength(os[1].toString(), "业主信息选项中" + (osIndex + 1) + "行业主名称为空"); Assert.hasLength(os[2].toString(), "业主信息选项中" + (osIndex + 1) + "行业主性别为空"); Assert.hasValue(os[0], "业主信息选项中" + (osIndex + 1) + "行业主编号为空"); Assert.hasValue(os[1], "业主信息选项中" + (osIndex + 1) + "行业主名称为空"); Assert.hasValue(os[2], "业主信息选项中" + (osIndex + 1) + "行业主性别为空"); String tel = StringUtil.isNullOrNone(os[4]) ? "19999999999" : os[4].toString(); String idCard = StringUtil.isNullOrNone(os[5]) ? "10000000000000000001" : os[5].toString(); String age = StringUtil.isNullOrNone(os[3]) ? CommonUtil.getAgeByCertId(idCard) : os[3].toString(); @@ -942,10 +942,10 @@ continue; } Assert.hasLength(os[0].toString(), "楼栋单元选项中" + (osIndex + 1) + "行楼栋号为空"); Assert.hasLength(os[1].toString(), "楼栋单元选项中" + (osIndex + 1) + "行单元编号为空"); Assert.hasLength(os[2].toString(), "楼栋单元选项中" + (osIndex + 1) + "行总楼层为空"); Assert.hasLength(os[3].toString(), "楼栋单元选项中" + (osIndex + 1) + "行是否有电梯为空"); Assert.hasValue(os[0], "楼栋单元选项中" + (osIndex + 1) + "行楼栋号为空"); Assert.hasValue(os[1], "楼栋单元选项中" + (osIndex + 1) + "行单元编号为空"); Assert.hasValue(os[2], "楼栋单元选项中" + (osIndex + 1) + "行总楼层为空"); Assert.hasValue(os[3], "楼栋单元选项中" + (osIndex + 1) + "行是否有电梯为空"); importFloor = new ImportFloor(); importFloor.setFloorNum(os[0].toString()); importFloor.setUnitNum(os[1].toString());