ycl-common/src/main/java/constant/CheckConstants.java
@@ -11,8 +11,17 @@ //人脸规则 public static final Short Rule_Category_Face = 3; //省厅 public static final Short Examine_Tag_City = 0; //区县 public static final Short Examine_Tag_County = 1; public static final String Delete = "1"; //乘 public static final String Multiply = "*"; //除 public static final String Divided = "/"; public static final String Status_Use = "0"; public static final String Status_Stop = "1"; ycl-pojo/src/main/java/com/ycl/platform/base/CheckIndex.java
@@ -4,11 +4,14 @@ import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; import java.util.List; public abstract class CheckIndex { public Long id; //查询条件,日期 //查询条件,月份 public String date; //查询条件,日期 public String day; @Excel(name = "日期",dateFormat = "yyyy-MM-dd") public Date createTime; @@ -19,9 +22,9 @@ /** 考核标签(省厅/市局) */ @Excel(name = "考核标签", dictType = "platform_examine_tag") public Long examineTag; public Short examineTag; public List<Integer> deptIds; public Long getId() { return id; } @@ -62,11 +65,28 @@ this.deptName = deptName; } public Long getExamineTag() { public Short getExamineTag() { return examineTag; } public void setExamineTag(Long examineTag) { public void setExamineTag(Short examineTag) { this.examineTag = examineTag; } public List<Integer> getDeptIds() { return deptIds; } public String getDay() { return day; } public void setDay(String day) { this.day = day; } public void setDeptIds(List<Integer> deptIds) { this.deptIds = deptIds; } } ycl-pojo/src/main/java/com/ycl/platform/domain/dto/CheckScoreIndexDTO.java
@@ -1,9 +1,10 @@ package com.ycl.platform.domain.dto; import com.ycl.system.entity.BaseEntity; import lombok.Data; @Data public class CheckScoreIndexDTO { public class CheckScoreIndexDTO extends BaseEntity { private Long id; private String date; } ycl-pojo/src/main/java/com/ycl/platform/domain/dto/ScoreIndexDTO.java
New file @@ -0,0 +1,13 @@ package com.ycl.platform.domain.dto; import com.ycl.system.entity.BaseEntity; import lombok.Data; import lombok.experimental.Accessors; @Data @Accessors(chain = true) public class ScoreIndexDTO extends BaseEntity { private String tableName; private Long deptId; private String date; } ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckIndexCar.java
@@ -109,12 +109,12 @@ } @Override public Long getExamineTag() { public Short getExamineTag() { return super.getExamineTag(); } @Override public void setExamineTag(Long examineTag) { public void setExamineTag(Short examineTag) { super.setExamineTag(examineTag); } public void setViewConnectStability(BigDecimal viewConnectStability) ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckIndexFace.java
@@ -167,12 +167,12 @@ } @Override public Long getExamineTag() { public Short getExamineTag() { return super.getExamineTag(); } @Override public void setExamineTag(Long examineTag) { public void setExamineTag(Short examineTag) { super.setExamineTag(examineTag); } ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckIndexVideo.java
@@ -96,6 +96,9 @@ @Excel(name = "视频传输网边界完整性检测扣分项",width = 25) private BigDecimal videoTransmissionBoundaryIntegrityDetection; /** 视频传输网边界完整性检测扣分项 */ @Excel(name = "重点指挥图像在线率",width = 25) private BigDecimal keyCommandImageOnline; /** 月运行率 */ @Excel(name = "月运行率") private BigDecimal operatingRate; @@ -186,6 +189,14 @@ public void setKeyAnnotationAccuracy(BigDecimal keyAnnotationAccuracy) { this.keyAnnotationAccuracy = keyAnnotationAccuracy; } public BigDecimal getKeyCommandImageOnline() { return keyCommandImageOnline; } public void setKeyCommandImageOnline(BigDecimal keyCommandImageOnline) { this.keyCommandImageOnline = keyCommandImageOnline; } public BigDecimal getKeyTimingAccuracy() { @@ -311,12 +322,12 @@ } @Override public Long getExamineTag() { public Short getExamineTag() { return super.getExamineTag(); } @Override public void setExamineTag(Long examineTag) { public void setExamineTag(Short examineTag) { super.setExamineTag(examineTag); } ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckScore.java
@@ -6,12 +6,14 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.ycl.system.entity.BaseEntity; import lombok.Data; import lombok.experimental.Accessors; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.util.Date; import java.util.Map; /** * 考核积分明细对象 t_check_score @@ -21,7 +23,7 @@ */ @Data @TableName("t_check_score") public class CheckScore public class CheckScore extends BaseEntity { private static final long serialVersionUID = 1L; @@ -66,4 +68,5 @@ //折线图日期参数 @TableField(exist = false) private String date; } ycl-pojo/src/main/java/com/ycl/platform/domain/entity/CheckTemplateRule.java
@@ -44,6 +44,9 @@ @Excel(name = "规则权重") @TableField("weight") private BigDecimal weight; @TableField(exist = false) private String checkRuleName; @TableField(exist = false) private String ruleIndex; } ycl-pojo/src/main/java/com/ycl/system/entity/BaseEntity.java
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.experimental.Accessors; import java.io.Serializable; import java.util.Date; @@ -35,15 +36,16 @@ private Date createTime; /** 更新者 */ @TableField(fill = FieldFill.UPDATE) @TableField(exist = false) private String updateBy; /** 更新时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @TableField(fill = FieldFill.UPDATE) @TableField(exist = false) private Date updateTime; /** 备注 */ @TableField(exist = false) private String remark; /** 请求参数 */ ycl-server/src/main/java/com/ycl/platform/controller/CheckScoreController.java
@@ -35,7 +35,7 @@ /** * 查询考核积分卡片列表 */ @PreAuthorize("@ss.hasPermi('check:score:list')") // @PreAuthorize("@ss.hasPermi('check:score:list')") @GetMapping("/list") public AjaxResult list(CheckScore checkScore) { @@ -46,7 +46,7 @@ /** * 区县详情列表 */ @PreAuthorize("@ss.hasPermi('check:score:list')") // @PreAuthorize("@ss.hasPermi('check:score:list')") @GetMapping("/detail") public TableDataInfo detail(CheckScore checkScore) { @@ -59,7 +59,7 @@ /** * 获取考核指标详细信息 */ @PreAuthorize("@ss.hasPermi('check:score:query')") // @PreAuthorize("@ss.hasPermi('check:score:query')") @GetMapping(value = "/detail/index") public AjaxResult getIndex(CheckScoreIndexDTO checkScoreIndexDTO) { @@ -70,19 +70,18 @@ /** * 发布考核积分 */ @PreAuthorize("@ss.hasPermi('check:score:edit')") // @PreAuthorize("@ss.hasPermi('check:score:edit')") @Log(title = "发布考核积分", businessType = BusinessType.UPDATE) @PutMapping("/publish") public AjaxResult edit(@RequestBody CheckScoreDTO checkScoreDTO) { return toAjax(checkScoreService.publishCheckScore(checkScoreDTO)); } /** * 导出考核积分列表 */ @PreAuthorize("@ss.hasPermi('check:score:export')") // @PreAuthorize("@ss.hasPermi('check:score:export')") @Log(title = "导出考核积分", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, CheckScore checkScore) throws IOException { ycl-server/src/main/java/com/ycl/platform/controller/CheckTemplateController.java
@@ -1,6 +1,7 @@ package com.ycl.platform.controller; import annotation.Log; import com.ycl.exception.job.TaskException; import com.ycl.platform.domain.entity.CheckTemplate; import com.ycl.platform.domain.entity.CheckTemplateRule; import com.ycl.platform.domain.query.CheckTemplateQuery; @@ -12,6 +13,7 @@ import com.ycl.system.page.TableDataInfo; import enumeration.BusinessType; import io.swagger.annotations.ApiOperation; import org.quartz.SchedulerException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -63,8 +65,7 @@ @PreAuthorize("@ss.hasPermi('check:template:add')") @Log(title = "新增考核模板", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody @Validated CheckTemplateQuery checkTemplateDTO) { public AjaxResult add(@RequestBody @Validated CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException { return toAjax(checkTemplateService.insertCheckTemplate(checkTemplateDTO)); } @@ -75,8 +76,7 @@ @PreAuthorize("@ss.hasPermi('check:template:copy')") @Log(title = "复制考核模板", businessType = BusinessType.INSERT) @PostMapping("/copy") public AjaxResult copy(@RequestBody CheckTemplateQuery checkTemplateDTO) { public AjaxResult copy(@RequestBody CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException { return toAjax(checkTemplateService.copyCheckTemplate(checkTemplateDTO)); } @@ -86,8 +86,7 @@ @PreAuthorize("@ss.hasPermi('check:template:edit')") @Log(title = "修改考核模板", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody CheckTemplateQuery checkTemplateDTO) { public AjaxResult edit(@RequestBody CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException { return checkTemplateService.updateCheckTemplate(checkTemplateDTO); } @@ -107,8 +106,7 @@ @PreAuthorize("@ss.hasPermi('check:template:remove')") @Log(title = "删除考核模板", businessType = BusinessType.DELETE) @DeleteMapping("/{id}") public AjaxResult remove(@PathVariable String id) { public AjaxResult remove(@PathVariable String id) throws SchedulerException { return toAjax(checkTemplateService.deleteCheckTemplateById(Integer.parseInt(id))); } ycl-server/src/main/java/com/ycl/platform/mapper/CheckScoreMapper.java
@@ -3,6 +3,7 @@ import annotation.AutoFill; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ycl.platform.domain.dto.CheckScoreDTO; import com.ycl.platform.domain.dto.ScoreIndexDTO; import com.ycl.platform.domain.entity.CheckScore; import enumeration.OperationType; @@ -68,5 +69,8 @@ @AutoFill(OperationType.UPDATE) int publishCheckScore(CheckScoreDTO checkScoreDTO); List<Map> selectScoreIndex(String tableName,Long deptId,String date); List<Map> selectScoreIndex(ScoreIndexDTO scoreIndexDTO); void saveBatch(List<CheckScore> scoreList); } ycl-server/src/main/java/com/ycl/platform/service/ICheckScoreService.java
@@ -35,41 +35,41 @@ */ public Map<Long, List<CheckScore>> selectCheckScoreList(CheckScore checkScore); /** * 新增考核积分明细 * * @param checkScore 考核积分明细 * @return 结果 */ public int insertCheckScore(CheckScore checkScore); /** * 修改考核积分明细 * * @param checkScore 考核积分明细 * @return 结果 */ public int updateCheckScore(CheckScore checkScore); /** * 批量删除考核积分明细 * * @param ids 需要删除的考核积分明细主键集合 * @return 结果 */ public int deleteCheckScoreByIds(Long[] ids); /** * 删除考核积分明细信息 * * @param id 考核积分明细主键 * @return 结果 */ public int deleteCheckScoreById(Long id); int publishCheckScore(CheckScoreDTO checkScoreDTO); List<CheckScore> page(CheckScore checkScore); void exportIndex(HttpServletResponse response,CheckScore checkScore) throws IOException; // /** // * 新增考核积分明细 // * // * @param checkScore 考核积分明细 // * @return 结果 // */ // public int insertCheckScore(CheckScore checkScore); // // /** // * 修改考核积分明细 // * // * @param checkScore 考核积分明细 // * @return 结果 // */ // public int updateCheckScore(CheckScore checkScore); // // /** // * 批量删除考核积分明细 // * // * @param ids 需要删除的考核积分明细主键集合 // * @return 结果 // */ // public int deleteCheckScoreByIds(Long[] ids); // // /** // * 删除考核积分明细信息 // * // * @param id 考核积分明细主键 // * @return 结果 // */ // public int deleteCheckScoreById(Long id); } ycl-server/src/main/java/com/ycl/platform/service/ICheckTemplateService.java
@@ -1,10 +1,12 @@ package com.ycl.platform.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ycl.exception.job.TaskException; import com.ycl.platform.domain.entity.CheckTemplate; import com.ycl.platform.domain.query.CheckTemplateQuery; import com.ycl.system.AjaxResult; import com.ycl.system.Result; import org.quartz.SchedulerException; import java.util.List; @@ -38,7 +40,7 @@ * @param checkTemplateDTO 考核模板 * @return 结果 */ public int insertCheckTemplate(CheckTemplateQuery checkTemplateDTO); public int insertCheckTemplate(CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException; /** * 修改考核模板 @@ -46,15 +48,9 @@ * @param checkTemplateDTO 考核模板 * @return 结果 */ public AjaxResult updateCheckTemplate(CheckTemplateQuery checkTemplateDTO); public AjaxResult updateCheckTemplate(CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException; /** * 批量删除考核模板 * * @param ids 需要删除的考核模板主键集合 * @return 结果 */ public int deleteCheckTemplateByIds(Integer[] ids); /** * 删除考核模板信息 @@ -62,9 +58,17 @@ * @param id 考核模板主键 * @return 结果 */ public int deleteCheckTemplateById(Integer id); public int deleteCheckTemplateById(Integer id) throws SchedulerException; Result pullList(); int copyCheckTemplate(CheckTemplateQuery checkTemplateDTO); int copyCheckTemplate(CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException; // /** // * 批量删除考核模板 // * // * @param ids 需要删除的考核模板主键集合 // * @return 结果 // */ // public int deleteCheckTemplateByIds(Integer[] ids); } ycl-server/src/main/java/com/ycl/platform/service/impl/CheckScoreServiceImpl.java
@@ -1,10 +1,12 @@ package com.ycl.platform.service.impl; import annotation.DataScope; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.platform.base.BaseSelect; import com.ycl.platform.base.CheckIndex; import com.ycl.platform.domain.dto.CheckScoreDTO; import com.ycl.platform.domain.dto.CheckScoreIndexDTO; import com.ycl.platform.domain.dto.ScoreIndexDTO; import com.ycl.platform.domain.entity.*; import com.ycl.platform.domain.vo.CheckScoreDetailVO; import com.ycl.platform.mapper.CheckRuleMapper; @@ -68,12 +70,13 @@ @Autowired private ISysDeptService deptService; /** * 查询考核积分 * 查询考核积分指标 * * @param id 考核积分主键 * @return 考核积分 */ @Override @DataScope(deptAlias = "d",userAlias = "u") public CheckScoreDetailVO selectCheckScoreById(CheckScoreIndexDTO checkScoreIndexDTO) { Long checkScoreId = checkScoreIndexDTO.getId(); @@ -104,7 +107,13 @@ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); date = formatter.format(createTime); } List<Map> map = scoreMapper.selectScoreIndex(tableName,checkScore.getDeptId(),date); ScoreIndexDTO scoreIndexDTO = new ScoreIndexDTO() .setTableName(tableName) .setDeptId(checkScore.getDeptId()) .setDate(date); scoreIndexDTO.setParams(checkScoreIndexDTO.getParams()); List<Map> map = scoreMapper.selectScoreIndex(scoreIndexDTO); scoreMap.put("tableData",checkRules); scoreMap.put("dataMap",map); @@ -122,9 +131,11 @@ * @return 考核积分 */ @Override @DataScope(deptAlias = "d",userAlias = "u") public Map<Long, List<CheckScore>> selectCheckScoreList(CheckScore checkScore) { //TODO:数据权限 //区县只能看已发布 roleControl(checkScore); //查询成绩 String date = checkScore.getDate(); @@ -142,6 +153,8 @@ Map<Long, List<CheckScore>> deptMap = checkScores.stream().collect(Collectors.groupingBy(CheckScore::getDeptId)); return deptMap; } /** * 区县详情 * @@ -149,61 +162,13 @@ * @return 考核积分 */ @Override @DataScope(deptAlias = "d",userAlias = "u") public List<CheckScore> page(CheckScore checkScore) { //TODO:数据权限 //区县只能看已发布 roleControl(checkScore); return scoreMapper.selectCheckScoreList(checkScore); } /** * 新增考核积分 * * @param checkScore 考核积分 * @return 结果 */ @Override public int insertCheckScore(CheckScore checkScore) { checkScore.setCreateTime(DateUtils.getNowDate()); return scoreMapper.insertCheckScore(checkScore); } /** * 修改考核明细 * * @param checkScore 考核积分明细 * @return 结果 */ @Override public int updateCheckScore(CheckScore checkScore) { return scoreMapper.updateCheckScore(checkScore); } /** * 批量删除考核积分 * * @param ids 需要删除的考核积分主键 * @return 结果 */ @Override public int deleteCheckScoreByIds(Long[] ids) { return scoreMapper.deleteCheckScoreByIds(ids); } /** * 删除考核积分信息 * * @param id 考核积分主键 * @return 结果 */ @Override public int deleteCheckScoreById(Long id) { return scoreMapper.deleteCheckScoreById(id); } /** * 发布考核积分信息 * @@ -301,4 +266,64 @@ util.exportExcel(response, checkIndexes, "考核积分明细数据"); } private void roleControl(CheckScore checkScore) { List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles(); SysRole sysRole = roles.get(0); if("zg_province".equals(sysRole.getRoleKey())){ Map<String, Object> params = checkScore.getParams(); params.put("publish",PublishType.PUBLISHED.getCode()); } } // /** // * 新增考核积分 // * // * @param checkScore 考核积分 // * @return 结果 // */ // @Override // public int insertCheckScore(CheckScore checkScore) // { // checkScore.setCreateTime(DateUtils.getNowDate()); // return scoreMapper.insertCheckScore(checkScore); // } // // /** // * 修改考核明细 // * // * @param checkScore 考核积分明细 // * @return 结果 // */ // @Override // public int updateCheckScore(CheckScore checkScore) // { // // return scoreMapper.updateCheckScore(checkScore); // } // // /** // * 批量删除考核积分 // * // * @param ids 需要删除的考核积分主键 // * @return 结果 // */ // @Override // public int deleteCheckScoreByIds(Long[] ids) // { // return scoreMapper.deleteCheckScoreByIds(ids); // } // // /** // * 删除考核积分信息 // * // * @param id 考核积分主键 // * @return 结果 // */ // @Override // public int deleteCheckScoreById(Long id) // { // return scoreMapper.deleteCheckScoreById(id); // } } ycl-server/src/main/java/com/ycl/platform/service/impl/CheckTemplateServiceImpl.java
@@ -3,6 +3,7 @@ import com.alibaba.fastjson2.JSONArray; import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.exception.job.TaskException; import com.ycl.platform.base.BaseSelect; import com.ycl.platform.domain.entity.CheckTemplate; import com.ycl.platform.domain.entity.CheckTemplateRule; @@ -13,10 +14,13 @@ import com.ycl.platform.service.ICheckTemplateService; import com.ycl.system.AjaxResult; import com.ycl.system.Result; import com.ycl.system.domain.SysJob; import com.ycl.system.entity.SysDept; import com.ycl.system.service.ISysDeptService; import com.ycl.system.service.ISysJobService; import com.ycl.utils.SecurityUtils; import constant.CheckConstants; import org.quartz.SchedulerException; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -44,6 +48,8 @@ private ICheckTemplateRuleService templateRuleServicee; @Autowired private CheckTemplateRuleMapper checkTemplateRuleMapper; @Autowired private ISysJobService jobService; /** * 查询考核模板 @@ -70,8 +76,6 @@ list.add(map); } checkTemplateQuery.setRuleFormList(list); //TODO:查询template_rule表中的权重信息。 return checkTemplateQuery; } @@ -107,10 +111,7 @@ */ @Override @Transactional(rollbackFor = Exception.class) public int insertCheckTemplate(CheckTemplateQuery checkTemplateDTO) { //TODO:新增定时任务,状态同模板,然后赋值jobId给template public int insertCheckTemplate(CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException { String username = SecurityUtils.getUsername(); /** 插入t_template */ CheckTemplate checkTemplate = new CheckTemplate(); @@ -126,6 +127,12 @@ //不填报警分数---->零分---->不报警 .setAlarmScore(new BigDecimal(checkTemplateDTO.getAlarmScore() == null ? "" : checkTemplateDTO.getAlarmScore())); int i = checkTemplateMapper.insertCheckTemplate(checkTemplate); //新增定时任务,状态同模板,然后赋值jobId给template SysJob sysJob = addJob(checkTemplateDTO.setId(checkTemplate.getId())); checkTemplate.setJobId(Integer.parseInt(sysJob.getJobId() + "")); checkTemplateMapper.updateCheckTemplate(checkTemplate); /** t_template_rule新增权重 */ insertTemlpateRule(checkTemplateDTO, checkTemplate); @@ -140,9 +147,7 @@ */ @Override @Transactional(rollbackFor = Exception.class) public int copyCheckTemplate(CheckTemplateQuery checkTemplateDTO) { //TODO:新增定时任务,状态同模板,然后赋值jobId给template public int copyCheckTemplate(CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException { //插入模板表 CheckTemplate checkTemplate = checkTemplateMapper.selectCheckTemplateById(checkTemplateDTO.getId()); String username = SecurityUtils.getUsername(); @@ -155,7 +160,10 @@ List<CheckTemplateRule> templateRuleList = checkTemplateRuleMapper.selectListByTemplateId(checkTemplateDTO.getId()); templateRuleList.forEach(checkTemplateRule -> checkTemplateRule.setCheckTemplateId(checkTemplate.getId()).setId(null)); templateRuleServicee.saveBatch(templateRuleList); //新增定时任务,状态同模板,然后赋值jobId给template SysJob sysJob = addJob(checkTemplateDTO.setId(checkTemplate.getId())); checkTemplate.setJobId(Integer.parseInt(sysJob.getJobId() + "")); checkTemplateMapper.updateCheckTemplate(checkTemplate); return i; } @@ -167,7 +175,7 @@ */ @Override @Transactional(rollbackFor = Exception.class) public AjaxResult updateCheckTemplate(CheckTemplateQuery checkTemplateDTO) { public AjaxResult updateCheckTemplate(CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException { CheckTemplate checkTemplate = new CheckTemplate(); BeanUtils.copyProperties(checkTemplateDTO, checkTemplate); checkTemplate.setUpdateUserName(SecurityUtils.getUsername()); @@ -178,25 +186,17 @@ checkTemplateMapper.updateCheckTemplate(checkTemplate); /** t_template_rule修改权重 */ if (!CollectionUtils.isEmpty(checkTemplateDTO.getRuleFormList()) ) { if (!CollectionUtils.isEmpty(checkTemplateDTO.getRuleFormList())) { //先删除原数据 checkTemplateRuleMapper.deleteByTemplateId(checkTemplate.getId()); //插入新规则数据 insertTemlpateRule(checkTemplateDTO, checkTemplate); } //TODO:判断状态是否修改,调整job表里的状态 //调整job表里的状态 SysJob job = jobService.selectJobById(Long.valueOf(checkTemplateDTO.getJobId())); job.setStatus(checkTemplateDTO.getStatus()); jobService.updateJob(job); return AjaxResult.success(); } /** * 批量删除考核模板 * * @param ids 需要删除的考核模板主键 * @return 结果 */ @Override public int deleteCheckTemplateByIds(Integer[] ids) { return checkTemplateMapper.deleteCheckTemplateByIds(ids); } /** @@ -206,10 +206,15 @@ * @return 结果 */ @Override public int deleteCheckTemplateById(Integer id) { //TODO:删除定时任务 public int deleteCheckTemplateById(Integer id) throws SchedulerException { CheckTemplate checkTemplate = checkTemplateMapper.selectCheckTemplateById(id); //删除定时任务 SysJob job = new SysJob(); if (checkTemplate.getJobId() != null) { job.setJobId(Long.valueOf(checkTemplate.getJobId())); job.setJobGroup("CHECK"); jobService.deleteJob(job); } return checkTemplateMapper.updateCheckTemplate(new CheckTemplate().setId(id) .setDeleted(CheckConstants.Delete)); } @@ -236,4 +241,29 @@ templateRuleServicee.saveBatch(templateRuleList); } } private SysJob addJob(CheckTemplateQuery checkTemplateDTO) throws SchedulerException, TaskException { SysJob job = new SysJob(); job.setCreateBy(SecurityUtils.getLoginUser().getUsername()); //调用方法名 job.setInvokeTarget("checkScoreTask.executeTemplate(" + checkTemplateDTO.getId() + ")"); job.setConcurrent("1"); job.setStatus(checkTemplateDTO.getStatus()); job.setJobGroup("CHECK"); job.setCronExpression("0 0 12 * * ?"); job.setJobName(checkTemplateDTO.getTemplateName()); int i = jobService.insertJob(job); return job; } // /** // * 批量删除考核模板 // * // * @param ids 需要删除的考核模板主键 // * @return 结果 // */ // @Override // public int deleteCheckTemplateByIds(Integer[] ids) { // return checkTemplateMapper.deleteCheckTemplateByIds(ids); // } } ycl-server/src/main/java/com/ycl/task/CheckScore.java
File was deleted ycl-server/src/main/java/com/ycl/task/CheckScoreTask.java
New file @@ -0,0 +1,159 @@ package com.ycl.task; import com.alibaba.fastjson2.JSONArray; import com.google.common.base.CaseFormat; import com.ycl.platform.base.CheckIndex; import com.ycl.platform.domain.entity.*; import com.ycl.platform.mapper.CheckScoreMapper; import com.ycl.platform.mapper.CheckTemplateMapper; import com.ycl.platform.mapper.CheckTemplateRuleMapper; import com.ycl.platform.service.*; import constant.CheckConstants; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.stereotype.Component; import java.lang.reflect.Field; import java.math.BigDecimal; import java.math.RoundingMode; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; @Slf4j @Component("checkScoreTask") public class CheckScoreTask { @Autowired private CheckTemplateMapper templateMapper; @Autowired private CheckTemplateRuleMapper checkTemplateRuleMapper; @Autowired private CheckScoreMapper scoreMapper; @Autowired private MongoTemplate mongoTemplate; @Autowired private ICheckIndexVideoService videoService; @Autowired private ICheckIndexFaceService faceService; @Autowired private ICheckIndexCarService carService; public void executeTemplate(Integer templateId) { CheckTemplate checkTemplate = templateMapper.selectCheckTemplateById(templateId); if (checkTemplate != null) { log.info("执行考核模板---------->{}", checkTemplate.getTemplateName()); Short examineCategory = checkTemplate.getExamineCategory(); Short examineTag = checkTemplate.getExamineTag(); //查权重 CheckTemplateRule checkTemplateRule = new CheckTemplateRule(); checkTemplateRule.setCheckTemplateId(templateId); List<CheckTemplateRule> templateRuleList = checkTemplateRuleMapper.selectListByTemplateId(templateId); //查今天的index指标 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String day = dateFormat.format(new Date()); //创建score集合方便最后批量存储 List<CheckScore> scoreList = new ArrayList<>(); //根据考核类别和考核标签,查不同index表(区分省厅区县) if (CheckConstants.Rule_Category_Video.equals(examineCategory)) { CheckIndexVideo checkIndexVideo = new CheckIndexVideo(); checkIndexVideo.setExamineTag(examineTag); checkIndexVideo.setDay(day); checkIndexVideo.setDeptIds(JSONArray.parseArray(checkTemplate.getDeptId(), Integer.class)); //根据模板的考核标签查各区县对应省厅或市局视频数据 List<CheckIndexVideo> checkIndexVideos = videoService.selectCheckIndexVideoList(checkIndexVideo); for (CheckIndexVideo indexVideo : checkIndexVideos) { addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexVideo,CheckConstants.Rule_Category_Video); } } else if (CheckConstants.Rule_Category_Car.equals(examineCategory)) { CheckIndexCar checkIndexCar = new CheckIndexCar(); checkIndexCar.setDay(day); checkIndexCar.setExamineTag(examineTag); checkIndexCar.setDeptIds(JSONArray.parseArray(checkTemplate.getDeptId(), Integer.class)); //根据模板的考核标签查各区县对应省厅或市局车辆数据 List<CheckIndexCar> checkIndexCars = carService.selectCheckIndexCarList(checkIndexCar); for (CheckIndexCar indexCar : checkIndexCars) { addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexCar,CheckConstants.Rule_Category_Car); } } else if (CheckConstants.Rule_Category_Face.equals(examineCategory)) { CheckIndexFace checkIndexFace = new CheckIndexFace(); checkIndexFace.setDay(day); checkIndexFace.setExamineTag(examineTag); checkIndexFace.setDeptIds(JSONArray.parseArray(checkTemplate.getDeptId(), Integer.class)); //根据模板的考核标签查各区县对应省厅或市局人脸数据 List<CheckIndexFace> checkIndexFaces = faceService.selectCheckIndexFaceList(checkIndexFace); for (CheckIndexFace indexFace : checkIndexFaces) { addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexFace,CheckConstants.Rule_Category_Face); } } //储存分数 scoreMapper.saveBatch(scoreList); //TODO:根据报警分数阈值,添加报警信息 } } private <T extends CheckIndex>void addToList(Integer templateId, CheckTemplate checkTemplate, Short examineTag, List<CheckTemplateRule> templateRuleList, List<CheckScore> scoreList, T indexObject,Short checkCategory) { CheckScore checkScore = new CheckScore(); BigDecimal scoreFinal = BigDecimal.ZERO; for (CheckTemplateRule templateRule : templateRuleList) { //计算分数 scoreFinal = getScoreFinal(indexObject, scoreFinal, templateRule); } //补充checkScore fillCheckScore(templateId, checkTemplate, examineTag, indexObject, checkScore, scoreFinal,checkCategory); scoreList.add(checkScore); } //通用方法计算分数 private <T>BigDecimal getScoreFinal(T object, BigDecimal scoreFinal, CheckTemplateRule templateRule) { String ruleIndex = templateRule.getRuleIndex(); //将a_b_c转换为aBC String camelRuleIndex = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, ruleIndex); try { //反射获取属性值 Class<T> clazz = (Class<T>) object.getClass(); Field field = clazz.getDeclaredField(camelRuleIndex); field.setAccessible(true); BigDecimal index = (BigDecimal) field.get(object); BigDecimal score = index.multiply(templateRule.getWeight()); scoreFinal = scoreFinal.add(score); } catch (Exception e) { log.info("反射异常",e); } return scoreFinal; } //设置checkScore对象 private void fillCheckScore(Integer templateId, CheckTemplate checkTemplate, Short examineTag, CheckIndex checkIndex, CheckScore checkScore, BigDecimal scoreFinal,Short checkCategory) { //根据调整系数调整最终分数大小 String adjustWay = checkTemplate.getAdjustWay(); BigDecimal adjustCoefficient = checkTemplate.getAdjustCoefficient(); if(CheckConstants.Multiply.equals(adjustWay)){ scoreFinal = adjustCoefficient.multiply(scoreFinal).multiply(new BigDecimal(100)); }else if(CheckConstants.Divided.equals(adjustWay)){ //四舍五入保留小数后四位 scoreFinal = scoreFinal.divide(adjustCoefficient,4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); } checkScore.setCreateTime(new Date()); checkScore.setExamineTag(Integer.parseInt(examineTag +"")); checkScore.setExamineCategory(checkCategory); checkScore.setDeptId(checkIndex.getDeptId()); checkScore.setTemplateId(templateId); checkScore.setScore(scoreFinal); } //查mongo数据归档到mysql public void dataArchiving() { //TODO:归档check_index_car,区分省厅市局,每个区县一条数据 CheckIndexCar checkIndexCar = new CheckIndexCar(); //TODO:归档check_index_face CheckIndexFace checkIndexFace = new CheckIndexFace(); //TODO:归档check_index_video CheckIndexVideo checkIndexVideo = new CheckIndexVideo(); } } ycl-server/src/main/resources/mapper/zgyw/CheckIndexCarMapper.xml
@@ -29,9 +29,10 @@ select tcic.*,sd.dept_name from t_check_index_car tcic left join sys_dept sd on tcic.dept_id = sd.dept_id <where> <if test="deptId != null "> and dept_id = #{deptId}</if> <if test="deptId != null "> and tcic.dept_id = #{deptId}</if> <if test="examineTag != null "> and examine_tag = #{examineTag}</if> <if test="date != null "> and date_format(tcic.create_time,'%Y-%m') = #{date}</if> <if test="day != null "> and date(tcic.create_time) = #{day}</if> <if test="viewConnectStability != null "> and view_connect_stability = #{viewConnectStability}</if> <if test="siteOnline != null "> and site_online = #{siteOnline}</if> <if test="deviceDirectoryConsistent != null "> and device_directory_consistent = #{deviceDirectoryConsistent}</if> @@ -42,6 +43,11 @@ <if test="vehicleUploadTimeliness != null "> and vehicle_upload_timeliness = #{vehicleUploadTimeliness}</if> <if test="vehicleUrlAvailability != null "> and vehicle_url_availability = #{vehicleUrlAvailability}</if> <if test="vehiclePictureAvailability != null "> and vehicle_picture_availability = #{vehiclePictureAvailability}</if> <if test="deptIds != null ">and tcic.dept_id in <foreach collection="deptIds" separator="," open="(" close=")" item="deptId"> #{deptId} </foreach> </if> </where> </select> ycl-server/src/main/resources/mapper/zgyw/CheckIndexFaceMapper.xml
@@ -27,9 +27,10 @@ select tcif.*,sd.dept_name from t_check_index_face tcif left join sys_dept sd on tcif.dept_id = sd.dept_id <where> <if test="deptId != null "> and dept_id = #{deptId}</if> <if test="deptId != null "> and tcif.dept_id = #{deptId}</if> <if test="examineTag != null "> and examine_tag = #{examineTag}</if> <if test="date != null "> and date_format(tcif.create_time,'%Y-%m') = #{date}</if> <if test="day != null "> and date(tcif.create_time) = #{day}</if> <if test="viewConnectStability != null "> and view_connect_stability = #{viewConnectStability}</if> <if test="siteOnline != null "> and site_online = #{siteOnline}</if> <if test="deviceDirectoryConsistent != null "> and device_directory_consistent = #{deviceDirectoryConsistent}</if> @@ -38,6 +39,11 @@ <if test="faceTimingAccuracy != null "> and face_timing_accuracy = #{faceTimingAccuracy}</if> <if test="faceUploadTimeliness != null "> and face_upload_timeliness = #{faceUploadTimeliness}</if> <if test="facePictureAvailability != null "> and face_picture_availability = #{facePictureAvailability}</if> <if test="deptIds != null ">and tcif.dept_id in <foreach collection="deptIds" separator="," open="(" close=")" item="deptId"> #{deptId} </foreach> </if> </where> </select> ycl-server/src/main/resources/mapper/zgyw/CheckIndexVideoMapper.xml
@@ -39,9 +39,11 @@ select tciv.*,sd.dept_name from t_check_index_video tciv left join sys_dept sd on tciv.dept_id = sd.dept_id <where> <if test="deptId != null "> and dept_id = #{deptId}</if> <if test="deptId != null "> and tciv.dept_id = #{deptId}</if> <if test="examineTag != null "> and examine_tag = #{examineTag}</if> <if test="date != null "> and date_format(tciv.create_time,'%Y-%m') = #{date}</if> <if test="day != null "> and date(tciv.create_time) = #{day}</if> <if test="createTime != null "> and date(tciv.create_time) = #{createTime}</if> <if test="platformOnline != null "> and platform_online = #{platformOnline}</if> <if test="monitorQualification != null "> and monitor_qualification = #{monitorQualification}</if> <if test="monitorRegistration != null "> and monitor_registration = #{monitorRegistration}</if> @@ -62,6 +64,11 @@ <if test="videoTransmissionDangerousAssetsScore != null "> and video_transmission_dangerous_assets_score = #{videoTransmissionDangerousAssetsScore}</if> <if test="videoTransmissionBoundaryIntegrityDetection != null "> and video_transmission_boundary_integrity_detection = #{videoTransmissionBoundaryIntegrityDetection}</if> <if test="operatingRate != null "> and operating_rate = #{operatingRate}</if> <if test="deptIds != null ">and tciv.dept_id in <foreach collection="deptIds" separator="," open="(" close=")" item="deptId"> #{deptId} </foreach> </if> </where> </select> ycl-server/src/main/resources/mapper/zgyw/CheckScoreMapper.xml
@@ -18,20 +18,22 @@ </resultMap> <sql id="selectCheckScoreVo"> select id, score, dept_id, template_id, examine_tag, examine_category, create_time,update_time,update_user, publish from t_check_score select id, score, tcs.dept_id, template_id, examine_tag, examine_category, tcs.create_time,tcs.update_time,tcs.update_user, publish from t_check_score tcs left join sys_dept d on tcs.dept_id = d.dept_id </sql> <select id="selectCheckScoreList" resultMap="CheckScoreResult"> <include refid="selectCheckScoreVo"/> <where> <if test="score != null "> and score = #{score}</if> <if test="deptId != null "> and dept_id = #{deptId}</if> <if test="templateId != null "> and template_id = #{templateId}</if> <if test="createTime != null "> and DATE(create_time) = #{createTime}</if> <if test="date != null "> and date_format(create_time,'%Y-%m') = #{date}</if> <if test="createTime != null "> and DATE(tcs.create_time) = #{createTime}</if> <if test="date != null "> and date_format(tcs.create_time,'%Y-%m') = #{date}</if> <if test="examineTag != null "> and examine_tag = #{examineTag}</if> <if test="examineCategory != null "> and examine_category = #{examineCategory}</if> <if test="publish != null and publish != ''"> and publish = #{publish}</if> <if test="params.publish != null and params.publish != ''"> and publish = #{params.publish}</if> <if test="deptId != null "> and tcs.dept_id = #{deptId}</if> ${params.dataScope} </where> </select> @@ -101,6 +103,15 @@ </update> <select id="selectScoreIndex" resultType="java.util.Map"> select * from ${tableName} where dept_id =#{deptId} and date_format(create_time,'%Y-%m') = #{date} select t.* from ${tableName} t left join sys_dept d on t.dept_id = d.dept_id where t.dept_id =#{deptId} and date_format(t.create_time,'%Y-%m') = #{date} ${params.dataScope} </select> <insert id="saveBatch"> insert into t_check_score (score,dept_id,template_id,examine_tag,examine_category,create_time) values <foreach collection="scoreList" separator="," item="score"> (#{score.score},#{score.deptId},#{score.templateId},#{score.examineTag},#{score.examineCategory},#{score.createTime}) </foreach> </insert> </mapper> ycl-server/src/main/resources/mapper/zgyw/CheckTemplateRuleMapper.xml
@@ -67,7 +67,7 @@ delete from t_check_template_rule where check_template_id = #{templateId} </delete> <select id="selectListByTemplateId" resultType="com.ycl.platform.domain.entity.CheckTemplateRule"> select tctr.*,tcr.rule_name as checkRuleName from t_check_template_rule tctr select tctr.*,tcr.rule_name as checkRuleName,tcr.rule_index from t_check_template_rule tctr left join t_check_rule tcr on tctr.check_rule_id = tcr.id where check_template_id = #{checkTemplateId} </select>