mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 09:56:47 +08:00
整理用户的工程
This commit is contained in:
@@ -28,7 +28,7 @@ public class StartRunner implements ApplicationRunner {
|
||||
//用于存放 kid=newId
|
||||
try {
|
||||
//本地 971783273423056896,971783831047385088
|
||||
service.modifyCourseExamScore("971783273423056896","971783831047385088");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("执行失败",e);
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -6,18 +6,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/modify")
|
||||
@RequestMapping("/modify/user")
|
||||
public class ModifyApi {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新系统查出用户 并根据老库 更新sys_depart_id,commany_id
|
||||
* 单独的更新一个用户的接口
|
||||
* */
|
||||
@GetMapping("/save-user")
|
||||
public JsonResponse<Boolean> saveUser(){
|
||||
@GetMapping("/byid")
|
||||
public JsonResponse<Boolean> modifyUser(String id){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.StudyExam;
|
||||
import com.xboe.basic.entity.Account;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
@Repository
|
||||
public class StudyExamDao extends BaseDao<StudyExam>{
|
||||
public class AccountDao extends BaseDao<Account>{
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.StudyCourseItem;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
/**
|
||||
* 老系统的机构
|
||||
* */
|
||||
@Repository
|
||||
public class StudyCourseItemDao extends BaseDao<StudyCourseItem> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.Teacher;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
@Repository
|
||||
public class TeacherDao extends BaseDao<Teacher>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.basic.entity.User;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
|
||||
@Repository
|
||||
public class UserDao extends BaseDao<User>{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
import com.xboe.core.orm.annotation.MetaInfo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 账号表,只是记录登录的账号信息,无任务业务实名类的信息
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "account")
|
||||
public class Account extends IdEntity{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**0 临时数据*/
|
||||
public static final int STATUS_TEMPORARY=0;
|
||||
|
||||
/**1 正常数据*/
|
||||
public static final int STATUS_NORMAL=1;
|
||||
|
||||
/**2 停用数据*/
|
||||
public static final int STATUS_DEAD=2;
|
||||
|
||||
@MetaInfo("原系统中的id")
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
@MetaInfo("登录名")
|
||||
@Column(name = "login_name", nullable = true, length = 30)
|
||||
private String loginName;
|
||||
|
||||
@MetaInfo("用户头像地址")
|
||||
@Column(name = "avatar", nullable = true, length = 100)
|
||||
private String avatar;
|
||||
|
||||
@MetaInfo("手机号")
|
||||
@Column(name = "mobile", length = 11)
|
||||
private String mobile;
|
||||
|
||||
// 状态1, 正常,2停用
|
||||
@Column(name = "status", length = 1)
|
||||
private Integer status;
|
||||
|
||||
@Column(name = "deleted", length = 1)
|
||||
private Boolean deleted;
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/*
|
||||
* 课程学习记录表,相当于课程学习表的子表
|
||||
* */
|
||||
@Data
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = SysConstant.TABLE_PRE+"study_course_item")
|
||||
public class StudyCourseItem extends IdEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final int STATUS_NONE=1;
|
||||
|
||||
public static final int STATUS_STUDYING=2;
|
||||
|
||||
public static final int STATUS_FINISH=9;
|
||||
|
||||
/*
|
||||
* 学习id
|
||||
* */
|
||||
@Column(name = "study_id",nullable=false,length = 20)
|
||||
private String studyId;
|
||||
|
||||
/*
|
||||
* 课程id
|
||||
* */
|
||||
@Column(name = "course_id",nullable=false,length = 20)
|
||||
private String courseId;
|
||||
|
||||
/*
|
||||
* 课程内容id
|
||||
* */
|
||||
@Column(name = "content_id",nullable=true,length=20)
|
||||
private String contentId;
|
||||
|
||||
/**
|
||||
* 内容类型,用于查询
|
||||
*/
|
||||
@Column(name = "content_type",length=2)
|
||||
private Integer contentType;
|
||||
|
||||
/**
|
||||
* 账号id,记录学习人
|
||||
*/
|
||||
@Column(name = "aid",nullable=true,length=20)
|
||||
private String aid;
|
||||
|
||||
/**
|
||||
* 学习人姓名
|
||||
*/
|
||||
@Column(name = "aname",nullable=true,length=30)
|
||||
private String aname;
|
||||
|
||||
/**
|
||||
* 内容学习的最终得分
|
||||
*/
|
||||
@Column(name = "score",nullable=true)
|
||||
private Float score;
|
||||
|
||||
/*
|
||||
* 学习进度
|
||||
* */
|
||||
@Column(name = "progress")
|
||||
private Integer progress;
|
||||
|
||||
/**
|
||||
* 学习状态,当前未使用 ,以学习进度100来定义是否已学完
|
||||
* 1表未学习,2表学习中,9表学习完成
|
||||
*/
|
||||
@Column(name = "status",length=1)
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/*
|
||||
* 课程考试提交记录表,此表是课程考试的记录
|
||||
* */
|
||||
@Data
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = SysConstant.TABLE_PRE+"study_exam")
|
||||
public class StudyExam extends IdEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* 学习id
|
||||
* */
|
||||
@Column(name = "study_id",nullable=false,length = 20)
|
||||
private String studyId;
|
||||
|
||||
/**
|
||||
* 内容学习记录id
|
||||
*/
|
||||
@Column(name = "study_item_id",nullable=false,length = 20)
|
||||
private String studyItemId;
|
||||
|
||||
/*
|
||||
* 课程id
|
||||
* */
|
||||
@Column(name = "course_id",nullable=false,length = 20)
|
||||
private String courseId;
|
||||
|
||||
/*
|
||||
* 内容id
|
||||
* */
|
||||
@Column(name = "content_id",nullable=false,length = 20)
|
||||
private String contentId;
|
||||
|
||||
|
||||
/*
|
||||
* 学员id
|
||||
* */
|
||||
@Column(name = "student_id",nullable=false,length = 20)
|
||||
private String studentId;
|
||||
|
||||
/*
|
||||
* 学员name
|
||||
* */
|
||||
@Column(name = "student_name",length = 30)
|
||||
private String studentName;
|
||||
|
||||
|
||||
/*
|
||||
* 对应课程考试的id
|
||||
* */
|
||||
@Column(name = "test_id",nullable=false,length = 20)
|
||||
private String testId;
|
||||
|
||||
/*
|
||||
* 试卷内容
|
||||
* */
|
||||
@Column(name = "paper_json",columnDefinition = "text")
|
||||
private String paperJson;
|
||||
|
||||
/**本次得分 */
|
||||
@Column(name = "score" ,nullable=false)
|
||||
private Float score;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "teacher")
|
||||
public class Teacher extends IdEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 系统id
|
||||
*/
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
|
||||
/**
|
||||
* 在职状态 在职: 0 离职: 1
|
||||
*/
|
||||
@Column(name = "wait_status")
|
||||
private Integer waitStatus;
|
||||
|
||||
|
||||
/**状态,0表临时, 1表启用,2表停用的*/
|
||||
@Column(name = "status",length = 1)
|
||||
private Integer status;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 用户信息表
|
||||
* 存储所有的用户信息,原表中的部分信息
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "user")
|
||||
public class User extends IdEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 旧系统id
|
||||
*/
|
||||
@Column(name = "sys_id", length = 36)
|
||||
private String sysId;
|
||||
|
||||
/**
|
||||
* 旧系统机构id
|
||||
*/
|
||||
@Column(name = "sys_depart_id", length = 36)
|
||||
private String sysDepartId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@Column(name = "name", length = 30)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 员工编号
|
||||
*/
|
||||
@Column(name = "user_no", length = 30)
|
||||
private String userNo;
|
||||
|
||||
/**
|
||||
* 用户类型,1表学员,2表教师,3表管理员
|
||||
* 该字段暂用于表示是否前台管理员
|
||||
*/
|
||||
@Column(name = "user_type", length = 1)
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 学习总时长
|
||||
*/
|
||||
@Column(name = "study_total", length = 11)
|
||||
private Integer studyTotal;
|
||||
|
||||
/**
|
||||
* boe的时长,和系统时长单独保存
|
||||
*/
|
||||
@Column(name = "learning_Duration", length = 11)
|
||||
private Integer learningDuration;
|
||||
|
||||
/**
|
||||
* 最近一次登录时间
|
||||
*/
|
||||
@Column(name = "last_login_at")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastLoginAt;
|
||||
|
||||
}
|
||||
@@ -2,5 +2,5 @@ package com.xboe.basic.service;
|
||||
|
||||
public interface IModifyService {
|
||||
|
||||
void modifyCourseExamScore(String courseId,String testId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +1,8 @@
|
||||
package com.xboe.basic.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.type.CollectionType;
|
||||
import com.xboe.basic.dao.StudyCourseItemDao;
|
||||
import com.xboe.basic.dao.StudyExamDao;
|
||||
import com.xboe.basic.entity.StudyExam;
|
||||
import com.xboe.basic.service.IModifyService;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,87 +11,6 @@ import com.xboe.core.orm.FieldFilters;
|
||||
@Service
|
||||
public class ModifyServiceImpl implements IModifyService {
|
||||
|
||||
@Autowired
|
||||
StudyExamDao sexameDao;
|
||||
|
||||
@Autowired
|
||||
StudyCourseItemDao scitemDao;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void modifyCourseExamScore(String courseId,String testId) {
|
||||
|
||||
ObjectMapper mapper=new ObjectMapper();
|
||||
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,true);
|
||||
mapper.configure(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT,true);
|
||||
mapper.enable(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
||||
|
||||
//String json="{\"items\":[{\"id\":\"6978553381937754113\",\"type\":102,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"3P付薪理念指?\",\"options\":[{\"id\":\"6978553498178695168\",\"content\":\"为岗位价值付薪\",\"answer\":true,\"checked\":true},{\"id\":\"6978553498178695169\",\"content\":\"为个人差异付薪 \",\"answer\":true,\"checked\":false},{\"id\":\"6978553498178695170\",\"content\":\"为绩效付薪\",\"answer\":true,\"checked\":true},{\"id\":\"6978553498178695171\",\"content\":\"为工龄付薪\",\"answer\":false,\"checked\":false}],\"userAnswer\":[\"6978553498178695168\",\"6978553498178695169\",\"6978553498178695170\"]},{\"id\":\"6978553396823339008\",\"type\":102,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"BOE业绩贡献薪酬主要包含?\",\"options\":[{\"id\":\"6978553618722992128\",\"content\":\"及时激励金\",\"answer\":true,\"checked\":true},{\"id\":\"6978553618722992129\",\"content\":\"绩效奖金\",\"answer\":true,\"checked\":true},{\"id\":\"6978553618722992130\",\"content\":\"年度业绩奖金\",\"answer\":true,\"checked\":true},{\"id\":\"6978553618722992131\",\"content\":\"股权激励计划\",\"answer\":true,\"checked\":true}],\"userAnswer\":[\"6978553618722992128\",\"6978553618722992129\",\"6978553618722992130\",\"6978553618722992131\"]},{\"id\":\"6978553399407030272\",\"type\":102,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"企业年金领取条件?\",\"options\":[{\"id\":\"6978553732237635584\",\"content\":\"达到国家规定的退休年龄\",\"answer\":true,\"checked\":true},{\"id\":\"6978553732241829888\",\"content\":\"出国(境)定居\",\"answer\":true,\"checked\":true},{\"id\":\"6978553732241829889\",\"content\":\"退休前身故\",\"answer\":true,\"checked\":true},{\"id\":\"6978553732241829890\",\"content\":\"经劳动能力鉴定委员会鉴定,因病(残)完全丧失劳动能力\",\"answer\":true,\"checked\":true}],\"userAnswer\":[\"6978553732237635584\",\"6978553732241829888\",\"6978553732241829889\",\"6978553732241829890\"]},{\"id\":\"6978553744212373504\",\"type\":101,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"考勤异常申诉每月最多可申请()次?\",\"options\":[{\"id\":\"6978553808188092416\",\"content\":\"3\",\"answer\":false,\"checked\":false},{\"id\":\"6978553808188092417\",\"content\":\"4\",\"answer\":false,\"checked\":false},{\"id\":\"6978553808188092418\",\"content\":\"5\",\"answer\":true,\"checked\":true},{\"id\":\"6978553808188092419\",\"content\":\"6\",\"answer\":false,\"checked\":false}],\"userAnswer\":\"6978553808188092418\"},{\"id\":\"6978553745848152064\",\"type\":101,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"员工签订劳动合同后办理结婚登记的,在试用期结束后可享受婚假,同时应在办理完结婚登记后()内申请。\",\"options\":[{\"id\":\"6978553896880844800\",\"content\":\"三个月\",\"answer\":false,\"checked\":false},{\"id\":\"6978553896880844801\",\"content\":\"半年\",\"answer\":false,\"checked\":false},{\"id\":\"6978553896880844802\",\"content\":\"一年\",\"answer\":true,\"checked\":true},{\"id\":\"6978553896880844803\",\"content\":\"两年\",\"answer\":false,\"checked\":false}],\"userAnswer\":\"6978553896880844802\"}]}";
|
||||
//String json="{\"items\":[{\"id\":\"6978553381937754113\",\"type\":102,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"3P付薪理念指?\",\"options\":[{\"id\":\"6978553498178695168\",\"content\":\"为岗位价值付薪\",\"answer\":true,\"checked\":true},{\"id\":\"6978553498178695169\",\"content\":\"为个人差异付薪 \",\"answer\":true,\"checked\":false},{\"id\":\"6978553498178695170\",\"content\":\"为绩效付薪\",\"answer\":true,\"checked\":false},{\"id\":\"6978553498178695171\",\"content\":\"为工龄付薪\",\"answer\":false,\"checked\":false}],\"userAnswer\":[\"6978553498178695168\"]},{\"id\":\"6978553396823339008\",\"type\":102,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"BOE业绩贡献薪酬主要包含?\",\"options\":[{\"id\":\"6978553618722992128\",\"content\":\"及时激励金\",\"answer\":true,\"checked\":false},{\"id\":\"6978553618722992129\",\"content\":\"绩效奖金\",\"answer\":true,\"checked\":false},{\"id\":\"6978553618722992130\",\"content\":\"年度业绩奖金\",\"answer\":true,\"checked\":false},{\"id\":\"6978553618722992131\",\"content\":\"股权激励计划\",\"answer\":true,\"checked\":true}],\"userAnswer\":[\"6978553618722992131\"]},{\"id\":\"6978553399407030272\",\"type\":102,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"企业年金领取条件?\",\"options\":[{\"id\":\"6978553732237635584\",\"content\":\"达到国家规定的退休年龄\",\"answer\":true,\"checked\":false},{\"id\":\"6978553732241829888\",\"content\":\"出国(境)定居\",\"answer\":true,\"checked\":false},{\"id\":\"6978553732241829889\",\"content\":\"退休前身故\",\"answer\":true,\"checked\":true},{\"id\":\"6978553732241829890\",\"content\":\"经劳动能力鉴定委员会鉴定,因病(残)完全丧失劳动能力\",\"answer\":true,\"checked\":false}],\"userAnswer\":[\"6978553732241829889\"]},{\"id\":\"6978553744212373504\",\"type\":101,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"考勤异常申诉每月最多可申请()次?\",\"options\":[{\"id\":\"6978553808188092416\",\"content\":\"3\",\"answer\":false,\"checked\":false},{\"id\":\"6978553808188092417\",\"content\":\"4\",\"answer\":false,\"checked\":false},{\"id\":\"6978553808188092418\",\"content\":\"5\",\"answer\":true,\"checked\":true},{\"id\":\"6978553808188092419\",\"content\":\"6\",\"answer\":false,\"checked\":false}],\"userAnswer\":\"6978553808188092418\"},{\"id\":\"6978553745848152064\",\"type\":101,\"score\":20,\"checked\":false,\"optShow\":false,\"content\":\"员工签订劳动合同后办理结婚登记的,在试用期结束后可享受婚假,同时应在办理完结婚登记后()内申请。\",\"options\":[{\"id\":\"6978553896880844800\",\"content\":\"三个月\",\"answer\":false,\"checked\":false},{\"id\":\"6978553896880844801\",\"content\":\"半年\",\"answer\":false,\"checked\":true},{\"id\":\"6978553896880844802\",\"content\":\"一年\",\"answer\":true,\"checked\":false},{\"id\":\"6978553896880844803\",\"content\":\"两年\",\"answer\":false,\"checked\":false}],\"userAnswer\":\"6978553896880844801\"},{\"id\":\"6991356164617457665\",\"type\":103,\"score\":5,\"checked\":false,\"optShow\":false,\"content\":\"是否\",\"options\":[{\"id\":\"6991356327297732608\",\"content\":\"正确\",\"answer\":true,\"checked\":true},{\"id\":\"6991356327297732609\",\"content\":\"错误\",\"answer\":false,\"checked\":false}],\"userAnswer\":\"6991356327297732608\"}]}";
|
||||
//查询出所有的
|
||||
|
||||
//List<StudyExam> list = sexameDao.findList(FieldFilters.eq("courseId", courseId),FieldFilters.eq("testId", testId));
|
||||
List<StudyExam> list = sexameDao.getAll();
|
||||
for(StudyExam se : list) {
|
||||
try {
|
||||
String pageJson=se.getPaperJson();
|
||||
if(StringUtils.isNotBlank(pageJson)) {
|
||||
float total=countTotal(mapper,pageJson);
|
||||
//System.out.println("【"+se.getId()+"】最后的得分="+total);
|
||||
|
||||
//更新分数
|
||||
sexameDao.updateFieldById(se.getId(),"score",total);
|
||||
//scitemDao.updateFieldById(se.getStudyItemId(), "score", total);
|
||||
scitemDao.update("update StudyCourseItem set score=?1 where id=?2 and score<?3",total,se.getStudyItemId(),total);
|
||||
}
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// float total=countTotal(mapper,json);
|
||||
// System.out.println("最后的得分="+total);
|
||||
|
||||
|
||||
//程序自动 退出
|
||||
|
||||
}
|
||||
|
||||
|
||||
private float countTotal(ObjectMapper mapper,String json) throws JsonMappingException, JsonProcessingException{
|
||||
|
||||
JsonNode root = mapper.readTree(json);
|
||||
|
||||
CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, PaperItem.class);
|
||||
|
||||
float total=0;
|
||||
float uscore=0;
|
||||
String jsonItems=root.get("items").toString();
|
||||
//System.out.println(root.get("items").toString());
|
||||
List<PaperItem> items=mapper.readValue(jsonItems, collectionType);
|
||||
|
||||
for(PaperItem item:items) {
|
||||
if(item.getOptions()!=null && !item.getOptions().isEmpty()) {
|
||||
boolean right=true;
|
||||
total+=item.getScore();
|
||||
for(PaperItemOption opt : item.getOptions()) {
|
||||
if(!opt.getChecked() && opt.getAnswer()) {
|
||||
right=false;
|
||||
}
|
||||
}
|
||||
if(right){
|
||||
uscore+=item.getScore();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(total!=100) {
|
||||
//转化为面分制
|
||||
uscore=Math.round(uscore*100/total);
|
||||
}
|
||||
return uscore;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.xboe.basic.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PaperItem {
|
||||
|
||||
private String id;
|
||||
private Integer type;
|
||||
private Integer score;
|
||||
private Boolean checked;
|
||||
private Boolean optShow;
|
||||
private String content;
|
||||
//private String userAnswer;
|
||||
|
||||
private List<PaperItemOption> options;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.xboe.basic.service.impl;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PaperItemOption {
|
||||
|
||||
private String id;
|
||||
private String content;
|
||||
private Boolean answer;
|
||||
private Boolean checked;
|
||||
}
|
||||
Reference in New Issue
Block a user