Browse Source

userscantool

master
zhizhi wu 4 years ago
parent
commit
d20eb82362
  1. 11
      src/main/java/com/ccsens/yanyuan/api/TrainPlanController.java
  2. 11
      src/main/java/com/ccsens/yanyuan/bean/dto/TrainPlanDto.java
  3. 84
      src/main/java/com/ccsens/yanyuan/bean/po/UserScanTool.java
  4. 561
      src/main/java/com/ccsens/yanyuan/bean/po/UserScanToolExample.java
  5. 37
      src/main/java/com/ccsens/yanyuan/bean/vo/TaskVo.java
  6. 30
      src/main/java/com/ccsens/yanyuan/bean/vo/TrainContentVo.java
  7. 8
      src/main/java/com/ccsens/yanyuan/persist/dao/TrainContentDao.java
  8. 30
      src/main/java/com/ccsens/yanyuan/persist/mapper/UserScanToolMapper.java
  9. 12
      src/main/java/com/ccsens/yanyuan/service/ITrainPlanService.java
  10. 33
      src/main/java/com/ccsens/yanyuan/service/ToolService.java
  11. 18
      src/main/java/com/ccsens/yanyuan/service/TrainPlanService.java
  12. 20
      src/main/java/com/ccsens/yanyuan/service/YTaskService.java
  13. 20
      src/main/resources/mapper_dao/TrainContentDao.xml
  14. 228
      src/main/resources/mapper_raw/UserScanToolMapper.xml
  15. 2
      src/main/resources/mbg.xml

11
src/main/java/com/ccsens/yanyuan/api/TrainPlanController.java

@ -10,6 +10,7 @@ import com.ccsens.yanyuan.bean.vo.TaskVo;
import com.ccsens.yanyuan.bean.vo.TrainPlanVo;
import com.ccsens.yanyuan.bean.vo.TraineeVo;
import com.ccsens.yanyuan.service.ITrainPlanService;
import com.ccsens.yanyuan.util.YanYuanCodeError;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -47,4 +48,14 @@ public class TrainPlanController {
log.info("查询训练计划详情结束{}",createUsers);
return JsonResponse.newInstance().ok(createUsers);
}
@MustLogin
@ApiOperation(value = "选择工具", notes = "选择工具")
@RequestMapping(value = "/chooseTool", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
public JsonResponse chooseTool(@ApiParam @Validated @RequestBody QueryDto<TrainPlanDto.ChooseTool> params) {
log.info("选择工具{}",params);
YanYuanCodeError codeError = trainPlanService.chooseTool(params.getParam(), params.getUserId());
log.info("选择工具结束,{}", codeError);
return JsonResponse.newInstance().ok(codeError);
}
}

11
src/main/java/com/ccsens/yanyuan/bean/dto/TrainPlanDto.java

@ -19,4 +19,15 @@ public class TrainPlanDto {
@ApiModelProperty("训练计划ID")
private Long recordId;
}
@Data
@ApiModel("选择工具-请求")
public static class ChooseTool {
@NotNull
@ApiModelProperty("训练计划ID")
private Long recordId;
@NotNull
@ApiModelProperty("设备ID")
private Long equipmentId;
}
}

84
src/main/java/com/ccsens/yanyuan/bean/po/UserScanTool.java

@ -0,0 +1,84 @@
package com.ccsens.yanyuan.bean.po;
import java.io.Serializable;
import java.util.Date;
public class UserScanTool implements Serializable {
private Long id;
private Long userId;
private Long toolId;
private Date createdAt;
private Date updatedAt;
private Byte recStatus;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getToolId() {
return toolId;
}
public void setToolId(Long toolId) {
this.toolId = toolId;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public Byte getRecStatus() {
return recStatus;
}
public void setRecStatus(Byte recStatus) {
this.recStatus = recStatus;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", toolId=").append(toolId);
sb.append(", createdAt=").append(createdAt);
sb.append(", updatedAt=").append(updatedAt);
sb.append(", recStatus=").append(recStatus);
sb.append("]");
return sb.toString();
}
}

561
src/main/java/com/ccsens/yanyuan/bean/po/UserScanToolExample.java

@ -0,0 +1,561 @@
package com.ccsens.yanyuan.bean.po;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class UserScanToolExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public UserScanToolExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
}
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
return (Criteria) this;
}
public Criteria andUserIdEqualTo(Long value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotEqualTo(Long value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThan(Long value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdGreaterThanOrEqualTo(Long value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThan(Long value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdLessThanOrEqualTo(Long value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
public Criteria andUserIdIn(List<Long> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<Long> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdBetween(Long value1, Long value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotBetween(Long value1, Long value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andToolIdIsNull() {
addCriterion("tool_id is null");
return (Criteria) this;
}
public Criteria andToolIdIsNotNull() {
addCriterion("tool_id is not null");
return (Criteria) this;
}
public Criteria andToolIdEqualTo(Long value) {
addCriterion("tool_id =", value, "toolId");
return (Criteria) this;
}
public Criteria andToolIdNotEqualTo(Long value) {
addCriterion("tool_id <>", value, "toolId");
return (Criteria) this;
}
public Criteria andToolIdGreaterThan(Long value) {
addCriterion("tool_id >", value, "toolId");
return (Criteria) this;
}
public Criteria andToolIdGreaterThanOrEqualTo(Long value) {
addCriterion("tool_id >=", value, "toolId");
return (Criteria) this;
}
public Criteria andToolIdLessThan(Long value) {
addCriterion("tool_id <", value, "toolId");
return (Criteria) this;
}
public Criteria andToolIdLessThanOrEqualTo(Long value) {
addCriterion("tool_id <=", value, "toolId");
return (Criteria) this;
}
public Criteria andToolIdIn(List<Long> values) {
addCriterion("tool_id in", values, "toolId");
return (Criteria) this;
}
public Criteria andToolIdNotIn(List<Long> values) {
addCriterion("tool_id not in", values, "toolId");
return (Criteria) this;
}
public Criteria andToolIdBetween(Long value1, Long value2) {
addCriterion("tool_id between", value1, value2, "toolId");
return (Criteria) this;
}
public Criteria andToolIdNotBetween(Long value1, Long value2) {
addCriterion("tool_id not between", value1, value2, "toolId");
return (Criteria) this;
}
public Criteria andCreatedAtIsNull() {
addCriterion("created_at is null");
return (Criteria) this;
}
public Criteria andCreatedAtIsNotNull() {
addCriterion("created_at is not null");
return (Criteria) this;
}
public Criteria andCreatedAtEqualTo(Date value) {
addCriterion("created_at =", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtNotEqualTo(Date value) {
addCriterion("created_at <>", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtGreaterThan(Date value) {
addCriterion("created_at >", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) {
addCriterion("created_at >=", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtLessThan(Date value) {
addCriterion("created_at <", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtLessThanOrEqualTo(Date value) {
addCriterion("created_at <=", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtIn(List<Date> values) {
addCriterion("created_at in", values, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtNotIn(List<Date> values) {
addCriterion("created_at not in", values, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtBetween(Date value1, Date value2) {
addCriterion("created_at between", value1, value2, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtNotBetween(Date value1, Date value2) {
addCriterion("created_at not between", value1, value2, "createdAt");
return (Criteria) this;
}
public Criteria andUpdatedAtIsNull() {
addCriterion("updated_at is null");
return (Criteria) this;
}
public Criteria andUpdatedAtIsNotNull() {
addCriterion("updated_at is not null");
return (Criteria) this;
}
public Criteria andUpdatedAtEqualTo(Date value) {
addCriterion("updated_at =", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtNotEqualTo(Date value) {
addCriterion("updated_at <>", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtGreaterThan(Date value) {
addCriterion("updated_at >", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) {
addCriterion("updated_at >=", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtLessThan(Date value) {
addCriterion("updated_at <", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtLessThanOrEqualTo(Date value) {
addCriterion("updated_at <=", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtIn(List<Date> values) {
addCriterion("updated_at in", values, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtNotIn(List<Date> values) {
addCriterion("updated_at not in", values, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtBetween(Date value1, Date value2) {
addCriterion("updated_at between", value1, value2, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtNotBetween(Date value1, Date value2) {
addCriterion("updated_at not between", value1, value2, "updatedAt");
return (Criteria) this;
}
public Criteria andRecStatusIsNull() {
addCriterion("rec_status is null");
return (Criteria) this;
}
public Criteria andRecStatusIsNotNull() {
addCriterion("rec_status is not null");
return (Criteria) this;
}
public Criteria andRecStatusEqualTo(Byte value) {
addCriterion("rec_status =", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusNotEqualTo(Byte value) {
addCriterion("rec_status <>", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusGreaterThan(Byte value) {
addCriterion("rec_status >", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) {
addCriterion("rec_status >=", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusLessThan(Byte value) {
addCriterion("rec_status <", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusLessThanOrEqualTo(Byte value) {
addCriterion("rec_status <=", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusIn(List<Byte> values) {
addCriterion("rec_status in", values, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusNotIn(List<Byte> values) {
addCriterion("rec_status not in", values, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusBetween(Byte value1, Byte value2) {
addCriterion("rec_status between", value1, value2, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusNotBetween(Byte value1, Byte value2) {
addCriterion("rec_status not between", value1, value2, "recStatus");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

37
src/main/java/com/ccsens/yanyuan/bean/vo/TaskVo.java

@ -125,46 +125,13 @@ public class TaskVo {
private List<TrainContentVo.Supplementary> supplementaries;
@ApiModelProperty("其他详情")
private List<TrainContentVo.TrainDetail> contentDetails;
// @ApiModelProperty("训练元素")
// private List<TrainContentVo.TrainDetail> elements;
// @ApiModelProperty("训练步骤")
// private List<TrainContentVo.TrainDetail> steps;
// @ApiModelProperty("训练原理")
// private List<TrainContentVo.TrainDetail> principles;
@ApiModelProperty("训练情况")
private List<TrainContentVo.TrainRecord> trains;
// public void transTrainDetail(List<TrainContentVo.TrainDetail> trainDetails){
// if (CollectionUtil.isEmpty(trainDetails)) {
// return;
// }
// trainDetails.forEach(detail -> {
// switch (detail.getType()) {
// case YanYuanConstant.Train.CONTENT_TYPE_PURPOSE:
// purposes = purposes == null ? new ArrayList<>() : purposes;
// purposes.add(detail);
// break;
// case YanYuanConstant.Train.CONTENT_TYPE_ELEMENT:
// elements = elements == null ? new ArrayList<>() : elements;
// elements.add(detail);
// break;
// case YanYuanConstant.Train.CONTENT_TYPE_PRINCIPLE:
// principles = principles == null ? new ArrayList<>() : principles;
// principles.add(detail);
// break;
// case YanYuanConstant.Train.CONTENT_TYPE_STEP:
// steps = steps == null ? new ArrayList<>() : steps;
// steps.add(detail);
// break;
// }
// });
// }
@ApiModelProperty("工具箱")
private List<TrainContentVo.ScanTool> tools;
}
}

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

@ -26,18 +26,30 @@ public class TrainContentVo {
@ApiModelProperty("题目等级")
private byte level;
}
// @Data
// @ApiModel("训练题目详情和训练情况")
// public static class Detail{
// @ApiModelProperty("补充图片")
// private List<TrainContentVo.Supplementary> supplementaries;
// @ApiModelProperty("其他详情")
// private List<TrainContentVo.TrainDetail> contentDetails;
// @ApiModelProperty("训练情况")
// private List<TrainContentVo.TrainRecord> trains;
// }
@Data
@ApiModel("训练题目详情和训练情况")
public static class Detail{
@ApiModelProperty("补充图片")
private List<TrainContentVo.Supplementary> supplementaries;
@ApiModelProperty("其他详情")
private List<TrainContentVo.TrainDetail> contentDetails;
@ApiModelProperty("训练情况")
private List<TrainContentVo.TrainRecord> trains;
@ApiModel("用户扫描过的工具箱-响应")
public static class ScanTool {
@ApiModelProperty("工具箱ID")
private Long toolId;
@ApiModelProperty("点读笔ID")
private Long equipmentId;
@ApiModelProperty("工具箱编号")
private String toolCode;
@ApiModelProperty("训练计划使用情况 0:未使用 1:使用")
private Byte useStatus;
}
@Data
@ApiModel("训练题目的补充内容")
public static class SupplementaryMessage{

8
src/main/java/com/ccsens/yanyuan/persist/dao/TrainContentDao.java

@ -23,4 +23,12 @@ public interface TrainContentDao extends TrainContentMapper {
* @return 训练计划
*/
TrainContentVo.SupplementaryMessage querySupplementaries(@Param("contentId") Long contentId);
/**
* 查询用户工具及指定测评使用的情况
* @param recordId 训练计划ID
* @param userId 用户ID
* @return 工具箱
*/
List<TrainContentVo.ScanTool> queryUserTool(@Param("recordId") Long recordId, @Param("userId") Long userId);
}

30
src/main/java/com/ccsens/yanyuan/persist/mapper/UserScanToolMapper.java

@ -0,0 +1,30 @@
package com.ccsens.yanyuan.persist.mapper;
import com.ccsens.yanyuan.bean.po.UserScanTool;
import com.ccsens.yanyuan.bean.po.UserScanToolExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UserScanToolMapper {
long countByExample(UserScanToolExample example);
int deleteByExample(UserScanToolExample example);
int deleteByPrimaryKey(Long id);
int insert(UserScanTool record);
int insertSelective(UserScanTool record);
List<UserScanTool> selectByExample(UserScanToolExample example);
UserScanTool selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") UserScanTool record, @Param("example") UserScanToolExample example);
int updateByExample(@Param("record") UserScanTool record, @Param("example") UserScanToolExample example);
int updateByPrimaryKeySelective(UserScanTool record);
int updateByPrimaryKey(UserScanTool record);
}

12
src/main/java/com/ccsens/yanyuan/service/ITrainPlanService.java

@ -2,6 +2,7 @@ package com.ccsens.yanyuan.service;
import com.ccsens.yanyuan.bean.dto.TrainPlanDto;
import com.ccsens.yanyuan.bean.vo.TaskVo;
import com.ccsens.yanyuan.util.YanYuanCodeError;
/**
* @author whj
@ -18,6 +19,15 @@ public interface ITrainPlanService {
/**
* 完善训练计划内容
* @param train 训练计划
* @param userId
*/
void perfectTrain(TaskVo.Train train);
void perfectTrain(TaskVo.Train train, Long userId);
/**
* 选择工具
* @param param 记录ID和工具箱ID
* @param userId 操作人
* @return 成功与否
*/
YanYuanCodeError chooseTool(TrainPlanDto.ChooseTool param, Long userId);
}

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

@ -3,9 +3,9 @@ package com.ccsens.yanyuan.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.ccsens.cloudutil.feign.Tall3FeignClient;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.PropUtil;
import com.ccsens.util.exception.BaseException;
@ -13,10 +13,13 @@ import com.ccsens.wechatutil.bean.dto.WechatCode;
import com.ccsens.wechatutil.wxmini.MiniCodeUtil;
import com.ccsens.yanyuan.bean.dto.ToolDto;
import com.ccsens.yanyuan.bean.po.Tool;
import com.ccsens.yanyuan.bean.po.UserScanTool;
import com.ccsens.yanyuan.bean.po.UserScanToolExample;
import com.ccsens.yanyuan.bean.vo.ToolVo;
import com.ccsens.yanyuan.bean.vo.UserPowerVo;
import com.ccsens.yanyuan.persist.dao.ToolDao;
import com.ccsens.yanyuan.persist.dao.UserRelationDao;
import com.ccsens.yanyuan.persist.mapper.UserScanToolMapper;
import com.ccsens.yanyuan.util.YanYuanCodeError;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -24,15 +27,18 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.File;
import java.util.List;
/**
* @author mz
*/
@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class ToolService implements IToolService {
@Resource
private Snowflake snowflake;
@Resource
private ToolDao toolDao;
@Resource
@ -40,9 +46,7 @@ public class ToolService implements IToolService {
@Resource
private IUserPowerService userPowerService;
@Resource
private Tall3FeignClient tall3FeignClient;
@Resource
private MiniCodeUtil miniCodeUtil;
private UserScanToolMapper userScanToolMapper;
@Override
public ToolVo.BindTool bindTool(ToolDto.BindTool param, String phone, Long userId) {
@ -50,6 +54,9 @@ public class ToolService implements IToolService {
//查询是否已经绑定
Tool tool = toolDao.queryByCode(param.getToolCode());
if (ObjectUtil.isNotNull(tool)) {
// 存储扫描关系表
saveScan(tool.getId(), userId);
// 绑定
if (ObjectUtil.isNotNull(tool.getUserId()) && tool.getUserId() != 0) {
//绑定人是否自己
if (tool.getUserId().equals(userId)) {
@ -73,6 +80,20 @@ public class ToolService implements IToolService {
}
}
private void saveScan(Long toolId, Long userId) {
UserScanToolExample toolExample = new UserScanToolExample();
toolExample.createCriteria().andUserIdEqualTo(userId).andToolIdEqualTo(toolId);
long l = userScanToolMapper.countByExample(toolExample);
if (l > 0) {
return;
}
UserScanTool tool = new UserScanTool();
tool.setId(snowflake.nextId());
tool.setToolId(toolId);
tool.setUserId(userId);
userScanToolMapper.insertSelective(tool);
}
@Override
public ToolVo.QrCode generateQrCode(ToolDto.QrCode param, Long userId) throws Exception {
Tool tool = toolDao.selectByPrimaryKey(param.getId());

18
src/main/java/com/ccsens/yanyuan/service/TrainPlanService.java

@ -4,10 +4,8 @@ import cn.hutool.core.collection.CollectionUtil;
import com.ccsens.yanyuan.bean.dto.TrainPlanDto;
import com.ccsens.yanyuan.bean.vo.TaskVo;
import com.ccsens.yanyuan.bean.vo.TrainContentVo;
import com.ccsens.yanyuan.persist.dao.TrainCardDao;
import com.ccsens.yanyuan.persist.dao.TrainContentDao;
import com.ccsens.yanyuan.persist.dao.TrainRecordDao;
import com.ccsens.yanyuan.persist.dao.TrainResultDao;
import com.ccsens.yanyuan.persist.dao.*;
import com.ccsens.yanyuan.util.YanYuanCodeError;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -39,12 +37,12 @@ public class TrainPlanService implements ITrainPlanService {
@Override
public TaskVo.Train queryDetail(TrainPlanDto.TrainPlanId param, Long userId) {
TaskVo.Train train = trainRecordDao.queryById(param.getRecordId());
perfectTrain(train);
perfectTrain(train, userId);
return train;
}
@Override
public void perfectTrain(TaskVo.Train train) {
public void perfectTrain(TaskVo.Train train, Long userId) {
// 查询题目补充
TrainContentVo.SupplementaryMessage supplementaryMessage = trainContentDao.querySupplementaries(train.getContentId());
if (supplementaryMessage != null) {
@ -59,5 +57,13 @@ public class TrainPlanService implements ITrainPlanService {
details.addAll(cards);
CollectionUtil.sort(details, (o1, o2) -> (int) (o1.getCreatedAt().getTime() - o2.getCreatedAt().getTime()));
train.setTrains(details);
// 查找用户关联的工具箱和使用情况
List<TrainContentVo.ScanTool> tools = trainContentDao.queryUserTool(train.getRecordId(), userId);
train.setTools(tools);
}
@Override
public YanYuanCodeError chooseTool(TrainPlanDto.ChooseTool param, Long userId) {
return null;
}
}

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

@ -6,7 +6,6 @@ import com.ccsens.yanyuan.bean.dto.TaskDto;
import com.ccsens.yanyuan.bean.po.MentalTest;
import com.ccsens.yanyuan.bean.po.MentalTestExample;
import com.ccsens.yanyuan.bean.vo.TaskVo;
import com.ccsens.yanyuan.bean.vo.TrainContentVo;
import com.ccsens.yanyuan.persist.dao.*;
import com.ccsens.yanyuan.util.YanYuanConstant;
import lombok.extern.slf4j.Slf4j;
@ -83,7 +82,7 @@ public class YTaskService implements IYTaskService {
List<TaskVo.QueryTask> queryTaskList = new ArrayList<>();
String templateCode = param.getTemplateCode();
if (YanYuanConstant.Project.TEMPLATE_USER.equals(templateCode)) {
queryTaskList.addAll(queryUserTask(param));
queryTaskList.addAll(queryUserTask(param, userId));
} else if (YanYuanConstant.Project.TEMPLATE_ADMIN.equals(templateCode)) {
}
@ -93,9 +92,10 @@ public class YTaskService implements IYTaskService {
/**
* 查询用户的训练任务最大请求数不能超过10个
* @param param 请求参数
* @param userId
* @return 任务列表
*/
private List<TaskVo.QueryTask> queryUserTask(TaskDto.QueryRegularTask param) {
private List<TaskVo.QueryTask> queryUserTask(TaskDto.QueryRegularTask param, Long userId) {
List<TaskVo.QueryTask> tasks = new ArrayList<>();
List<MentalTest> mentalTests = getMentalTests(param);
log.info("脑力测评:{}" , mentalTests);
@ -106,18 +106,24 @@ public class YTaskService implements IYTaskService {
if (queryType == YanYuanConstant.Task.DIRECTION_PRE) {
// 向上翻页
for (int i = mentalTests.size() - 1; i >= 0 ; i--) {
tasks.addAll(initMentalTask(mentalTests.get(i)));
tasks.addAll(initMentalTask(mentalTests.get(i), userId));
}
} else {
// 向下翻页
mentalTests.forEach(mentalTest -> {
tasks.addAll(initMentalTask(mentalTest));
tasks.addAll(initMentalTask(mentalTest, userId));
});
}
return tasks;
}
private List<TaskVo.QueryTask> initMentalTask(MentalTest mentalTest) {
/**
* 初始化脑力测评任务和训练计划任务
* @param mentalTest 脑力测评
* @param userId 用户ID
* @return 一周期任务
*/
private List<TaskVo.QueryTask> initMentalTask(MentalTest mentalTest, Long userId) {
List<TaskVo.QueryTask> tasks = new ArrayList<>();
// 添加脑力测评任务
TaskVo.QueryTask mentalTask = new TaskVo.QueryTask(mentalTest);
@ -141,7 +147,7 @@ public class YTaskService implements IYTaskService {
continue;
}
hasShow = true;
trainPlanService.perfectTrain(train);
trainPlanService.perfectTrain(train, userId);
tasks.add(trainTask);
}
return tasks;

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

@ -48,4 +48,24 @@
where c.id = #{contentId} and c.rec_status = 0
order by ci.sort, d.id, di.sort
</select>
<select id="queryUserTool" resultType="com.ccsens.yanyuan.bean.vo.TrainContentVo$ScanTool">
SELECT
t.id AS toolId,
t.`code` AS toolCode,
e.id AS equipmentId,
IF( te.id IS NULL, 0, 1 ) AS useStatus
FROM
u_user_scan_tool st
LEFT JOIN t_tool t ON st.tool_id = t.id
LEFT JOIN t_tool_equipment e ON t.id = e.tool_id
LEFT JOIN u_train_equipment te ON e.id = te.equipment_id
AND te.record_id = #{recordId}
AND te.rec_status = 0
WHERE
st.user_id = #{userId}
AND st.rec_status = 0
AND t.rec_status = 0
AND e.rec_status = 0
GROUP BY t.id
</select>
</mapper>

228
src/main/resources/mapper_raw/UserScanToolMapper.xml

@ -0,0 +1,228 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccsens.yanyuan.persist.mapper.UserScanToolMapper">
<resultMap id="BaseResultMap" type="com.ccsens.yanyuan.bean.po.UserScanTool">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="tool_id" jdbcType="BIGINT" property="toolId" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, user_id, tool_id, created_at, updated_at, rec_status
</sql>
<select id="selectByExample" parameterType="com.ccsens.yanyuan.bean.po.UserScanToolExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from u_user_scan_tool
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from u_user_scan_tool
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from u_user_scan_tool
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.ccsens.yanyuan.bean.po.UserScanToolExample">
delete from u_user_scan_tool
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.ccsens.yanyuan.bean.po.UserScanTool">
insert into u_user_scan_tool (id, user_id, tool_id,
created_at, updated_at, rec_status
)
values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{toolId,jdbcType=BIGINT},
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}
)
</insert>
<insert id="insertSelective" parameterType="com.ccsens.yanyuan.bean.po.UserScanTool">
insert into u_user_scan_tool
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="toolId != null">
tool_id,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="recStatus != null">
rec_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="toolId != null">
#{toolId,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
#{recStatus,jdbcType=TINYINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.ccsens.yanyuan.bean.po.UserScanToolExample" resultType="java.lang.Long">
select count(*) from u_user_scan_tool
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update u_user_scan_tool
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.toolId != null">
tool_id = #{record.toolId,jdbcType=BIGINT},
</if>
<if test="record.createdAt != null">
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
</if>
<if test="record.updatedAt != null">
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="record.recStatus != null">
rec_status = #{record.recStatus,jdbcType=TINYINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update u_user_scan_tool
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
tool_id = #{record.toolId,jdbcType=BIGINT},
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
rec_status = #{record.recStatus,jdbcType=TINYINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.yanyuan.bean.po.UserScanTool">
update u_user_scan_tool
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="toolId != null">
tool_id = #{toolId,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
rec_status = #{recStatus,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.yanyuan.bean.po.UserScanTool">
update u_user_scan_tool
set user_id = #{userId,jdbcType=BIGINT},
tool_id = #{toolId,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
rec_status = #{recStatus,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

2
src/main/resources/mbg.xml

@ -55,7 +55,7 @@
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<table tableName="t_tool_equipment" domainObjectName="ToolEquipment"></table>
<table tableName="u_user_scan_tool" domainObjectName="UserScanTool"></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