permission

This commit is contained in:
xzb 2022-10-14 16:33:30 +08:00
parent d9828671c7
commit 7159663aec
11 changed files with 175 additions and 50 deletions

View File

@ -0,0 +1,2 @@
ALTER TABLE `joylink`.`rts_paper_composition`
ADD COLUMN `full_score` int NULL COMMENT '满分' AFTER `pass_score`;

View File

@ -38,15 +38,7 @@ public class PaperCompositionController {
*/
@PutMapping("/basic")
public void updatePaperCompositionProfile(@RequestBody PaperCompositionBasicVo req, @RequestAttribute AccountVO user) {
compositionService.updatePaperCompositionProfile(req, user);
}
/**
* 修改试卷蓝图详细信息
*/
//@PutMapping("/detail")
public void updatePaperCompositionDetail(@RequestBody PaperCompositionDetailVo req, @RequestAttribute AccountVO user) {
compositionService.updatePaperCompositionDetail(req, user);
compositionService.updatePaperCompositionBasic(req, user);
}
/**

View File

@ -50,6 +50,11 @@ public class PaperComposition implements Serializable {
*/
private Integer passScore;
/**
* 满分
*/
private Integer fullScore;
/**
* 创建者id
*/

View File

@ -625,6 +625,66 @@ public class PaperCompositionExample {
return (Criteria) this;
}
public Criteria andFullScoreIsNull() {
addCriterion("full_score is null");
return (Criteria) this;
}
public Criteria andFullScoreIsNotNull() {
addCriterion("full_score is not null");
return (Criteria) this;
}
public Criteria andFullScoreEqualTo(Integer value) {
addCriterion("full_score =", value, "fullScore");
return (Criteria) this;
}
public Criteria andFullScoreNotEqualTo(Integer value) {
addCriterion("full_score <>", value, "fullScore");
return (Criteria) this;
}
public Criteria andFullScoreGreaterThan(Integer value) {
addCriterion("full_score >", value, "fullScore");
return (Criteria) this;
}
public Criteria andFullScoreGreaterThanOrEqualTo(Integer value) {
addCriterion("full_score >=", value, "fullScore");
return (Criteria) this;
}
public Criteria andFullScoreLessThan(Integer value) {
addCriterion("full_score <", value, "fullScore");
return (Criteria) this;
}
public Criteria andFullScoreLessThanOrEqualTo(Integer value) {
addCriterion("full_score <=", value, "fullScore");
return (Criteria) this;
}
public Criteria andFullScoreIn(List<Integer> values) {
addCriterion("full_score in", values, "fullScore");
return (Criteria) this;
}
public Criteria andFullScoreNotIn(List<Integer> values) {
addCriterion("full_score not in", values, "fullScore");
return (Criteria) this;
}
public Criteria andFullScoreBetween(Integer value1, Integer value2) {
addCriterion("full_score between", value1, value2, "fullScore");
return (Criteria) this;
}
public Criteria andFullScoreNotBetween(Integer value1, Integer value2) {
addCriterion("full_score not between", value1, value2, "fullScore");
return (Criteria) this;
}
public Criteria andCreatorIdIsNull() {
addCriterion("creator_id is null");
return (Criteria) this;

View File

@ -27,6 +27,7 @@ public enum PaperExceptionAssert implements BusinessExceptionAssert {
PuqCanSubmit(60019,"用户可以提交试题答案"),
PpValid(60020,"请求参数有效"),
PdValid(60021,"数据有效"),
PcScore(60022,"试卷定义中分数"),
;
int code;

View File

@ -341,7 +341,15 @@ public class DraftMapService implements IDraftMapService {
@Override
public void publish(Long id, DraftMapVO draftMapVO, AccountVO accountVO) {
DraftMapWithBLOBs draftMap = draftMapDAO.selectByPrimaryKey(id);
MapDataVO mapDataVO = new MapDataVO(JsonUtils.read(draftMap.getGraphData(), MapGraphDataNewVO.class), getMapLogicDataNew(id),
//修改地图逻辑数据中调度台的id为null
MapLogicDataNewVO mapLogicDataNewVO = getMapLogicDataNew(id);
if(null!=mapLogicDataNewVO.getDisStationList()){
mapLogicDataNewVO.getDisStationList().forEach(dis->{
dis.setId(null);
dis.setMapId(null);
});
}
MapDataVO mapDataVO = new MapDataVO(JsonUtils.read(draftMap.getGraphData(), MapGraphDataNewVO.class),mapLogicDataNewVO ,
MapCheckConfig.fromJson(draftMap.getCheckConfig()));
mapDataVO.setMap3dDataVO(find3dMapDataByMapId(id));
iMapService.publish(new MapVO(draftMap, draftMapVO.getName(), draftMapVO.getCityCode()), mapDataVO, accountVO);
@ -526,6 +534,7 @@ public class DraftMapService implements IDraftMapService {
if (!CollectionUtils.isEmpty(logicDataVO.getDisStationList())){
logicDataVO.getDisStationList().forEach(mapDisStationVo->{
mapDisStationVo.setMapId(id);
mapDisStationVo.setId(null);
draftMapDisStationService.store(mapDisStationVo);
});
}

View File

@ -37,6 +37,8 @@ public class PaperCompositionService {
private PaperRuleDAO ruleDAO;
@Autowired
private SysAccountDAO sysAccountDAO;
@Autowired
private PaperRuleService paperRuleService;
/**
* 创建试卷蓝图
@ -55,6 +57,7 @@ public class PaperCompositionService {
newPc.setEndTime(req.getEndTime());
newPc.setValidDuration(req.getValidDuration());
newPc.setPassScore(req.getPassScore());
newPc.setFullScore(req.getFullScore());
newPc.setCreateTime(LocalDateTime.now());
newPc.setUpdateTime(LocalDateTime.now());
newPc.setCreatorId(user.getId());
@ -77,7 +80,7 @@ public class PaperCompositionService {
* 修改试卷蓝图基础信息(名称项目简介)
*/
@Transactional(rollbackFor = Exception.class)
public void updatePaperCompositionProfile(PaperCompositionBasicVo req, AccountVO user) {
public void updatePaperCompositionBasic(PaperCompositionBasicVo req, AccountVO user) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(req.getId());
assertPaperCompositionCanModify(curPc);
//
@ -97,26 +100,10 @@ public class PaperCompositionService {
curPc.setEndTime(req.getEndTime());
curPc.setValidDuration(req.getValidDuration());
curPc.setPassScore(req.getPassScore());
curPc.setFullScore(req.getFullScore());
compositionDAO.updateByPrimaryKeySelective(curPc);
}
/**
* 修改试卷蓝图详细信息
*/
@Transactional(rollbackFor = Exception.class)
public void updatePaperCompositionDetail(PaperCompositionDetailVo req, AccountVO user) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(req.getId());
assertPaperCompositionCanModify(curPc);
//
PaperComposition updatePc = new PaperComposition();
updatePc.setId(req.getId());
updatePc.setUpdateTime(LocalDateTime.now());
updatePc.setStartTime(req.getStartTime());
updatePc.setEndTime(req.getEndTime());
updatePc.setValidDuration(req.getValidDuration());
updatePc.setPassScore(req.getPassScore());
//
compositionDAO.updateByPrimaryKeySelective(updatePc);
//校验分值
PaperExceptionAssert.PcScore.assertTrue(paperRuleService.checkRulesScoreLessOrEqualFull(curPc.getId()),"规则总分值大于试卷总分值");
}
/**
@ -131,6 +118,8 @@ public class PaperCompositionService {
nPc.setId(curPc.getId());
nPc.setState(PaperCompositionState.Locked.getValue());
compositionDAO.updateByPrimaryKeySelective(nPc);
// 封存试卷时校验总分值与规则总分值是否相等
PaperExceptionAssert.PcScore.assertTrue(paperRuleService.checkRulesScoreEqualFull(curPc.getId()),"规则总分值不等于试卷总分值");
}
/**
@ -383,4 +372,5 @@ public class PaperCompositionService {
example.createCriteria().andPcIdEqualTo(pcId);
return ruleDAO.selectByExample(example);
}
}

View File

@ -39,39 +39,42 @@ public class PaperRuleService {
//
compositionService.assertPaperCompositionCanModify(rule.getPcId());
}
/**
* 试卷蓝图添加规则
*/
@Transactional(rollbackFor = Exception.class)
public void createPaperCompositionRule(CreatePaperRuleReqVo req, AccountVO user) {
//
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(),req.getType());
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(), req.getType());
//
assertPaperCompositionRuleNotExist(req.getPcId(),req.getSubtype());
assertPaperCompositionRuleNotExist(req.getPcId(), req.getSubtype());
compositionService.assertPaperCompositionCanModify(req.getPcId());
//
PaperRule rule = PaperRuleConvertor.convert(req);
//
ruleDAO.insertSelective(rule);
}
/**
* 断言试卷蓝图某类型的规则不存在
* 断言试卷蓝图某类型的规则不存在
*/
@Transactional(readOnly = true)
private void assertPaperCompositionRuleNotExist(Long pcId, PaperQType.SubType ruleType){
private void assertPaperCompositionRuleNotExist(Long pcId, PaperQType.SubType ruleType) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
PaperRuleExample example = new PaperRuleExample();
example.createCriteria().andPcIdEqualTo(pcId).andSubtypeEqualTo(ruleType.getValue());
List<PaperRule> list = ruleDAO.selectByExample(example);
PaperExceptionAssert.PrNotExisted.assertTrue(CollectionUtils.isEmpty(list),String.format("试卷定义(pcId=%s)的规则(%s)已经存在",pcId,ruleType.name()));
PaperExceptionAssert.PrNotExisted.assertTrue(CollectionUtils.isEmpty(list), String.format("试卷定义(pcId=%s)的规则(%s)已经存在", pcId, ruleType.name()));
}
/**
* 更新(保存)试卷蓝图的规则
*/
@Transactional(rollbackFor = Exception.class)
public void updatePaperCompositionRule(PaperRuleVo req, AccountVO user) {
//
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(),req.getType());
PaperQType.assertPaperSubTypeMatchGroupType(req.getSubtype(), req.getType());
//
assertPaperCompositionRuleCanModify(req.getId());
//
@ -83,11 +86,11 @@ public class PaperRuleService {
findRuleEx.createCriteria().andPcIdEqualTo(req.getPcId()).andTypeEqualTo(req.getType().getValue()).andSubtypeEqualTo(req.getSubtype().getValue());
List<PaperRule> findRuleList = ruleDAO.selectByExample(findRuleEx);
PaperRule rule = PaperRuleConvertor.convert(req);
if(CollectionUtils.isEmpty(findRuleList)){//新类型直接更新
if (CollectionUtils.isEmpty(findRuleList)) {//新类型直接更新
ruleDAO.updateByPrimaryKeySelective(rule);
}else{//类型不变更新
} else {//类型不变更新
PaperRule findRule = findRuleList.get(0);
PaperExceptionAssert.PrNotExisted.assertTrue(updateRule.getId().compareTo(findRule.getId())==0,String.format("试卷定义规则已经存在pcId=%s type=%s subType=%s",req.getPcId(),req.getType().name(),req.getSubtype().name()));
PaperExceptionAssert.PrNotExisted.assertTrue(updateRule.getId().compareTo(findRule.getId()) == 0, String.format("试卷定义规则已经存在pcId=%s type=%s subType=%s", req.getPcId(), req.getType().name(), req.getSubtype().name()));
ruleDAO.updateByPrimaryKeySelective(rule);
}
}
@ -104,15 +107,19 @@ public class PaperRuleService {
//
ruleDAO.deleteByPrimaryKey(ruleId);
}
/**
* 查询试卷蓝图的所有规则
*
* @param pcId 试卷蓝图的id
*/
@Transactional(readOnly = true)
public List<PaperRuleVo> findAllPaperCompositionRule(Long pcId, AccountVO user) {
List<PaperRule> list = findAllByPcId(pcId);
if(CollectionUtils.isEmpty(list)) return new ArrayList<>();
return list.stream().map(pr->{return PaperRuleConvertor.convert(pr);}).collect(Collectors.toList());
List<PaperRule> list = findAllByPcId(pcId);
if (CollectionUtils.isEmpty(list)) return new ArrayList<>();
return list.stream().map(pr -> {
return PaperRuleConvertor.convert(pr);
}).collect(Collectors.toList());
}
@Transactional(readOnly = true)
@ -121,4 +128,38 @@ public class PaperRuleService {
example.createCriteria().andPcIdEqualTo(pcId);
return ruleDAO.selectByExample(example);
}
/**
* 校验规则当前规定的总分值是否小于等于试卷蓝图中的满分
*/
@Transactional(readOnly = true)
public boolean checkRulesScoreLessOrEqualFull(Long pcId) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
PaperExceptionAssert.PcExisted.assertTrue(null != curPc, String.format("试卷定义[id = %s]不存在", pcId));
List<PaperRule> ruleList = findAllByPcId(pcId);
int ruleScore = 0;
if (!CollectionUtils.isEmpty(ruleList)) {
ruleScore = ruleList.stream().mapToInt(rule -> {
return rule.getScore() * rule.getAmount();
}).sum();
}
return ruleScore <= curPc.getFullScore();
}
/**
* 校验规则当前规定的总分值是否等于试卷蓝图中的满分
*/
@Transactional(readOnly = true)
public boolean checkRulesScoreEqualFull(Long pcId) {
PaperComposition curPc = compositionDAO.selectByPrimaryKey(pcId);
PaperExceptionAssert.PcExisted.assertTrue(null != curPc, String.format("试卷定义[id = %s]不存在", pcId));
List<PaperRule> ruleList = findAllByPcId(pcId);
int ruleScore = 0;
if (!CollectionUtils.isEmpty(ruleList)) {
ruleScore = ruleList.stream().mapToInt(rule -> {
return rule.getScore() * rule.getAmount();
}).sum();
}
return ruleScore == curPc.getFullScore();
}
}

View File

@ -41,5 +41,11 @@ public class CreatePaperCompositionReqVo {
/**
* 及格分
*/
@NotNull
private Integer passScore;
/**
* 满分
*/
@NotNull
private Integer fullScore;
}

View File

@ -49,4 +49,8 @@ public class PaperCompositionBasicVo {
* 及格分
*/
private Integer passScore;
/**
* 满分
*/
private Integer fullScore;
}

View File

@ -10,6 +10,7 @@
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
<result column="valid_duration" jdbcType="INTEGER" property="validDuration" />
<result column="pass_score" jdbcType="INTEGER" property="passScore" />
<result column="full_score" jdbcType="INTEGER" property="fullScore" />
<result column="creator_id" jdbcType="BIGINT" property="creatorId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
@ -74,8 +75,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, profile, org_id, start_time, end_time, valid_duration, pass_score, creator_id,
create_time, update_time, `state`
id, `name`, profile, org_id, start_time, end_time, valid_duration, pass_score, full_score,
creator_id, create_time, update_time, `state`
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.paper.PaperCompositionExample" resultMap="BaseResultMap">
select
@ -118,14 +119,14 @@
<insert id="insert" parameterType="club.joylink.rtss.entity.paper.PaperComposition">
insert into rts_paper_composition (id, `name`, profile,
org_id, start_time, end_time,
valid_duration, pass_score, creator_id,
create_time, update_time, `state`
)
valid_duration, pass_score, full_score,
creator_id, create_time, update_time,
`state`)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{profile,jdbcType=VARCHAR},
#{orgId,jdbcType=BIGINT}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
#{validDuration,jdbcType=INTEGER}, #{passScore,jdbcType=INTEGER}, #{creatorId,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{state,jdbcType=INTEGER}
)
#{validDuration,jdbcType=INTEGER}, #{passScore,jdbcType=INTEGER}, #{fullScore,jdbcType=INTEGER},
#{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{state,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.paper.PaperComposition">
insert into rts_paper_composition
@ -154,6 +155,9 @@
<if test="passScore != null">
pass_score,
</if>
<if test="fullScore != null">
full_score,
</if>
<if test="creatorId != null">
creator_id,
</if>
@ -192,6 +196,9 @@
<if test="passScore != null">
#{passScore,jdbcType=INTEGER},
</if>
<if test="fullScore != null">
#{fullScore,jdbcType=INTEGER},
</if>
<if test="creatorId != null">
#{creatorId,jdbcType=BIGINT},
</if>
@ -239,6 +246,9 @@
<if test="record.passScore != null">
pass_score = #{record.passScore,jdbcType=INTEGER},
</if>
<if test="record.fullScore != null">
full_score = #{record.fullScore,jdbcType=INTEGER},
</if>
<if test="record.creatorId != null">
creator_id = #{record.creatorId,jdbcType=BIGINT},
</if>
@ -266,6 +276,7 @@
end_time = #{record.endTime,jdbcType=TIMESTAMP},
valid_duration = #{record.validDuration,jdbcType=INTEGER},
pass_score = #{record.passScore,jdbcType=INTEGER},
full_score = #{record.fullScore,jdbcType=INTEGER},
creator_id = #{record.creatorId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
@ -298,6 +309,9 @@
<if test="passScore != null">
pass_score = #{passScore,jdbcType=INTEGER},
</if>
<if test="fullScore != null">
full_score = #{fullScore,jdbcType=INTEGER},
</if>
<if test="creatorId != null">
creator_id = #{creatorId,jdbcType=BIGINT},
</if>
@ -322,6 +336,7 @@
end_time = #{endTime,jdbcType=TIMESTAMP},
valid_duration = #{validDuration,jdbcType=INTEGER},
pass_score = #{passScore,jdbcType=INTEGER},
full_score = #{fullScore,jdbcType=INTEGER},
creator_id = #{creatorId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},