Commit 1b54cf30 authored by 王琮's avatar 王琮

修改首页统计

parent 641d7e6f
......@@ -51,9 +51,9 @@ public class YxryController extends BaseController
* 获取首页数据
*/
@GetMapping(value = "/statistics")
public AjaxResult statistics()
public AjaxResult statistics(Yxry yxry)
{
return success(yxryService.statistics());
return success(yxryService.statistics(yxry));
}
/**
......
package com.ruoyi.system.domain;
import java.time.LocalDate;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.data.annotation.Transient;
/**
* 阳性人员对象 yxry
......@@ -148,6 +150,17 @@ public class Yxry extends BaseEntity
/** 身份证是否重复 */
private String isCf;
@Transient
private String begin;
@Transient
private String end;
@Transient
private String value;
@Transient
private LocalDate date;
/** 采样时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
......@@ -306,6 +319,14 @@ public class Yxry extends BaseEntity
this.committee = committee;
}
public LocalDate getDate() {
return date;
}
public void setDate(LocalDate date) {
this.date = date;
}
public String getFcName() {
return fcName;
}
......@@ -338,6 +359,30 @@ public class Yxry extends BaseEntity
this.cyTime = cyTime;
}
public String getBegin() {
return begin;
}
public void setBegin(String begin) {
this.begin = begin;
}
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
......@@ -4,6 +4,7 @@ import java.time.LocalDate;
import java.util.List;
import com.ruoyi.system.domain.Fcry;
import com.ruoyi.system.domain.Gldry;
import com.ruoyi.system.domain.Yxry;
import org.apache.ibatis.annotations.Param;
/**
......@@ -70,9 +71,9 @@ public interface FcryMapper
List<Gldry> selectGldryByCard(@Param("cardNo")String cardNo, @Param("id")Long id);
int selectToday(@Param("date") LocalDate date);
int selectToday(Yxry yxry);
int selectCurrent();
int selectCurrent(Yxry yxry);
List<Fcry> selectAll();
......
......@@ -3,6 +3,7 @@ package com.ruoyi.system.mapper;
import java.time.LocalDate;
import java.util.List;
import com.ruoyi.system.domain.Fkqk;
import com.ruoyi.system.domain.Yxry;
import org.apache.ibatis.annotations.Param;
/**
......@@ -71,19 +72,18 @@ public interface FkqkMapper
/**
* 查询小区封控情况列表
*
* @param today 当天日期
* @return 小区封控情况集合
*/
public List<Fkqk> selectFkToday(@Param("today") LocalDate today);
public List<Fkqk> selectFkToday(Yxry yxry);
/**
* 查询小区封控情况列表
*
* @return 小区封控情况集合
*/
public List<Fkqk> selectCurrent();
public List<Fkqk> selectCurrent(Yxry yxry);
// 根据小区分组
List<Fkqk> selectCumulativeData();
List<Fkqk> selectCumulativeData(Yxry yxry);
}
......@@ -3,6 +3,7 @@ package com.ruoyi.system.mapper;
import java.time.LocalDate;
import java.util.List;
import com.ruoyi.system.domain.Gldry;
import com.ruoyi.system.domain.Yxry;
import org.apache.ibatis.annotations.Param;
/**
......@@ -69,9 +70,9 @@ public interface GldryMapper
*/
List<Gldry> selectGldryByCard(@Param("cardNo") String cardNo, @Param("id") Long id);
int selectToday(@Param("date") LocalDate date);
int selectToday(Yxry yxry);
int selectCurrent();
int selectCurrent(Yxry yxry);
List<Gldry> selectAll();
......
......@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.Hscj;
import com.ruoyi.system.domain.Yxry;
import org.apache.ibatis.annotations.Param;
/**
......@@ -62,7 +63,7 @@ public interface HscjMapper
List<Hscj> checkCard(Hscj hscj);
List<Hscj> selectToday(@Param("begin") String begin, @Param("end") String end);
List<Hscj> selectToday( Yxry yxry);
List<Hscj> checkCardBatch(List<Hscj> hscjList);
......
......@@ -126,4 +126,6 @@ public interface SysUserMapper
public SysUser checkEmailUnique(String email);
public String selectUserTypeById(Long id);
public String selectTypeById(Long id);
}
......@@ -67,9 +67,9 @@ public interface YxryMapper
int updateBatchYxry(@Param("list")List<Yxry> list);
List<Yxry> statistics(@Param("begin") String begin,@Param("end") String end);
List<Yxry> statistics(Yxry yxry);
int selectNum();
int selectNum(Yxry userType);
int updateBatch(@Param("list")List<Yxry> list);
}
......@@ -68,5 +68,5 @@ public interface IYxryService
Map selectByCard(String card);
Map statistics();
Map statistics(Yxry yxry);
}
......@@ -18,6 +18,7 @@ import com.ruoyi.system.mapper.FcryMapper;
import com.ruoyi.system.mapper.FkqkMapper;
import com.ruoyi.system.mapper.GldryMapper;
import com.ruoyi.system.mapper.HscjMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import io.netty.util.internal.ObjectUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.math3.stat.descriptive.summary.Product;
......@@ -41,6 +42,9 @@ public class YxryServiceImpl implements IYxryService {
@Autowired
private FcryMapper fcryMapper;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private YxryMapper yxryMapper;
......@@ -298,7 +302,8 @@ public class YxryServiceImpl implements IYxryService {
}
@Override
public Map statistics() {
@DataScope(deptAlias = "d", userAlias = "u")
public Map statistics(Yxry yxry) {
Map map = new HashMap();
List<Object> todayData = new ArrayList<>();
Map today = new HashMap();
......@@ -306,65 +311,99 @@ public class YxryServiceImpl implements IYxryService {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String begin = sdf.format(TimeUtils.getStartTime());
String end = sdf.format(TimeUtils.getEndTime());
List<Yxry> yxryList = yxryMapper.statistics(begin, end);
// 按照权限查询
String type = sysUserMapper.selectTypeById(SecurityUtils.getUserId());
String userType = sysUserMapper.selectUserTypeById(SecurityUtils.getUserId());
yxry.setBegin(begin);
yxry.setEnd(end);
yxry.setUserType(userType);
if (userType != null && userType.equals("00"))
yxry.setUserType("1");
if ("2".equals(userType))
yxry.setValue(DataUtils.getKey(null, String.valueOf(SecurityUtils.getUserId()), null, null, null));
else if ("3".equals(userType))
yxry.setValue(DataUtils.getKey(null, null, String.valueOf(SecurityUtils.getUserId()), null, null));
List<Yxry> yxryList = yxryMapper.statistics(yxry);
today.put("positiveNum", yxryList.size());
// 涉及小区数量
today.put("PositiveAreaNum", yxryList.stream().filter(y -> ObjectUtils.isNotEmpty(y.getCommunity()))
.distinct().map(Yxry::getCommunity).collect(Collectors.toList()).size());
today.put("PositiveAreaNum", yxryList.stream().filter(y -> y.getCommunity() != null)
.map(Yxry::getCommunity).distinct().collect(Collectors.toList()).size());
// 涉及单元数量
Map<String, List<Yxry>> prodMap = yxryList.stream().filter(y -> ObjectUtils.isNotEmpty(y.getCommunity())
&& ObjectUtils.isNotEmpty(y.getBuilding()) && ObjectUtils.isNotEmpty(y.getUnit()))
Map<String, List<Yxry>> prodMap = yxryList.stream().filter(y -> StringUtils.isNotEmpty(y.getCommunity())
&& StringUtils.isNotEmpty(y.getBuilding()) && StringUtils.isNotEmpty(y.getUnit()))
.collect(Collectors.groupingBy(item -> item.getCommunity() + "_" + item.getBuilding() + "_" + item.getUnit()));
today.put("unitBuildingInvolvedNum", prodMap.keySet().size());
// 查询当天采集异常数据(身份证不为空)
List<Hscj> hscjList = hscjMapper.selectToday(begin, end);
today.put("abnormalMixingNum", hscjList.stream().filter(cj -> ObjectUtils.isNotEmpty(cj.getCjgh())).distinct()
.map(Hscj::getCjgh).collect(Collectors.toList()).size());
today.put("abnormalMixingOfPipesNum", hscjList.stream().distinct().map(Hscj::getCardNo).collect(Collectors.toList()).size());
List<Hscj> hscjList = hscjMapper.selectToday(yxry);
today.put("abnormalMixingNum", hscjList.stream().filter(cj -> StringUtils.isNotEmpty(cj.getCjgh()))
.map(Hscj::getCjgh).distinct().collect(Collectors.toList()).size());
today.put("abnormalMixingOfPipesNum", hscjList.stream().map(Hscj::getCardNo).distinct().collect(Collectors.toList()).size());
// 查询封控数据
LocalDate date = LocalDate.now();
List<Fkqk> fkqkList = fkqkMapper.selectFkToday(date);
yxry.setDate(LocalDate.now());
List<Fkqk> fkqkList = fkqkMapper.selectFkToday(yxry);
// 获取真实时间是空的
today.put("cellBlockingControlNum", fkqkList.stream().filter(f -> ObjectUtils.isEmpty(f.getRealTime())
&& ObjectUtils.isNotEmpty(f.getCommunity()))
.distinct().map(Fkqk::getCommunity).collect(Collectors.toList()).size());
&& StringUtils.isNotEmpty(f.getCommunity()))
.map(Fkqk::getCommunity).distinct().collect(Collectors.toList()).size());
Map<String, List<Fkqk>> fkMap = fkqkList.stream().filter(f -> ObjectUtils.isEmpty(f.getRealTime())
&& ObjectUtils.isNotEmpty(f.getFloor()) && ObjectUtils.isNotEmpty(f.getUnit()))
&& StringUtils.isNotEmpty(f.getFloor()) && StringUtils.isNotEmpty(f.getUnit()))
.collect(Collectors.groupingBy(item -> item.getCommunity() + "_" + item.getFloor() + "_" + item.getUnit()));
today.put("unitSealingControlNum", fkMap.keySet().size());
Map<String, List<Fkqk>> jfMap = fkqkList.stream().filter(f -> ObjectUtils.isNotEmpty(f.getRealTime())
&& ObjectUtils.isNotEmpty(f.getFloor()) && ObjectUtils.isNotEmpty(f.getUnit()))
&& StringUtils.isNotEmpty(f.getFloor()) && StringUtils.isNotEmpty(f.getUnit()))
.collect(Collectors.groupingBy(item -> item.getCommunity() + "_" + item.getFloor() + "_" + item.getUnit()));
today.put("unpackingUnitNum", jfMap.keySet().size());
today.put("transferToShelterNum", fcryMapper.selectToday(date));
today.put("transferToIsolationPointNum", gldryMapper.selectToday(date));
Yxry y = new Yxry();
y.setUserType(null);
y.setParams(yxry.getParams());
y.setDate(yxry.getDate());
if (StringUtils.isNotEmpty(type) && type.equals("0")) {
yxry.setUserType(type);
today.put("transferToShelterNum", fcryMapper.selectToday(yxry) + "/" + fcryMapper.selectToday(y));
} else
today.put("transferToShelterNum", fcryMapper.selectToday(yxry));
if (StringUtils.isNotEmpty(type) && type.equals("1")) {
yxry.setUserType(type);
today.put("transferToIsolationPointNum", gldryMapper.selectToday(yxry) + "/" + gldryMapper.selectToday(y));
} else
today.put("transferToIsolationPointNum", gldryMapper.selectToday(yxry));
todayData.add(today);
map.put("todayData", todayData);
List<Object> currentData = new ArrayList<>();
Map curr = new HashMap();
curr.put("isolationPointNum", gldryMapper.selectCurrent());
curr.put("sheltersNum", fcryMapper.selectCurrent());
List<Fkqk> fkqks = fkqkMapper.selectCurrent();
List<String> j = fkqks.stream().distinct().map(Fkqk::getCommunity)
.collect(Collectors.toList());
System.out.println(j.size());
curr.put("BlockedControlCellNum", fkqks.stream().distinct().map(Fkqk::getCommunity).collect(Collectors.toList()).size());
if (StringUtils.isNotEmpty(type) && type.equals("1")) {
yxry.setUserType(type);
curr.put("isolationPointNum", gldryMapper.selectCurrent(yxry) + "/" + gldryMapper.selectCurrent(y));
} else
curr.put("isolationPointNum", gldryMapper.selectCurrent(yxry));
if (StringUtils.isNotEmpty(type) && type.equals("0")) {
yxry.setUserType(type);
curr.put("sheltersNum", fcryMapper.selectCurrent(yxry) + "/" + fcryMapper.selectCurrent(y));
} else
curr.put("sheltersNum", fcryMapper.selectCurrent(yxry));
yxry.setUserType(userType);
if (userType != null && userType.equals("00"))
yxry.setUserType("1");
List<Fkqk> fkqks = fkqkMapper.selectCurrent(yxry);
curr.put("BlockedControlCellNum", fkqks.stream().map(Fkqk::getCommunity).distinct().collect(Collectors.toList()).size());
Map<String, List<Fkqk>> fk = fkqks.stream()
.collect(Collectors.groupingBy(item -> item.getCommunity() + "_" + item.getFloor() + "_" + item.getUnit()));
curr.put("sealingControlUnitNum", fk.keySet().size());
List<Yxry> yxries = yxryMapper.statistics(null, null);
yxry.setBegin(null);
yxry.setEnd(null);
List<Yxry> yxries = yxryMapper.statistics(yxry);
curr.put("positivePersonnelNum", yxries.size());
currentData.add(curr);
map.put("currentData", currentData);
List<Object> CumulativeData = new ArrayList<>();
Map cum = new HashMap();
cum.put("CumulativePositivePerNum", yxryMapper.selectNum());
List<Fkqk> fks = fkqkMapper.selectCumulativeData();
cum.put("CumulativePositivePerNum", yxryMapper.selectNum(yxry));
List<Fkqk> fks = fkqkMapper.selectCumulativeData(yxry);
cum.put("CumulativeSealingControlUnitNum", fks.size());
cum.put("CumulativeBlockedControlCellNum", fks.stream().distinct().map(Fkqk::getCommunity)
cum.put("CumulativeBlockedControlCellNum",fks.stream().map(Fkqk::getCommunity).distinct()
.collect(Collectors.toList()).size());
cum.put("CumulativeUnpackingUnitNum", fks.stream().filter(f -> f.getRealTime()!=null)
.distinct().map(Fkqk::getCommunity)
cum.put("CumulativeUnpackingUnitNum", fks.stream().filter(f -> f.getRealTime() != null)
.map(Fkqk::getCommunity).distinct()
.collect(Collectors.toList()).size());
CumulativeData.add(cum);
map.put("CumulativeData", CumulativeData);
......
......@@ -149,18 +149,28 @@
<if test="id != null">and id != #{id}</if>
</select>
<select id="selectToday" resultType="java.lang.Integer">
select count(DISTINCT card_no)
from fcry
where zr_time = #{date}
and del_flag = '0'
and card_no is not null
select count(DISTINCT f.card_no)
from fcry f
left join sys_user u on u.user_id = f.create_by
left join sys_dept d on u.dept_id = d.dept_id
where f.zr_time = #{date}
and f.del_flag = '0'
and f.card_no is not null
<if test="userType != null and userType == '0'.toString()">${params.dataScope}</if>
<if test="userType != null and userType == '2'.toString()">and f.street = #{value}</if>
<if test="userType != null and userType == '3'.toString()">and f.committee = #{value}</if>
</select>
<select id="selectCurrent" resultType="java.lang.Integer">
select count(DISTINCT card_no)
from fcry
where zc_time is null
and del_flag = '0'
and card_no is not null
select count(DISTINCT f.card_no)
from fcry f
left join sys_user u on u.user_id = f.create_by
left join sys_dept d on u.dept_id = d.dept_id
where f.zc_time is null
and f.del_flag = '0'
and f.card_no is not null
<if test="userType != null and userType == '0'.toString()">${params.dataScope}</if>
<if test="userType != null and userType == '2'.toString()">and f.street = #{value}</if>
<if test="userType != null and userType == '3'.toString()">and f.committee = #{value}</if>
</select>
<insert id="insertFcry" parameterType="Fcry" useGeneratedKeys="true" keyProperty="id">
......
......@@ -73,24 +73,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE dict_type = 'shelter_name' AND status = '0'
</select>
<select id="selectFkToday" resultMap="FkqkResult">
select community, floor, unit, fk_time, real_time
from fkqk
where del_flag = '0' and (fk_time = #{today}
or real_time = #{today} )
select f.community, f.floor, f.unit, f.fk_time, f.real_time
from fkqk f
left join sys_user u on u.user_id = f.create_by
left join sys_dept d on u.dept_id = d.dept_id
where f.del_flag = '0' and (f.fk_time = #{date}
or f.real_time = #{date} )
<if test="userType != null and userType != '1'.toString() ">${params.dataScope}</if>
</select>
<select id="selectCurrent" resultMap="FkqkResult">
select community, floor, unit, fk_time, real_time
from fkqk
where del_flag = '0'
and real_time is null
and community is not null
select k.community, k.floor, k.unit, k.fk_time, k.real_time
from fkqk k
left join sys_user u on u.user_id = k.create_by
left join sys_dept d on u.dept_id = d.dept_id
where k.del_flag = '0'
and k.real_time is null
and k.community is not null
<if test="userType != null and userType != '1'.toString() ">${params.dataScope}</if>
</select>
<select id="selectCumulativeData" resultMap="FkqkResult">
<include refid="selectFkqkVo"/>
where del_flag = '0'
and community is not null
and floor is not null
and unit is not null
select k.community,k.floor, k.unit, k.fk_time, k.real_time from fkqk k
left join sys_user u on u.user_id = k.create_by
left join sys_dept d on u.dept_id = d.dept_id
where k.del_flag = '0'
and k.community is not null
and k.floor is not null
and k.unit is not null
<if test="userType != null and userType != '1'.toString() ">${params.dataScope}</if>
group by community,floor, unit
</select>
<insert id="insertFkqk" parameterType="Fkqk" useGeneratedKeys="true" keyProperty="id">
......
......@@ -82,19 +82,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="id != null">and id != #{id}</if>
</select>
<select id="selectToday" resultType="java.lang.Integer">
select count(DISTINCT card_no)
from gldry
where zr_time = #{date}
and del_flag = '0'
and card_no is not null
select count(DISTINCT g.card_no)
from gldry g
left join sys_user u on u.user_id = g.create_by
left join sys_dept d on u.dept_id = d.dept_id
where g.zr_time = #{date}
and g.del_flag = '0'
and g.card_no is not null
<if test="userType != null and userType == '1'.toString()">${params.dataScope}</if>
<if test="userType != null and userType == '2'.toString()">and g.street = #{value}</if>
<if test="userType != null and userType == '3'.toString()">and g.committee = #{value}</if>
</select>
<select id="selectCurrent" resultType="java.lang.Integer">
select count(DISTINCT card_no)
from gldry
where zc_time is null
and del_flag = '0'
and card_no is not null
select count(DISTINCT g.card_no)
from gldry g
left join sys_user u on u.user_id = g.create_by
left join sys_dept d on u.dept_id = d.dept_id
where g.zc_time is null
and g.del_flag = '0'
and g.card_no is not null
<if test="userType != null and userType == '1'.toString()">${params.dataScope}</if>
<if test="userType != null and userType == '2'.toString()">and g.street = #{value}</if>
<if test="userType != null and userType == '3'.toString()">and g.committee = #{value}</if>
</select>
<insert id="insertGldry" parameterType="Gldry" useGeneratedKeys="true" keyProperty="id">
......
......@@ -133,13 +133,16 @@
</select>
<select id="selectToday" resultType="com.ruoyi.system.domain.Hscj">
select card_no, cjgh
from hscj
where cj_result = '0'
and del_flag = '0'
and is_hun = '1'
and cj_time BETWEEN #{begin} and #{end}
and card_no is not null
select j.card_no, j.cjgh
from hscj j
left join sys_user u on u.user_id = j.create_by
left join sys_dept d on u.dept_id = d.dept_id
where j.cj_result = '0'
and j.del_flag = '0'
and j.is_hun = '1'
and j.cj_time BETWEEN #{begin} and #{end}
and j.card_no is not null
<if test="userType != null and userType != '1'.toString() ">${params.dataScope}</if>
</select>
......
......@@ -146,6 +146,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select user_type from sys_user where user_id = #{id}
</select>
<select id="selectTypeById" parameterType="Long" resultType="java.lang.String">
select type from sys_user where user_id = #{id}
</select>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
......
......@@ -140,18 +140,26 @@
y.unit
FROM yxry y
LEFT JOIN jcglry j ON y.card_no = j.card_no and j.del_flag = '0'
left join sys_user u on u.user_id = y.create_by
left join sys_dept d on u.dept_id = d.dept_id
WHERE y.del_flag = '0'
<if test="begin!=null and end!=null">
AND y.sb_date BETWEEN #{begin} and #{end}
</if>
AND y.card_no IS NOT NULL
and y.street is not null
AND (j.card_no IS NULL OR y.sb_date > j.jc_time)
<if test="userType != null and userType != '1'.toString() ">${params.dataScope}</if>
GROUP BY y.card_no
</select>
<select id="selectNum" resultType="java.lang.Integer">
select count(DISTINCT card_no) from yxry
where del_flag='0'
and card_no is not null
select count(DISTINCT y.card_no)
from yxry y
left join sys_user u on u.user_id = y.create_by
left join sys_dept d on u.dept_id = d.dept_id
where y.del_flag = '0'
and y.card_no is not null
<if test="userType != null and userType != '1'.toString() ">${params.dataScope}</if>
</select>
<insert id="insertYxry" parameterType="Yxry" useGeneratedKeys="true" keyProperty="id">
......
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