Browse Source

增加公共接口

wangli 4 years ago
parent
commit
6ff0d1152d

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

@@ -1,5 +1,6 @@
 package com.bz.smart_city.commom.util;
 package com.bz.smart_city.commom.util;
 
 
+import com.bz.smart_city.dto.AreaDto;
 import com.bz.smart_city.dto.ChannelDto;
 import com.bz.smart_city.dto.ChannelDto;
 import com.bz.smart_city.dto.CustomerDto;
 import com.bz.smart_city.dto.CustomerDto;
 import com.bz.smart_city.dto.OrganizationDto;
 import com.bz.smart_city.dto.OrganizationDto;
@@ -122,6 +123,26 @@ public class TreeUtil {
         }
         }
     }
     }
 
 
+    public static List<AreaDto> getArea(List<AreaDto> list, Integer id, Integer leve) {
+        List<AreaDto> temList = newArrayList();
+        if (list != null) {
+            for (AreaDto areaDto : list) {
+                if (id.equals(areaDto.getPid())) {
+                    List<AreaDto> chidren = getArea(list, areaDto.getCode(), ++leve);
+                    AreaDto tempArea = new AreaDto();
+                    BeanUtils.copyProperties(areaDto, tempArea);
+                    tempArea.setChildren(chidren);
+                    temList.add(tempArea);
+                    leve--;
+                }
+            }
+        }
+        if(temList.size() > 0){
+            return temList;
+        }else {
+            return null;
+        }
+    }
 
 
 
 
 }
 }

+ 57 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/common/CommonController.java

@@ -0,0 +1,57 @@
+package com.bz.smart_city.controller.common;
+
+import com.bz.smart_city.commom.model.AjaxMessage;
+import com.bz.smart_city.commom.model.ResultStatus;
+import com.bz.smart_city.commom.util.TreeUtil;
+import com.bz.smart_city.dao.AreaMapper;
+import com.bz.smart_city.dto.AreaDto;
+import com.bz.smart_city.dto.ChannelDeviceCountDto;
+import com.bz.smart_city.dto.DeviceDto;
+import com.bz.smart_city.dto.DeviceTypeDto;
+import com.bz.smart_city.service.ChannelService;
+import com.bz.smart_city.service.DeviceService;
+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.format.annotation.DateTimeFormat;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Controller
+@ResponseBody
+@RequestMapping("common")
+@Api(tags = "公共模块")
+public class CommonController {
+
+    @Autowired
+    private ChannelService channelService;
+
+    @Resource
+    private AreaMapper areaMapper;
+
+    @GetMapping("/getChanelList")
+    @ApiOperation(value = "获取场景列表")
+    public AjaxMessage<List<ChannelDeviceCountDto>> getChanelList(
+    ) {
+        List<ChannelDeviceCountDto> list = channelService.getList();
+        return new AjaxMessage<>(ResultStatus.OK, list);
+    }
+
+    @GetMapping("/getAllArea")
+    @ApiOperation(value = "获取所有的省市区")
+    public AjaxMessage<List<AreaDto>> getAllArea(
+    ) {
+        List<AreaDto> list = areaMapper.getAllArea();
+        return new AjaxMessage<>(ResultStatus.OK, TreeUtil.getArea(list, 100000, 1));
+    }
+
+
+}

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/AreaMapper.java

@@ -1,5 +1,6 @@
 package com.bz.smart_city.dao;
 package com.bz.smart_city.dao;
 
 
+import com.bz.smart_city.dto.AreaDto;
 import com.bz.smart_city.dto.AreaRelevanceDto;
 import com.bz.smart_city.dto.AreaRelevanceDto;
 import com.bz.smart_city.entity.Area;
 import com.bz.smart_city.entity.Area;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
@@ -14,5 +15,7 @@ import java.util.List;
 public interface AreaMapper {
 public interface AreaMapper {
     List<Area> findByIds(@Param("ids")List<Integer> ids);
     List<Area> findByIds(@Param("ids")List<Integer> ids);
 
 
+    List<AreaDto> getAllArea();
+
     List<AreaRelevanceDto> findByLevelType(@Param("levelType")Integer levelType);
     List<AreaRelevanceDto> findByLevelType(@Param("levelType")Integer levelType);
 }
 }

+ 11 - 2
smart-city-platform/src/main/java/com/bz/smart_city/quartz/service/impl/AmountSynServiceImpl.java

@@ -104,11 +104,14 @@ public class AmountSynServiceImpl implements AmountSynService {
             amountSynParamDto.setYyyymm(year+""+month);
             amountSynParamDto.setYyyymm(year+""+month);
             amountSynParamDto.setCustomerNo(customerNo);
             amountSynParamDto.setCustomerNo(customerNo);
             //一次查询五百条
             //一次查询五百条
+            List<String> selectList = new ArrayList<>();
             if(i+500 >= metercodes.size()){
             if(i+500 >= metercodes.size()){
-                amountSynParamDto.setFileNo(metercodes.subList(i,metercodes.size()));
+                selectList=metercodes.subList(i,metercodes.size());
             }else{
             }else{
-                amountSynParamDto.setFileNo(metercodes.subList(i,i+500));
+                selectList=metercodes.subList(i,i+500);
             }
             }
+            amountSynParamDto.setFileNo(selectList);
+
             String context=JSON.toJSON(amountSynParamDto).toString();
             String context=JSON.toJSON(amountSynParamDto).toString();
             try {
             try {
                 String result= HttpClientUtils.doPostWithJson(amountSynUrl,context);
                 String result= HttpClientUtils.doPostWithJson(amountSynUrl,context);
@@ -130,8 +133,14 @@ public class AmountSynServiceImpl implements AmountSynService {
                 e.printStackTrace();
                 e.printStackTrace();
             }
             }
         }
         }
+
+
+
+
         Map<String ,AmountSynRespDto> map = lists.stream().collect(Collectors.toMap(AmountSynRespDto::getFileNo, Function.identity(), (key1, key2) -> key2));
         Map<String ,AmountSynRespDto> map = lists.stream().collect(Collectors.toMap(AmountSynRespDto::getFileNo, Function.identity(), (key1, key2) -> key2));
 
 
+
+
         //换表记录
         //换表记录
         HashMap<BigInteger, ReplaceMeterCountDto> replaceMap = new HashMap<>();
         HashMap<BigInteger, ReplaceMeterCountDto> replaceMap = new HashMap<>();
         LocalDateTime stTime = LocalDateTime.ofInstant(baseClosingAccountInfoDto.getStartTime().toInstant(), ZoneId.systemDefault());
         LocalDateTime stTime = LocalDateTime.ofInstant(baseClosingAccountInfoDto.getStartTime().toInstant(), ZoneId.systemDefault());

+ 4 - 0
smart-city-platform/src/main/resources/mapper/AreaMapper.xml

@@ -31,6 +31,10 @@
         </if>
         </if>
     </select>
     </select>
 
 
+    <select id="getAllArea" resultType="com.bz.smart_city.dto.AreaDto">
+        select id as code,parent_id as pid,name from sc_area
+    </select>
+
 	<select id="findByLevelType"
 	<select id="findByLevelType"
 		resultType="com.bz.smart_city.dto.AreaRelevanceDto">
 		resultType="com.bz.smart_city.dto.AreaRelevanceDto">
 		select a1.id,a1.name ,a2.`name` as property1,a3.`name` as property2
 		select a1.id,a1.name ,a2.`name` as property1,a3.`name` as property2