监测点权重代码提交

This commit is contained in:
wr
2023-08-25 15:52:50 +08:00
parent 4059db12ba
commit c2aed9a9ae
5 changed files with 118 additions and 24 deletions

View File

@@ -1,12 +1,14 @@
package com.njcn.device.pq.controller; package com.njcn.device.pq.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType; import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.param.TerminalMainQueryParam;
import com.njcn.device.pq.pojo.po.PqsLineWeight; import com.njcn.device.pq.pojo.po.PqsLineWeight;
import com.njcn.device.pq.pojo.vo.PqsLineWeightVo; import com.njcn.device.pq.pojo.vo.PqsLineWeightVo;
import com.njcn.device.pq.service.IPqsLineWeightService; import com.njcn.device.pq.service.IPqsLineWeightService;
@@ -22,7 +24,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.*;
/** /**
* <p> * <p>
@@ -43,18 +44,18 @@ public class PqsLineWeightController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/LineWeightList") @PostMapping("/LineWeightList")
@ApiOperation("查询监测点权重") @ApiOperation("查询监测点权重")
public HttpResult<List<PqsLineWeightVo>> LineWeightList() { public HttpResult<Page<PqsLineWeightVo>> LineWeightList(@RequestBody TerminalMainQueryParam terminalMainQueryParam) {
String methodDescribe = getMethodDescribe("nodeTree"); String methodDescribe = getMethodDescribe("LineWeightList");
List<PqsLineWeightVo> pqsLineWeightVos = iPqsLineWeightService.LineWeightList(); Page<PqsLineWeightVo> pqsLineWeightVoPage = iPqsLineWeightService.LineWeightList(terminalMainQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqsLineWeightVos, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqsLineWeightVoPage, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addLineWeight") @PostMapping("/addLineWeight")
@ApiOperation("监测点评分权重修改") @ApiOperation("监测点评分权重修改")
public HttpResult<Boolean> LineWeightList(@RequestBody PqsLineWeight lineWeight) { public HttpResult<Boolean> addLineWeight(@RequestBody PqsLineWeight lineWeight) {
String methodDescribe = getMethodDescribe("nodeTree"); String methodDescribe = getMethodDescribe("addLineWeight");
Boolean aBoolean = iPqsLineWeightService.addLineWeight(lineWeight); Boolean aBoolean = iPqsLineWeightService.addLineWeight(lineWeight);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, aBoolean, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, aBoolean, methodDescribe);
@@ -70,9 +71,16 @@ public class PqsLineWeightController extends BaseController {
@ApiOperation("批量导入监测点评分权重") @ApiOperation("批量导入监测点评分权重")
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
public HttpResult<String> batchTerminal(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) { public HttpResult<String> batchTerminal(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("batchTerminal"); String methodDescribe = getMethodDescribe("batchWeight");
iPqsLineWeightService.batchWeight(file, response); iPqsLineWeightService.batchWeight(file, response);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/exportList")
@ApiOperation("监测点评分权重信息导出")
public void export(@RequestBody TerminalMainQueryParam terminalMainQueryParam) throws IOException {
iPqsLineWeightService.exportWeight(terminalMainQueryParam);
}
} }

View File

@@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
/** /**
* <p> * <p>
* Mapper 接口 * Mapper 接口
@@ -26,7 +27,8 @@ public interface PqsLineWeightMapper extends BaseMapper<PqsLineWeight> {
* @Author: wr * @Author: wr
* @Date: 2023/8/24 10:45 * @Date: 2023/8/24 10:45
*/ */
List<PqsLineWeightVo> selectWeight(); Page<PqsLineWeightVo> selectWeight(Page page,@Param("param") TerminalMainQueryParam terminalMainQueryParam
);
/** /**
* @Description: 根据区域/供电公司/终端等查询监测点id * @Description: 根据区域/供电公司/终端等查询监测点id
@@ -37,4 +39,13 @@ public interface PqsLineWeightMapper extends BaseMapper<PqsLineWeight> {
*/ */
String getLineID( @Param("param") PqsLineWeightVo.WeightExcel param); String getLineID( @Param("param") PqsLineWeightVo.WeightExcel param);
/**
* @Description: 批量导出查询列表
* @param terminalMainQueryParam
* @return: java.util.List<com.njcn.device.pq.pojo.vo.PqsLineWeightVo>
* @Author: wr
* @Date: 2023/8/25 9:15
*/
List<PqsLineWeightVo.WeightExcel> selectWeights(@Param("param") TerminalMainQueryParam terminalMainQueryParam);
} }

View File

@@ -4,7 +4,7 @@
<select id="selectWeight" resultType="com.njcn.device.pq.pojo.vo.PqsLineWeightVo"> <select id="selectWeight" resultType="com.njcn.device.pq.pojo.vo.PqsLineWeightVo">
SELECT SELECT
area.id AS areaName, sys.name AS areaName,
gd.NAME AS gbName, gd.NAME AS gbName,
sub.NAME AS subName, sub.NAME AS subName,
dev.NAME AS devName, dev.NAME AS devName,
@@ -28,8 +28,27 @@
INNER JOIN pq_line sub ON sub.Id = dev.Pid INNER JOIN pq_line sub ON sub.Id = dev.Pid
INNER JOIN pq_line gd ON gd.Id = sub.Pid INNER JOIN pq_line gd ON gd.Id = sub.Pid
INNER JOIN pq_line area ON area.Id = gd.Pid INNER JOIN pq_line area ON area.Id = gd.Pid
INNER JOIN sys_area sys ON area.NAME = sys.id
LEFT JOIN pqs_line_weight plw ON line.Id = plw.LINE_INDEX LEFT JOIN pqs_line_weight plw ON line.Id = plw.LINE_INDEX
where line.State = 1 <where>
line.State = 1
<if test="param.runFlag!=null">
and pd.Run_Flag = #{param.runFlag}
</if>
<if test="param.lineGrade!=null and param.lineGrade!=''">
and pld.line_grade = #{param.lineGrade}
</if>
<if test="param.searchValue!=null and param.searchValue!=''">
and (
area.name like CONCAT('%', #{param.searchValue}, '%')
or gd.name like CONCAT('%', #{param.searchValue}, '%')
or sub.name like CONCAT('%', #{param.searchValue}, '%')
or dev.name like CONCAT('%', #{param.searchValue}, '%')
or line.name like CONCAT('%', #{param.searchValue}, '%')
)
</if>
</where>
order by area.sort asc,gd.sort asc,sub.sort asc,dev.sort asc,line.sort asc
</select> </select>
<select id="getLineID" resultType="java.lang.String"> <select id="getLineID" resultType="java.lang.String">
SELECT SELECT
@@ -48,4 +67,52 @@
and gd.name = #{param.gbName} and gd.name = #{param.gbName}
and area.id = #{param.areaName} and area.id = #{param.areaName}
</select> </select>
<select id="selectWeights" resultType="com.njcn.device.pq.pojo.vo.PqsLineWeightVo$WeightExcel">
SELECT
sys.name AS areaName,
gd.NAME AS gbName,
sub.NAME AS subName,
dev.NAME AS devName,
line.NAME AS lineName,
pd.Run_Flag AS runFlag,
pld.Line_Grade AS lineGrade,
line.id AS lineIndex,
COMMUN_FEE_MARK,
SERVICE_MARK,
AGENT_MARK,
COMPANY_MARK,
USER_MARK,
LINE_TYPE_MARK,
BUSINESS_MARK
FROM
pq_line line
INNER JOIN pq_line_detail pld ON line.Id = pld.Id
INNER JOIN pq_line vol ON vol.Id = line.Pid
INNER JOIN pq_line dev ON dev.Id = vol.Pid
INNER JOIN pq_device pd ON pd.Id = dev.Id
INNER JOIN pq_line sub ON sub.Id = dev.Pid
INNER JOIN pq_line gd ON gd.Id = sub.Pid
INNER JOIN pq_line area ON area.Id = gd.Pid
INNER JOIN sys_area sys ON area.NAME = sys.id
LEFT JOIN pqs_line_weight plw ON line.Id = plw.LINE_INDEX
<where>
line.State = 1
<if test="param.runFlag!=null">
and pd.Run_Flag = #{param.runFlag}
</if>
<if test="param.lineGrade!=null and param.lineGrade!=''">
and pld.line_grade = #{param.lineGrade}
</if>
<if test="param.searchValue!=null and param.searchValue!=''">
and (
area.name like CONCAT('%', #{param.searchValue}, '%')
or gd.name like CONCAT('%', #{param.searchValue}, '%')
or sub.name like CONCAT('%', #{param.searchValue}, '%')
or dev.name like CONCAT('%', #{param.searchValue}, '%')
or line.name like CONCAT('%', #{param.searchValue}, '%')
)
</if>
</where>
order by area.sort asc,gd.sort asc,sub.sort asc,dev.sort asc,line.sort asc
</select>
</mapper> </mapper>

View File

@@ -1,6 +1,8 @@
package com.njcn.device.pq.service; package com.njcn.device.pq.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.device.pq.pojo.param.TerminalMainQueryParam;
import com.njcn.device.pq.pojo.po.PqsLineWeight; import com.njcn.device.pq.pojo.po.PqsLineWeight;
import com.njcn.device.pq.pojo.vo.PqsLineWeightVo; import com.njcn.device.pq.pojo.vo.PqsLineWeightVo;
import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.InputStreamResource;
@@ -8,7 +10,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.List;
/** /**
@@ -37,7 +38,7 @@ public interface IPqsLineWeightService extends IService<PqsLineWeight> {
* @Author: wr * @Author: wr
* @Date: 2023/8/24 10:44 * @Date: 2023/8/24 10:44
*/ */
List<PqsLineWeightVo> LineWeightList(); Page<PqsLineWeightVo> LineWeightList(TerminalMainQueryParam terminalMainQueryParam);
/** /**
* @Description: 导出模板 * @Description: 导出模板
@@ -56,4 +57,12 @@ public interface IPqsLineWeightService extends IService<PqsLineWeight> {
* @Date: 2023/8/24 15:00 * @Date: 2023/8/24 15:00
*/ */
void batchWeight(MultipartFile file, HttpServletResponse response); void batchWeight(MultipartFile file, HttpServletResponse response);
/**
* @Description: 导出模板
* @param
* @Author: wr
* @Date: 2023/8/24 11:47
*/
void exportWeight(TerminalMainQueryParam terminalMainQueryParam) throws IOException;
} }

View File

@@ -10,8 +10,10 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.device.pq.mapper.LineMapper; import com.njcn.device.pq.mapper.LineMapper;
import com.njcn.device.pq.mapper.PqsLineWeightMapper; import com.njcn.device.pq.mapper.PqsLineWeightMapper;
import com.njcn.device.pq.pojo.param.TerminalMainQueryParam;
import com.njcn.device.pq.pojo.po.PqsLineWeight; import com.njcn.device.pq.pojo.po.PqsLineWeight;
import com.njcn.device.pq.pojo.vo.PqsLineWeightVo; import com.njcn.device.pq.pojo.vo.PqsLineWeightVo;
import com.njcn.device.pq.pojo.vo.TerminalTree; import com.njcn.device.pq.pojo.vo.TerminalTree;
@@ -61,17 +63,8 @@ public class PqsLineWeightServiceImpl extends ServiceImpl<PqsLineWeightMapper, P
} }
@Override @Override
public List<PqsLineWeightVo> LineWeightList() { public Page<PqsLineWeightVo> LineWeightList(TerminalMainQueryParam param) {
List<PqsLineWeightVo> lines = this.baseMapper.selectWeight(); return this.baseMapper.selectWeight(new Page(param.getPageNum(), param.getPageSize()),param);
List<TerminalTree> provinceList = lineMapper.getProvinceList(null, 0);
Map<String, String> areaMap = provinceList.stream().collect(Collectors.toMap(TerminalTree::getId, TerminalTree::getName));
lines.stream().forEach(x -> {
if (areaMap.containsKey(x.getAreaName())) {
x.setAreaName(areaMap.get(x.getAreaName()));
}
}
);
return lines;
} }
@Override @Override
@@ -112,6 +105,12 @@ public class PqsLineWeightServiceImpl extends ServiceImpl<PqsLineWeightMapper, P
} }
} }
@Override
public void exportWeight(TerminalMainQueryParam terminalMainQueryParam) {
List<PqsLineWeightVo.WeightExcel> weightExcels = this.baseMapper.selectWeights(terminalMainQueryParam);
ExcelUtil.exportExcel("监测点权重信息.xlsx",PqsLineWeightVo.WeightExcel.class,weightExcels);
}
private void saveWeightBase(List<PqsLineWeightVo.WeightExcel> weightList) { private void saveWeightBase(List<PqsLineWeightVo.WeightExcel> weightList) {
List<PqsLineWeightVo.Msg> weightExcelMsg = new ArrayList<>(); List<PqsLineWeightVo.Msg> weightExcelMsg = new ArrayList<>();
List<PqsLineWeight> info = new ArrayList<>(); List<PqsLineWeight> info = new ArrayList<>();