Просмотр исходного кода

Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

java110 лет назад: 3
Родитель
Сommit
620f22a366

+ 18 - 0
java110-bean/src/main/java/com/java110/dto/userDownloadFile/UserDownloadFileDto.java

@@ -31,10 +31,12 @@ public class UserDownloadFileDto extends PageDto implements Serializable {
     private String downloadId;
     private String downloadUserId;
     private String state;
+    private String stateName;
     private String tempUrl;
     private String communityId;
     private String downloadUserName;
     private String fileType;
+    private String fileTypeName;
 
 
     private Date createTime;
@@ -132,4 +134,20 @@ public class UserDownloadFileDto extends PageDto implements Serializable {
     public void setRemark(String remark) {
         this.remark = remark;
     }
+
+    public String getStateName() {
+        return stateName;
+    }
+
+    public void setStateName(String stateName) {
+        this.stateName = stateName;
+    }
+
+    public String getFileTypeName() {
+        return fileTypeName;
+    }
+
+    public void setFileTypeName(String fileTypeName) {
+        this.fileTypeName = fileTypeName;
+    }
 }

+ 11 - 5
java110-core/src/main/java/com/java110/core/client/FileUploadTemplate.java

@@ -11,6 +11,8 @@ import java.io.InputStream;
 @Component
 public class FileUploadTemplate {
 
+    private static final String ROOT_PATH = "hc/";
+
 
     @Autowired
     private FtpUploadTemplate ftpUploadTemplate;
@@ -27,22 +29,26 @@ public class FileUploadTemplate {
 
     public String saveFile(InputStream inputStream,String fileName){
 
+        String newfileName = ROOT_PATH+ fileName;
+
         String ossSwitch = MappingCache.getValue(OSSUtil.DOMAIN, OSSUtil.OSS_SWITCH);
 
         if (OSSUtil.OSS_SWITCH_OSS.equals(ossSwitch)) {
-            fileName = ossUploadTemplate.upload(inputStream, fileName);
+            newfileName = ossUploadTemplate.upload(inputStream, newfileName);
         } else if (COSUtil.COS_SWITCH_COS.equals(ossSwitch)) {
-            fileName = cosUploadTemplate.upload(inputStream, fileName);
+            newfileName = cosUploadTemplate.upload(inputStream, newfileName);
         } else {
             String ftpServer = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_SERVER);
             int ftpPort = Integer.parseInt(MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_PORT));
             String ftpUserName = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERNAME);
             String ftpUserPassword = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERPASSWORD);
 
-            fileName = ftpUploadTemplate.upload(inputStream, ftpServer,
+            newfileName = ftpUploadTemplate.upload(inputStream, ftpServer,
                     ftpPort, ftpUserName,
-                    ftpUserPassword, fileName);
+                    ftpUserPassword, newfileName);
         }
-        return fileName;
+
+        String imgUrl = MappingCache.getValue("IMG_PATH");
+        return imgUrl+fileName;
     }
 }

+ 1 - 2
java110-core/src/main/java/com/java110/core/client/OssUploadTemplate.java

@@ -112,7 +112,6 @@ public class OssUploadTemplate {
     }
 
     public String upload(InputStream inputStream,  String ftpPath) {
-        String fileName = "";
         OSSClient ossClient = null;
         try {
             ossClient = OSSUtil.getOSSClient();
@@ -122,7 +121,7 @@ public class OssUploadTemplate {
             throw new IllegalArgumentException("上传文件失败");
         } finally {
         }
-        return fileName;
+        return ftpPath;
     }
 
     /*

+ 3 - 1
java110-db/src/main/resources/mapper/job/UserDownloadFileV1ServiceDaoImplMapper.xml

@@ -20,8 +20,10 @@
         select t.name,t.download_id,t.download_id downloadId,t.download_user_id,t.download_user_id
         downloadUserId,t.status_cd,t.status_cd statusCd,t.state,t.temp_url,t.temp_url
         tempUrl,t.community_id,t.community_id communityId,t.download_user_name,t.download_user_name
-        downloadUserName,t.file_type,t.file_type fileType
+        downloadUserName,t.file_type,t.file_type fileType,td.name stateName,td1.name fileTypeName,t.create_time createTime,t.remark
         from user_download_file t
+        left join t_dict td on t.state = td.status_cd and td.table_name = 'user_download_file' and td.table_columns = 'state'
+        left join t_dict td1 on t.file_type = td1.status_cd and td1.table_name = 'user_download_file' and td1.table_columns = 'file_type'
         where 1 =1
         <if test="name !=null and name != ''">
             and t.name= #{name}

+ 6 - 4
service-common/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java

@@ -23,6 +23,8 @@ import java.util.List;
 @RestController
 public class FileInnerServiceSMOImpl extends BaseServiceSMO implements IFileInnerServiceSMO {
 
+    private static final String ROOT_PATH = "hc/";
+
     @Autowired
     private IFileServiceDao fileServiceDaoImpl;
 
@@ -51,21 +53,21 @@ public class FileInnerServiceSMOImpl extends BaseServiceSMO implements IFileInne
         if (OSSUtil.OSS_SWITCH_OSS.equals(ossSwitch)) {
             fileName = ossUploadTemplate.upload(fileDto.getContext(), java110Properties.getFtpServer(),
                     java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
-                    java110Properties.getFtpUserPassword(), java110Properties.getFtpPath());
+                    java110Properties.getFtpUserPassword(), ROOT_PATH);
         } else if (COSUtil.COS_SWITCH_COS.equals(ossSwitch)) {
             fileName = cosUploadTemplate.upload(fileDto.getContext(), java110Properties.getFtpServer(),
                     java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
-                    java110Properties.getFtpUserPassword(), java110Properties.getFtpPath());
+                    java110Properties.getFtpUserPassword(), ROOT_PATH);
         } else {
             String ftpServer = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_SERVER);
             int ftpPort = Integer.parseInt(MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_PORT));
             String ftpUserName = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERNAME);
             String ftpUserPassword = MappingCache.getValue(FtpUploadTemplate.FTP_DOMAIN, FtpUploadTemplate.FTP_USERPASSWORD);
-            String ftpPath = java110Properties.getFtpPath();
+            //String ftpPath = java110Properties.getFtpPath();
 
             fileName = ftpUploadTemplate.upload(fileDto.getContext(), ftpServer,
                         ftpPort, ftpUserName,
-                        ftpUserPassword, ftpPath);
+                        ftpUserPassword, ROOT_PATH);
         }
         return fileName;
     }

+ 3 - 3
service-job/src/main/java/com/java110/job/cmd/export/ExportDataCmd.java

@@ -27,7 +27,7 @@ import java.util.List;
 @Java110Cmd(serviceCode = "export.exportData")
 public class ExportDataCmd extends Cmd {
 
-    private static final String EXPORT_DATA_PRE = "hc/temp/export/data/";
+    private static final String EXPORT_DATA_PRE = "temp/export/data/";
 
     public static final String CODE_PREFIX_ID = "10";
 
@@ -60,7 +60,7 @@ public class ExportDataCmd extends Cmd {
         exportDataDto.setReqJson(reqJson);
         String fileName = DateUtil.getyyyyMMddhhmmssDateString()
                 + ".xlsx";
-        exportDataDto.setFileName(exportDataDto
+        exportDataDto.setFileName(EXPORT_DATA_PRE
                 + reqJson.getString("pagePath")
                 + "/"
                 + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B)
@@ -70,7 +70,7 @@ public class ExportDataCmd extends Cmd {
         UserDownloadFilePo userDownloadFilePo = new UserDownloadFilePo();
         userDownloadFilePo.setDownloadId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
         userDownloadFilePo.setDownloadUserId(userId);
-        userDownloadFilePo.setDownloadUserName(userDtos.get(0).getUserName());
+        userDownloadFilePo.setDownloadUserName(userDtos.get(0).getName());
         userDownloadFilePo.setFileType(reqJson.getString("pagePath"));
         userDownloadFilePo.setCommunityId(reqJson.getString("communityId"));
         userDownloadFilePo.setName(fileName);

+ 4 - 3
service-job/src/main/java/com/java110/job/cmd/userDownloadFile/DeleteUserDownloadFileCmd.java

@@ -31,6 +31,7 @@ import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 /**
  * 类表述:删除
  * 服务编码:userDownloadFile.deleteUserDownloadFile
@@ -43,7 +44,7 @@ import org.slf4j.LoggerFactory;
  */
 @Java110Cmd(serviceCode = "userDownloadFile.deleteUserDownloadFile")
 public class DeleteUserDownloadFileCmd extends Cmd {
-  private static Logger logger = LoggerFactory.getLogger(DeleteUserDownloadFileCmd.class);
+    private static Logger logger = LoggerFactory.getLogger(DeleteUserDownloadFileCmd.class);
 
     @Autowired
     private IUserDownloadFileV1InnerServiceSMO userDownloadFileV1InnerServiceSMOImpl;
@@ -51,7 +52,7 @@ public class DeleteUserDownloadFileCmd extends Cmd {
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "downloadId", "downloadId不能为空");
-Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
+        Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
 
     }
 
@@ -59,7 +60,7 @@ Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
-       UserDownloadFilePo userDownloadFilePo = BeanConvertUtil.covertBean(reqJson, UserDownloadFilePo.class);
+        UserDownloadFilePo userDownloadFilePo = BeanConvertUtil.covertBean(reqJson, UserDownloadFilePo.class);
         int flag = userDownloadFileV1InnerServiceSMOImpl.deleteUserDownloadFile(userDownloadFilePo);
 
         if (flag < 1) {

+ 17 - 12
service-job/src/main/java/com/java110/job/cmd/userDownloadFile/ListUserDownloadFileCmd.java

@@ -30,8 +30,10 @@ import com.java110.utils.util.BeanConvertUtil;
 import com.java110.vo.ResultVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import com.java110.dto.userDownloadFile.UserDownloadFileDto;
+
 import java.util.List;
 import java.util.ArrayList;
+
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.HttpStatus;
 import org.slf4j.Logger;
@@ -51,7 +53,7 @@ import org.slf4j.LoggerFactory;
 @Java110Cmd(serviceCode = "userDownloadFile.listUserDownloadFile")
 public class ListUserDownloadFileCmd extends Cmd {
 
-  private static Logger logger = LoggerFactory.getLogger(ListUserDownloadFileCmd.class);
+    private static Logger logger = LoggerFactory.getLogger(ListUserDownloadFileCmd.class);
     @Autowired
     private IUserDownloadFileV1InnerServiceSMO userDownloadFileV1InnerServiceSMOImpl;
 
@@ -63,22 +65,25 @@ public class ListUserDownloadFileCmd extends Cmd {
     @Override
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
 
-           UserDownloadFileDto userDownloadFileDto = BeanConvertUtil.covertBean(reqJson, UserDownloadFileDto.class);
+        String userId = cmdDataFlowContext.getReqHeaders().get("user-id");
+
+        UserDownloadFileDto userDownloadFileDto = BeanConvertUtil.covertBean(reqJson, UserDownloadFileDto.class);
+        userDownloadFileDto.setDownloadUserId(userId);
 
-           int count = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFilesCount(userDownloadFileDto);
+        int count = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFilesCount(userDownloadFileDto);
 
-           List<UserDownloadFileDto> userDownloadFileDtos = null;
+        List<UserDownloadFileDto> userDownloadFileDtos = null;
 
-           if (count > 0) {
-               userDownloadFileDtos = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFiles(userDownloadFileDto);
-           } else {
-               userDownloadFileDtos = new ArrayList<>();
-           }
+        if (count > 0) {
+            userDownloadFileDtos = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFiles(userDownloadFileDto);
+        } else {
+            userDownloadFileDtos = new ArrayList<>();
+        }
 
-           ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, userDownloadFileDtos);
+        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, userDownloadFileDtos);
 
-           ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
 
-           cmdDataFlowContext.setResponseEntity(responseEntity);
+        cmdDataFlowContext.setResponseEntity(responseEntity);
     }
 }

+ 20 - 7
service-job/src/main/java/com/java110/job/export/ExportDataExecutor.java

@@ -30,19 +30,30 @@ public class ExportDataExecutor implements Runnable {
     //默认线程大小
     private static final int DEFAULT_EXPORT_POOL = 4;
 
-    public ExportDataExecutor() {
+    private boolean isRun = false;
+
+    public ExportDataExecutor(boolean isRun) {
         this.userDownloadFileV1InnerServiceSMOImpl = ApplicationContextFactory.getBean("userDownloadFileV1InnerServiceSMOImpl", IUserDownloadFileV1InnerServiceSMO.class);
         this.fileUploadTemplate = ApplicationContextFactory.getBean("fileUploadTemplate", FileUploadTemplate.class);
+        this.isRun = isRun;
+    }
+
+    public ExportDataExecutor() {
     }
 
     @Override
     public void run() {
 
-        try {
-            doExportData();
-        } catch (Exception e) {
-            log.error("处理消息异常", e);
-            e.printStackTrace();
+        while (isRun) {
+            log.debug("导出数据线程开始处理");
+            try {
+                doExportData();
+            } catch (Exception e) {
+                log.error("处理消息异常", e);
+                e.printStackTrace();
+            }
+            log.debug("导出数据线程处理完成");
+
         }
 
     }
@@ -76,6 +87,8 @@ public class ExportDataExecutor implements Runnable {
             inputStream = new ByteArrayInputStream(os.toByteArray());
 
             fileName = fileUploadTemplate.saveFile(inputStream, exportDataDto.getFileName());
+
+
             updateUserDownloadFile(exportDataDto, UserDownloadFileDto.STATE_FINISH,fileName, "下载完成");
 
         } catch (Exception e) {
@@ -116,6 +129,6 @@ public class ExportDataExecutor implements Runnable {
      */
     public static void startExportDataExecutor() {
         ExecutorService executorService = Executors.newFixedThreadPool(DEFAULT_EXPORT_POOL);
-        executorService.execute(new ExportDataExecutor());
+        executorService.execute(new ExportDataExecutor(true));
     }
 }

+ 128 - 0
service-job/src/main/java/com/java110/job/export/adapt/ListOweFeeAdapt.java

@@ -0,0 +1,128 @@
+package com.java110.job.export.adapt;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.dto.data.ExportDataDto;
+import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsDto;
+import com.java110.job.export.IExportDataAdapt;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 欠费信息 数据导出功能
+ *
+ */
+@Service("reportPayFeeDetail")
+public class ListOweFeeAdapt implements IExportDataAdapt {
+
+    private static final int MAX_ROW = 100;
+
+    @Override
+    public SXSSFWorkbook exportData(ExportDataDto exportDataDto) {
+
+        SXSSFWorkbook workbook = null;  //工作簿
+        String userId = "";
+        //工作表
+        workbook = new SXSSFWorkbook();
+        workbook.setCompressTempFiles(false);
+
+
+        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("支付方式");
+        row.createCell(7).setCellValue("费用开始时间");
+        row.createCell(8).setCellValue("费用结束时间");
+        row.createCell(9).setCellValue("缴费时间");
+        row.createCell(10).setCellValue("应收金额");
+        row.createCell(11).setCellValue("实收金额");
+        row.createCell(12).setCellValue("优惠金额");
+        row.createCell(13).setCellValue("减免金额");
+        row.createCell(14).setCellValue("赠送金额");
+        row.createCell(15).setCellValue("滞纳金");
+        row.createCell(16).setCellValue("空置房打折金额");
+        row.createCell(17).setCellValue("空置房减免金额");
+        row.createCell(18).setCellValue("面积");
+        row.createCell(19).setCellValue("车位");
+
+
+        JSONObject reqJson = exportDataDto.getReqJson();
+        ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto = BeanConvertUtil.covertBean(reqJson,ReportFeeMonthStatisticsDto.class);
+        if(reqJson.containsKey("roomName") && !StringUtil.isEmpty(reqJson.getString("roomName"))){
+            String[] roomNameArray = reqJson.getString("roomName").split("-",3);
+            reportFeeMonthStatisticsDto.setFloorNum(roomNameArray[0]);
+            reportFeeMonthStatisticsDto.setUnitNum(roomNameArray[1]);
+            reportFeeMonthStatisticsDto.setRoomNum(roomNameArray[2]);
+        }
+
+        //查询数据
+        getRepairPayFeeDetail(sheet, reportFeeMonthStatisticsDto);
+
+        return workbook;
+
+    }
+
+    private void getRepairPayFeeDetail(Sheet sheet, ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
+        reportFeeMonthStatisticsDto.setPage(1);
+        reportFeeMonthStatisticsDto.setRow(MAX_ROW);
+        ResultVo resultVo = null;//queryPayFeeDetailInnerServiceSMOImpl.query(reportFeeMonthStatisticsDto);
+        appendData(resultVo,sheet,0);
+
+        if(resultVo.getRecords() < 2){
+            return ;
+        }
+
+        for(int page = 2;page <= resultVo.getRecords(); page++){
+            reportFeeMonthStatisticsDto.setPage(page);
+            reportFeeMonthStatisticsDto.setRow(MAX_ROW);
+            resultVo = null; //queryPayFeeDetailInnerServiceSMOImpl.query(reportFeeMonthStatisticsDto);
+            appendData(resultVo,sheet,(page-1)*MAX_ROW);
+        }
+    }
+
+    private void appendData(ResultVo resultVo,Sheet sheet,int step) {
+
+        List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = (List<ReportFeeMonthStatisticsDto>)resultVo.getData();
+        Row row = null;
+        JSONObject dataObj = null;
+        for (int roomIndex = 0; roomIndex < reportFeeMonthStatisticsDtos.size(); roomIndex++) {
+            row = sheet.createRow(roomIndex +step + 1);
+            dataObj = JSONObject.parseObject(JSONObject.toJSONString(reportFeeMonthStatisticsDtos.get(roomIndex)));
+            row.createCell(0).setCellValue(dataObj.getString("oId"));
+            if (!StringUtil.isEmpty(dataObj.getString("payerObjType")) && dataObj.getString("payerObjType").equals("3333")) { //房屋
+                row.createCell(1).setCellValue(dataObj.getString("floorNum") + "-" + dataObj.getString("unitNum") + "-" + dataObj.getString("roomNum"));
+            } else {
+                row.createCell(1).setCellValue(dataObj.getString("objName"));
+            }
+            row.createCell(2).setCellValue(dataObj.getString("ownerName"));
+            row.createCell(3).setCellValue(dataObj.getString("feeName"));
+            row.createCell(4).setCellValue(dataObj.getString("feeTypeCdName"));
+            row.createCell(5).setCellValue(dataObj.getString("stateName"));
+            row.createCell(6).setCellValue(dataObj.getString("primeRate"));
+            row.createCell(7).setCellValue(dataObj.getString("startTime"));
+            row.createCell(8).setCellValue(dataObj.getString("endTime"));
+            row.createCell(9).setCellValue(dataObj.getString("createTime"));
+            row.createCell(10).setCellValue(dataObj.getDouble("receivableAmount"));
+            row.createCell(11).setCellValue(dataObj.getDouble("receivedAmount"));
+            row.createCell(12).setCellValue(dataObj.getDouble("preferentialAmount"));
+            row.createCell(13).setCellValue(dataObj.getDouble("deductionAmount"));
+            row.createCell(14).setCellValue(dataObj.getDouble("giftAmount"));
+            row.createCell(15).setCellValue(dataObj.getDouble("lateFee"));
+            row.createCell(16).setCellValue(dataObj.getDouble("vacantHousingDiscount"));
+            row.createCell(17).setCellValue(dataObj.getDouble("vacantHousingReduction"));
+            row.createCell(18).setCellValue(dataObj.getString("builtUpArea"));
+            row.createCell(19).setCellValue(dataObj.getString("psName"));
+        }
+    }
+}

+ 4 - 0
springboot/src/main/java/com/java110/boot/BootApplicationStart.java

@@ -27,6 +27,7 @@ import com.java110.doc.annotation.Java110CmdDocDiscovery;
 import com.java110.doc.registrar.ApiDocCmdPublishing;
 import com.java110.doc.registrar.ApiDocPublishing;
 import com.java110.intf.dev.ICacheV1InnerServiceSMO;
+import com.java110.job.export.ExportDataExecutor;
 import com.java110.service.init.ServiceStartInit;
 import com.java110.utils.factory.ApplicationContextFactory;
 import com.java110.utils.util.StringUtil;
@@ -187,6 +188,9 @@ public class BootApplicationStart {
 
             Environment.setSystemStartWay(Environment.SPRING_BOOT);
 
+            //启动导出数据线程处理器
+            ExportDataExecutor.startExportDataExecutor();
+
             //刷新缓存
             flushMainCache(args);
         } catch (Throwable e) {