Browse Source

Merge branch '20210204' into 20210223

lin 4 years ago
parent
commit
4a9f4004e7
23 changed files with 834 additions and 32 deletions
  1. 138 0
      smart-city-platform/src/main/java/com/bz/smart_city/commom/util/ExcelUtil.java
  2. 3 2
      smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java
  3. 2 1
      smart-city-platform/src/main/java/com/bz/smart_city/controller/assistant/InstallController.java
  4. 17 6
      smart-city-platform/src/main/java/com/bz/smart_city/controller/common/FileController.java
  5. 14 0
      smart-city-platform/src/main/java/com/bz/smart_city/dao/TaskMapper.java
  6. 3 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/ProgramItem.java
  7. 31 0
      smart-city-platform/src/main/java/com/bz/smart_city/entity/Task.java
  8. 17 2
      smart-city-platform/src/main/java/com/bz/smart_city/excel/download/column/GeneralDownload.java
  9. 2 2
      smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/DefaultHandleExcelService.java
  10. 20 0
      smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/RabbitConfig.java
  11. 42 0
      smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/listener/DownloadDeviceReceiver.java
  12. 43 0
      smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/listener/DownloadInstallReceiver.java
  13. 42 0
      smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/model/RabbitDeviceParamData.java
  14. 40 0
      smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/model/RabbitInstallParamData.java
  15. 5 1
      smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java
  16. 15 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/TaskService.java
  17. 227 13
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java
  18. 63 0
      smart-city-platform/src/main/java/com/bz/smart_city/service/impl/TaskServiceImpl.java
  19. 6 1
      smart-city-platform/src/main/resources/application-dev.properties
  20. 6 2
      smart-city-platform/src/main/resources/application-prd.properties
  21. 5 1
      smart-city-platform/src/main/resources/application-sit.properties
  22. 1 1
      smart-city-platform/src/main/resources/application.properties
  23. 92 0
      smart-city-platform/src/main/resources/mapper/TaskMapper.xml

+ 138 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/util/ExcelUtil.java

@@ -203,6 +203,144 @@ public class ExcelUtil {
 
     }
 
+
+    public void download(String path) throws Exception {
+        try {
+            HSSFWorkbook workbook = new HSSFWorkbook();                        // 创建工作簿对象
+            int pointsDataLimit = 60000;
+            int part = dataList.size() / pointsDataLimit;//分批数
+            for (int p = 0; p <= part; p++) {
+                if(dataList.size() <  pointsDataLimit){
+                    pointsDataLimit = dataList.size();
+                }
+                List<Object[]> listPage = dataList.subList(0, pointsDataLimit);
+                HSSFSheet sheet = workbook.createSheet("Sheet"+(p+1));                     // 创建工作表
+
+                // 产生表格标题行
+                HSSFRow rowm = sheet.createRow(0);
+                HSSFCell cellTiltle = rowm.createCell(0);
+
+                //sheet样式定义【getColumnTopStyle()/getStyle()均为自定义方法 - 在下面  - 可扩展】
+                HSSFCellStyle columnTopStyle = this.getColumnTopStyle(workbook);//获取列头样式对象
+                HSSFCellStyle style = this.getStyle(workbook);                    //单元格样式对象
+
+                sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, (rowName.length - 1)));
+                cellTiltle.setCellStyle(columnTopStyle);
+                cellTiltle.setCellValue(title);
+
+
+                HSSFRow rowRowName = null;
+                if(eList != null && eList.size() > 0){
+                    for(int i=0; i<eList.size(); i++){
+                        Row searchFormRow = sheet.createRow(2+i);
+                        Cell searchFormCell = searchFormRow.createCell(0);
+                        searchFormCell.setCellValue(eList.get(i));
+                        sheet.addMergedRegion(new CellRangeAddress(searchFormRow.getRowNum(),
+                                searchFormRow.getRowNum(), 0, (rowName.length - 1)));
+                    }
+                    rowRowName = sheet.createRow(4);                // 在索引4的位置创建行(最顶端的行开始的第二行)
+                }else{
+                    rowRowName = sheet.createRow(2);                // 在索引2的位置创建行(最顶端的行开始的第二行)
+                }
+
+                // 定义所需列数
+                int columnNum = rowName.length;
+
+                // 将列头设置到sheet的单元格中
+                for (int n = 0; n < columnNum; n++) {
+                    HSSFCell cellRowName = rowRowName.createCell(n);                //创建列头对应个数的单元格
+                    cellRowName.setCellType(CellType.STRING);                //设置列头单元格的数据类型
+                    HSSFRichTextString text = new HSSFRichTextString(rowName[n]);
+                    cellRowName.setCellValue(text);                                    //设置列头单元格的值
+                    cellRowName.setCellStyle(columnTopStyle);                        //设置列头单元格样式
+                }
+
+                //将查询出的数据设置到sheet对应的单元格中
+                for (int i = 0; i < listPage.size(); i++) {
+                    Object[] obj = listPage.get(i);//遍历每个对象
+                    HSSFRow row = null;
+                    if(eList != null && eList.size() > 0){
+                        row = sheet.createRow(i + 5);//创建所需的行数
+                    }else{
+                        row = sheet.createRow(i + 3);//创建所需的行数
+                    }
+
+
+                    for (int j = 0; j < obj.length; j++) {
+                        HSSFCell cell = null;   //设置单元格的数据类型
+                        if (j == 0) {
+                            cell = row.createCell(j, CellType.NUMERIC);
+                            cell.setCellValue(i + 1);
+                        } else {
+                            cell = row.createCell(j, CellType.STRING);
+                            if (obj[j] != null && !"".equals(obj[j])) {
+                                cell.setCellValue(obj[j].toString());                        //设置单元格的值
+                            }else {
+                                cell.setCellValue("-");
+                            }
+                        }
+                        cell.setCellStyle(style);                                    //设置单元格样式
+                    }
+                }
+                //让列宽随着导出的列长自动适应
+                for (int colNum = 0; colNum < columnNum; colNum++) {
+                    int columnWidth = sheet.getColumnWidth(colNum) / 256;
+                    for (int rowNum = 0; rowNum <= sheet.getLastRowNum(); rowNum++) {
+                        HSSFRow currentRow;
+                        //当前行未被使用过
+                        if (sheet.getRow(rowNum) == null) {
+                            currentRow = sheet.createRow(rowNum);
+                        } else {
+                            currentRow = sheet.getRow(rowNum);
+                        }
+                        if (currentRow.getCell(colNum) != null) {
+                            HSSFCell currentCell = currentRow.getCell(colNum);
+                            String numbers = "";
+
+                            if (currentCell.getCellTypeEnum() == CellType.STRING) {
+                                int length = calculateLength(currentCell.getStringCellValue());
+                                if (columnWidth < length) {
+                                    columnWidth = length;
+                                }
+                                if(eList != null && eList.size() > 0){
+                                    if(rowNum == 4){
+                                        numbers = currentCell != null ? currentCell.getStringCellValue() : "";
+                                    }
+                                    if(numbers.equals("序号")){
+                                        columnWidth = 18;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                    if(columnWidth > 60){
+                        sheet.setColumnWidth(colNum, 60 * 256);
+                    }else {
+                        sheet.setColumnWidth(colNum, columnWidth * 256);
+                    }
+                }
+                //剔除
+                dataList.subList(0, pointsDataLimit).clear();
+            }
+
+            try {
+                //输出Excel文件
+                FileOutputStream output = new FileOutputStream(path);
+                workbook.write(output);
+                output.flush();
+                workbook.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }finally {
+                workbook.close();
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
     /*
      * 列头单元格样式
      */

+ 3 - 2
smart-city-platform/src/main/java/com/bz/smart_city/controller/DeviceController.java

@@ -93,9 +93,10 @@ public class DeviceController {
         return new AjaxMessage<>(ResultStatus.OK, pageInfo);
     }
 
+    @ResponseBody
     @GetMapping("/getDeviceListExcel")
     @ApiOperation(value = "导出设备列表excel")
-    public void getDeviceListExcel(
+    public AjaxMessage getDeviceListExcel(
             @ApiParam(value = "别名", required = false) @RequestParam(required = false) String alias,
             @ApiParam(value = "系统id", required = false) @RequestParam(required = false) Integer sysId,
             @ApiParam(value = "客户id", required = false) @RequestParam(required = false) Integer customerId,
@@ -129,7 +130,7 @@ public class DeviceController {
         deviceService.getDeviceListExcel(alias,sysId, buildingId, StringUtils.trim(deviceNo), status, floor, StringUtils.trim(locDesc),
                 province, city, region, community,concentratorId, concentratorNo, collectorId,collectorNo,channelNumberId, errorType, customerId, days,
                 deviceTypeId,valveStatus,registerStatus,issueStatus,syncStatus, startReading, endReading, sortColumn, sortOrder, httpServletResponse);
-
+        return new AjaxMessage<>(ResultStatus.OK,"导出执行成功,请稍后在消息查看导出文件并下载。");
     }
 
 

+ 2 - 1
smart-city-platform/src/main/java/com/bz/smart_city/controller/assistant/InstallController.java

@@ -262,7 +262,7 @@ public class InstallController {
 	@ResponseBody
 	@GetMapping("/exportInstallList")
 	@ApiOperation(value = "导出已安装列表")
-	public void exportInstalledList(
+	public AjaxMessage exportInstalledList(
 			@ApiParam(value = "场景id 40:lora水表 58:NB水表 55:远传", required = false) @RequestParam(required = false) Integer channelId,
 		@ApiParam(value = "设备编号/水表电子号", required = false) @RequestParam(required = false) String deviceNo,
 		@ApiParam(value = "状态  1:正常 2:故障 3:无 4: 预警 5:未启用", required = false) @RequestParam(required = false) Integer status,
@@ -289,6 +289,7 @@ public class InstallController {
 		deviceService.exportInstallList(channelId,deviceNo,status,errorType,customerId,province,city,region,community,buildingId,locDesc,deviceTypeId,registerStatus,
 				issueStatus,concentratorId,channelNumberId,collectorNo,
 				startDate,endDate,sortColumn,sortOrder,httpServletResponse);
+		return new AjaxMessage<>(ResultStatus.OK,"导出执行成功,请稍后在消息查看导出文件并下载。");
 	}
 
     @ResponseBody

+ 17 - 6
smart-city-platform/src/main/java/com/bz/smart_city/controller/common/FileController.java

@@ -4,20 +4,18 @@ import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.entity.File;
 import com.bz.smart_city.service.FileService;
+import com.bz.smart_city.service.TaskService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.IOException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 @Controller
 @ResponseBody
@@ -28,6 +26,8 @@ public class FileController {
 
     @Autowired
     private FileService fileService;
+    @Autowired
+    private TaskService taskService;
 
     @PostMapping
     @ApiOperation(value = "文件上传")
@@ -44,4 +44,15 @@ public class FileController {
     	File fileInfo = fileService.getFileInfo(fileId);
         return new AjaxMessage<>(ResultStatus.OK,fileInfo);
     }
+
+
+    @GetMapping("/task/download")
+    @ApiOperation(value = "下载任务文件")
+    public void downloadFailTemplate(
+            @ApiParam(value = "id", required = true) @RequestParam(required = true) Integer objId,
+            @ApiParam(value = "token", required = true) @RequestParam(required = true) String token,
+            HttpServletRequest request, HttpServletResponse response
+    ) {
+        taskService.download(objId,response);
+    }
 }

+ 14 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/TaskMapper.java

@@ -0,0 +1,14 @@
+package com.bz.smart_city.dao;
+
+import com.bz.smart_city.entity.Task;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface TaskMapper {
+    int insertSelective(Task record);
+
+    int updateByPrimaryKeySelective(Task record);
+
+    Task findById(@Param("Id") Integer Id);
+}

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/ProgramItem.java

@@ -1,5 +1,6 @@
 package com.bz.smart_city.entity;
 
+import com.alibaba.fastjson.annotation.JSONField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -35,9 +36,11 @@ public class ProgramItem implements Serializable {
     @ApiModelProperty(value="状态")
     private Integer status;
 
+    @JSONField(format="yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value="创建时间")
     private LocalDateTime dateCreate;
 
+    @JSONField(format="yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value="更新时间")
     private LocalDateTime dateUpdate;
 

+ 31 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/Task.java

@@ -0,0 +1,31 @@
+package com.bz.smart_city.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.time.LocalDateTime;
+import lombok.Data;
+
+@ApiModel(value="com-bz-smart_city-entity-Task")
+@Data
+public class Task {
+    @ApiModelProperty(value="")
+    private Integer id;
+
+    @ApiModelProperty(value="")
+    private String name;
+
+    @ApiModelProperty(value="")
+    private Integer type;
+
+    @ApiModelProperty(value="")
+    private String path;
+
+    @ApiModelProperty(value="")
+    private Integer status;
+
+    @ApiModelProperty(value="")
+    private LocalDateTime createDate;
+
+    @ApiModelProperty(value="")
+    private LocalDateTime updateDate;
+}

+ 17 - 2
smart-city-platform/src/main/java/com/bz/smart_city/excel/download/column/GeneralDownload.java

@@ -5,10 +5,12 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.util.ExcelUtil;
+import com.bz.smart_city.commom.util.Util;
 import com.bz.smart_city.dto.DeviceDto;
 import com.bz.smart_city.service.ScConfigurationService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletResponse;
@@ -19,11 +21,21 @@ import static com.google.common.collect.Lists.newArrayList;
 @Service
 public class GeneralDownload {
 
+    @Value("${files.path}")
+    private String filesPath;
+
     private DeviceColumnTranslator deviceColumnTranslator = new DeviceColumnTranslator();
 
     @Autowired
     private ScConfigurationService scConfigurationService;
 
+    protected String getFilePath() {
+        String name = Util.createUUIDId();
+        String fullPath = filesPath + "/file/" + name + ".xls";
+        return fullPath;
+    }
+
+
     private List<String> getRowsNameList(List<String> list) {
         List<String>  rowsNameList = newArrayList();
         JSONArray all =  scConfigurationService.getDeviceAllColumn();
@@ -40,7 +52,7 @@ public class GeneralDownload {
         }
         return rowsNameList;
     }
-    public void export(String title, String alias, List<DeviceDto> deviceList, HttpServletResponse httpServletResponse){
+    public String export(String title, String alias, List<DeviceDto> deviceList, HttpServletResponse httpServletResponse){
         if (alias == null) {
             alias = "general";
         }
@@ -63,11 +75,14 @@ public class GeneralDownload {
             }
             ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
             try {
-                excelUtil.export(httpServletResponse);
+                String filePath = this.getFilePath();
+                excelUtil.download(filePath);
+                return filePath;
             } catch (Exception e) {
                 throw new ServiceException(-900, "导出异常");
             }
         }
+        return null;
     }
 
 

+ 2 - 2
smart-city-platform/src/main/java/com/bz/smart_city/excel/resolver/DefaultHandleExcelService.java

@@ -46,7 +46,7 @@ public class DefaultHandleExcelService implements HandleExcelService {
     public void exception(ExcelData data) {
         data.getMessageContent().append("导入失败,读取文件错误。");
         Message message = new Message();
-        message.setSiteId(data.getRecord().getUserId());
+        message.setSiteId(data.getRecord().getSiteId());
         message.setUserId(data.getRecord().getUserId());
         message.setMessageType(data.getRecord().getType());
         message.setMessageTitle(data.getMessageTitle());
@@ -101,7 +101,7 @@ public class DefaultHandleExcelService implements HandleExcelService {
 
         //更新完成生成消息
         Message message = new Message();
-        message.setSiteId(data.getRecord().getUserId());
+        message.setSiteId(data.getRecord().getSiteId());
         message.setUserId(data.getRecord().getUserId());
         message.setMessageType(data.getRecord().getType());
         message.setMessageTitle(data.getMessageTitle());

+ 20 - 0
smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/RabbitConfig.java

@@ -4,11 +4,15 @@ package com.bz.smart_city.rabbitmq;
 import com.bz.smart_city.dao.ScRabbitConfigMapper;
 import com.bz.smart_city.entity.ScRabbitConfig;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
 import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
 import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.rabbit.connection.SimpleResourceHolder;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.DependsOn;
 
 import javax.annotation.Resource;
 import java.util.HashMap;
@@ -54,5 +58,21 @@ public class RabbitConfig {
 
 
     }
+
+
+    @Bean("platformListenerContainerFactory")
+    @DependsOn("routeConnectionFactory")
+    public SimpleRabbitListenerContainerFactory containerFactory(SimpleRabbitListenerContainerFactoryConfigurer configurer) {
+        ConnectionFactory connectionFactory = DynamicRoutingConnectionFactory.getInstance().getTargetConnectionFactory("platform");
+
+
+        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
+        //设置线程数
+        factory.setConcurrentConsumers(1);
+        //最大线程数
+        factory.setMaxConcurrentConsumers(1);
+        configurer.configure(factory, connectionFactory);
+        return factory;
+    }
 }
 

+ 42 - 0
smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/listener/DownloadDeviceReceiver.java

@@ -0,0 +1,42 @@
+package com.bz.smart_city.rabbitmq.listener;
+
+import com.alibaba.fastjson.JSON;
+import com.bz.smart_city.rabbitmq.model.RabbitDeviceParamData;
+import com.bz.smart_city.service.DeviceService;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+
+@Component
+@Slf4j
+public class DownloadDeviceReceiver {
+
+    @Autowired
+    private DeviceService deviceService;
+
+
+
+    @RabbitListener(queues = {"${spring.rabbitmq.download-device-queue}"},containerFactory = "platformListenerContainerFactory")
+    public void receiver(Channel channel, Message message) throws IOException {
+        //String str = new String(body);
+        try {
+        String msg = new String(message.getBody());
+        log.info("-----DownloadDeviceReceiver msg-----,"  +msg);
+        RabbitDeviceParamData data = JSON.parseObject(msg, RabbitDeviceParamData.class);
+        //log.info("-----DownloadDeviceReceiver params-----,"  +JSON.toJSONString(data));
+        // 1,处理消息
+        deviceService.executeDeviceListExcel(data);
+
+        // 2,确认消息消费成功 
+        //channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+        } catch (Exception e) {
+            channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
+            log.error("consumer message error !",e);
+        }
+    }
+}

+ 43 - 0
smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/listener/DownloadInstallReceiver.java

@@ -0,0 +1,43 @@
+package com.bz.smart_city.rabbitmq.listener;
+
+import com.alibaba.fastjson.JSON;
+import com.bz.smart_city.rabbitmq.model.RabbitDeviceParamData;
+import com.bz.smart_city.rabbitmq.model.RabbitInstallParamData;
+import com.bz.smart_city.service.DeviceService;
+import com.rabbitmq.client.Channel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+
+@Component
+@Slf4j
+public class DownloadInstallReceiver {
+
+    @Autowired
+    private DeviceService deviceService;
+
+
+
+    @RabbitListener(queues = {"${spring.rabbitmq.download-install-queue}"},containerFactory = "platformListenerContainerFactory")
+    public void receiver(Channel channel, Message message) throws IOException {
+        //String str = new String(body);
+        try {
+        String msg = new String(message.getBody());
+        log.info("-----DownloadInstallReceiver msg-----,"  +msg);
+        RabbitInstallParamData data = JSON.parseObject(msg, RabbitInstallParamData.class);
+        //log.info("-----DownloadInstallReceiver params-----,"  +JSON.toJSONString(data));
+        // 1,处理消息
+        deviceService.executeExportInstallList(data);
+
+        // 2,确认消息消费成功 
+        //channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
+        } catch (Exception e) {
+            channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);
+            log.error("consumer message error !",e);
+        }
+    }
+}

+ 42 - 0
smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/model/RabbitDeviceParamData.java

@@ -0,0 +1,42 @@
+package com.bz.smart_city.rabbitmq.model;
+
+import com.bz.smart_city.entity.ProgramItem;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class RabbitDeviceParamData {
+    private Integer taskId;
+    private Integer userId;
+    private String alias;
+    private Integer sysId;
+    private Integer buildingId;
+    private Integer siteId;
+    private String deviceNo;
+    private Integer status;
+    private Integer floor;
+    private String locDesc;
+    private Integer province;
+    private Integer city;
+    private Integer region;
+    private Integer community;
+    private Integer concentratorId;
+    private String concentratorNo;
+    private Integer collectorId;
+    private String collectorNo;
+    private String errorType;
+    private Integer customerId;
+    private Integer days;
+    private Integer deviceTypeId;
+    private Integer valveStatus;
+    private Integer registerStatus;
+    private Integer issueStatus;
+    private Integer syncStatus;
+    private Double startReading;
+    private Double endReading;
+    private String sortColumn;
+    private String sortOrder;
+    private String title;
+    private List<ProgramItem> programItemList;
+}

+ 40 - 0
smart-city-platform/src/main/java/com/bz/smart_city/rabbitmq/model/RabbitInstallParamData.java

@@ -0,0 +1,40 @@
+package com.bz.smart_city.rabbitmq.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.bz.smart_city.entity.ProgramItem;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Data
+public class RabbitInstallParamData {
+    private Integer taskId;
+    private Integer userId;
+    private Integer siteId;
+    private Integer channelId;
+    private String deviceNo;
+    private Integer status;
+    private String errorType;
+    private Integer customerId;
+    private Integer province;
+    private Integer city;
+    private Integer region;
+    private Integer community;
+    private Integer buildingId;
+    private String locDesc;
+    private Integer deviceTypeId;
+    private Integer registerStatus;
+    private Integer issueStatus;
+    private Integer concentratorId;
+    private Integer channelNumberId;
+    private String collectorNo;
+    @JSONField(format="yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime startDate;
+    @JSONField(format="yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime endDate;
+    private String sortColumn;
+    private String sortOrder;
+    private String title;
+    private List<ProgramItem> programItemList;
+}

+ 5 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/DeviceService.java

@@ -13,6 +13,8 @@ import com.bz.smart_city.dto.udip.CommandRspNotifyResult;
 import com.bz.smart_city.entity.Device;
 import com.bz.smart_city.entity.ProgramItem;
 import com.bz.smart_city.entity.Site;
+import com.bz.smart_city.rabbitmq.model.RabbitDeviceParamData;
+import com.bz.smart_city.rabbitmq.model.RabbitInstallParamData;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
@@ -51,7 +53,7 @@ public interface DeviceService{
                             String locDesc, Integer province, Integer city, Integer region, Integer community, Integer concentratorId, String concentratorNo, Integer collectorId, String collectorNo,Integer channelNumberId, String errorType,
                             Integer customerId, Integer days,  Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
 
-
+    void executeDeviceListExcel(RabbitDeviceParamData paramData);
 
     void exportDeviceListAsXML(Integer sysId,
                                Integer buildingId,
@@ -116,6 +118,8 @@ public interface DeviceService{
 
     void exportInstallList(Integer channelId, String deviceNo, Integer status, String errorType, Integer customerId, Integer province, Integer city, Integer region, Integer community, Integer buildingId, String locDesc, Integer deviceTypeId, Integer registerStatus, Integer issueStatus, Integer concentratorId, Integer channelNumberId, String collectorNo, LocalDateTime startDate, LocalDateTime endDate, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse);
 
+    void executeExportInstallList(RabbitInstallParamData data);
+
     Device deviceDetail(Long deviceId);
 
     DeviceDto deviceDetailV2(Long deviceId);

+ 15 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/TaskService.java

@@ -0,0 +1,15 @@
+package com.bz.smart_city.service;
+
+import com.bz.smart_city.entity.Task;
+
+import javax.servlet.http.HttpServletResponse;
+
+public interface TaskService{
+
+
+    int insertSelective(Task record);
+
+    int updateByPrimaryKeySelective(Task record);
+
+    void download(Integer objId, HttpServletResponse response);
+}

+ 227 - 13
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/DeviceServiceImpl.java

@@ -17,6 +17,8 @@ import com.bz.smart_city.excel.download.column.GeneralDownload;
 import com.bz.smart_city.excel.download.template.GdDeviceDownloadExcelTemplate;
 import com.bz.smart_city.excel.download.template.GeneralDownloadExcelTemplate;
 import com.bz.smart_city.excel.download.template.WaterDownloadExcelTemplate;
+import com.bz.smart_city.rabbitmq.model.RabbitDeviceParamData;
+import com.bz.smart_city.rabbitmq.model.RabbitInstallParamData;
 import com.bz.smart_city.service.*;
 import com.bz.smart_city.service.udip.*;
 import com.github.pagehelper.PageHelper;
@@ -28,6 +30,8 @@ import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.output.Format;
 import org.jdom.output.XMLOutputter;
+import org.springframework.amqp.rabbit.connection.SimpleResourceHolder;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Async;
@@ -40,6 +44,7 @@ import java.io.File;
 import java.math.BigInteger;
 import java.net.URLEncoder;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -125,6 +130,20 @@ public  class DeviceServiceImpl implements DeviceService {
     private MessageService messageService;
     @Autowired
     private ChannelDeviceTypeUseMapper channelDeviceTypeUseMapper;
+    @Autowired
+    private RabbitTemplate rabbitTemplate;
+
+    @Value("${spring.rabbitmq.exchange}")
+    private String exchange;
+    @Value("${spring.rabbitmq.download-device-queue}")
+    private String deviceQueue;
+    @Value("${spring.rabbitmq.download-install-queue}")
+    private String installQueue;
+    @Value("${service.domain}")
+    private String domain;
+
+    @Resource
+    private TaskMapper taskMapper;
 
     @Override
     public int insert(Device device) {
@@ -196,14 +215,111 @@ public  class DeviceServiceImpl implements DeviceService {
     @Override
     public void getDeviceListExcel(String alias, Integer sysId, Integer buildingId, String deviceNo, Integer status, Integer floor, String locDesc, Integer province, Integer city, Integer region, Integer community, Integer concentratorId, String concentratorNo, Integer collectorId, String collectorNo,Integer channelNumberId, String errorType, Integer customerId, Integer days, Integer deviceTypeId, Integer valveStatus, Integer registerStatus, Integer issueStatus, Integer syncStatus, Double startReading, Double endReading, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse) {
         LoginUser loginUser = UserUtil.getCurrentUser();
-
-        List<DeviceDto> list = deviceMapper.getList(sysId, buildingId, loginUser.getSiteId(), UserUtil.getCurrentSiteProgramItems(loginUser), deviceNo, status,
-                floor, locDesc, province, city, region, community, concentratorId, concentratorNo, collectorId, collectorNo, null, errorType, customerId,
-                days, deviceTypeId, valveStatus, registerStatus, issueStatus, syncStatus, startReading, endReading, sortColumn, sortOrder);
         String title = "设备列表";
 
+        RabbitDeviceParamData paramData = new RabbitDeviceParamData();
+        paramData.setAlias(alias);
+        paramData.setUserId(loginUser.getId());
+        paramData.setSysId(sysId);
+        paramData.setBuildingId(buildingId);
+        paramData.setSiteId(loginUser.getSiteId());
+        paramData.setDeviceNo(deviceNo);
+        paramData.setStatus(status);
+        paramData.setFloor(floor);
+        paramData.setLocDesc(locDesc);
+        paramData.setProvince(province);
+        paramData.setCity(city);
+        paramData.setRegion(region);
+        paramData.setCommunity(community);
+        paramData.setConcentratorId(concentratorId);
+        paramData.setConcentratorNo(concentratorNo);
+        paramData.setCollectorId(collectorId);
+        paramData.setCollectorNo(collectorNo);
+        paramData.setErrorType(errorType);
+        paramData.setCustomerId(customerId);
+        paramData.setDays(days);
+        paramData.setDeviceTypeId(deviceTypeId);
+        paramData.setValveStatus(valveStatus);
+        paramData.setRegisterStatus(registerStatus);
+        paramData.setIssueStatus(issueStatus);
+        paramData.setSyncStatus(syncStatus);
+        paramData.setStartReading(startReading);
+        paramData.setEndReading(endReading);
+        paramData.setSortColumn(sortColumn);
+        paramData.setSortOrder(sortOrder);
+        paramData.setProgramItemList(UserUtil.getCurrentSiteProgramItems(loginUser));
+        paramData.setTitle(title);
+
+
+        Channel channel = channelMapper.findById(sysId);
+
+
+        DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+        LocalDateTime date = LocalDateTime.now();
+        String fileName = channel.getChannelName()+ title + "-" + date.format(f) + ".xls";
+
+        Task task = new Task();
+        task.setName(fileName);
+        task.setType(1);
+        task.setStatus(1);
+        task.setCreateDate(LocalDateTime.now());
+        task.setUpdateDate(LocalDateTime.now());
+        taskMapper.insertSelective(task);
+        paramData.setTaskId(task.getId());
+
+        String message = JSON.toJSONString(paramData);
+
+        //设置当前线程lookupKey,内部由ThreadLocal实现
+        SimpleResourceHolder.bind(rabbitTemplate.getConnectionFactory(), "platform");
+        //业务操作会根据线程中的lookupKey从routeConnectionFactory的targetConnectionFactories中选择对应的connectionFactory
+        rabbitTemplate.convertAndSend(exchange,deviceQueue, message);
+        //操作完以后记得解绑。不影响线程的后序其他工厂操作
+        SimpleResourceHolder.unbind(rabbitTemplate.getConnectionFactory());
+
+
+
+
+    }
 
-        generalDownload.export(title,alias,list,httpServletResponse);
+    public void executeDeviceListExcel(RabbitDeviceParamData paramData){
+        List<DeviceDto> list = deviceMapper.getList(paramData.getSysId(), paramData.getBuildingId(), paramData.getSiteId(), paramData.getProgramItemList(), paramData.getDeviceNo(), paramData.getStatus(),
+                paramData.getFloor(), paramData.getLocDesc(), paramData.getProvince(), paramData.getCity(), paramData.getRegion(), paramData.getCommunity(), paramData.getConcentratorId(), paramData.getConcentratorNo(), paramData.getCollectorId(), paramData.getCollectorNo(), null, paramData.getErrorType(), paramData.getCustomerId(),
+                paramData.getDays(), paramData.getDeviceTypeId(), paramData.getValveStatus(), paramData.getRegisterStatus(), paramData.getIssueStatus(), paramData.getSyncStatus(), paramData.getStartReading(), paramData.getEndReading(), paramData.getSortColumn(), paramData.getSortOrder());
+        Task taskTemp = taskMapper.findById(paramData.getTaskId());
+        try {
+            String filePath = generalDownload.export(paramData.getTitle(),paramData.getAlias(),list,null);
+
+
+            //生成下载文件
+            Task task = new Task();
+            task.setId(paramData.getTaskId());
+            task.setPath(filePath);
+            task.setUpdateDate(LocalDateTime.now());
+            taskMapper.updateByPrimaryKeySelective(task);
+
+            //生成消息
+            Message message = new Message();
+            message.setSiteId(paramData.getSiteId());
+            message.setUserId(paramData.getUserId());
+            message.setMessageType(2);
+            message.setMessageTitle(paramData.getTitle()+"-导出");
+            message.setMessageContent(taskTemp.getName()+"导出完成");
+            message.setMessageUrl(domain+"/api/file/task/download?objId="+paramData.getTaskId());
+            message.setObjId(paramData.getTaskId());
+            message.setRead(0);
+            messageService.insertSelective(message);
+        }catch (Exception e){
+            log.info("Exception {},{}",e.getMessage(),e);
+            Message message = new Message();
+            message.setSiteId(paramData.getSiteId());
+            message.setUserId(paramData.getUserId());
+            message.setMessageType(2);
+            message.setMessageTitle(paramData.getTitle()+"-导出");
+            message.setMessageContent(taskTemp.getName()+"导出失败");
+            message.setObjId(paramData.getTaskId());
+            message.setRead(0);
+            messageService.insertSelective(message);
+        }
 
     }
 
@@ -1124,16 +1240,114 @@ public  class DeviceServiceImpl implements DeviceService {
     public void exportInstallList(Integer channelId, String deviceNo, Integer status, String errorType, Integer customerId, Integer province, Integer city, Integer region, Integer community, Integer buildingId, String locDesc, Integer deviceTypeId, Integer registerStatus, Integer issueStatus, Integer concentratorId, Integer channelNumberId, String collectorNo, LocalDateTime startDate, LocalDateTime endDate, String sortColumn, String sortOrder, HttpServletResponse httpServletResponse) {
         String title = "已装水表列表";
         LoginUser loginUser = UserUtil.getCurrentUser();
-        List<Integer> deviceTypeIdList = channelDeviceTypeUseMapper.findDeviceTypeByChannelId(channelId);
-        List<DeviceDto> rtnList = deviceMapper.getInstallList(loginUser.getSiteId(), channelId, deviceNo, status, errorType, customerId, province, city, region, community, buildingId, locDesc, deviceTypeId, registerStatus, issueStatus, concentratorId, channelNumberId, collectorNo, startDate, endDate,UserUtil.getCurrentSiteProgramItems(loginUser), deviceTypeIdList, sortColumn,sortOrder);
-        if(55 == channelId){
-            generalDownload.export(title,"installRemoteMeter",rtnList,httpServletResponse);
+
+
+        RabbitInstallParamData data = new RabbitInstallParamData();
+        data.setUserId(loginUser.getId());
+        data.setSiteId(loginUser.getSiteId());
+        data.setChannelId(channelId);
+        data.setDeviceNo(deviceNo);
+        data.setStatus(status);
+        data.setErrorType(errorType);
+        data.setCustomerId(customerId);
+        data.setProvince(province);
+        data.setCity(city);
+        data.setRegion(region);
+        data.setCommunity(community);
+        data.setBuildingId(buildingId);
+        data.setLocDesc(locDesc);
+        data.setDeviceTypeId(deviceTypeId);
+        data.setRegisterStatus(registerStatus);
+        data.setIssueStatus(issueStatus);
+        data.setConcentratorId(concentratorId);
+        data.setChannelNumberId(channelNumberId);
+        data.setCollectorNo(collectorNo);
+        data.setStartDate(startDate);
+        data.setEndDate(endDate);
+        data.setSortColumn(sortColumn);
+        data.setSortOrder(sortOrder);
+        data.setTitle(title);
+        data.setProgramItemList(UserUtil.getCurrentSiteProgramItems(loginUser));
+
+        Channel channel = channelMapper.findById(channelId);
+
+
+        DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
+        LocalDateTime date = LocalDateTime.now();
+        String fileName = channel.getChannelName()+ title + "-" + date.format(f) + ".xls";
+
+        Task task = new Task();
+        task.setName(fileName);
+        task.setType(1);
+        task.setStatus(1);
+        task.setCreateDate(LocalDateTime.now());
+        task.setUpdateDate(LocalDateTime.now());
+        taskMapper.insertSelective(task);
+        data.setTaskId(task.getId());
+
+        String message = JSON.toJSONString(data);
+
+        //设置当前线程lookupKey,内部由ThreadLocal实现
+        SimpleResourceHolder.bind(rabbitTemplate.getConnectionFactory(), "platform");
+        //业务操作会根据线程中的lookupKey从routeConnectionFactory的targetConnectionFactories中选择对应的connectionFactory
+        rabbitTemplate.convertAndSend(exchange,installQueue, message);
+        //操作完以后记得解绑。不影响线程的后序其他工厂操作
+        SimpleResourceHolder.unbind(rabbitTemplate.getConnectionFactory());
+
+
+
+
+    }
+
+    public void executeExportInstallList(RabbitInstallParamData data) {
+        String title = "已装水表列表";
+
+        List<Integer> deviceTypeIdList = channelDeviceTypeUseMapper.findDeviceTypeByChannelId(data.getChannelId());
+        List<DeviceDto> rtnList = deviceMapper.getInstallList(data.getSiteId(), data.getChannelId(), data.getDeviceNo(), data.getStatus(), data.getErrorType(), data.getCustomerId(), data.getProvince(), data.getCity(), data.getRegion(), data.getCommunity(), data.getBuildingId(), data.getLocDesc(),
+                data.getDeviceTypeId(), data.getRegisterStatus(), data.getIssueStatus(), data.getConcentratorId(), data.getChannelNumberId(), data.getCollectorNo(), data.getStartDate(), data.getEndDate(),data.getProgramItemList(), deviceTypeIdList, data.getSortColumn(),data.getSortOrder());
+        String filePath = null;
+        if(55 == data.getChannelId()){
+            filePath = generalDownload.export(title,"installRemoteMeter",rtnList,null);
         }
-        if(40 == channelId){
-            generalDownload.export(title,"installLoraMeter",rtnList,httpServletResponse);
+        if(40 == data.getChannelId()){
+            filePath = generalDownload.export(title,"installLoraMeter",rtnList,null);
         }
-        if(58 == channelId){
-            generalDownload.export(title,"installNbiotMeter",rtnList,httpServletResponse);
+        if(58 == data.getChannelId()){
+            filePath = generalDownload.export(title,"installNbiotMeter",rtnList,null);
+        }
+
+        Task taskTemp = taskMapper.findById(data.getTaskId());
+        try {
+
+            //生成下载文件
+            Task task = new Task();
+            task.setId(data.getTaskId());
+            task.setPath(filePath);
+            task.setUpdateDate(LocalDateTime.now());
+            taskMapper.updateByPrimaryKeySelective(task);
+
+            //生成消息
+            Message message = new Message();
+            message.setSiteId(data.getSiteId());
+            message.setUserId(data.getUserId());
+            message.setMessageType(2);
+            message.setMessageTitle(data.getTitle()+"-导出");
+            message.setMessageContent(taskTemp.getName()+"导出完成");
+            message.setMessageUrl(domain+"/api/file/task/download?objId="+data.getTaskId());
+            message.setObjId(data.getTaskId());
+            message.setRead(0);
+            messageService.insertSelective(message);
+        }catch (Exception e){
+            log.info("Exception {},{}",e.getMessage(),e);
+            Message message = new Message();
+            message.setSiteId(data.getSiteId());
+            message.setUserId(data.getUserId());
+            message.setMessageType(2);
+            message.setMessageTitle(data.getTitle()+"-导出");
+            message.setMessageContent(taskTemp.getName()+"导出失败");
+            message.setObjId(data.getTaskId());
+            message.setRead(0);
+            messageService.insertSelective(message);
         }
 
     }

+ 63 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/TaskServiceImpl.java

@@ -0,0 +1,63 @@
+package com.bz.smart_city.service.impl;
+
+import com.bz.smart_city.commom.exception.ServiceException;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import com.bz.smart_city.entity.Task;
+import com.bz.smart_city.dao.TaskMapper;
+import com.bz.smart_city.service.TaskService;
+
+import java.io.FileInputStream;
+import java.net.URLEncoder;
+
+@Service
+public class TaskServiceImpl implements TaskService{
+
+    @Resource
+    private TaskMapper taskMapper;
+
+    @Override
+    public int insertSelective(Task record) {
+        return taskMapper.insertSelective(record);
+    }
+
+    @Override
+    public int updateByPrimaryKeySelective(Task record) {
+        return taskMapper.updateByPrimaryKeySelective(record);
+    }
+
+    @Override
+    public void download(Integer objId, HttpServletResponse response) {
+        Task result = taskMapper.findById(objId);
+        if (result != null) {
+            if (result.getPath() != null && !StringUtils.equals("",result.getPath())) {
+                try {
+                    //下面步骤为浏览器下载部分
+                    //指定数据生成后的文件输入流(将上述out的路径作为文件的输入流)
+                    FileInputStream fileInputStream = new FileInputStream(result.getPath());
+                    //导出excel文件,设置文件名
+                    String filename = URLEncoder.encode(result.getName(), "UTF-8");
+                    //设置下载头
+                    response.setHeader("Content-Disposition", "attachment;filename=" + filename);
+                    ServletOutputStream outputStream = response.getOutputStream();
+
+                    //将文件写入浏览器
+                    byte[] bys = new byte[fileInputStream.available()];
+                    fileInputStream.read(bys);
+                    outputStream.write(bys);
+                    outputStream.flush();
+                    outputStream.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+
+        }else {
+            throw new ServiceException(-900, "导入记录不存在");
+        }
+    }
+}

+ 6 - 1
smart-city-platform/src/main/resources/application-dev.properties

@@ -185,4 +185,9 @@ account_userInfo_url=http://114.135.61.188:58084/api/pay/getAccountInfoByMeterco
 sync_customer_no_url=http://114.135.61.188:58084/api/customer/synCustomer
 platform_appid=1001
 platform_appSecret=123456
-platform_url=http://114.135.61.187:38081/user-auth/user/getUniqId?appId={appId}&appSecret={appSecret}&code={code}
+platform_url=http://114.135.61.187:38081/user-auth/user/getUniqId?appId={appId}&appSecret={appSecret}&code={code}
+
+
+spring.rabbitmq.exchange=task-handler-exchange
+spring.rabbitmq.download-device-queue=download-device-queue
+spring.rabbitmq.download-install-queue=download-install-queue

+ 6 - 2
smart-city-platform/src/main/resources/application-prd.properties

@@ -143,7 +143,7 @@ geomap.api.url=https://restapi.amap.com/v3/geocode/geo
 #慧联无线网关查询接口
 easylinkin.api.url.gateway.ap=http://api.easylinkin.com/api/v1/application/ap
 
-service.domain=http://www.zoniot.com
+service.domain=https://www.zoniot.com
 #富锦水司推送配置
 fj.push.customer.id=24
 fj.push.company.id=HUAXU
@@ -189,4 +189,8 @@ account_userInfo_url=http://114.135.61.188:58084/api/pay/getAccountInfoByMeterco
 sync_customer_no_url=http://114.135.61.188:58084/api/customer/synCustomer
 platform_appid=1001
 platform_appSecret=123456
-platform_url=http://114.135.61.187:38081/user-auth/user/getUniqId?appId={appId}&appSecret={appSecret}&code={code}
+platform_url=http://114.135.61.187:38081/user-auth/user/getUniqId?appId={appId}&appSecret={appSecret}&code={code}
+
+spring.rabbitmq.exchange=task-handler-exchange
+spring.rabbitmq.download-device-queue=download-device-queue
+spring.rabbitmq.download-install-queue=download-install-queue

+ 5 - 1
smart-city-platform/src/main/resources/application-sit.properties

@@ -187,4 +187,8 @@ account_userInfo_url=http://114.135.61.188:58084/api/pay/getAccountInfoByMeterco
 sync_customer_no_url=http://114.135.61.188:58084/api/customer/synCustomer
 platform_appid=1001
 platform_appSecret=123456
-platform_url=http://114.135.61.187:38081/user-auth/user/getUniqId?appId={appId}&appSecret={appSecret}&code={code}
+platform_url=http://114.135.61.187:38081/user-auth/user/getUniqId?appId={appId}&appSecret={appSecret}&code={code}
+
+spring.rabbitmq.exchange=task-handler-exchange
+spring.rabbitmq.download-device-queue=download-device-queue
+spring.rabbitmq.download-install-queue=download-install-queue

+ 1 - 1
smart-city-platform/src/main/resources/application.properties

@@ -1,2 +1,2 @@
 #开发环境:dev  测试环境:sit  线上环境:prd  演示环境:uat
-spring.profiles.active=prd
+spring.profiles.active=dev

+ 92 - 0
smart-city-platform/src/main/resources/mapper/TaskMapper.xml

@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bz.smart_city.dao.TaskMapper">
+  <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.Task">
+    <!--@mbg.generated-->
+    <!--@Table sc_task-->
+    <id column="id" property="id" />
+    <result column="name" property="name" />
+    <result column="type" property="type" />
+    <result column="path" property="path" />
+    <result column="status" property="status" />
+    <result column="create_date" property="createDate" />
+    <result column="update_date" property="updateDate" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id, `name`, `type`, `path`, `status`, create_date, update_date
+  </sql>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.Task" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into sc_task
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="name != null">
+        `name`,
+      </if>
+      <if test="type != null">
+        `type`,
+      </if>
+      <if test="path != null">
+        `path`,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="createDate != null">
+        create_date,
+      </if>
+      <if test="updateDate != null">
+        update_date,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="name != null">
+        #{name},
+      </if>
+      <if test="type != null">
+        #{type},
+      </if>
+      <if test="path != null">
+        #{path},
+      </if>
+      <if test="status != null">
+        #{status},
+      </if>
+      <if test="createDate != null">
+        #{createDate},
+      </if>
+      <if test="updateDate != null">
+        #{updateDate},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.Task">
+    <!--@mbg.generated-->
+    update sc_task
+    <set>
+      <if test="name != null">
+        `name` = #{name},
+      </if>
+      <if test="type != null">
+        `type` = #{type},
+      </if>
+      <if test="path != null">
+        `path` = #{path},
+      </if>
+      <if test="status != null">
+        `status` = #{status},
+      </if>
+      <if test="createDate != null">
+        create_date = #{createDate},
+      </if>
+      <if test="updateDate != null">
+        update_date = #{updateDate},
+      </if>
+    </set>
+    where id = #{id}
+  </update>
+
+  <select id="findById" resultMap="BaseResultMap">
+    select <include refid="Base_Column_List"/> from sc_task where status = 1 and id = #{Id}
+  </select>
+</mapper>