Browse Source

bug修复 判断是否是项目成员 查询完成的题目数

master
zhizhi wu 4 years ago
parent
commit
9fd66457e8
  1. 10
      src/main/java/com/ccsens/yanyuan/api/FamilyController.java
  2. 10
      src/main/java/com/ccsens/yanyuan/api/QuestionController.java
  3. 7
      src/main/java/com/ccsens/yanyuan/bean/dto/FamilyDto.java
  4. 2
      src/main/java/com/ccsens/yanyuan/bean/dto/MedicineDto.java
  5. 10
      src/main/java/com/ccsens/yanyuan/bean/dto/QuestionDto.java
  6. 8
      src/main/java/com/ccsens/yanyuan/bean/po/ToolCard.java
  7. 30
      src/main/java/com/ccsens/yanyuan/bean/po/ToolCardExample.java
  8. 19
      src/main/java/com/ccsens/yanyuan/bean/vo/FamilyVo.java
  9. 11
      src/main/java/com/ccsens/yanyuan/bean/vo/QuestionVo.java
  10. 4
      src/main/java/com/ccsens/yanyuan/bean/vo/TrainBelongVo.java
  11. 25
      src/main/java/com/ccsens/yanyuan/bean/vo/TrainContentVo.java
  12. 2
      src/main/java/com/ccsens/yanyuan/bean/vo/UserPowerVo.java
  13. 3
      src/main/java/com/ccsens/yanyuan/bean/vo/ZaritVo.java
  14. 208
      src/main/java/com/ccsens/yanyuan/mq/TalkingPenReceive.java
  15. 3
      src/main/java/com/ccsens/yanyuan/persist/dao/CareDao.java
  16. 9
      src/main/java/com/ccsens/yanyuan/persist/dao/EvaluationNumDao.java
  17. 3
      src/main/java/com/ccsens/yanyuan/persist/dao/FamilyDao.java
  18. 9
      src/main/java/com/ccsens/yanyuan/persist/dao/TrainCardDao.java
  19. 4
      src/main/java/com/ccsens/yanyuan/persist/dao/TrainEquipmentDao.java
  20. 19
      src/main/java/com/ccsens/yanyuan/persist/dao/TrainRecordDao.java
  21. 9
      src/main/java/com/ccsens/yanyuan/persist/dao/TraineeDao.java
  22. 16
      src/main/java/com/ccsens/yanyuan/service/FamilyService.java
  23. 8
      src/main/java/com/ccsens/yanyuan/service/IFamilyService.java
  24. 8
      src/main/java/com/ccsens/yanyuan/service/IQuestionService.java
  25. 20
      src/main/java/com/ccsens/yanyuan/service/MedicineService.java
  26. 17
      src/main/java/com/ccsens/yanyuan/service/MentalTestService.java
  27. 16
      src/main/java/com/ccsens/yanyuan/service/QuestionService.java
  28. 6
      src/main/java/com/ccsens/yanyuan/service/ToolService.java
  29. 1
      src/main/java/com/ccsens/yanyuan/service/UserPowerService.java
  30. 2
      src/main/java/com/ccsens/yanyuan/service/ZaritService.java
  31. 2
      src/main/java/com/ccsens/yanyuan/util/YanYuanCodeError.java
  32. 83
      src/main/java/com/ccsens/yanyuan/util/YanYuanConstant.java
  33. 2
      src/main/resources/druid-dev.yml
  34. 2
      src/main/resources/druid-test.yml
  35. 3
      src/main/resources/mapper_dao/CareDao.xml
  36. 12
      src/main/resources/mapper_dao/EvaluationNumDao.xml
  37. 6
      src/main/resources/mapper_dao/FamilyDao.xml
  38. 3
      src/main/resources/mapper_dao/TrainCardDao.xml
  39. 14
      src/main/resources/mapper_dao/TrainContentDao.xml
  40. 4
      src/main/resources/mapper_dao/TrainEquipmentDao.xml
  41. 35
      src/main/resources/mapper_dao/TrainRecordDao.xml
  42. 19
      src/main/resources/mapper_dao/TraineeDao.xml
  43. 22
      src/main/resources/mapper_dao/UserRelationDao.xml
  44. 14
      src/main/resources/mapper_raw/ToolCardMapper.xml
  45. 2
      src/main/resources/mbg.xml

10
src/main/java/com/ccsens/yanyuan/api/FamilyController.java

@ -36,6 +36,16 @@ public class FamilyController {
@Resource
private IFamilyService familyService;
@MustLogin
@ApiOperation(value = "查询用户是否是项目成员")
@RequestMapping(value = "/isMember", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<FamilyVo.Member> isMember(@ApiParam @Validated @RequestBody QueryDto<FamilyDto.Member> params) throws Exception{
log.info("查询用户是否是项目成员:{}",params);
FamilyVo.Member personal = familyService.isMember(params.getParam(), params.getUserId());
log.info("查询用户是否是项目成员结束:{}",personal);
return JsonResponse.newInstance().ok(personal);
}
@MustLogin
@ApiOperation(value = "查询个人信息")
@RequestMapping(value = "/personal", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})

10
src/main/java/com/ccsens/yanyuan/api/QuestionController.java

@ -35,6 +35,16 @@ public class QuestionController {
@Resource
private IQuestionService questionService;
@MustLogin
@ApiOperation(value = "查询已经完成的试题编号", notes = "查询已经完成的试题编号")
@RequestMapping(value = "/finish", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse<QuestionVo.Complete> finish(@ApiParam @Validated @RequestBody QueryDto<QuestionDto.Complete> params) {
log.info("查询已经完成的试题编号:{}",params);
QuestionVo.Complete message = questionService.finish(params.getParam(), params.getUserId());
log.info("查询已经完成的试题编号:{}", message);
return JsonResponse.newInstance().ok(message);
}
@MustLogin
@ApiOperation(value = "试题查询", notes = "试题查询")
@RequestMapping(value = "/get", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})

7
src/main/java/com/ccsens/yanyuan/bean/dto/FamilyDto.java

@ -65,4 +65,11 @@ public class FamilyDto {
@ApiModelProperty("项目id")
private Long projectId;
}
@Data
@ApiModel("用户是否是家庭成员-请求")
public static class Member {
@NotNull
@ApiModelProperty("项目id")
private Long projectId;
}
}

2
src/main/java/com/ccsens/yanyuan/bean/dto/MedicineDto.java

@ -36,8 +36,6 @@ public class MedicineDto {
private String adiScore;
@ApiModelProperty("npi得分")
private String npiScore;
@ApiModelProperty("总分")
private String totalScore;
@ApiModelProperty("第一种药物")
private String firstMedicine;
@ApiModelProperty("第二种药物")

10
src/main/java/com/ccsens/yanyuan/bean/dto/QuestionDto.java

@ -13,6 +13,16 @@ import javax.validation.constraints.NotNull;
* @time: 2021/11/11 17:37
*/
public class QuestionDto {
@ApiModel("查询试题完成情况-请求")
@Data
public static class Complete {
@NotEmpty
@ApiModelProperty("题目code NLCP:脑力测评 ZARIT:照顾者负担量表")
private String code;
@NotNull
@ApiModelProperty("测评ID 脑力测评ID或zaritID")
private Long reportId;
}
@ApiModel("查询试题-请求")
@Data
public static class Get {

8
src/main/java/com/ccsens/yanyuan/bean/po/ToolCard.java

@ -6,7 +6,7 @@ import java.util.Date;
public class ToolCard implements Serializable {
private Long id;
private Byte type;
private String type;
private Integer realNum;
@ -36,12 +36,12 @@ public class ToolCard implements Serializable {
this.id = id;
}
public Byte getType() {
public String getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public Integer getRealNum() {

30
src/main/java/com/ccsens/yanyuan/bean/po/ToolCardExample.java

@ -175,52 +175,62 @@ public class ToolCardExample {
return (Criteria) this;
}
public Criteria andTypeEqualTo(Byte value) {
public Criteria andTypeEqualTo(String value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Byte value) {
public Criteria andTypeNotEqualTo(String value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Byte value) {
public Criteria andTypeGreaterThan(String value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Byte value) {
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Byte value) {
public Criteria andTypeLessThan(String value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Byte value) {
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Byte> values) {
public Criteria andTypeLike(String value) {
addCriterion("type like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("type not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Byte> values) {
public Criteria andTypeNotIn(List<String> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Byte value1, Byte value2) {
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Byte value1, Byte value2) {
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}

19
src/main/java/com/ccsens/yanyuan/bean/vo/FamilyVo.java

@ -55,6 +55,8 @@ public class FamilyVo {
private String avatarUrl;
@ApiModelProperty("手机号")
private String phone;
@ApiModelProperty("审核权限 0:无 1:有")
private byte auditPrivilege;
public String getPhone() {
if (StrUtil.isNotBlank(phone)) {
@ -62,6 +64,10 @@ public class FamilyVo {
}
return phone;
}
public byte getAuditPrivilege() {
return (byte) (auditPrivilege > 0 ? 1 : 0);
}
}
@Data
@ -74,4 +80,17 @@ public class FamilyVo {
@ApiModelProperty("用户zarit最新分数")
private Integer score;
}
@Data
@ApiModel("用户是否是家庭成员-返回")
public static class Member {
@ApiModelProperty("家庭成员状态:-1:不是家庭成员 0:申请待处理 1:审核通过 2:审核未通过")
private byte familyStatus;
@ApiModelProperty("使用者userID")
private Long keyUserId;
@ApiModelProperty("用户姓名")
private String userName;
@ApiModelProperty("性别 1:男 2:女 0:未知")
private Integer sex;
}
}

11
src/main/java/com/ccsens/yanyuan/bean/vo/QuestionVo.java

@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
@ -12,6 +14,15 @@ import java.util.List;
* @time: 2021/11/11 17:37
*/
public class QuestionVo {
@ApiModel("查询试题完成情况-响应")
@Data
public static class Complete {
@ApiModelProperty("已经完成的最大题号")
private int finishNum;
@ApiModelProperty("最大题号")
private int totalNum ;
}
@Data
@ApiModel("题目综合信息")
public static class QuestionMessage {

4
src/main/java/com/ccsens/yanyuan/bean/vo/TrainBelongVo.java

@ -40,8 +40,8 @@ public class TrainBelongVo {
// 记录
@ApiModelProperty("卡片ID")
private Long assistId;
@ApiModelProperty("卡片类型 0:迷宫 1:找不同")
private byte cardType;
@ApiModelProperty("卡片类型 MG:迷宫 ZBT:找不同")
private String cardType;
@ApiModelProperty("卡片路径")
private String cardUrl;
@ApiModelProperty("过程记录")

25
src/main/java/com/ccsens/yanyuan/bean/vo/TrainContentVo.java

@ -1,5 +1,6 @@
package com.ccsens.yanyuan.bean.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -135,13 +136,33 @@ public class TrainContentVo {
@Data
@ApiModel("题目对应的语音")
public static class Audio {
@ApiModelProperty("题目ID")
private Long contentId;
@ApiModelProperty("训练计划ID")
private Long recordId;
@ApiModelProperty("题目类型 0:训练 1:休息")
private Byte trainType;
@ApiModelProperty("语音位置")
private Integer audioPosition;
@ApiModelProperty("训练计划时间")
private Long startTime;
@ApiModelProperty("题目code")
private String code;
}
@Data
@ApiModel("训练计划对应的训练结果数量")
public static class RecordResultCount{
@ApiModelProperty("训练计划ID")
private Long recordId;
@ApiModelProperty("已有训练计划数量")
private int count;
}
@Data
@ApiModel("训练计划时间")
public static class RecordTime{
@ApiModelProperty("训练计划ID")
private Long recordId;
@ApiModelProperty("训练时间")
private Long startTime;
}
}

2
src/main/java/com/ccsens/yanyuan/bean/vo/UserPowerVo.java

@ -24,7 +24,7 @@ public class UserPowerVo {
@ApiModelProperty("用户类型(0:普通用户 1:企业用户)")
private Byte isCompany;
@ApiModelProperty("是否满员 0:未满员 1:满员")
private Byte isMax;
private Byte isMax = 0;
@ApiModelProperty("老人数量")
private Integer personNumber;
}

3
src/main/java/com/ccsens/yanyuan/bean/vo/ZaritVo.java

@ -18,6 +18,8 @@ public class ZaritVo {
private Long keyUserId;
@ApiModelProperty("填写人userId")
private Long recordUserId;
@ApiModelProperty("登录用户填写 0:否 1:是")
private Byte selfFill;
@ApiModelProperty("照顾人姓名")
private String careName;
@ApiModelProperty(" 1:男 2:女")
@ -36,6 +38,7 @@ public class ZaritVo {
private String zaritState;
@ApiModelProperty("分数")
private String zaritPoint;
}
@Data
@ApiModel("zarit分数计算-返参")

208
src/main/java/com/ccsens/yanyuan/mq/TalkingPenReceive.java

@ -12,14 +12,11 @@ import com.ccsens.util.DateUtil;
import com.ccsens.util.RedisUtil;
import com.ccsens.util.bean.message.common.*;
import com.ccsens.yanyuan.bean.dto.message.TalkingPenDto;
import com.ccsens.yanyuan.bean.po.EquipmentLog;
import com.ccsens.yanyuan.bean.po.ToolEquipment;
import com.ccsens.yanyuan.bean.po.ToolEquipmentExample;
import com.ccsens.yanyuan.bean.po.*;
import com.ccsens.yanyuan.bean.vo.TrainContentVo;
import com.ccsens.yanyuan.persist.dao.TrainContentDao;
import com.ccsens.yanyuan.persist.dao.TrainEquipmentDao;
import com.ccsens.yanyuan.persist.dao.UserRelationDao;
import com.ccsens.yanyuan.persist.dao.*;
import com.ccsens.yanyuan.persist.mapper.EquipmentLogMapper;
import com.ccsens.yanyuan.persist.mapper.ToolCardMapper;
import com.ccsens.yanyuan.persist.mapper.ToolEquipmentMapper;
import com.ccsens.yanyuan.service.IConstantService;
import com.ccsens.yanyuan.util.YanYuanConstant;
@ -29,8 +26,8 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
/**
* @description:
@ -60,6 +57,14 @@ public class TalkingPenReceive {
private TrainContentDao trainContentDao;
@Resource
private EquipmentLogMapper equipmentLogMapper;
@Resource
private TrainResultDao trainResultDao;
@Resource
private ToolCardMapper toolCardMapper;
@Resource
private TrainCardDao trainCardDao;
@Resource
private TrainRecordDao trainRecordDao;
@RabbitHandler
public void process(String messageJson) throws Exception {
@ -90,6 +95,9 @@ public class TalkingPenReceive {
case TalkingPenDto.Type.QUESTION:
dealQuestion(messageMap.get(type).get(0));
break;
case TalkingPenDto.Type.INDEX:
dealIndex(messageMap.get(type).get(0));
break;
default:
// 处理过程
dealProcess(messageMap.get(TalkingPenDto.Type.PACKAGE).get(0), messageMap.get(TalkingPenDto.Type.FRAME).get(0), messageMap.get(TalkingPenDto.Type.PROCESS));
@ -102,6 +110,148 @@ public class TalkingPenReceive {
log.info("保存日志");
}
/**
* 处理序号
* @param talkingPen 序号或结果
*/
private void dealIndex(TalkingPenDto talkingPen) throws Exception {
YanYuanConstant.Card card = YanYuanConstant.Card.getByCardIndex(talkingPen.getValue());
byte type = card == null ? YanYuanConstant.CardType.INDEX : card.getType();
Long value = card == null ? talkingPen.getValue() : card.getRealIndex();
// 查找点读笔
ToolEquipment toolEquipment = getToolEquipment(talkingPen.getAuthId());
if (toolEquipment == null) {
return;
}
Long equipmentId = toolEquipment.getId();
// 查找使用者
Long keyUserId = getUser(equipmentId, talkingPen.getAuthId());
if (keyUserId < 0) {
// 未找到题目
saveResult(type, 0L, toolEquipment.getId(), value);
return;
}
// 如果是序号,查找卡片对应题目code
ToolCard toolCard = null;
if (type == YanYuanConstant.CardType.INDEX) {
ToolCardExample cardExample = new ToolCardExample();
cardExample.createCriteria().andRealNumEqualTo(Math.toIntExact(value));
cardExample.setOrderByClause(" id desc limit 1");
List<ToolCard> toolCards = toolCardMapper.selectByExample(cardExample);
log.info("卡片对应类型:{}", toolCards);
if (CollectionUtil.isEmpty(toolCards)) {
saveResult(type, 0L, toolEquipment.getId(), value);
return;
}
toolCard = toolCards.get(0);
}
// 查询点读笔正在读的题目
String key = StrUtil.format(YanYuanConstant.Equipment.TALKING_PEN_QUESTION, toolEquipment.getId(), keyUserId);
Object o = redisUtil.get(key);
log.info("点读笔{}正在读的题目:{}", key, o);
// 有正在读的题目,结果直接保存,序号判断类型一致保存
if (o!=null) {
TrainContentVo.Audio audioRedis = (TrainContentVo.Audio) o;
//
boolean save = type == YanYuanConstant.CardType.RESULT ||
(type == YanYuanConstant.CardType.INDEX && toolCard.getType().equals(audioRedis.getCode()));
if (save) {
// 结果 或 序号,判断类型是否一致
saveResult(type, audioRedis.getRecordId(), toolEquipment.getId(), value);
return;
}
}
long today = DateUtil.beginOfDay(new Date()).getTime();
// 点读笔没有正在进行的题目
if (type == YanYuanConstant.CardType.RESULT) {
// 查询今天的训练计划和结果
saveTrainResult(value, toolEquipment.getId(), keyUserId, today);
} else {
// 查询前后一周的、同类型的训练计划
saveCard(toolCard, toolEquipment.getId(), keyUserId, today);
}
}
/**
* 保存卡片序号
* @param toolCard 卡片
* @param toolEquipmentId 设备ID
* @param keyUserId 使用者
* @param today 今天
*/
private void saveCard(ToolCard toolCard, Long toolEquipmentId, Long keyUserId, long today) {
long startTime = today - YanYuanConstant.MentalTest.PERIOD / 2 * YanYuanConstant.DAY_TIME;
long endTime = today + YanYuanConstant.MentalTest.PERIOD / 2 * YanYuanConstant.DAY_TIME;
List<TrainContentVo.RecordTime> times = trainRecordDao.queryTime(keyUserId, startTime, endTime, toolCard.getType());
if (CollectionUtil.isEmpty(times)) {
saveCard(toolCard, 0L, keyUserId, today);
return;
}
Long recordId = null;
Long subTime = null;
for (TrainContentVo.RecordTime time: times) {
if (subTime == null || subTime > Math.abs(today - time.getStartTime())) {
recordId = time.getRecordId();
subTime = Math.abs(today - time.getStartTime());
}
}
saveResult(YanYuanConstant.CardType.INDEX, recordId, toolEquipmentId, toolCard.getRealNum());
}
/**
* 保存答案
* @param value 答案
* @param toolEquipmentId 设备ID
* @param keyUserId 用户ID
* @param today 时间
*/
private void saveTrainResult(Long value, Long toolEquipmentId, Long keyUserId, long today) {
List<TrainContentVo.RecordResultCount> records = trainRecordDao.queryCount(keyUserId, today);
log.info("{}今天{}的训练计划:{}", keyUserId, today, records);
if (CollectionUtil.isEmpty(records)) {
saveResult(YanYuanConstant.CardType.RESULT, 0L, toolEquipmentId, value);
} else if (records.size() == 1) {
saveResult(YanYuanConstant.CardType.RESULT, records.get(0).getRecordId(), toolEquipmentId, value);
} else {
// 找到第一个没有答案的进行记录
for (TrainContentVo.RecordResultCount record: records) {
if (record.getCount() == 0) {
saveResult(YanYuanConstant.CardType.RESULT, record.getRecordId(), toolEquipmentId, value);
return;
}
}
// 都有答案,记录在最后一道题下
saveResult(YanYuanConstant.CardType.RESULT, records.get(records.size()).getRecordId(), toolEquipmentId, value);
}
}
private void saveResult(Byte type, Long recordId, Long equipmentId, long value) {
log.info("保存类型为:{}的结果,recordId:{}, equipmentId:{}, value:{}", type, recordId, equipmentId, value);
if (type == null || type == YanYuanConstant.CardType.INDEX) {
// 序号
// 根据序号查询卡片
ToolCardExample example = new ToolCardExample();
example.createCriteria().andRealNumEqualTo((int)value);
example.setOrderByClause("id desc limit 1");
List<ToolCard> cards = toolCardMapper.selectByExample(example);
// 存储训练结果
TrainCard trainCard = new TrainCard();
trainCard.setId(snowflake.nextId());
trainCard.setRecordId(recordId);
trainCard.setAssistId(CollectionUtil.isEmpty(cards) ? 0 : cards.get(0).getId());
trainCard.setEquipmentId(equipmentId);
trainCardDao.insertSelective(trainCard);
} else if (type == YanYuanConstant.CardType.RESULT) {
// 结果
TrainResult result = new TrainResult();
result.setId(snowflake.nextId());
result.setRecordId(recordId);
result.setEquipmentId(equipmentId);
result.setFinishResult(new BigDecimal(value));
trainResultDao.insertSelective(result);
}
}
/**
* 存储日志
* @param messageMap 数据信息
@ -134,8 +284,11 @@ public class TalkingPenReceive {
* @param processList 坐标数据
*/
private void dealProcess(TalkingPenDto packageDto, TalkingPenDto frameDto, List<TalkingPenDto> processList) {
String indexTime = constantService.getValue(YanYuanConstant.Equipment.VALID_INDEX_TIME_KEY);
// 查询点读笔对应的序号
TrainCard trainCard = trainCardDao.getRecent(packageDto.getAuthId(), System.currentTimeMillis() - Long.parseLong(indexTime) * 3600 * 1000);
//校验是否已经存在
System.out.println(packageDto + "" + frameDto + processList);
}
/**
@ -148,20 +301,19 @@ public class TalkingPenReceive {
if (toolEquipment == null) {
return;
}
Long equipmentId = toolEquipment.getId();
// 查找使用者
Long keyUserId = getUser(equipmentId, talkingPen.getAuthId());
Long keyUserId = getUser(toolEquipment.getId(), talkingPen.getAuthId());
if (keyUserId < 0) {
return;
}
// 查找题目
TrainContentVo.Audio nextPlan = getNextPlan(talkingPen, equipmentId, keyUserId, talkingPen.getAuthId());
log.info("{}的下一个训练计划:{}", equipmentId, nextPlan);
TrainContentVo.Audio nextPlan = getNextPlan(talkingPen, toolEquipment.getId(), keyUserId, talkingPen.getAuthId());
log.info("{}的下一个训练计划:{}", toolEquipment.getId(), nextPlan);
if (nextPlan == null) {
return;
}
String key = StrUtil.format(YanYuanConstant.Equipment.TALKING_PEN_QUESTION, equipmentId, keyUserId);
redisUtil.set(key, nextPlan, YanYuanConstant.DAY_TIME / 1000);
String key = StrUtil.format(YanYuanConstant.Equipment.TALKING_PEN_QUESTION, toolEquipment.getId(), keyUserId);
redisUtil.set(key, nextPlan, YanYuanConstant.Train.TALKING_PEN_WRITE_TIME);
//通知点读笔
sendAudio(nextPlan.getAudioPosition() == null ? YanYuanConstant.Equipment.AUDIO_DEFAULT : nextPlan.getAudioPosition(), talkingPen.getAuthId());
}
@ -181,22 +333,23 @@ public class TalkingPenReceive {
// 提醒登录小程序进行脑力测评
sendAudio(YanYuanConstant.Equipment.AUDIO_MENTAL, serial);
return null;
} else {
return audio;
}
} else {
TrainContentVo.Audio audioRedis = (TrainContentVo.Audio) o;
audio = trainContentDao.getNext(audioRedis.getContentId(), talkingPen.getValue());
if (audio == null) {
if (talkingPen.getValue() != YanYuanConstant.Equipment.NEXT) {
// 上一道为空 提醒没有更多题目
sendAudio(YanYuanConstant.Equipment.AUDIO_TRAIN_PLAN_NO, serial);
return null;
}
}
TrainContentVo.Audio audioRedis = (TrainContentVo.Audio) o;
audio = trainContentDao.getNext(audioRedis.getRecordId(), talkingPen.getValue());
if (audio == null) {
if (talkingPen.getValue() != YanYuanConstant.Equipment.NEXT) {
// 上一道为空 提醒没有更多题目
sendAudio(YanYuanConstant.Equipment.AUDIO_TRAIN_PLAN_NO, serial);
} else {
// 下一道为空
//当前题目日期小于今天 提醒登录小程序进行脑力测评, 否则 提醒没有更多题目
int audioIndex = audioRedis.getStartTime() < todayBegin ? YanYuanConstant.Equipment.AUDIO_MENTAL : YanYuanConstant.Equipment.AUDIO_TRAIN_PLAN_NO;
sendAudio(audioIndex, serial);
return null;
}
return null;
}
return audio;
}
@ -210,8 +363,10 @@ public class TalkingPenReceive {
// 查询时间
String key = YanYuanConstant.Equipment.VALID_TIME_KEY;
String value = constantService.getValue(key);
Long time = System.currentTimeMillis() - Long.parseLong(value) * YanYuanConstant.DAY_TIME;
Long keyUserId = trainEquipmentDao.queryRecentUserId(equipmentId, time);
long time = System.currentTimeMillis() - Long.parseLong(value) * YanYuanConstant.DAY_TIME;
Date date = new Date();
date.setTime(time);
Long keyUserId = trainEquipmentDao.queryRecentUserId(equipmentId, date);
log.info("{}有效期内选择的用户:{}", equipmentId, keyUserId);
if (keyUserId != null) {
return keyUserId;
@ -219,6 +374,7 @@ public class TalkingPenReceive {
// 查询购买者关联的用户
List<Long> userIds = userRelationDao.countUserByEquipment(equipmentId);
log.info("{}关联的使用者:{}", equipmentId, userIds);
// TODO 记录一下点读笔发送的语音,时长1分钟,若1分钟内发送过相同的内容,则不再发送(仅限用户未绑定,时长待定)
if (CollectionUtil.isEmpty(userIds)) {
sendAudio(YanYuanConstant.Equipment.AUDIO_NO_TRAINEE, authId);
return YanYuanConstant.Equipment.BIND_USER_NUM_ZERO;

3
src/main/java/com/ccsens/yanyuan/persist/dao/CareDao.java

@ -16,9 +16,10 @@ public interface CareDao extends CareMapper {
/**
* 查询使用者负担量表的列表
* @param projectId 使用者userId
* @param userId 用户ID
* @return 负担量表的列表
*/
List<ZaritVo.ZaritInfo> queryList(@Param("projectId") Long projectId);
List<ZaritVo.ZaritInfo> queryList( @Param("projectId") Long projectId, @Param("userId") Long userId);
/**
* 查询当前用户负担量表历史记录

9
src/main/java/com/ccsens/yanyuan/persist/dao/EvaluationNumDao.java

@ -32,11 +32,18 @@ public interface EvaluationNumDao extends EvaluationNumMapper {
* @param code
* @return
*/
int getMaxNum(@Param("code") String code);
Integer getMaxNum(@Param("code") String code);
/**
* 更新题目
* @param nums 题目
*/
void modifyBatch(List<EvaluationNum> nums);
/**
* 查询已经完成的最大编号
* @param reportId 报告单ID
* @return 已经完成的最大编号
*/
Integer getFinishMaxNum(@Param("reportId") Long reportId);
}

3
src/main/java/com/ccsens/yanyuan/persist/dao/FamilyDao.java

@ -21,9 +21,10 @@ public interface FamilyDao extends UserFamilyMapper {
/**
* 查询家庭信息列表
* @param projectId 项目id(使用者userId)
* @param userId 查询者ID
* @return 使用者家庭信息列表
*/
List<FamilyVo.FamilyInfo> queryList(@Param("projectId") Long projectId);
List<FamilyVo.FamilyInfo> queryList(@Param("projectId") Long projectId, @Param("userId") Long userId);
/**
* 查询待审核数量

9
src/main/java/com/ccsens/yanyuan/persist/dao/TrainCardDao.java

@ -1,5 +1,6 @@
package com.ccsens.yanyuan.persist.dao;
import com.ccsens.yanyuan.bean.po.TrainCard;
import com.ccsens.yanyuan.bean.vo.TrainBelongVo;
import com.ccsens.yanyuan.bean.vo.TrainContentVo;
import com.ccsens.yanyuan.persist.mapper.TrainCardMapper;
@ -25,4 +26,12 @@ public interface TrainCardDao extends TrainCardMapper {
* @return 训练记录
*/
List<TrainBelongVo.Content> queryUnknown(@Param("userId") Long userId);
/**
* 查询点读笔指定时间内最新的选择序号的记录
* @param serial 点读笔编号
* @param startTime 开始时间
* @return 最新的记录
*/
TrainCard getRecent(@Param("serial") String serial, @Param("startTime") long startTime);
}

4
src/main/java/com/ccsens/yanyuan/persist/dao/TrainEquipmentDao.java

@ -3,6 +3,8 @@ package com.ccsens.yanyuan.persist.dao;
import com.ccsens.yanyuan.persist.mapper.TrainEquipmentMapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/**
* @author whj
*/
@ -13,5 +15,5 @@ public interface TrainEquipmentDao extends TrainEquipmentMapper {
* @param startTime 开始时间
* @return 使用者ID
*/
Long queryRecentUserId(@Param("equipmentId") Long equipmentId, @Param("startTime") Long startTime);
Long queryRecentUserId(@Param("equipmentId") Long equipmentId, @Param("startTime") Date startTime);
}

19
src/main/java/com/ccsens/yanyuan/persist/dao/TrainRecordDao.java

@ -2,6 +2,7 @@ package com.ccsens.yanyuan.persist.dao;
import com.ccsens.yanyuan.bean.po.TrainRecord;
import com.ccsens.yanyuan.bean.vo.TaskVo;
import com.ccsens.yanyuan.bean.vo.TrainContentVo;
import com.ccsens.yanyuan.bean.vo.TrainPlanVo;
import com.ccsens.yanyuan.persist.mapper.TrainRecordMapper;
import org.apache.ibatis.annotations.Param;
@ -40,4 +41,22 @@ public interface TrainRecordDao extends TrainRecordMapper {
* @return 训练计划
*/
List<TrainPlanVo.Simple> query(@Param("keyUserId") Long keyUserId, @Param("startTime") long startTime, @Param("endTime") long endTime);
/**
* 查询训练计划对应的训练结果的数量
* @param keyUserId 使用者ID
* @param startTime 训练开始时间
* @return 训练计划ID和训练结果数量
*/
List<TrainContentVo.RecordResultCount> queryCount(@Param("keyUserId") Long keyUserId, @Param("startTime") long startTime);
/**
* 查询用户在指定时间指定类型的训练计划
* @param keyUserId 用户ID
* @param startTime 开始时间
* @param endTime 结束时间不包含
* @param code 训练类型
* @return 训练时间
*/
List<TrainContentVo.RecordTime> queryTime(@Param("keyUserId") Long keyUserId, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("code") String code);
}

9
src/main/java/com/ccsens/yanyuan/persist/dao/TraineeDao.java

@ -1,6 +1,7 @@
package com.ccsens.yanyuan.persist.dao;
import com.ccsens.yanyuan.bean.po.User;
import com.ccsens.yanyuan.bean.vo.FamilyVo;
import com.ccsens.yanyuan.bean.vo.TraineeVo;
import com.ccsens.yanyuan.persist.mapper.UserMapper;
import org.apache.ibatis.annotations.Param;
@ -42,4 +43,12 @@ public interface TraineeDao extends UserMapper {
* @return 使用者信息
*/
User queryByKeyId(@Param("userId") Long projectId);
/**
* 查询用户是否是家庭成员
* @param keyUserId 使用者
* @param userId 登录用户
* @return 使用者信息 + 用户和使用者关系
*/
FamilyVo.Member getMember(@Param("keyUserId") Long keyUserId, @Param("userId") Long userId);
}

16
src/main/java/com/ccsens/yanyuan/service/FamilyService.java

@ -84,7 +84,7 @@ public class FamilyService implements IFamilyService {
log.info("绑定数量:{}", relationCount);
if (relationCount > 0) {
// 3.1存在,通知无需重复提交
return YanYuanCodeError.MESSAGE_EXIST;
continue;
} else {
// 3.2不存在,提交
UserRelation relation = new UserRelation();
@ -124,7 +124,7 @@ public class FamilyService implements IFamilyService {
@Override
public List<FamilyVo.FamilyInfo> queryList(FamilyDto.QueryFamily param, Long userId) {
return familyDao.queryList(param.getProjectId());
return familyDao.queryList(param.getProjectId(), userId);
}
@Override
@ -155,12 +155,20 @@ public class FamilyService implements IFamilyService {
if (YanYuanConstant.Audit.SUCCESS == param.getAuditStatus()) {
//查询使用者信息
User user = traineeDao.queryByKeyId(param.getProjectId());
ProjectDto.SaveProjectDto userProject = YanYuanConstant.Project.getUserProject(user.getKeyId(),userId,user.getUserName(),user.getCreatedAt());
JsonResponse response = tall3FeignClient.saveProjectList(userProject);
ProjectDto.SaveUserProject userProject = new ProjectDto.SaveUserProject();
userProject.setProjectId(CollectionUtil.newArrayList(user.getKeyId()));
userProject.setUserId(CollectionUtil.newArrayList(userRelation.getUserId()));
JsonResponse response = tall3FeignClient.saveUserProject(userProject);
log.info("添加用户项目:{},结果:{}", userProject, response);
}
return YanYuanCodeError.SUCCESS;
}
@Override
public FamilyVo.Member isMember(FamilyDto.Member param, Long userId) {
FamilyVo.Member member = traineeDao.getMember(param.getProjectId(), userId);
return member;
}
}

8
src/main/java/com/ccsens/yanyuan/service/IFamilyService.java

@ -49,4 +49,12 @@ public interface IFamilyService {
* @return 成功/失败
*/
CodeError.Code auditFamily(FamilyDto.AuditFamily param, Long userId);
/**
* 判断用户是否是项目成员
* @param param 项目信息
* @param userId 用户信息
* @return 是否是成员
*/
FamilyVo.Member isMember(FamilyDto.Member param, Long userId);
}

8
src/main/java/com/ccsens/yanyuan/service/IQuestionService.java

@ -31,4 +31,12 @@ public interface IQuestionService {
* @throws Exception 文件解析
*/
void importSpecial(File file, Long userId) throws Exception;
/**
* 查询已经完成的题目编号和最大编号
* @param param 测评类型 测评ID
* @param userId 用户ID
* @return 完成的最大编号该类型的最大编号
*/
QuestionVo.Complete finish(QuestionDto.Complete param, Long userId);
}

20
src/main/java/com/ccsens/yanyuan/service/MedicineService.java

@ -12,6 +12,7 @@ import com.ccsens.yanyuan.bean.po.FollowUp;
import com.ccsens.yanyuan.bean.vo.MedicineVo;
import com.ccsens.yanyuan.persist.dao.FollowUpDao;
import com.ccsens.yanyuan.persist.dao.UserYDao;
import com.ccsens.yanyuan.util.YanYuanCodeError;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -57,19 +58,14 @@ public class MedicineService implements IMedicineService {
@Override
public CodeError.Code updateMedicineUse(MedicineDto.UpdateMedicineUse param, Long userId) {
Object o = redisUtil.get(param.getId());
if (ObjectUtil.isNull(o)){
redisUtil.set(param.getId(),"1");
FollowUp followUp = new FollowUp();
BeanUtil.copyProperties(param,followUp);
followUp.setId(param.getId());
if (StrUtil.isNotBlank(param.getAdiScore())) {
followUp.setAdlScore(param.getAdiScore());
}
followUpDao.updateByPrimaryKeySelective(followUp);
redisUtil.del(param.getId());
}
FollowUp followUp = new FollowUp();
BeanUtil.copyProperties(param, followUp);
followUp.setId(param.getId());
if (StrUtil.isNotBlank(param.getAdiScore())) {
followUp.setAdlScore(param.getAdiScore());
}
followUpDao.updateByPrimaryKeySelective(followUp);
return CodeError.SUCCESS;
}

17
src/main/java/com/ccsens/yanyuan/service/MentalTestService.java

@ -4,7 +4,9 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.StrUtil;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.RedisUtil;
import com.ccsens.util.exception.BaseException;
import com.ccsens.yanyuan.bean.dto.MentalTestDto;
import com.ccsens.yanyuan.bean.po.*;
@ -48,6 +50,8 @@ public class MentalTestService implements IMentalTestService {
private TrainContentDao trainContentDao;
@Resource
private MentalRecordMapper mentalRecordMapper;
@Resource
private RedisUtil redisUtil;
@Override
public MentalTestVo.Simple generateMentalTestByValid(MentalTestDto.GenerateOne param, Long userId) {
@ -118,18 +122,27 @@ public class MentalTestService implements IMentalTestService {
@Override
public MentalTestVo.Result calculate(MentalTestDto.Id param, Long userId) {
String key = StrUtil.format(YanYuanConstant.MentalTest.CALCULATE_KEY, param.getMentalTestId());
Object o = redisUtil.get(key);
if (o != null) {
throw new BaseException(YanYuanCodeError.CALCULATE_RUNNING);
}
redisUtil.set(key, param.getMentalTestId(), YanYuanConstant.DAY_TIME);
MentalTestVo.Result result = new MentalTestVo.Result();
//判断是否有成绩
MentalTestExample testExample = new MentalTestExample();
testExample.createCriteria().andKeyIdEqualTo(param.getMentalTestId());
List<MentalTest> mentalTests = mentalTestDao.selectByExample(testExample);
if (CollectionUtil.isEmpty(mentalTests)) {
redisUtil.del(key);
throw new BaseException(YanYuanCodeError.PARAM_ERROR);
}
MentalTest mentalTest = mentalTests.get(0);
if (mentalTest.getFinishStatus() == YanYuanConstant.MentalTest.FINISH_STATUS_YES) {
BeanUtils.copyProperties(mentalTest, result);
log.info("脑力测评成绩已存在:{}", mentalTest);
return result;
}
// 计算分数
result = mentalTestDao.calculateScore(param.getMentalTestId());
@ -142,6 +155,7 @@ public class MentalTestService implements IMentalTestService {
result = new MentalTestVo.Result();
result.zero();
} else {
redisUtil.del(key);
throw new BaseException(YanYuanCodeError.MENTAL_TEST_UNFINISHED);
}
}
@ -150,12 +164,15 @@ public class MentalTestService implements IMentalTestService {
BeanUtils.copyProperties(result, updateTest);
updateTest.setFinishStatus(YanYuanConstant.MentalTest.FINISH_STATUS_YES);
updateTest.setId(mentalTest.getId());
Date now = new Date();
updateTest.setTestAt(DateUtil.beginOfDay(now));
mentalTestDao.updateByPrimaryKeySelective(updateTest);
// 根据分数生成训练题目
List<TrainRecord> twoRecords = getTrainRecords(userId, result.getGradeResult(), mentalTest.getId(), mentalTest.getKeyId());
if (CollectionUtil.isNotEmpty(twoRecords)) {
trainRecordDao.insertBatch(twoRecords);
}
redisUtil.del(key);
return result;
}

16
src/main/java/com/ccsens/yanyuan/service/QuestionService.java

@ -64,8 +64,8 @@ public class QuestionService implements IQuestionService {
if (param.getNum() == 1) {
message.setNumStatus(YanYuanConstant.MentalTest.NUM_STATUS_FIRST);
} else {
int max = evaluationNumDao.getMaxNum(param.getCode());
message.setNumStatus(param.getNum() >= max ? YanYuanConstant.MentalTest.NUM_STATUS_LAST : YanYuanConstant.MentalTest.NUM_STATUS_CENTER);
Integer max = evaluationNumDao.getMaxNum(param.getCode());
message.setNumStatus(max == null || param.getNum() >= max ? YanYuanConstant.MentalTest.NUM_STATUS_LAST : YanYuanConstant.MentalTest.NUM_STATUS_CENTER);
}
return message;
}
@ -187,6 +187,18 @@ public class QuestionService implements IQuestionService {
}
@Override
public QuestionVo.Complete finish(QuestionDto.Complete param, Long userId) {
// 查询完成的最大编号
Integer finishNum = evaluationNumDao.getFinishMaxNum(param.getReportId());
// 查询类型的最大编号
Integer maxNum = evaluationNumDao.getMaxNum(param.getCode());
QuestionVo.Complete complete = new QuestionVo.Complete();
complete.setFinishNum(finishNum == null ? 0 : finishNum);
complete.setTotalNum(maxNum == null ? 0 : maxNum);
return complete;
}
/**
* 初始化题目和选项
* @param userId 操作者ID

6
src/main/java/com/ccsens/yanyuan/service/ToolService.java

@ -108,10 +108,10 @@ public class ToolService implements IToolService {
WechatCode.WechatCodeB wechatCodeB = new WechatCode.WechatCodeB();
wechatCodeB.setScene("toolCode=" + tool.getCode());
wechatCodeB.setPage("pages/index/index");
String path = PropUtil.path + getPosition();
String position = getPosition();
String path = PropUtil.path + position;
MiniCodeUtil.getWxCodeB(wechatCodeB, path);
String visitUrl = PropUtil.imgDomain + getPosition();
String visitUrl = PropUtil.imgDomain + position;
code.setUrl(visitUrl);
return code;

1
src/main/java/com/ccsens/yanyuan/service/UserPowerService.java

@ -44,6 +44,7 @@ public class UserPowerService implements IUserPowerService{
userPower.setIsMax(isMax);
}else {
userPower.setIsCompany((byte) 1);
userPower.setIsMax((byte)0);
}
//查询已关联老人数量
Integer personNumber = userRelationDao.queryPersonNumber(userId);

2
src/main/java/com/ccsens/yanyuan/service/ZaritService.java

@ -43,7 +43,7 @@ public class ZaritService implements IZaritService{
@Override
public List<ZaritVo.ZaritInfo> queryList(ZaritDto.QueryZarit param, Long userId) {
return careDao.queryList(param.getProjectId());
return careDao.queryList(param.getProjectId(), userId);
}

2
src/main/java/com/ccsens/yanyuan/util/YanYuanCodeError.java

@ -35,6 +35,8 @@ public class YanYuanCodeError extends CodeError {
public static final Code QUESTION_IMPORT_SORT_LACK = new Code(525,"排序未填写", true);
public static final Code ZARIT_UNFINISHED = new Code(526,"您还没有填写照顾者负担量表,请先回答问卷内容。", true);
public static final Code STATUS_EXIST = new Code(527,"操作已提交,请勿重复提交", true);
public static final Code CALCULATE_RUNNING = new Code(528,"脑力测评分数计算中,请勿重复提交。", true);
public static final Code MODIFY_RUNNING = new Code(529,"数据正在修改中,请勿重复提交。", true);

83
src/main/java/com/ccsens/yanyuan/util/YanYuanConstant.java

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Getter;
import javax.smartcardio.Card;
import java.util.*;
/**
@ -26,6 +27,74 @@ public class YanYuanConstant {
public static final long DAY_TIME = 24 * 3600 * 1000;
public static final String CONSTANT = "constant_";
public static class CardType {
/**
* 序号
*/
public final static byte INDEX = 0;
/**
* 结果
*/
public final static byte RESULT = 1;
}
/**
* 卡片序号则默认为序号
*/
public enum Card {
/**
* 非常困难
*/
RESULT_VERY_DIFFICULT(1, 1, CardType.RESULT),
/**
* 略为困难
*/
RESULT_LITTLE_DIFFICULT(2, 2, CardType.RESULT),
/**
* 非常轻松
*/
RESULT_VERY_EASY(3, 3, CardType.RESULT),
;
private long cardIndex;
private long realIndex;
/**
* 0:训练结果
*/
private byte type;
Card(long cardIndex, long realIndex, byte type){
this.cardIndex = cardIndex;
this.realIndex = realIndex;
this.type = type;
}
public static Card getByCardIndex(long cardIndex) {
for (Card card: Card.values()) {
if (card.cardIndex == cardIndex) {
return card;
}
}
return null;
}
public long getCardIndex() {
return cardIndex;
}
public long getRealIndex() {
return realIndex;
}
public byte getType() {
return type;
}
}
public static class Equipment{
/**
* 点读笔一个寄存器的位数
@ -35,6 +104,10 @@ public class YanYuanConstant {
* 点读笔选择用户的有效时长
*/
public final static String VALID_TIME_KEY = "talking_pen_choose";
/**
* 选择卡片的有效时长
*/
public final static String VALID_INDEX_TIME_KEY = "talking_pen_card_index";
/**
* 关联0个使用者
*/
@ -115,13 +188,15 @@ public class YanYuanConstant {
* 记录过程
*/
public final static byte RECORD_PROCESS = 1;
/**
* 点读笔读出的题目ID的有效时间:12H
*/
public final static long TALKING_PEN_WRITE_TIME = 12 * DAY_TIME;
}
public static class MentalTest{
public final static byte PERIOD = 14;
public final static byte PERIOD_MAX = 28;
public final static byte FINISH_STATUS_NO = 0;
public final static byte FINISH_STATUS_YES = 1;
public final static byte FINISH_STATUS_OUT_DATE = 2;
@ -132,6 +207,8 @@ public class YanYuanConstant {
public final static byte NUM_STATUS_CENTER = 1;
public final static byte NUM_STATUS_LAST = 2;
public final static String CALCULATE_KEY = "calculate_{}";
}
public static class User{
@ -185,7 +262,7 @@ public class YanYuanConstant {
return dto;
}
}
public class Task{
public static class Task{
/**向前翻页*/
public final static byte DIRECTION_PRE = 0;
/**向后翻页*/

2
src/main/resources/druid-dev.yml

@ -28,7 +28,7 @@ spring:
testOnReturn: false
testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://49.233.89.188:3306/yanyuantest?useUnicode=true&characterEncoding=UTF-8
url: jdbc:mysql://49.233.89.188:3306/yanyuantest?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
# url: jdbc:mysql://www.tall.wiki/defaultwbs?useUnicode=true&characterEncoding=UTF-8
# url: jdbc:mysql://127.0.0.1/mt?useUnicode=true&characterEncoding=UTF-8
username: root

2
src/main/resources/druid-test.yml

@ -27,7 +27,7 @@ spring:
testOnReturn: false
testWhileIdle: true
timeBetweenEvictionRunsMillis: 60000
url: jdbc:mysql://test.tall.wiki/yanyuantest?useUnicode=true&characterEncoding=UTF-8
url: jdbc:mysql://test.tall.wiki/yanyuantest?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true
username: root
validationQuery: SELECT 1 FROM DUAL
env: CCSENS_TALL

3
src/main/resources/mapper_dao/CareDao.xml

@ -16,7 +16,8 @@
care_period,
care_relation,
zarit_point,
zarit_state
zarit_state,
if (record_user_id = #{userId}, 1, 0) as selfFill
FROM
u_care
WHERE

12
src/main/resources/mapper_dao/EvaluationNumDao.xml

@ -122,4 +122,16 @@
<select id="getMaxNum" resultType="java.lang.Integer">
SELECT max(num) FROM `t_evaluation_num` where code = #{code} and rec_status = 0
</select>
<select id="getFinishMaxNum" resultType="java.lang.Integer">
SELECT
max( n.num )
FROM
u_mental_record r,
t_evaluation_num n
WHERE
r.num_id = n.id
AND r.test_id = #{reportId}
AND r.rec_status = 0
AND n.rec_status = 0
</select>
</mapper>

6
src/main/resources/mapper_dao/FamilyDao.xml

@ -29,16 +29,20 @@
r.audit_status,
r.relation_type,
u.avatar_url,
u.phone
a.identifier as phone,
sum(if(r2.user_id = #{userId}, 1, 0)) as audit_privilege
FROM
u_user_relation AS r
LEFT JOIN u_user_family AS f ON r.user_id = f.user_id
LEFT JOIN tall3.t_sys_user AS u ON u.id= f.user_id AND u.rec_status = 0
LEFT JOIN tall3.t_sys_auth AS a ON u.id= a.user_id AND a.identify_type = 1 AND a.rec_status = 0
LEFT JOIN u_user_relation AS r2 ON r.key_user_id = r2.key_user_id and r2.relation_type in (0,1) and r2.rec_status = 0
WHERE
r.rec_status = 0
AND r.relation_type = 2
AND r.key_user_id = #{projectId}
AND f.rec_status = 0
group by r.id
ORDER BY
r.audit_status,
r.created_at DESC

3
src/main/resources/mapper_dao/TrainCardDao.xml

@ -104,4 +104,7 @@
AND tc.rec_status = 0) t
order by createTime desc, trainRecordId desc
</select>
<select id="getRecent" resultType="com.ccsens.yanyuan.bean.po.TrainCard">
</select>
</mapper>

14
src/main/resources/mapper_dao/TrainContentDao.xml

@ -70,14 +70,17 @@
</select>
<select id="getFirst" resultType="com.ccsens.yanyuan.bean.vo.TrainContentVo$Audio">
SELECT
r.id as contentId,
r.id as recordId,
r.train_type as trainType,
a.audio_position as audioPosition,
r.start_time as startTime
r.start_time as startTime,
ta.code
FROM
u_train_record r
LEFT JOIN u_mental_test t ON r.key_test_id = t.key_id
LEFT JOIN t_train_audio a ON r.question_id = a.content_id AND a.rec_status = 0
LEFT JOIN t_train_content c on r.question_id = c.id and c.rec_status = 0
LEFT JOIN t_train_aid ta on c.aid_id = ta.id and ta.rec_status = 0
WHERE
r.start_time = #{startTime}
AND t.key_user_id = #{keyUserId}
@ -87,10 +90,11 @@
</select>
<select id="getNext" resultType="com.ccsens.yanyuan.bean.vo.TrainContentVo$Audio">
SELECT
r.id as contentId,
r.id as recordId,
r.train_type as trainType,
a.audio_position as audioPosition,
r.start_time as startTime
r.start_time as startTime,
ta.code
FROM
(
SELECT
@ -112,6 +116,8 @@
AND r.rec_status = 0
LEFT JOIN t_train_audio a ON r.question_id = a.content_id
AND a.rec_status = 0
LEFT JOIN t_train_content c on r.question_id = c.id and c.rec_status = 0
LEFT JOIN t_train_aid ta on c.aid_id = ta.id and ta.rec_status = 0
WHERE
<choose>
<when test="type==1">r.start_time &gt;= t1.start_time</when>

4
src/main/resources/mapper_dao/TrainEquipmentDao.xml

@ -6,11 +6,11 @@
t.key_user_id
FROM
u_train_equipment e,
u_mental_record r,
u_train_record r,
u_mental_test t
WHERE
e.record_id = r.id
AND r.test_id = t.key_id
AND r.key_test_id = t.key_id
AND e.equipment_id = #{equipmentId}
AND e.created_at >= #{startTime}
AND e.rec_status = 0

35
src/main/resources/mapper_dao/TrainRecordDao.xml

@ -52,4 +52,39 @@
ORDER BY
r.start_time
</select>
<select id="queryCount" resultType="com.ccsens.yanyuan.bean.vo.TrainContentVo$RecordResultCount">
SELECT
record.id AS recordId,
count( result.id ) AS count
FROM
u_train_record record
LEFT JOIN u_mental_test test ON record.key_test_id = test.key_id
LEFT JOIN u_train_result result ON record.id = result.record_id
AND result.rec_status = 0
WHERE
test.key_user_id = #{keyUserId}
AND record.start_time = #{startTime}
AND record.rec_status = 0
GROUP BY
record.id
order by
record.start_time,
record.id
</select>
<select id="queryTime" resultType="com.ccsens.yanyuan.bean.vo.TrainContentVo$RecordTime">
SELECT
r.id AS recordId,
r.start_time as startTime
FROM
u_train_record r
LEFT JOIN u_mental_test t ON r.key_test_id = t.key_id and t.rec_status = 0
LEFT JOIN t_train_content c on r.question_id = c.id and c.rec_status = 0
LEFT JOIN t_train_aid a on c.aid_id = a.id and a.rec_status = 0
WHERE
t.key_user_id = #{keyUserId}
AND r.start_time &gt;= #{startTime}
AND r.start_time &lt; #{endTime}
AND a.code = #{code}
AND r.rec_status = 0
</select>
</mapper>

19
src/main/resources/mapper_dao/TraineeDao.xml

@ -61,4 +61,23 @@
AND `status` = 1
AND key_id = #{userId}
</select>
<select id="getMember" resultType="com.ccsens.yanyuan.bean.vo.FamilyVo$Member">
SELECT
u.key_id AS keyUserId,
u.user_name AS userName,
u.sex,
IF( r.id IS NULL, - 1, r.audit_status ) AS familyStatus
FROM
u_user u
LEFT JOIN u_user_relation r ON u.key_id = r.key_user_id
AND r.user_id = #{userId}
AND r.rec_status = 0
WHERE
u.key_id = #{keyUserId}
AND u.rec_status = 0
ORDER BY
r.audit_status ASC,
r.id DESC
LIMIT 1
</select>
</mapper>

22
src/main/resources/mapper_dao/UserRelationDao.xml

@ -51,13 +51,25 @@
<select id="queryPersonNumber" resultType="java.lang.Integer">
SELECT
COUNT(id)
count( DISTINCT r.key_user_id )
FROM
u_user_relation
(
SELECT DISTINCT
t2.user_id
FROM
u_user_scan_tool t1,
u_user_scan_tool t2
WHERE
t1.tool_id = t2.tool_id
AND t1.user_id = #{userId}
AND t1.rec_status = 0
AND t2.rec_status = 0
) t1,
u_user_relation r
WHERE
rec_status = 0
AND
user_id = #{userId}
t1.user_id = r.user_id
AND r.audit_status = 1
AND r.rec_status = 0
</select>
<select id="queryRelation" resultType="com.ccsens.yanyuan.bean.vo.TraineeVo$UserInfoSimple">
SELECT

14
src/main/resources/mapper_raw/ToolCardMapper.xml

@ -3,7 +3,7 @@
<mapper namespace="com.ccsens.yanyuan.persist.mapper.ToolCardMapper">
<resultMap id="BaseResultMap" type="com.ccsens.yanyuan.bean.po.ToolCard">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="type" jdbcType="TINYINT" property="type" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="real_num" jdbcType="INTEGER" property="realNum" />
<result column="show_num" jdbcType="INTEGER" property="showNum" />
<result column="url" jdbcType="VARCHAR" property="url" />
@ -111,7 +111,7 @@
show_num, url, level,
description, operator, created_at,
updated_at, rec_status)
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=TINYINT}, #{realNum,jdbcType=INTEGER},
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{realNum,jdbcType=INTEGER},
#{showNum,jdbcType=INTEGER}, #{url,jdbcType=VARCHAR}, #{level,jdbcType=TINYINT},
#{description,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP},
#{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT})
@ -158,7 +158,7 @@
#{id,jdbcType=BIGINT},
</if>
<if test="type != null">
#{type,jdbcType=TINYINT},
#{type,jdbcType=VARCHAR},
</if>
<if test="realNum != null">
#{realNum,jdbcType=INTEGER},
@ -202,7 +202,7 @@
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.type != null">
type = #{record.type,jdbcType=TINYINT},
type = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.realNum != null">
real_num = #{record.realNum,jdbcType=INTEGER},
@ -239,7 +239,7 @@
<update id="updateByExample" parameterType="map">
update t_tool_card
set id = #{record.id,jdbcType=BIGINT},
type = #{record.type,jdbcType=TINYINT},
type = #{record.type,jdbcType=VARCHAR},
real_num = #{record.realNum,jdbcType=INTEGER},
show_num = #{record.showNum,jdbcType=INTEGER},
url = #{record.url,jdbcType=VARCHAR},
@ -257,7 +257,7 @@
update t_tool_card
<set>
<if test="type != null">
type = #{type,jdbcType=TINYINT},
type = #{type,jdbcType=VARCHAR},
</if>
<if test="realNum != null">
real_num = #{realNum,jdbcType=INTEGER},
@ -291,7 +291,7 @@
</update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.yanyuan.bean.po.ToolCard">
update t_tool_card
set type = #{type,jdbcType=TINYINT},
set type = #{type,jdbcType=VARCHAR},
real_num = #{realNum,jdbcType=INTEGER},
show_num = #{showNum,jdbcType=INTEGER},
url = #{url,jdbcType=VARCHAR},

2
src/main/resources/mbg.xml

@ -55,7 +55,7 @@
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="t_equipment_log" domainObjectName="EquipmentLog"></table>
<table tableName="t_tool_card" domainObjectName="ToolCard"></table>
<!-- <table tableName="u_mental_test" domainObjectName="MentalTest"></table>-->
<!-- <table tableName="u_mental_test" domainObjectName="MentalTest"></table>-->
<!--<table tableName="s_config" domainObjectName="Config"></table>

Loading…
Cancel
Save