dcs 3 months ago
parent
commit
54934d689b

+ 17 - 3
virgo.api/src/main/java/com/bosshand/virgo/api/job/JobCityWeatherQuartz.java

@@ -3,7 +3,10 @@ package com.bosshand.virgo.api.job;
 import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.bosshand.virgo.api.dao.ProjectCityWeatherDao;
+import com.bosshand.virgo.api.dao.ProjectDao;
+import com.bosshand.virgo.api.model.Project;
 import com.bosshand.virgo.api.model.ProjectCityWeather;
+import com.bosshand.virgo.core.utils.HttpsUtils;
 import org.quartz.JobDataMap;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -20,6 +23,9 @@ public class JobCityWeatherQuartz extends QuartzJobBean {
     @Autowired
     ProjectCityWeatherDao projectCityWeatherDao;
 
+    @Autowired
+    ProjectDao projectDao;
+
     static Logger log = LoggerFactory.getLogger(JobCityWeatherQuartz.class);
 
     @Override
@@ -40,10 +46,18 @@ public class JobCityWeatherQuartz extends QuartzJobBean {
         JSONObject json = JSONObject.parseObject(data);
         ProjectCityWeather projectCityWeather = new ProjectCityWeather();
         projectCityWeather.setDate(jobExecutionContext.getFireTime());
-        projectCityWeather.setProjectId(json.getLongValue("projectId"));
+        long projectId = json.getLongValue("projectId");
+        projectCityWeather.setProjectId(projectId);
+
+        Project project = projectDao.get(projectId);
+
         //String url = "https://restapi.amap.com/v3/weather/weatherInfo?city=" + json.getString("city") + "&extensions=all&key=8d6519155e085eb1b83d1de7953b2414";
-        //String url = "https://www.weatherol.cn/api/home/getCurrAnd15dAnd24h?cityid=" + CityUtil.getCode(json.getString("city"));
-        //projectCityWeather.setWeatherData(HttpsUtils.getResult(url));
+        String weatherCityCode = project.getWeatherCityCode() != null ? project.getWeatherCityCode() : "101010100";
+        String url = "https://www.weatherol.cn/api/home/getCurrAnd15dAnd24h?cityid=" + weatherCityCode;
+        String result = HttpsUtils.getResult(url);
+        JSONObject jsonObject = JSONObject.parseObject(result);
+        String cityWeather = jsonObject.getJSONObject("data").getJSONArray("forecast15d").getJSONObject(1).toJSONString();
+        projectCityWeather.setWeatherData(cityWeather);
         projectCityWeatherDao.save(projectCityWeather);
 
     }

+ 13 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/model/Project.java

@@ -75,6 +75,11 @@ public class Project {
      */
     private String addressCode;
 
+    /**
+     * 城市天气code
+     */
+    private String weatherCityCode;
+
     /**
      * 照片
      */
@@ -226,6 +231,14 @@ public class Project {
         this.addressCode = addressCode;
     }
 
+    public String getWeatherCityCode() {
+        return weatherCityCode;
+    }
+
+    public void setWeatherCityCode(String weatherCityCode) {
+        this.weatherCityCode = weatherCityCode;
+    }
+
     public String getPicture() {
         return picture;
     }

+ 36 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/controller/OperateDeviceController.java

@@ -1,8 +1,10 @@
 package com.bosshand.virgo.api.operate.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.bosshand.virgo.api.model.Project;
 import com.bosshand.virgo.api.operate.model.*;
 import com.bosshand.virgo.api.operate.service.GodownService;
+import com.bosshand.virgo.api.operate.service.OperateDeviceLevelService;
 import com.bosshand.virgo.api.operate.service.OperateDeviceService;
 import com.bosshand.virgo.api.service.ProjectItemTargetService;
 import com.bosshand.virgo.api.service.ProjectService;
@@ -27,6 +29,9 @@ import java.util.Map;
 @Api(tags = {"运营设备"})
 public class OperateDeviceController {
 
+    @Autowired
+    OperateDeviceLevelService operateDeviceLevelService;
+
     @Autowired
     OperateDeviceService operateDeviceService;
 
@@ -131,6 +136,37 @@ public class OperateDeviceController {
         ExcelUtils.exportTemplate(response, "资产模板表", OperateDeviceExportDto.class);
     }
 
+    /**
+     * 导出数据(目录id,id多选,分割字符串)
+     */
+    @ApiOperation(value = "资产导出数据(目录id,id多选,分割字符串)", notes = "资产导出数据(目录id,id多选,分割字符串)")
+    @PostMapping("/exportData")
+    public void export(HttpServletResponse response, @RequestBody JSONObject data) {
+        long operateDeviceLevelId = data.getLongValue("operateDeviceLevelId");
+        String ids = data.getString("ids");
+        List<OperateDeviceExportDto> list = new ArrayList<>();
+        OperateDevice operateDevice = new OperateDevice();
+        if (operateDeviceLevelId != 0) {
+            List<Long> levelIds = new ArrayList<>();
+            operateDeviceLevelService.getLevel(levelIds, operateDeviceLevelId);
+            List<String> stringList = new ArrayList<>();
+            for (Long l : levelIds) {
+                stringList.add(l.toString());
+            }
+            operateDevice.setOperateDeviceLevelIds(String.join(", ", stringList));
+        }
+        if (ids != null) {
+            operateDevice.setIds(ids);
+        }
+        List<OperateDevice> dataList = operateDeviceService.getExport(operateDevice);
+        for (OperateDevice o : dataList) {
+            OperateDeviceExportDto dto = new OperateDeviceExportDto();
+            BeanUtils.copyProperties(o, dto);
+            list.add(dto);
+        }
+        ExcelUtils.export(response, "资产表", list, OperateDeviceExportDto.class);
+    }
+
     /**
      * 导出数据
      */

+ 10 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/model/OperateDevice.java

@@ -7,6 +7,8 @@ public class OperateDevice {
 
     private long id;
 
+    private String ids;
+
     private long projectId;
 
     private long projectItemId;
@@ -160,6 +162,14 @@ public class OperateDevice {
         this.id = id;
     }
 
+    public String getIds() {
+        return ids;
+    }
+
+    public void setIds(String ids) {
+        this.ids = ids;
+    }
+
     public long getProjectId() {
         return projectId;
     }

+ 1 - 1
virgo.api/src/main/java/com/bosshand/virgo/api/operate/model/OperateDeviceStocktakingDto.java

@@ -17,7 +17,7 @@ public class OperateDeviceStocktakingDto {
     private String name;
 
     /**
-     * 资产名称
+     * 是否存在
      */
     @ExcelExport("是否存在")
     private String exist;

+ 3 - 0
virgo.api/src/main/resources/mapper/OperateDeviceMapper.xml

@@ -45,6 +45,9 @@
         <where>
             <if test="projectId!=0">and projectId=#{projectId}</if>
             <if test="godownId!=0">and godownId=#{godownId}</if>
+            <if test="operateDeviceLevelId!=0">and operateDeviceLevelId=#{operateDeviceLevelId}</if>
+            <if test="operateDeviceLevelIds!=null">and operateDeviceLevelId in (${operateDeviceLevelIds})</if>
+            <if test="ids!=null">and id in (${ids})</if>
         </where>
     </select>
 

+ 5 - 2
virgo.api/src/main/resources/mapper/ProjectMapper.xml

@@ -17,6 +17,7 @@
 		<result column="organizationName" property="organizationName"/>
 		<result column="address" property="address"/>
 		<result column="addressCode" property="addressCode"/>
+		<result column="weatherCityCode" property="weatherCityCode"/>
 		<result column="picture" property="picture"/>
 		<result column="tagIds" property="tagIds"/>
 		<result column="comment" property="comment"/>
@@ -39,6 +40,7 @@
 		<result column="organizationId" property="organizationId"/>
 		<result column="address" property="address"/>
 		<result column="addressCode" property="addressCode"/>
+		<result column="weatherCityCode" property="weatherCityCode"/>
 		<result column="picture" property="picture"/>
 		<result column="tagIds" property="tagIds"/>
 		<result column="comment" property="comment"/>
@@ -103,8 +105,8 @@
 	</select>
 
 	<insert id="insert" parameterType="com.bosshand.virgo.api.model.Project" useGeneratedKeys="true" keyProperty="id">
-		INSERT INTO project(`projectType`, `specificLocation`, `completionTime`, `buildingArea`, `generateWeeklyDate`, `type`, `name`, `createDate`, `organizationId`, `address`, `addressCode`, `picture`, `tagIds`, `comment`, `coordinates`, `supportingFacilities`, `data`)
-		VALUES (#{projectType}, #{specificLocation}, #{completionTime}, #{buildingArea}, #{generateWeeklyDate}, #{type}, #{name}, now(), #{organizationId}, #{address}, #{addressCode}, #{picture}, #{tagIds}, #{comment}, #{coordinates}, #{supportingFacilities}, #{data})
+		INSERT INTO project(`projectType`, `specificLocation`, `completionTime`, `buildingArea`, `generateWeeklyDate`, `type`, `name`, `createDate`, `organizationId`, `address`, `addressCode`, `weatherCityCode`, `picture`, `tagIds`, `comment`, `coordinates`, `supportingFacilities`, `data`)
+		VALUES (#{projectType}, #{specificLocation}, #{completionTime}, #{buildingArea}, #{generateWeeklyDate}, #{type}, #{name}, now(), #{organizationId}, #{address}, #{addressCode}, #{weatherCityCode}, #{picture}, #{tagIds}, #{comment}, #{coordinates}, #{supportingFacilities}, #{data})
 	</insert>
 
 	<update id="delete">
@@ -125,6 +127,7 @@
 			<if test="organizationId!=0">organizationId=#{organizationId},</if>
 			<if test="address!=null">address=#{address},</if>
 			<if test="addressCode!=null">addressCode=#{addressCode},</if>
+			<if test="weatherCityCode!=null">weatherCityCode=#{weatherCityCode},</if>
 			<if test="picture!=null">picture=#{picture},</if>
 			<if test="tagIds!=null">tagIds=#{tagIds},</if>
 			<if test="comment!=null">comment=#{comment},</if>