diff --git a/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java b/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java index 2047f7cb9..c83dcda89 100644 --- a/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java +++ b/src/main/java/club/joylink/rtss/controller/paper/PaperUserController.java @@ -1,9 +1,6 @@ package club.joylink.rtss.controller.paper; -import club.joylink.rtss.services.paper.PaperUserCreateService; -import club.joylink.rtss.services.paper.PaperUserLoadQuestionService; -import club.joylink.rtss.services.paper.PaperUserService; -import club.joylink.rtss.services.paper.PaperUserSubmitAnswerService; +import club.joylink.rtss.services.paper.*; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.paper.*; @@ -26,6 +23,8 @@ public class PaperUserController { private PaperUserLoadQuestionService paperUserLoadQuestionService; @Autowired private PaperUserSubmitAnswerService paperUserSubmitAnswerService; + @Autowired + private PaperUserFindPageService paperUserFindPageService; /** * 根据试卷蓝图生成用户的试卷 @@ -89,11 +88,11 @@ public class PaperUserController { } /** - * 分页查看用户试卷基本信息 + * 分页查询某个试卷蓝图的所有用户试卷基本信息 */ - public PageVO findPageUserByPage(@RequestBody FindPaperUserByPageReqVo req, @RequestAttribute AccountVO user) { - - return null; + @PostMapping("/user/page/composition") + public PageVOfindPaperUserByPage(@RequestBody FindPaperUserForCompositionReqVo req, @RequestAttribute AccountVO user){ + return this.paperUserFindPageService.findPaperUserByPage(req,user); } } diff --git a/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java b/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java index e97da8b0d..4e4231f38 100644 --- a/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java +++ b/src/main/java/club/joylink/rtss/controller/project/ProjectInfoController.java @@ -3,9 +3,10 @@ package club.joylink.rtss.controller.project; import club.joylink.rtss.entity.project.Project; import club.joylink.rtss.entity.project.ProjectView; import club.joylink.rtss.services.project.ProjectService; -import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.project.ProjectQueryVO; import club.joylink.rtss.vo.project.ProjectVO; +import club.joylink.rtss.vo.project.ProjectViewQueryVO; import club.joylink.rtss.vo.project.ProjectViewVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -23,7 +24,7 @@ public class ProjectInfoController { private ProjectService projectService; @GetMapping("/page") - public PageVO pagingQuery(PageQueryVO queryVO) { + public PageVO pagingQuery(ProjectQueryVO queryVO) { return projectService.pagingQuery(queryVO); } @@ -58,7 +59,7 @@ public class ProjectInfoController { } @GetMapping("/viewSetting/page") - public PageVO projectViewPagingQuery(PageQueryVO queryVO) { + public PageVO projectViewPagingQuery(ProjectViewQueryVO queryVO) { return projectService.projectViewPagingQuery(queryVO); } diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserFindPageService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserFindPageService.java new file mode 100644 index 000000000..1eec417ff --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserFindPageService.java @@ -0,0 +1,78 @@ +package club.joylink.rtss.services.paper; + +import club.joylink.rtss.dao.paper.PaperCompositionDAO; +import club.joylink.rtss.dao.paper.PaperUserDAO; +import club.joylink.rtss.entity.paper.PaperComposition; +import club.joylink.rtss.entity.paper.PaperUser; +import club.joylink.rtss.entity.paper.PaperUserExample; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.vo.AccountVO; +import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.paper.FindPaperUserForCompositionReqVo; +import club.joylink.rtss.vo.paper.PaperUserInfoVo; +import club.joylink.rtss.vo.paper.convertor.PaperUserConvertor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * 用户试卷分页查询业务实现 + */ +@Service +public class PaperUserFindPageService { + @Autowired + private PaperCompositionDAO paperCompositionDAO; + @Autowired + private PaperUserDAO paperUserDAO; + + /** + * 分页查询某个试卷蓝图的所有用户试卷基本信息 + */ + public PageVO findPaperUserByPage(FindPaperUserForCompositionReqVo req, AccountVO user) { + PageVO page = new PageVO<>(); + // + PaperComposition pc = paperCompositionDAO.selectByPrimaryKey(req.getPcId()); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(pc); + PaperUserExample example = new PaperUserExample(); + PaperUserExample.Criteria c = example.createCriteria().andPcIdEqualTo(req.getPcId()); + switch (req.getFindType()){ + case Pass:c.andScoreIsNotNull().andScoreGreaterThanOrEqualTo(pc.getPassScore());break; + case NotPass:c.andScoreIsNotNull().andScoreLessThan(pc.getPassScore());break; + case NotComplete:c.andScoreIsNull();break; + case Complete:c.andScoreIsNotNull();break; + case All:break; + } + long sum = paperUserDAO.countByExample(example); + page.setTotal(sum); + page.setPageNum(req.getPageNum()); + page.setPageSize(req.getPageSize()); + page.setList(new ArrayList<>()); + if (sum > 0) { + // + String orderBy = req.getOrderBy().with(); + long startIndex = (req.getPageNum() - 1) * req.getPageSize(); + // + if (req.getDesc()) { + example.setOrderByClause(String.format("%s desc limit %s,%s", orderBy, startIndex, req.getPageSize())); + } else { + example.setOrderByClause(String.format("%s limit %s,%s", orderBy, startIndex, req.getPageSize())); + } + List pContent = this.paperUserDAO.selectByExample(example); + if (null != pContent) { + pContent.forEach(t -> { + PaperUserInfoVo pi = new PaperUserInfoVo(); + pi.setPcId(pc.getId()); + pi.setName(pc.getName()); + pi.setProfile(pc.getProfile()); + pi.setCompanyId(pc.getCompanyId()); + pi.setPaper(PaperUserConvertor.convert(t)); + page.getList().add(pi); + }); + } + } + // + return page; + } +} diff --git a/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java b/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java index bb0dfbaaf..b6db61cc5 100644 --- a/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java +++ b/src/main/java/club/joylink/rtss/services/paper/PaperUserSubmitAnswerService.java @@ -64,7 +64,6 @@ public class PaperUserSubmitAnswerService { break; case Training: rsp.setResult(submitTrainingAnswer(puq, req)); - ; break; } //记录用户答题情况 diff --git a/src/main/java/club/joylink/rtss/services/project/ProjectService.java b/src/main/java/club/joylink/rtss/services/project/ProjectService.java index ea92c7337..333a1ccab 100644 --- a/src/main/java/club/joylink/rtss/services/project/ProjectService.java +++ b/src/main/java/club/joylink/rtss/services/project/ProjectService.java @@ -2,9 +2,10 @@ package club.joylink.rtss.services.project; import club.joylink.rtss.entity.project.Project; import club.joylink.rtss.entity.project.ProjectView; -import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.project.ProjectQueryVO; import club.joylink.rtss.vo.project.ProjectVO; +import club.joylink.rtss.vo.project.ProjectViewQueryVO; import club.joylink.rtss.vo.project.ProjectViewVO; import java.util.List; @@ -17,7 +18,7 @@ public interface ProjectService { /** * 分页 */ - PageVO pagingQuery(PageQueryVO queryVO); + PageVO pagingQuery(ProjectQueryVO queryVO); /** * 列表 @@ -52,7 +53,7 @@ public interface ProjectService { /** * 前端设置信息分页 */ - PageVO projectViewPagingQuery(PageQueryVO queryVO); + PageVO projectViewPagingQuery(ProjectViewQueryVO queryVO); /** * 获取所有的前端配置 diff --git a/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java b/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java index 6a549ae85..284742bc3 100644 --- a/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/project/ProjectServiceImpl.java @@ -8,9 +8,10 @@ import club.joylink.rtss.entity.project.ProjectView; import club.joylink.rtss.entity.project.ProjectViewExample; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; +import club.joylink.rtss.vo.project.ProjectQueryVO; import club.joylink.rtss.vo.project.ProjectVO; +import club.joylink.rtss.vo.project.ProjectViewQueryVO; import club.joylink.rtss.vo.project.ProjectViewVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; @@ -40,10 +41,16 @@ public class ProjectServiceImpl implements ProjectService { private ProjectViewDAO projectViewDAO; @Override - public PageVO pagingQuery(PageQueryVO queryVO) { + public PageVO pagingQuery(ProjectQueryVO queryVO) { PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); ProjectExample projectExample = new ProjectExample(); - projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS); + ProjectExample.Criteria criteria = projectExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS); + if (!StringUtils.isEmpty(queryVO.getCode())) { + criteria.andCodeEqualTo(queryVO.getCode()); + } + if (!StringUtils.isEmpty(queryVO.getName())) { + criteria.andNameLike(queryVO.getName()); + } Page page = (Page) projectDAO.selectWithBLOBsByExample(projectExample); return PageVO.convert(page, page.getResult()); } @@ -113,10 +120,16 @@ public class ProjectServiceImpl implements ProjectService { } @Override - public PageVO projectViewPagingQuery(PageQueryVO queryVO) { + public PageVO projectViewPagingQuery(ProjectViewQueryVO queryVO) { PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); ProjectViewExample projectViewExample = new ProjectViewExample(); - projectViewExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS); + ProjectViewExample.Criteria criteria = projectViewExample.createCriteria().andStatusEqualTo(EFFECT_PROJECT_STATUS); + if (!StringUtils.isEmpty(queryVO.getProject())) { + criteria.andProjectEqualTo(queryVO.getProject()); + } + if (!StringUtils.isEmpty(queryVO.getMarkKey())) { + criteria.andMarkKeyEqualTo(queryVO.getMarkKey()); + } Page page = (Page) projectViewDAO.selectWithBLOBsByExample(projectViewExample); return PageVO.convert(page, page.getResult()); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/data/DisCmdDb.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/data/DisCmdDb.java index daf70b723..aca14c932 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/data/DisCmdDb.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/data/DisCmdDb.java @@ -149,13 +149,12 @@ public class DisCmdDb { locker.unlock(); } } - + //当receiptState为AllSigned时member为null private DisCmdReceipt createReceipt(DisCmdReceipt.Status receiptState, DisCmd cmd, DisCmdCompany cp, SimulationMember member) { DisCmdReceipt r = new DisCmdReceipt(); r.setId(this.getCmdReceiptId()); // DisCmdCompany sendCp = cmd.getSendCompany(); - MapElement memDev = member.getDevice(); // DisCmdCompanyState state = this.cmdStateMap.get(cp.getId()); r.setState(receiptState); @@ -174,7 +173,7 @@ public class DisCmdDb { case AllSigned:break; case TrainSrmSent: case TrainSrmReceived:r.setSrmStationCode(cp.getTransStationCode());break; - case Signed:r.setRcCpCode(memDev.getCode()); + case Signed:r.setRcCpCode(member.getDevice().getCode()); case ProxySigned:r.setSignedBy(member.getName());break; case Rejected:r.setRejectBy(member.getName());break; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/service/DisCmdFindService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/service/DisCmdFindService.java index c0b637c73..62a96fb2c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/service/DisCmdFindService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/service/DisCmdFindService.java @@ -33,6 +33,7 @@ public class DisCmdFindService { db.lock(); //迭代所有调令 db.getUnSafeCmdMap().values().forEach(cmd->{ + //迭代调令的所有单位 cmd.companies().forEach(cp->{ if(cp.getCpType().equals(holderType)){ @@ -41,6 +42,12 @@ public class DisCmdFindService { rsp.addDisCmd(cmd.copy()); rsp.addCompany(cp.copy()); rsp.addCompanyState(db.getUnSafeCmdStateMap().get(cp.getId()).copy()); + if(!cp.getRsCompany()){//发令单位 + cmd.getRcvCompanies().forEach(rcp->{ + rsp.addCompany(rcp.copy()); + rsp.addCompanyState(db.getUnSafeCmdStateMap().get(rcp.getId()).copy()); + }); + } } } }); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/service/DisCmdSendService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/service/DisCmdSendService.java index 124a00fc8..ba6a2fae9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/service/DisCmdSendService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/rail/dcmd/service/DisCmdSendService.java @@ -68,8 +68,8 @@ public class DisCmdSendService { // cmd.getRcvCompanies().forEach(rc -> { this.doSend(simulation, db, cmd, rc, sender); - this.pushDisCmdToClient(simulation, db, cmd, rc); }); + this.pushDisCmdToClient(simulation, db, cmd); } finally { db.unlock(); } @@ -128,12 +128,12 @@ public class DisCmdSendService { /** * 推送调令到前端客户端 */ - private void pushDisCmdToClient(Simulation simulation, DisCmdDb db, DisCmd cmd, DisCmdCompany to) { + private void pushDisCmdToClient(Simulation simulation, DisCmdDb db, DisCmd cmd) { //获取客户端未读的受令推送 cmd.getRcvCompanies().forEach(rc -> { DisCmdCompanyState rcState = db.getUnSafeCmdStateMap().get(rc.getId()); if (DisCmdCompanyState.Status.Sent.equals(rcState.getState())) {//已发送但未读 - this.sendDisCmdMessage(simulation, db, cmd, to); + this.sendDisCmdMessage(simulation, db, cmd, rc); } }); } diff --git a/src/main/java/club/joylink/rtss/vo/paper/FindPaperUserByPageReqVo.java b/src/main/java/club/joylink/rtss/vo/paper/FindPaperUserByPageReqVo.java index 3a3f895e5..bf8ffa218 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/FindPaperUserByPageReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/FindPaperUserByPageReqVo.java @@ -1,13 +1,29 @@ package club.joylink.rtss.vo.paper; import club.joylink.rtss.vo.client.PageQueryVO; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import javax.validation.constraints.NotNull; + +/** + * 分页查询用户试卷请求 + */ @Getter @Setter @NoArgsConstructor public class FindPaperUserByPageReqVo extends PageQueryVO { + /** + * 试卷蓝图id + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long pcId; + /** + * 组织id + */ + private String companyId; } diff --git a/src/main/java/club/joylink/rtss/vo/paper/FindPaperUserForCompositionReqVo.java b/src/main/java/club/joylink/rtss/vo/paper/FindPaperUserForCompositionReqVo.java new file mode 100644 index 000000000..1a0eab58e --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/paper/FindPaperUserForCompositionReqVo.java @@ -0,0 +1,117 @@ +package club.joylink.rtss.vo.paper; + +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.PageQueryVO; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import javax.validation.constraints.NotNull; +import java.util.HashMap; +import java.util.Map; + +/** + * 根据试卷蓝图分页查询相关用户试卷 + */ +@Getter +@Setter +@NoArgsConstructor +public class FindPaperUserForCompositionReqVo extends PageQueryVO { + + /** + * 试卷蓝图id + */ + @JsonSerialize(using = ToStringSerializer.class) + @NotNull + private Long pcId; + /** + * 查询类型,默认所有 + */ + private FindType findType = FindType.All; + /** + * 以什么来排序,默认以用户试卷创建时间 + */ + private OrderByType orderBy = OrderByType.CreateTime; + /** + * 是否降序,true-降序,false-升序,默认值为true; + */ + private Boolean desc = true; + + /////////////////////////////////////////////////////////////////// + public enum OrderByType { + CreateTime(1, "create_time"),//用户试卷创建时间 + StartTime(2, "start_time"),//用户开始答题时间 + Score(3, "score"),//用户最终得分 + ; + private Integer value; + private String orderBy; + + private OrderByType(Integer value, String type) { + this.value = value; + this.orderBy = type; + } + + public String with() { + return this.orderBy; + } + + @JsonCreator + public static OrderByType getItem(Integer value) { + return map.get(value); + } + + @JsonValue + public Integer getValue() { + return this.value; + } + + //////////////////////////////////////////////////////////////// + private static Map map = new HashMap<>(); + + static { + for (OrderByType t : values()) { + map.put(t.value, t); + } + } + } + + /** + * 查询类型枚举 + */ + public enum FindType { + All(1),//所有 + Pass(2),//所有及格的 + NotPass(3),//所有不及格的 + NotComplete(4),//未完成考试 + Complete(5),//完成考试,即及格和不及格的 + ; + private Integer value; + + private FindType(Integer value) { + this.value = value; + } + + @JsonCreator + public static FindType getItem(Integer value) { + return map.get(value); + } + + @JsonValue + public Integer getValue() { + return this.value; + } + + //////////////////////////////////////////////////////////////// + private static Map map = new HashMap<>(); + + static { + for (FindType t : values()) { + map.put(t.value, t); + } + } + } +} diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionVo.java index 0e9309662..f0a0148de 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperCompositionVo.java @@ -28,7 +28,7 @@ public class PaperCompositionVo { private String profile; /** - * 项目code + * 组织id */ private String companyId; diff --git a/src/main/java/club/joylink/rtss/vo/paper/PaperUserInfoVo.java b/src/main/java/club/joylink/rtss/vo/paper/PaperUserInfoVo.java index 8524784ac..75d9fb824 100644 --- a/src/main/java/club/joylink/rtss/vo/paper/PaperUserInfoVo.java +++ b/src/main/java/club/joylink/rtss/vo/paper/PaperUserInfoVo.java @@ -7,4 +7,27 @@ import lombok.Data; */ @Data public class PaperUserInfoVo { + /** + * 试卷蓝图id + */ + private Long pcId; + + /** + * 试卷蓝图名称 + */ + private String name; + + /** + * 试卷蓝图简介 + */ + private String profile; + + /** + * 组织id + */ + private String companyId; + /** + * 试卷 + */ + private PaperUserVo paper; } diff --git a/src/main/java/club/joylink/rtss/vo/project/ProjectQueryVO.java b/src/main/java/club/joylink/rtss/vo/project/ProjectQueryVO.java new file mode 100644 index 000000000..707d19a10 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/project/ProjectQueryVO.java @@ -0,0 +1,21 @@ +package club.joylink.rtss.vo.project; + +import club.joylink.rtss.vo.client.PageQueryVO; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class ProjectQueryVO extends PageQueryVO { + /** + * 项目编码,后端使用 + */ + private String code; + + /** + * 项目名称 + */ + private String name; +} diff --git a/src/main/java/club/joylink/rtss/vo/project/ProjectViewQueryVO.java b/src/main/java/club/joylink/rtss/vo/project/ProjectViewQueryVO.java new file mode 100644 index 000000000..0fa9514b8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/project/ProjectViewQueryVO.java @@ -0,0 +1,18 @@ +package club.joylink.rtss.vo.project; + +import club.joylink.rtss.vo.client.PageQueryVO; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Setter +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class ProjectViewQueryVO extends PageQueryVO { + + private String markKey; + + private String project; +}