Merge remote-tracking branch 'lis8.0/master'
This commit is contained in:
commit
75fe5105cc
@ -0,0 +1,105 @@
|
|||||||
|
package com.czlis.transitPF.controller;
|
||||||
|
|
||||||
|
import com.czlis.common.annotation.Anonymous;
|
||||||
|
import com.czlis.common.core.domain.Result;
|
||||||
|
import com.czlis.common.utils.DateUtils;
|
||||||
|
import com.czlis.transitPF.mapper.RegStatMapper;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
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.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域检验中心,统计
|
||||||
|
*/
|
||||||
|
@Api(tags = "区域检验中心-统计")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/transitstat")
|
||||||
|
@Slf4j
|
||||||
|
public class RegStatController {
|
||||||
|
@Autowired
|
||||||
|
RegStatMapper regStatMapper;
|
||||||
|
@Anonymous
|
||||||
|
@ApiOperation("获取业务数据总数")
|
||||||
|
@GetMapping("/getallcount")
|
||||||
|
public Result getallcount() {
|
||||||
|
Date st= DateUtils.parseDate("2025-10-01");
|
||||||
|
Date et= DateUtils.parseDate("2025-11-01");
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
Map<String, Object> regStatAll=regStatMapper.selectRegStatAll();
|
||||||
|
map.put("regStatAll", regStatAll);
|
||||||
|
List<Map<String,Object>> regStatMonth=regStatMapper.selectRegStatMonth(st,et);
|
||||||
|
List<Map<String, Object>> regStatMonth0 = regStatMonth.stream()
|
||||||
|
.sorted(Comparator.comparingInt(o -> (Integer) o.get("daynum"))).collect(Collectors.toList());
|
||||||
|
map.put("regStatMonth", regStatMonth0);
|
||||||
|
List<Map<String,Object>> regStatHospMonth=regStatMapper.selectRegStatHospMonth(st,et);
|
||||||
|
if(!regStatHospMonth.isEmpty()) {
|
||||||
|
List<Map<String, Object>> regStatHospMonth0 = regStatHospMonth.stream()
|
||||||
|
.sorted(Comparator.comparingInt(o -> (Integer) o.get("daynum"))).collect(Collectors.toList());
|
||||||
|
List<Map<String, Object>> regStatHospMonth1=setmapgroup(regStatHospMonth0);
|
||||||
|
List<Map<String, Object>> regStatHospMonth2 = regStatHospMonth1.stream()
|
||||||
|
.sorted(Comparator.comparingInt((Map<String, Object> o) -> (Integer) o.get("groupsum")).reversed()).collect(Collectors.toList());
|
||||||
|
|
||||||
|
map.put("regStatHospMonth", regStatHospMonth2);
|
||||||
|
}
|
||||||
|
List<Map<String,Object>> regStatStatus=regStatMapper.selectRegStatStatus(st,et);
|
||||||
|
List<Map<String, Object>> regStatStatus0 = regStatStatus.stream()
|
||||||
|
.sorted((o1, o2) -> {
|
||||||
|
int val1 = (Integer) o1.get("sl");
|
||||||
|
int val2 = (Integer) o2.get("sl");
|
||||||
|
return Integer.compare(val2, val1);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
map.put("regStatStatus", regStatStatus0);
|
||||||
|
List<Map<String,Object>> regStatSample=regStatMapper.selectRegStatSample(st,et);
|
||||||
|
List<Map<String, Object>> regStatSample0 = regStatSample.stream()
|
||||||
|
.sorted((o1, o2) -> {
|
||||||
|
int val1 = (Integer) o1.get("sl");
|
||||||
|
int val2 = (Integer) o2.get("sl");
|
||||||
|
return Integer.compare(val2, val1);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
map.put("regStatSample", regStatSample0);
|
||||||
|
return new Result("0","成功",map);
|
||||||
|
}
|
||||||
|
private List<Map<String,Object>> setmapgroup(List<Map<String,Object>> maps){
|
||||||
|
List<Map<String,Object>> mapref=new ArrayList<>();
|
||||||
|
if(!maps.isEmpty()) {
|
||||||
|
int total = maps.stream().mapToInt(map2 -> ((int) map2.get("sl"))).sum();
|
||||||
|
if (total == 0) {
|
||||||
|
return mapref;
|
||||||
|
}
|
||||||
|
List<Map<String, Object>> distinctList = new ArrayList<>(maps.stream()
|
||||||
|
.collect(Collectors.toMap(map0 -> map0.get("SrcHospName"), map0 -> map0, (existing, replacement) -> existing
|
||||||
|
)).values());
|
||||||
|
DecimalFormat df = new DecimalFormat("0.00%");
|
||||||
|
df.setRoundingMode(RoundingMode.HALF_UP);
|
||||||
|
for (Map<String, Object> map1 : distinctList) {
|
||||||
|
String srcHospName= map1.get("SrcHospName").toString();
|
||||||
|
List<Map<String, Object>> result = maps.stream()
|
||||||
|
.filter(map2 -> Objects.equals(map2.get("SrcHospName"), srcHospName))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
if(!result.isEmpty()) {
|
||||||
|
int total0 = result.stream().mapToInt(map2 -> ((int) map2.get("sl"))).sum();
|
||||||
|
double percentage = (double) total0 / (double)total;
|
||||||
|
Map<String, Object> maptemp = new HashMap<>();
|
||||||
|
maptemp.put("groupname", srcHospName);
|
||||||
|
maptemp.put("groupsum",total0);
|
||||||
|
maptemp.put("percentage", df.format(percentage));
|
||||||
|
maptemp.put("dayline", result);
|
||||||
|
mapref.add(maptemp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return mapref;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.czlis.transitPF.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface RegStatMapper {
|
||||||
|
Map<String,Object> selectRegStatAll();
|
||||||
|
List<Map<String,Object>> selectRegStatMonth(@Param("st") Date st, @Param("et")Date et);
|
||||||
|
List<Map<String,Object>> selectRegStatHospMonth(@Param("st") Date st, @Param("et")Date et);
|
||||||
|
List<Map<String,Object>> selectRegStatStatus(@Param("st") Date st, @Param("et")Date et);
|
||||||
|
List<Map<String,Object>> selectRegStatSample(@Param("st") Date st, @Param("et")Date et);
|
||||||
|
|
||||||
|
}
|
||||||
62
transitPF/src/main/resources/mapper/RegStatMapper.xml
Normal file
62
transitPF/src/main/resources/mapper/RegStatMapper.xml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.czlis.transitPF.mapper.RegStatMapper">
|
||||||
|
|
||||||
|
<select id="selectRegStatAll" resultType="map">
|
||||||
|
SELECT * FROM v_reg_statall
|
||||||
|
</select>
|
||||||
|
<select id="selectRegStatMonth" resultType="map">
|
||||||
|
select day(OrderTime) as daynum,count(1) sl
|
||||||
|
from reg_TransitSample
|
||||||
|
<where>
|
||||||
|
<if test="st != null ">
|
||||||
|
and OrderTime >= #{st}
|
||||||
|
</if>
|
||||||
|
<if test="et != null ">
|
||||||
|
and #{et} > OrderTime
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
group by day(OrderTime)
|
||||||
|
</select>
|
||||||
|
<select id="selectRegStatHospMonth" resultType="map">
|
||||||
|
select SrcHospName,day(OrderTime) as daynum,count(1) sl
|
||||||
|
from reg_TransitSample
|
||||||
|
<where>
|
||||||
|
<if test="st != null ">
|
||||||
|
and OrderTime >= #{st}
|
||||||
|
</if>
|
||||||
|
<if test="et != null ">
|
||||||
|
and #{et} > OrderTime
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
group by SrcHospName,day(OrderTime)
|
||||||
|
</select>
|
||||||
|
<select id="selectRegStatStatus" resultType="map">
|
||||||
|
select b.dict_name,count(1) sl
|
||||||
|
from reg_TransitSample a join reg_dict b on b.dict_type='ZT' and a.Status=b.dict_code
|
||||||
|
<where>
|
||||||
|
<if test="st != null ">
|
||||||
|
and a.OrderTime >= #{st}
|
||||||
|
</if>
|
||||||
|
<if test="et != null ">
|
||||||
|
and #{et} > a.OrderTime
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
group by b.dict_name
|
||||||
|
</select>
|
||||||
|
<select id="selectRegStatSample" resultType="map">
|
||||||
|
select SampleTypeName,count(1) sl
|
||||||
|
from reg_TransitSample
|
||||||
|
<where>
|
||||||
|
<if test="st != null ">
|
||||||
|
and OrderTime >= #{st}
|
||||||
|
</if>
|
||||||
|
<if test="et != null ">
|
||||||
|
and #{et} > OrderTime
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
group by SampleTypeName
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
x
Reference in New Issue
Block a user