Browse Source

解决冲突

master
zhizhi wu 5 years ago
parent
commit
637dbcbcb6
  1. 12
      health/src/main/java/com/ccsens/health/bean/vo/HealthVo.java
  2. 2
      health/src/main/java/com/ccsens/health/persist/dao/HealthRecordsDao.java
  3. 185
      health/src/main/java/com/ccsens/health/service/HealthService.java
  4. 4
      health/src/main/resources/application.yml
  5. 43
      health/src/main/resources/mapper_dao/HealthRecordDao.xml
  6. 4
      util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java

12
health/src/main/java/com/ccsens/health/bean/vo/HealthVo.java

@ -53,8 +53,8 @@ public class HealthVo {
private String healthCode;
@ApiModelProperty("健康状态名字")
private String healthTypeName;
@ApiModelProperty("备注的文件信息")
private List<HealthRemarkFileInfo> fileInfoList;
@ApiModelProperty("备注的文件路径")
private List<String> filePath;
}
@Data
@ -171,4 +171,12 @@ public class HealthVo {
@ApiModelProperty("上传时间")
private Long time;
}
@Data
public static class HealthTypeNumber{
private String name;
private int independent;
private int number;
}
}

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

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

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

@ -41,7 +41,7 @@ import java.util.concurrent.Future;
@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class HealthService implements IHealthService{
public class HealthService implements IHealthService {
@Autowired
private Snowflake snowflake;
@ -83,13 +83,13 @@ public class HealthService implements IHealthService{
/**
* 上报健康信息
*
* @param params
* @return
*/
@Override
public HealthVo.HealthInfo addHealthInfo(QueryDto<HealthDto.healthInfo> params) throws Exception {
log.info("保存健康码:{}", params);
HealthVo.HealthInfo healthInfoVo = new HealthVo.HealthInfo();
//1、获取健康信息和userId
HealthDto.healthInfo healthInfo = params.getParam();
@ -112,7 +112,7 @@ public class HealthService implements IHealthService{
healthRecords.setId(snowflake.nextId());
healthRecords.setTime(System.currentTimeMillis());
healthRecords.setUserId(userId);
BeanUtil.copyProperties(healthInfo,healthRecords);
BeanUtil.copyProperties(healthInfo, healthRecords);
healthRecordsDao.insertSelective(healthRecords);
healthInfoVo.setHealthLevel(0);
@ -122,17 +122,18 @@ public class HealthService implements IHealthService{
//如果健康状态异常,健康码为橙色
if(healthType.getQuarantine() != 0){
healthInfoVo.setHealthLevel(1);
}else {
} else {
//如果选择状态正常,检查温度是否正常(36.0°~37.3°)
BigDecimal minAnimalHeat = BigDecimal.valueOf(36.0);
BigDecimal maxAnimalHeat = BigDecimal.valueOf(37.3);
if(healthInfo.getAnimalHeat().compareTo(minAnimalHeat) == -1 ||
healthInfo.getAnimalHeat().compareTo(maxAnimalHeat) == 1){
if (healthInfo.getAnimalHeat().compareTo(minAnimalHeat) == -1 ||
healthInfo.getAnimalHeat().compareTo(maxAnimalHeat) == 1) {
throw new BaseException(CodeEnum.ANIMAL_HEAT_ERROR);
}
}
healthInfoVo.setHealthTypeName(healthType.getName());
}
Long aa2 = System.currentTimeMillis();
//TODO 4、生成健康码,返回地址
// String fileName = "/qrCode/" + cn.hutool.core.date.DateUtil.today() + "/" + System.currentTimeMillis() + ".png";
// String path = WebConstant.UPLOAD_PATH_BASE+fileName;
@ -140,25 +141,24 @@ public class HealthService implements IHealthService{
// ,"d="+userId,color,path);
// String qrcodePath = PropUtil.qrCode + fileName;
//关联备注文件信息
List<HealthVo.HealthRemarkFileInfo> healthRemarkFileInfoList = new ArrayList<>();
if(CollectionUtil.isNotEmpty(healthInfo.getFileIdList())){
for(Long fileId : healthInfo.getFileIdList()){
List<String> filePath = new ArrayList<>();
if (CollectionUtil.isNotEmpty(healthInfo.getFileIdList())) {
for (Long fileId : healthInfo.getFileIdList()) {
HealthRemarkFile healthRemarkFile = healthRemarkFileDao.selectByPrimaryKey(fileId);
if(ObjectUtil.isNull(healthRemarkFile)){
if (ObjectUtil.isNull(healthRemarkFile)) {
throw new BaseException(CodeEnum.NOT_DELIVER_FILE);
}
healthRemarkFile.setHealthRecordsId(healthRecords.getId());
healthRemarkFileDao.updateByPrimaryKeySelective(healthRemarkFile);
//添加至返回信息
HealthVo.HealthRemarkFileInfo fileInfo = new HealthVo.HealthRemarkFileInfo();
fileInfo.setFileId(healthRemarkFile.getId());
fileInfo.setFileName(healthRemarkFile.getName());
fileInfo.setFilePath(healthRemarkFile.getPath());
fileInfo.setTime(healthRemarkFile.getTime());
healthRemarkFileInfoList.add(fileInfo);
filePath.add(healthRemarkFile.getPath());
// HealthVo.HealthRemarkFileInfo fileInfo = new HealthVo.HealthRemarkFileInfo();
// fileInfo.setFileId(healthRemarkFile.getId());
// fileInfo.setFileName(healthRemarkFile.getName());
// fileInfo.setFilePath(healthRemarkFile.getPath());
// fileInfo.setTime(healthRemarkFile.getTime());
// healthRemarkFileInfoList.add(fileInfo);
}
}
@ -175,11 +175,13 @@ public class HealthService implements IHealthService{
healthQRCode.setQrcodePath(qrcodePath);
healthQRCode.setTime(System.currentTimeMillis());
healthQRCodeDao.insertSelective(healthQRCode);
//6、查询健康信息和健康码地址返回前端
BeanUtil.copyProperties(healthRecords,healthInfoVo);
BeanUtil.copyProperties(healthRecords, healthInfoVo);
healthInfoVo.setUserId(userId);
healthInfoVo.setHealthCode(qrcodePath);
healthInfoVo.setFileInfoList(healthRemarkFileInfoList);
healthInfoVo.setFilePath(filePath);
return healthInfoVo;
}
@ -199,6 +201,7 @@ public class HealthService implements IHealthService{
/**
* 获取个人健康信息
*
* @param params
* @return
*/
@ -209,34 +212,32 @@ public class HealthService implements IHealthService{
Long startTime = selectDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : selectDate.getStartTime();
Long endTime = selectDate.getEndTime() == null ? System.currentTimeMillis() : selectDate.getEndTime();
Long userId = params.getUserId();
// if(StrUtil.isEmpty(userId)){
// throw new BaseException(CodeEnum.NOT_LOGIN);
// }
// //2、通过userid查询出成员id
// Employee employee = userService.getEmployeeByUserId(Long.valueOf(userId));
//3、查询该成员符合时间的记录
List<HealthVo.HealthInfo> healthInfoList = healthRecordsDao.selectHealthInfoByDate(userId,startTime,endTime);
if(CollectionUtil.isNotEmpty(healthInfoList)){
for(HealthVo.HealthInfo healthInfo : healthInfoList){
healthInfo.setHealthLevel(0);
//获取健康状态
HealthType healthType = healthTypeDao.selectByPrimaryKey(healthInfo.getHealthTypeId());
if(ObjectUtil.isNotNull(healthType)){
//如果健康状态异常,健康码为橙色
if(healthType.getQuarantine() != 0){
healthInfo.setHealthLevel(1);
}
healthInfo.setHealthTypeName(healthType.getName());
}
log.info("获取个人健康打卡记录 userid:{}", userId);
}
}
//3、查询该成员符合时间的记录
List<HealthVo.HealthInfo> healthInfoList = healthRecordsDao.selectHealthInfoByDate(userId, startTime, endTime);
// if(CollectionUtil.isNotEmpty(healthInfoList)){
// for(HealthVo.HealthInfo healthInfo : healthInfoList){
// healthInfo.setHealthLevel(0);
// //获取健康状态
// HealthType healthType = healthTypeDao.selectByPrimaryKey(healthInfo.getHealthTypeId());
// if(ObjectUtil.isNotNull(healthType)){
// //如果健康状态异常,健康码为橙色
// if(healthType.getQuarantine() != 0){
// healthInfo.setHealthLevel(1);
// }
// healthInfo.setHealthTypeName(healthType.getName());
// }
//
// }
// }
//4、返回
return healthInfoList;
}
/**
* 获取健康类型
*
* @return
*/
@Override
@ -246,8 +247,8 @@ public class HealthService implements IHealthService{
HealthTypeExample healthTypeExample = new HealthTypeExample();
healthTypeExample.clear();
List<HealthType> healthTypeList = healthTypeDao.selectByExample(healthTypeExample);
if(CollectionUtil.isNotEmpty(healthTypeList)){
for(HealthType healthType : healthTypeList){
if (CollectionUtil.isNotEmpty(healthTypeList)) {
for (HealthType healthType : healthTypeList) {
HealthVo.HealthTypeVo healthTypeVo = new HealthVo.HealthTypeVo();
healthTypeVo.setId(healthType.getId());
healthTypeVo.setName(healthType.getName());
@ -259,6 +260,7 @@ public class HealthService implements IHealthService{
/**
* 健康状态统计
*
* @param
* @return
*/
@ -270,47 +272,81 @@ public class HealthService implements IHealthService{
Long startTime = statisticsDate.getStartTime() == null ? DateUtil.getZeroTime(new Date()) : statisticsDate.getStartTime();
Long endTime = statisticsDate.getEndTime() == null ? System.currentTimeMillis() : statisticsDate.getEndTime();
//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);
List<HealthVo.HealthTypeNumber> healthTypeNumberList = healthRecordsDao.selectHealthTypeNumber(startTime, endTime);
int other = 0;
if(CollectionUtil.isNotEmpty(healthTypeNumberList)){
for(HealthVo.HealthTypeNumber healthTypeNumber : healthTypeNumberList){
if(healthTypeNumber.getIndependent() == 0){
other += healthTypeNumber.getNumber();
}else {
HealthVo.HealthTypeStatistics healthTypeStatistics = new HealthVo.HealthTypeStatistics();
healthTypeStatistics.setName(healthType.getName());
healthTypeStatistics.setNumber(number);
healthTypeStatistics.setName(healthTypeNumber.getName());
healthTypeStatistics.setNumber(healthTypeNumber.getNumber());
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);
healthTypeStatistics.setNumber(other);
healthTypeStatisticsList.add(healthTypeStatistics);
}
//获取查询的天数(正常应该一天打卡一次)
Long days = (endTime - startTime) / (3600 * 24 * 1000) + 1;
//未上报的次数
HealthVo.NotUpload notUpload = healthRecordsDao.getNotUpload(days, startTime, endTime);
//获取查询的天数(正常应该一天打卡一次)
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);
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);
// //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;
}
@ -324,6 +360,7 @@ public class HealthService implements IHealthService{
/**
* 上传备注文件
*
* @param filePath
* @param name
* @return

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

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

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

@ -8,6 +8,7 @@
<result column="hDistrict" property="district"/>
<result column="hAddress" property="address"/>
<result column="hHealthTypeId" property="healthTypeId"/>
<result column="hAnimalHeat" property="animalHeat"/>
<result column="hHospital" property="hospital"/>
<result column="hTouchHuBei" property="touchHubei"/>
<result column="hTouchSick" property="touchSick"/>
@ -18,11 +19,11 @@
<result column="hRemark" property="remark"/>
<result column="hHealthAgreement" property="healthAgreement"/>
<result column="hSelfFill" property="selfFill"/>
<collection property="fileInfoList" ofType="com.ccsens.health.bean.vo.HealthVo$HealthRemarkFileInfo">
<id column="fileId" property="fileId"/>
<result column="fileName" property="fileName"/>
<result column="filePath" property="filePath"/>
<result column="fTime" property="time"/>
<result column="hHealthCode" property="healthCode"/>
<result column="hHealthTypeName" property="healthTypeName"/>
<result column="hHealthLevel" property="healthLevel"/>
<collection property="filePath" ofType="String">
<result column="fFilePath"/>
</collection>
</resultMap>
@ -37,6 +38,12 @@
<result column="times" property="times"/>
</resultMap>
<resultMap id="resultMap_healthTypeNumber" type="com.ccsens.health.bean.vo.HealthVo$HealthTypeNumber">
<result column="name" property="name"/>
<result column="independent" property="independent"/>
<result column="number" property="number"/>
</resultMap>
<select id="selectHealthInfoByDate" resultMap="resultMap_HealthInfo" parameterType="java.util.Map">
select
h.id as hId,
@ -45,6 +52,7 @@
h.district as hDistrict,
h.address as hAddress,
h.health_type_id as hHealthTypeId,
h.animal_heat as hAnimalHeat,
h.hospital as hHospital,
h.touch_hubei as hTouchHuBei,
h.touch_sick as hTouchSick,
@ -55,14 +63,14 @@
h.remark as hRemark,
h.health_agreement as hHealthAgreement,
h.self_fill as hSelfFill,
f.id as fileId,
f.name as fileName,
f.path as filePath,
f.time as fTime,
q.qrcode_path as hHealthCode
f.path as fFilePath,
q.qrcode_path as hHealthCode,
ht.name as hHealthTypeName,
if(ht.quarantine = 0,0,1) as hHealthLevel
from
t_health_records h join t_health_qrcode q on q.health_records_id = h.id
left join t_health_remark_file f on f.health_records_id = h.id
join t_health_type ht on h.health_type_id = ht.id
where
h.rec_status = 0
and
@ -74,7 +82,7 @@
ORDER By h.time DESC
</select>
<select id="selectByTypeId" parameterType="java.util.Map" resultType="int">
<select id="selectByTypeId" parameterType="java.util.Map" resultType="int">
select
COUNT(*)
@ -109,7 +117,18 @@
limit 1
</select>
<select id="getNotUpload" parameterType="java.util.Map" resultMap="resultMap_notUpload">
<select id="selectHealthTypeNumber" resultMap="resultMap_healthTypeNumber" parameterType="java.util.Map">
select
if(t.independent = 1 , t.name , '其他') as name,
t.independent as independent,
count(*) as number
from
t_health_type t left join t_health_records r
on t.id = r.health_type_id
GROUP BY t.name
</select>
<select id="getNotUpload" parameterType="java.util.Map" resultMap="resultMap_notUpload">
SELECT
count(*) as number,
a.times as times

4
util/src/main/java/com/ccsens/util/wx/WxXcxUtil.java

@ -235,6 +235,7 @@ public class WxXcxUtil {
* @throws Exception
*/
public static void getWxCode(String page,String scene,LineColor color,String path) throws Exception {
String url = String.format(URL_GET_WX_CODE_B, WxGzhUtil.getAccessToken());
WechatCode wechatCode = new WechatCode();
@ -247,7 +248,8 @@ public class WxXcxUtil {
String postStr = JacksonUtil.beanToJson(wechatCode);
System.out.println(postStr);
HttpsUtil.httpsRequest(url,"POST",postStr,path);
}
}
/**
* 获取小程序二维码/小程序码(长度128有数量限制)

Loading…
Cancel
Save