Commit 9941397c authored by zhangsen's avatar zhangsen

树API和公用API

parent 8ed79c9a
package com.yeejoin.amos.boot.module.jxiop.api.dto;
import lombok.Data;
import java.util.List;
@Data
public class TreeDto {
/**
* 树节点名称
*/
private String name;
/**
* 树节点CODE
*/
private String code;
/**
* 树父节点CODE
*/
private String parentCode;
/**
* 树节点ID
*/
private String id;
/**
* 是否可点击 0-否 1-是
*/
private Integer isOnClick;
/**
* 子节点
*/
private List<TreeDto> children;
}
package com.yeejoin.amos.boot.module.jxiop.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mysql.cj.x.protobuf.MysqlxCrud;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
......@@ -17,4 +18,14 @@ public interface MonitorFanIndicatorMapper extends BaseMapper<MonitorFanIndicato
//批量修改
void UpdateMonitorFanIndicator(@Param(value = "list") List<IndexDto> list);
Integer queryByPageTotal(@Param("fanCode") String fanCode,
@Param("gateway") String gateway,
@Param("frontModule") String frontModule);
Page<MonitorFanIndicator> queryByPage(@Param("size") long size,
@Param("fanCode") String fanCode,
@Param("gateway") String gateway,
@Param("frontModule") String frontModule,
@Param("offset") int offset);
}
......@@ -49,4 +49,12 @@ public interface StationBasicMapper extends BaseMapper<StationBasic> {
*/
List<StationTaksDto> getStationBasicDtoList();
/**
* 根据所属地区code获取场站列表信息
* @param regionCode 所属地区code
*/
List<TreeDto> getStationListByRegionCode(@Param("regionCode")String regionCode);
}
package com.yeejoin.amos.boot.module.jxiop.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mysql.cj.x.protobuf.MysqlxCrud;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import java.util.List;
......
package com.yeejoin.amos.boot.module.jxiop.api.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
@Service
@Component
public interface IMonitorFanIndicatorService extends IService<MonitorFanIndicator> {
}
......@@ -10,5 +10,34 @@
</foreach>
</update>
<select id="queryByPage" resultType="com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator">
select * from monitor_fan_indicator
<where>
<if test="fanCode != null and fanCode !=''">
fan_code like concat('%', #{fanCode},'%')
</if>
<if test="gateway != null and gateway !=''">
AND gateway = #{gateway}
</if>
<if test="frontModule != null and frontModule !=''">
AND front_module = #{frontModule}
</if>
</where>
limit #{offset}, #{size}
</select>
<select id="queryByPageTotal" resultType="java.lang.Integer">
select count(1) from monitor_fan_indicator
<where>
<if test="fanCode != null and fanCode !=''">
fan_code like concat('%', #{fanCode},'%')
</if>
<if test="gateway != null and gateway !=''">
AND gateway = #{gateway}
</if>
<if test="frontModule != null and frontModule !=''">
AND front_module = #{frontModule}
</if>
</where>
</select>
</mapper>
......@@ -150,4 +150,19 @@
FROM
station_basic
</select>
<select id="getStationListByRegionCode" resultType="com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto">
select
station_name as name,
station_code as code,
station_type as parentCode,
sequence_nbr as id,
'1' as isOnclick
from station_basic
<where>
<if test="regionCode != null and regionCode != ''">
belong_area like concat('%', #{regionCode}, '%')
</if>
</where>
</select>
</mapper>
......@@ -45,7 +45,7 @@ import java.net.InetAddress;
@EnableScheduling
@MapperScan({ "org.typroject.tyboot.demo.face.orm.dao*", "org.typroject.tyboot.face.*.orm.dao*",
"org.typroject.tyboot.core.auth.face.orm.dao*", "org.typroject.tyboot.component.*.face.orm.dao*",
"com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper","com.yeejoin.amos.boot.module.common.biz.*" })
"com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper","com.yeejoin.amos.boot.module.common.biz.*","com.yeejoin.amos.boot.module.jxiop.api.mapper" })
@ComponentScan(basePackages = { "org.typroject", "com.yeejoin.amos" })
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class})
//@SpringBootApplication
......
package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.MonitorFanIndicatorImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
@RestController
@Api(tags = "大屏相关API")
@RequestMapping(value = "/monitorFanIdx")
public class MonitorFanIdxController extends BaseController {
@Autowired
MonitorFanIndicatorImpl monitorFanIndicatorImpl;
@Autowired
MonitorFanIndicatorImpl monitorFanIndicator;
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据风机编码、网关ID、前段展示模块查询表数据")
@GetMapping("/getFanIdxInfoByPage")
public ResponseModel<IPage<MonitorFanIndicator>> getFanIdxInfoByPage(@RequestParam(value = "fanCode", required = false) String fanCode,
@RequestParam(value = "gateway", required = false) String gateway,
@RequestParam(value = "frontModule", required = false) String frontModule,
@RequestParam(value = "current", required = false) int current,
@RequestParam(value = "size", required = false) int size) {
return ResponseHelper.buildResponse(monitorFanIndicator.getFanIdxInfoByPage(fanCode, gateway, frontModule, current, size));
}
@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@ApiOperation(value = "左侧树API")
@GetMapping("/getTreeInfo")
public ResponseModel<TreeDto> getTreeInfo(@RequestParam(value = "sequenceNbr", required = true) String sequenceNbr) {
return ResponseHelper.buildResponse(monitorFanIndicator.getTreeInfo(sequenceNbr));
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jxiop.api.dto.IndexDto;
import com.yeejoin.amos.boot.module.jxiop.api.dto.TreeDto;
import com.yeejoin.amos.boot.module.jxiop.api.entity.MonitorFanIndicator;
import com.yeejoin.amos.boot.module.jxiop.api.entity.Region;
import com.yeejoin.amos.boot.module.jxiop.api.entity.StationBasic;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.MonitorFanIndicatorMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.RegionMapper;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import com.yeejoin.amos.boot.module.jxiop.api.service.IMonitorFanIndicator;
import com.yeejoin.amos.component.robot.BadRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @description:
......@@ -20,7 +31,13 @@ import java.util.List;
public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
@Autowired
MonitorFanIndicatorMapper monitorFanIndicatorregionMapper;
private MonitorFanIndicatorMapper monitorFanIndicatorregionMapper;
@Autowired
private StationBasicMapper stationBasicMapper;
@Autowired
private RegionMapper regionMapper;
@Override
public void UpdateMonitorFanIndicator(List<IndexDto> list) {
......@@ -29,4 +46,49 @@ public class MonitorFanIndicatorImpl implements IMonitorFanIndicator {
}
public IPage<MonitorFanIndicator> getFanIdxInfoByPage(String fanCode, String gateway, String frontModule, int current, int size) {
Page<MonitorFanIndicator> page = new Page<>(current, size);
Integer integer = monitorFanIndicatorregionMapper.queryByPageTotal(fanCode, gateway, frontModule);
Page<MonitorFanIndicator> monitorFanIndicators = monitorFanIndicatorregionMapper.queryByPage(page.getSize(), fanCode, gateway, frontModule, (current - 1) * size);
monitorFanIndicators.setTotal(integer);
return monitorFanIndicators;
}
public TreeDto getTreeInfo(String sequenceNbr) {
StationBasic stationBasic = stationBasicMapper.selectById(sequenceNbr);
List<Integer> integers = JSON.parseArray(stationBasic.getBelongArea(), Integer.class);
if (CollectionUtils.isEmpty(integers)) {
throw new BadRequest("所属地区不能为空");
}
LambdaQueryWrapper<Region> regionLambda = new LambdaQueryWrapper<>();
regionLambda.eq(Region::getRegionCode, integers.get(0));
Region region = regionMapper.selectOne(regionLambda);
TreeDto treeDto = new TreeDto();
treeDto.setCode(String.valueOf(region.getRegionCode()));
treeDto.setName(region.getRegionName());
treeDto.setId(String.valueOf(region.getSequenceNbr()));
treeDto.setParentCode("0");
treeDto.setIsOnClick(0);
List<TreeDto> stationListByRegionCode = stationBasicMapper.getStationListByRegionCode(String.valueOf(region.getRegionCode()));
TreeDto fdzTreeDto = new TreeDto();
fdzTreeDto.setName("风电站");
fdzTreeDto.setCode("FDZ");
fdzTreeDto.setParentCode(String.valueOf(region.getRegionCode()));
fdzTreeDto.setIsOnClick(0);
List<TreeDto> fdz = stationListByRegionCode.stream().filter(t -> t.getParentCode().equals("FDZ")).collect(Collectors.toList());
fdzTreeDto.setChildren(fdz);
TreeDto gfzTreeDto = new TreeDto();
gfzTreeDto.setName("光伏站");
gfzTreeDto.setCode("GFZ");
gfzTreeDto.setParentCode(String.valueOf(region.getRegionCode()));
gfzTreeDto.setIsOnClick(0);
List<TreeDto> gfz = stationListByRegionCode.stream().filter(t -> t.getParentCode().equals("GFZ")).collect(Collectors.toList());
gfzTreeDto.setChildren(gfz);
List<TreeDto> treeDtos = Arrays.asList(fdzTreeDto, gfzTreeDto);
treeDto.setChildren(treeDtos);
return treeDto;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment