Browse Source

0403.1

master
zhangye 5 years ago
parent
commit
efff8d9f3c
  1. 2
      health/src/main/java/com/ccsens/health/api/HealthController.java
  2. 2
      health/src/main/java/com/ccsens/health/bean/dto/AbnormalDto.java
  3. 11
      health/src/main/java/com/ccsens/health/bean/po/HealthType.java
  4. 60
      health/src/main/java/com/ccsens/health/bean/po/HealthTypeExample.java
  5. 30
      health/src/main/java/com/ccsens/health/bean/vo/AbnormalVo.java
  6. 2
      health/src/main/java/com/ccsens/health/persist/dao/HealthRecordsDao.java
  7. 3
      health/src/main/java/com/ccsens/health/persist/dao/MemberDao.java
  8. 32
      health/src/main/java/com/ccsens/health/service/AbnormalService.java
  9. 68
      health/src/main/java/com/ccsens/health/service/HealthService.java
  10. 6
      health/src/main/resources/application-prod.yml
  11. 4
      health/src/main/resources/application.yml
  12. 46
      health/src/main/resources/mapper_dao/HealthAbnormalDao.xml
  13. 40
      health/src/main/resources/mapper_dao/HealthRecordDao.xml
  14. 8
      health/src/main/resources/mapper_dao/SiteClockInDao.xml
  15. 27
      health/src/main/resources/mapper_raw/HealthTypeMapper.xml

2
health/src/main/java/com/ccsens/health/api/HealthController.java

@ -57,7 +57,7 @@ public class HealthController {
}
@MustLogin
@ApiOperation(value = "查询健康状态类型", notes = "")
@ApiOperation(value = "小程序查询健康状态类型", notes = "")
@RequestMapping(value = "type", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<List<HealthVo.HealthTypeVo>> getHealthType() throws Exception {
log.info("查询健康状态类型");

2
health/src/main/java/com/ccsens/health/bean/dto/AbnormalDto.java

@ -6,6 +6,7 @@ import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
@Data
@ -41,6 +42,7 @@ public class AbnormalDto {
@ApiModel("新增异常人员信息")
public static class AddAbnormal{
@NotEmpty
@Size(max = 16,min = 0,message = "信息格式错误")
@ApiModelProperty("学号")
private String wkno;
@NotEmpty

11
health/src/main/java/com/ccsens/health/bean/po/HealthType.java

@ -14,6 +14,8 @@ public class HealthType implements Serializable {
private Byte quarantine;
private Byte scene;
private Date createdAt;
private Date updatedAt;
@ -62,6 +64,14 @@ public class HealthType implements Serializable {
this.quarantine = quarantine;
}
public Byte getScene() {
return scene;
}
public void setScene(Byte scene) {
this.scene = scene;
}
public Date getCreatedAt() {
return createdAt;
}
@ -97,6 +107,7 @@ public class HealthType implements Serializable {
sb.append(", name=").append(name);
sb.append(", independent=").append(independent);
sb.append(", quarantine=").append(quarantine);
sb.append(", scene=").append(scene);
sb.append(", createdAt=").append(createdAt);
sb.append(", updatedAt=").append(updatedAt);
sb.append(", recStatus=").append(recStatus);

60
health/src/main/java/com/ccsens/health/bean/po/HealthTypeExample.java

@ -425,6 +425,66 @@ public class HealthTypeExample {
return (Criteria) this;
}
public Criteria andSceneIsNull() {
addCriterion("scene is null");
return (Criteria) this;
}
public Criteria andSceneIsNotNull() {
addCriterion("scene is not null");
return (Criteria) this;
}
public Criteria andSceneEqualTo(Byte value) {
addCriterion("scene =", value, "scene");
return (Criteria) this;
}
public Criteria andSceneNotEqualTo(Byte value) {
addCriterion("scene <>", value, "scene");
return (Criteria) this;
}
public Criteria andSceneGreaterThan(Byte value) {
addCriterion("scene >", value, "scene");
return (Criteria) this;
}
public Criteria andSceneGreaterThanOrEqualTo(Byte value) {
addCriterion("scene >=", value, "scene");
return (Criteria) this;
}
public Criteria andSceneLessThan(Byte value) {
addCriterion("scene <", value, "scene");
return (Criteria) this;
}
public Criteria andSceneLessThanOrEqualTo(Byte value) {
addCriterion("scene <=", value, "scene");
return (Criteria) this;
}
public Criteria andSceneIn(List<Byte> values) {
addCriterion("scene in", values, "scene");
return (Criteria) this;
}
public Criteria andSceneNotIn(List<Byte> values) {
addCriterion("scene not in", values, "scene");
return (Criteria) this;
}
public Criteria andSceneBetween(Byte value1, Byte value2) {
addCriterion("scene between", value1, value2, "scene");
return (Criteria) this;
}
public Criteria andSceneNotBetween(Byte value1, Byte value2) {
addCriterion("scene not between", value1, value2, "scene");
return (Criteria) this;
}
public Criteria andCreatedAtIsNull() {
addCriterion("created_at is null");
return (Criteria) this;

30
health/src/main/java/com/ccsens/health/bean/vo/AbnormalVo.java

@ -23,21 +23,21 @@ public class AbnormalVo {
private Integer code;
@ApiModelProperty("数量")
private int number;
public String getAbnormalName(){
if(code == null){
return null;
}
switch (code){
case 0: return "健康";
case 1: return "治愈";
case 2: return "隔离";
case 3: return "疑似";
case 4: return "确诊";
case 5: return "出行异常";
case 6: return "未上报";
default:return null;
}
}
// public String getAbnormalName(){
// if(code == null){
// return null;
// }
// switch (code){
// case 0: return "健康";
// case 1: return "治愈";
// case 2: return "隔离";
// case 3: return "疑似";
// case 4: return "确诊";
// case 5: return "出行异常";
// case 6: return "未上报";
// default:return null;
// }
// }
}
@Data

2
health/src/main/java/com/ccsens/health/persist/dao/HealthRecordsDao.java

@ -35,4 +35,6 @@ public interface HealthRecordsDao extends HealthRecordsMapper {
List<HealthVo.HealthList> list(HealthDto.QueryList param);
List<HealthVo.HealthTypeNumber> selectHealthTypeNumber(@Param("startTime")Long startTime, @Param("endTime")Long endTime);
Integer getUploadCount(@Param("startTime")Long startTime, @Param("endTime")Long endTime);
}

3
health/src/main/java/com/ccsens/health/persist/dao/MemberDao.java

@ -4,9 +4,10 @@ import com.ccsens.health.bean.po.Member;
import com.ccsens.health.bean.vo.MemberVo;
import com.ccsens.health.persist.mapper.MemberMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MemberDao extends MemberMapper {
/**

32
health/src/main/java/com/ccsens/health/service/AbnormalService.java

@ -11,8 +11,10 @@ import com.ccsens.health.bean.po.HealthQRCode;
import com.ccsens.health.bean.po.HealthQRCodeExample;
import com.ccsens.health.bean.po.HealthRecords;
import com.ccsens.health.bean.vo.AbnormalVo;
import com.ccsens.health.bean.vo.HealthVo;
import com.ccsens.health.persist.dao.HealthAbnormalDao;
import com.ccsens.health.persist.dao.HealthQRCodeDao;
import com.ccsens.health.persist.dao.HealthRecordsDao;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.bean.dto.QueryDto;
import com.ccsens.util.exception.BaseException;
@ -38,6 +40,8 @@ public class AbnormalService implements IAbnormalService {
@Autowired
private HealthAbnormalDao healthAbnormalDao;
@Autowired
private HealthRecordsDao healthRecordsDao;
@Autowired
private HealthQRCodeDao healthQRCodeDao;
@Autowired
private IAsyncService asyncService;
@ -62,13 +66,39 @@ public class AbnormalService implements IAbnormalService {
abnormalOverview.setAbnormalType(1);
}
}
//健康打卡
List<HealthVo.HealthTypeNumber> healthTypeNumberList = healthRecordsDao.selectHealthTypeNumber(selectAbnormal.getStartTime(), selectAbnormal.getEndTime());
int other = 0;
if(CollectionUtil.isNotEmpty(healthTypeNumberList)){
for(HealthVo.HealthTypeNumber healthTypeNumber : healthTypeNumberList){
if(healthTypeNumber.getIndependent() == 0){
other += healthTypeNumber.getNumber();
}else {
if("发烧".equalsIgnoreCase(healthTypeNumber.getName())){
AbnormalVo.AbnormalOverview abnormalOverview = new AbnormalVo.AbnormalOverview();
abnormalOverview.setAbnormalType(0);
abnormalOverview.setAbnormalName(healthTypeNumber.getName());
abnormalOverview.setNumber(healthTypeNumber.getNumber());
abnormalOverviewList.add(abnormalOverview);
}
}
}
AbnormalVo.AbnormalOverview abnormalOverview = new AbnormalVo.AbnormalOverview();
abnormalOverview.setAbnormalType(0);
abnormalOverview.setAbnormalName("其他");
abnormalOverview.setNumber(other);
abnormalOverviewList.add(abnormalOverview);
}
//行程异常
int journeyNumber = healthAbnormalDao.selectJourneyNumber(selectAbnormal.getDepartment(), selectAbnormal.getStartTime(), selectAbnormal.getEndTime());
AbnormalVo.AbnormalOverview abnormalOverview = new AbnormalVo.AbnormalOverview();
abnormalOverview.setAbnormalType(2);
abnormalOverview.setCode(5);
abnormalOverview.setAbnormalName("出行异常");
abnormalOverview.setNumber(journeyNumber);
abnormalOverviewList.add(abnormalOverview);
//未上报
return abnormalOverviewList;
}

68
health/src/main/java/com/ccsens/health/service/HealthService.java

@ -49,6 +49,8 @@ public class HealthService implements IHealthService {
@Autowired
private HealthQRCodeDao healthQRCodeDao;
@Autowired
private MemberDao memberDao;
@Autowired
private HealthRemarkFileDao healthRemarkFileDao;
@Autowired
private HealthAbnormalDao healthAbnormalDao;
@ -280,7 +282,7 @@ public class HealthService implements IHealthService {
List<HealthVo.HealthTypeVo> healthTypeVoList = new ArrayList<>();
HealthTypeExample healthTypeExample = new HealthTypeExample();
healthTypeExample.clear();
healthTypeExample.createCriteria().andSceneEqualTo((byte) 0);
List<HealthType> healthTypeList = healthTypeDao.selectByExample(healthTypeExample);
if (CollectionUtil.isNotEmpty(healthTypeList)) {
for (HealthType healthType : healthTypeList) {
@ -306,7 +308,9 @@ public class HealthService implements IHealthService {
JourneyDto.StatisticsDate statisticsDate = params.getParam();
Long startTime = statisticsDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : statisticsDate.getStartTime();
Long endTime = statisticsDate.getEndTime() == null ? System.currentTimeMillis() : statisticsDate.getEndTime();
if(startTime >= endTime){
throw new BaseException(CodeEnum.PARAM_ERROR);
}
List<HealthVo.HealthTypeNumber> healthTypeNumberList = healthRecordsDao.selectHealthTypeNumber(startTime, endTime);
int other = 0;
@ -327,61 +331,23 @@ public class HealthService implements IHealthService {
healthTypeStatisticsList.add(healthTypeStatistics);
}
//获取查询的天数(正常应该一天打卡一次)
Long days = (endTime - startTime) / (3600 * 24 * 1000) + 1;
//未上报的次数
HealthVo.NotUpload notUpload = healthRecordsDao.getNotUpload(days, startTime, endTime);
// //未上报的次数
// HealthVo.NotUpload notUpload = healthRecordsDao.getNotUpload(days, startTime, endTime);
//总人数
MemberExample memberExample = new MemberExample();
memberExample.clear();
Long memberNumber = memberDao.countByExample(memberExample);
//已经上报的人数
Integer notUploadNumber = healthRecordsDao.getUploadCount(startTime, endTime);
notUploadNumber = notUploadNumber == null ? 0 : notUploadNumber;
HealthVo.HealthTypeStatistics notUploadStatistics = new HealthVo.HealthTypeStatistics();
notUploadStatistics.setName("未上报");
if (ObjectUtil.isNotNull(notUpload)) {
notUploadStatistics.setNumber((int) (notUpload.getNumber() * days - notUpload.getTimes()));
} else {
notUploadStatistics.setNumber(0);
}
notUploadStatistics.setNumber((int) (memberNumber * days - notUploadNumber));
healthTypeStatisticsList.add(notUploadStatistics);
// //2、获取所有健康状态
// int otherNumber = 0;
// HealthTypeExample healthTypeExample = new HealthTypeExample();
// healthTypeExample.clear();
// List<HealthType> healthTypeList = healthTypeDao.selectByExample(healthTypeExample);
// if(CollectionUtil.isNotEmpty(healthTypeList)){
// for(HealthType healthType : healthTypeList){
// //3、若需要单独统计则单独返回,否则都归为其他类返回总数
// if(healthType.getIndependent() == 1){
// //查询此状态在时间内的打卡人数
// int number = healthRecordsDao.selectByTypeId(healthType.getId(),startTime,endTime);
// HealthVo.HealthTypeStatistics healthTypeStatistics = new HealthVo.HealthTypeStatistics();
// healthTypeStatistics.setName(healthType.getName());
// healthTypeStatistics.setNumber(number);
// healthTypeStatisticsList.add(healthTypeStatistics);
// }else {
// //查询此状态在时间内的打卡人数
// int number = healthRecordsDao.selectByTypeId(healthType.getId(),startTime,endTime);
// otherNumber += number;
// }
// }
// HealthVo.HealthTypeStatistics healthTypeStatistics = new HealthVo.HealthTypeStatistics();
// healthTypeStatistics.setName("其他");
// healthTypeStatistics.setNumber(otherNumber);
// healthTypeStatisticsList.add(healthTypeStatistics);
//
//
// //获取查询的天数(正常应该一天打卡一次)
// Long days = (endTime - startTime) / (3600 * 24 * 1000) + 1;
// //未上报的次数
// HealthVo.NotUpload notUpload = healthRecordsDao.getNotUpload(days,startTime,endTime);
//
// HealthVo.HealthTypeStatistics notUploadStatistics = new HealthVo.HealthTypeStatistics();
// notUploadStatistics.setName("未上报");
// if(ObjectUtil.isNotNull(notUpload)){
// notUploadStatistics.setNumber((int) (notUpload.getNumber() * days - notUpload.getTimes()));
// }else {
// notUploadStatistics.setNumber(0);
// }
// healthTypeStatisticsList.add(notUploadStatistics);
// }
return healthTypeStatisticsList;
}

6
health/src/main/resources/application-prod.yml

@ -1,11 +1,11 @@
server:
port: 7081
port: 7080
servlet:
context-path:
spring:
snowflake:
datacenterId: 2
workerId: 2
datacenterId: 1
workerId: 1
application:
name: health
datasource:

4
health/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring:
profiles:
active: dev
include: common, util-dev
active: test
include: common, util-test

46
health/src/main/resources/mapper_dao/HealthAbnormalDao.xml

@ -16,7 +16,7 @@
<resultMap id="resultMap_abnormal_overview" type="com.ccsens.health.bean.vo.AbnormalVo$AbnormalOverview">
<id column="id" property="id"/>
<result column="code" property="code"/>
<result column="abnormalName" property="abnormalName"/>
<result column="number" property="number"/>
</resultMap>
@ -55,30 +55,26 @@
<select id="abnormalOverview" resultMap="resultMap_abnormal_overview" parameterType="java.util.Map">
SELECT
a.health_status as code,
count(*) as number
FROM
t_health_abnormal a join (
SELECT
ha.health_status as h_status
FROM
t_health_abnormal ha LEFT JOIN t_member m on ha.wkno = m.wkno
WHERE
ha.rec_status = 0
<if test="department != null and department !=''">
and
m.department = #{department}
</if>
<if test="endTime != null">
and
ha.start_time &lt;= #{endTime}
</if>
<if test="startTime != null">
and
ha.end_time &gt;= #{startTime}
</if>
) h on a.health_status = h.h_status
GROUP BY a.health_status
t.`name` as abnormalName,
count(ha.id) as number
FROM
t_health_type t LEFT JOIN t_health_abnormal ha on ha.health_status = t.id
<if test="endTime != null">
and
(ha.start_time &lt;= #{endTime} or ha.start_time is null)
</if>
<if test="startTime != null">
and
(ha.end_time &gt;= #{startTime} or ha.start_time is null)
</if>
LEFT JOIN t_member m on ha.wkno = m.wkno
<if test="department != null and department !=''">
and
(m.department = #{department} or m.department is null)
</if>
WHERE
t.scene = 1
GROUP BY t.id
</select>

40
health/src/main/resources/mapper_dao/HealthRecordDao.xml

@ -128,33 +128,42 @@
(
select
t.id as id,
count(r.id) as num
count(distinct r.user_id) as num
from
t_health_type t
left join t_health_records r on t.id = r.health_type_id
where
t.scene = 0
<if test="endTime != null">
and
(r.time &lt;= #{endTime} or r.time is null)
</if>
<if test="startTime != null">
and
(r.time &gt;= #{startTime} or r.time is null)
</if>
GROUP BY t.name
) a on t.id = a.id
WHERE
t.scene = 0
</select>
<select id="getNotUpload" parameterType="java.util.Map" resultMap="resultMap_notUpload">
SELECT
count(*) as number,
a.times as times
SUM(a.times)
FROM
(
SELECT
count(*) as times
count(n.user_id) as times
FROM
t_employee e LEFT JOIN t_health_records r on e.tall_user_id = r.user_id
t_member m LEFT JOIN t_real_name_auth n on m.wkno = n.no
LEFT join t_health_records r on r.user_id = n.user_id
where
r.time &lt;= #{endTime}
(r.time &lt;= #{endTime} or r.time is null)
and
r.time &gt;= #{startTime}
GROUP BY e.id
(r.time &gt;= #{startTime} or r.time is null)
GROUP BY m.id
)a
WHERE
a.times &lt; #{days}
@ -199,4 +208,21 @@
</if>
and r.rec_status = 0
</select>
<select id="getUploadCount" parameterType="java.util.Map" resultType="java.lang.Integer">
select sum(total) from
(
select FROM_UNIXTIME(time/1000,'%Y-%m-%d'), count(distinct
user_id) as total
from
t_health_records
WHERE
time &lt;= #{endTime}
and
time &gt;= #{startTime}
group by FROM_UNIXTIME(time/1000,'%Y-%m-%d')
) t;
</select>
</mapper>

8
health/src/main/resources/mapper_dao/SiteClockInDao.xml

@ -65,7 +65,7 @@
<select id="queryRecord" resultType="com.ccsens.health.bean.vo.ClockVo$ClockInMsg">
select i.user_id as userId, a.no, a.name, m.department, s.id as siteId,
s.site_name as siteName, i.time, i.out_time as outTime from
t_site_clock_in i left join t_real_name_auth a on i.user_id = a.id
t_site_clock_in i left join t_real_name_auth a on i.user_id = a.user_id
left join t_site s on i.site_id = s.id
left join t_member m on a.no = m.wkno
<where>
@ -91,12 +91,12 @@
<select id="queryRecordBySite" resultType="com.ccsens.health.bean.vo.ClockVo$ClockInMsg">
select i.user_id as userId, a.no, a.name, m.department, s.id as siteId,
s.site_name as siteName, i.time, i.out_time as outTime from
t_site_clock_in i left join t_real_name_auth a on i.user_id = a.id
t_site_clock_in i left join t_real_name_auth a on i.user_id = a.user_id
left join t_site s on i.site_id = s.id
left join t_member m on a.no = m.wkno
<where>
<foreach collection="lit" item="item" separator="or" open="(" close=")">
(s.id = #{item.siteId} and i.out_time &gt;= #{item.inTime} and i.time &lt;= #{item.outTime})
<foreach collection="list" item="item" separator="or" open="(" close=")">
(s.id = #{item.siteId} and i.out_time &gt;= #{item.time} and i.time &lt;= #{item.outTime})
</foreach>
and i.rec_status = 0
</where>

27
health/src/main/resources/mapper_raw/HealthTypeMapper.xml

@ -7,6 +7,7 @@
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="independent" jdbcType="TINYINT" property="independent" />
<result column="quarantine" jdbcType="TINYINT" property="quarantine" />
<result column="scene" jdbcType="TINYINT" property="scene" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
@ -70,7 +71,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, code, name, independent, quarantine, created_at, updated_at, rec_status
id, code, name, independent, quarantine, scene, created_at, updated_at, rec_status
</sql>
<select id="selectByExample" parameterType="com.ccsens.health.bean.po.HealthTypeExample" resultMap="BaseResultMap">
select
@ -104,11 +105,13 @@
</delete>
<insert id="insert" parameterType="com.ccsens.health.bean.po.HealthType">
insert into t_health_type (id, code, name,
independent, quarantine, created_at,
updated_at, rec_status)
independent, quarantine, scene,
created_at, updated_at, rec_status
)
values (#{id,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{independent,jdbcType=TINYINT}, #{quarantine,jdbcType=TINYINT}, #{createdAt,jdbcType=TIMESTAMP},
#{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT})
#{independent,jdbcType=TINYINT}, #{quarantine,jdbcType=TINYINT}, #{scene,jdbcType=TINYINT},
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}
)
</insert>
<insert id="insertSelective" parameterType="com.ccsens.health.bean.po.HealthType">
insert into t_health_type
@ -128,6 +131,9 @@
<if test="quarantine != null">
quarantine,
</if>
<if test="scene != null">
scene,
</if>
<if test="createdAt != null">
created_at,
</if>
@ -154,6 +160,9 @@
<if test="quarantine != null">
#{quarantine,jdbcType=TINYINT},
</if>
<if test="scene != null">
#{scene,jdbcType=TINYINT},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
@ -189,6 +198,9 @@
<if test="record.quarantine != null">
quarantine = #{record.quarantine,jdbcType=TINYINT},
</if>
<if test="record.scene != null">
scene = #{record.scene,jdbcType=TINYINT},
</if>
<if test="record.createdAt != null">
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
</if>
@ -210,6 +222,7 @@
name = #{record.name,jdbcType=VARCHAR},
independent = #{record.independent,jdbcType=TINYINT},
quarantine = #{record.quarantine,jdbcType=TINYINT},
scene = #{record.scene,jdbcType=TINYINT},
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
rec_status = #{record.recStatus,jdbcType=TINYINT}
@ -232,6 +245,9 @@
<if test="quarantine != null">
quarantine = #{quarantine,jdbcType=TINYINT},
</if>
<if test="scene != null">
scene = #{scene,jdbcType=TINYINT},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
@ -250,6 +266,7 @@
name = #{name,jdbcType=VARCHAR},
independent = #{independent,jdbcType=TINYINT},
quarantine = #{quarantine,jdbcType=TINYINT},
scene = #{scene,jdbcType=TINYINT},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
rec_status = #{recStatus,jdbcType=TINYINT}

Loading…
Cancel
Save