Merge remote-tracking branch 'origin/master'
|  |  |  | 
|---|
|  |  |  | import com.moral.service.DeviceService; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import static com.moral.common.util.WebUtils.getParametersStartingWith; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.Resource; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("device") | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Device> devices = deviceService.getDevicesByMonitorPointId(monitorPointId); | 
|---|
|  |  |  | return new ResultBean<List<Device>>(devices); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("professionId") | 
|---|
|  |  |  | public ResultBean<List<Device>> getDevicesByProfessionId(HttpServletRequest request) { | 
|---|
|  |  |  | Map<String, Object> parameters = getParametersStartingWith(request, null); | 
|---|
|  |  |  | List<Device> devices = deviceService.getDevicesByProfessionId(parameters); | 
|---|
|  |  |  | return new ResultBean<List<Device>>(devices); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Integer> getDeviceVersionIdByAreaCode(Map<String, Object> parameters); | 
|---|
|  |  |  | Integer getDeviceCountByRegion(Map<String, Object> parameters); | 
|---|
|  |  |  | List<Map> countByTimes(@Param("start")Date start,@Param("end")Date end,@Param("format")String format); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Device> getDevicesByProfession(Map<String, Object> parameters); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Map<String,String>> queryDevicesState(List<String> macList,Boolean withData); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Device queryById(Integer id); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Device> getDevicesByProfessionId(Map<String, Object> parameters); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return deviceMapper.selectByPrimaryKey(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<Device> getDevicesByProfessionId(Map<String, Object> parameters) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return deviceMapper.getDevicesByProfession(parameters); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | Map<String, BigDecimal> mapData = (Map<String, BigDecimal>) obj; | 
|---|
|  |  |  | BigDecimal sum = mapData.remove("sum"); | 
|---|
|  |  |  | for (Entry<String, BigDecimal> entry : mapData.entrySet()) { | 
|---|
|  |  |  | sortMap.put(entry.getKey() + "-" + index, new BigDecimal(100).multiply(entry.getValue()) | 
|---|
|  |  |  | .divide(sum, 2, BigDecimal.ROUND_HALF_UP).doubleValue()); | 
|---|
|  |  |  | if (!"name".equals(entry.getKey())) { | 
|---|
|  |  |  | sortMap.put(entry.getKey() + "-" + index, new BigDecimal(100).multiply(entry.getValue()) | 
|---|
|  |  |  | .divide(sum, 2, BigDecimal.ROUND_HALF_UP).doubleValue()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | <if test="level != null"> | 
|---|
|  |  |  | AND h.state = #{level} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="professionId != null"> | 
|---|
|  |  |  | AND d.profession_id = #{professionId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | GROUP BY | 
|---|
|  |  |  | <if test="dimension=='monitorPoint'"> | 
|---|
|  |  |  | mp.id, | 
|---|
|  |  |  | 
|---|
|  |  |  | AND mp.area_code = #{areaCode} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | <if test="professionId != null"> | 
|---|
|  |  |  | AND d.profession_id = #{professionId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <select id="getDevicesByProfession" resultType="com.moral.entity.Device"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | * | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | device d | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | d.is_delete = 0 | 
|---|
|  |  |  | AND d.monitor_point_id IN ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | mp.id | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | monitor_point mp | 
|---|
|  |  |  | WHERE | 
|---|
|  |  |  | mp.is_delete = 0 | 
|---|
|  |  |  | <if test="provinceCode != null"> | 
|---|
|  |  |  | AND mp.province_code = #{provinceCode} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="cityCode != null"> | 
|---|
|  |  |  | AND mp.city_code = #{cityCode} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="areaCode != null"> | 
|---|
|  |  |  | AND mp.area_code = #{areaCode} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | <if test="professionId != null"> | 
|---|
|  |  |  | AND d.profession_id = #{professionId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|
|  |  |  | 
|---|
|  |  |  | <if test="monitorPointId != null"> | 
|---|
|  |  |  | AND mp.id =    #{monitorPointId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="professionId != null"> | 
|---|
|  |  |  | AND d.profession_id = #{professionId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | <if test="mac != null"> | 
|---|
|  |  |  | AND d.mac =    #{mac} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="professionId != null"> | 
|---|
|  |  |  | AND d.profession_id = #{professionId} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </mapper> | 
|---|