Browse Source

fix: 完善单位问题画像、个人问题画像

main
wxc 1 year ago
parent
commit
d363825af3
  1. 2
      src/main/java/com/biutag/supervision/SupervisionApplication.java
  2. 1
      src/main/java/com/biutag/supervision/constants/enums/CaseVerifProblemNatureEnum.java
  3. 8
      src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfileDepartController.java
  4. 8
      src/main/java/com/biutag/supervision/controller/system/DepartController.java
  5. 42
      src/main/java/com/biutag/supervision/job/DepartJob.java
  6. 5
      src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java
  7. 4
      src/main/java/com/biutag/supervision/mapper/ProfileDepartMapper.java
  8. 8
      src/main/java/com/biutag/supervision/mapper/SupDepartPoliceSizeMapper.java
  9. 5
      src/main/java/com/biutag/supervision/mapper/SupPoliceMapper.java
  10. 27
      src/main/java/com/biutag/supervision/pojo/entity/SupDepartPoliceSize.java
  11. 11
      src/main/java/com/biutag/supervision/service/SupDepartPoliceSizeService.java
  12. 31
      src/main/java/com/biutag/supervision/service/SupDepartService.java
  13. 6
      src/main/resources/application-local.yml
  14. 17
      src/main/resources/mapper/ProfileDepartMapper.xml
  15. 45
      src/test/java/com/biutag/supervision/SupervisionApplicationTests.java
  16. 2
      src/test/java/com/biutag/supervision/tools/GenCodeTests.java

2
src/main/java/com/biutag/supervision/SupervisionApplication.java

@ -2,8 +2,10 @@ package com.biutag.supervision;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableAsync
@EnableScheduling
@SpringBootApplication
public class SupervisionApplication {

1
src/main/java/com/biutag/supervision/constants/enums/CaseVerifProblemNatureEnum.java

@ -16,4 +16,5 @@ public enum CaseVerifProblemNatureEnum {
@Getter
private String laebl;
}

8
src/main/java/com/biutag/supervision/controller/sensitivePerception/ProfileDepartController.java

@ -43,7 +43,6 @@ public class ProfileDepartController {
private final SupDepartService departService;
private final SupPoliceService policeService;
private final NegativeService negativeService;
private final NegativeBlameService negativeBlameService;
private final BusinessDepartService businessDepartService;
@GetMapping
@ -81,7 +80,14 @@ public class ProfileDepartController {
profileDepart.getDepartInfo().setAuxSize(polices.stream().filter(item -> PersonTypeEnum.aux.getValue().equals(item.getPersonType()) || PersonTypeEnum.xj.getValue().equals(item.getPersonType())).count());
List<Negative> list = negativeService.list(new LambdaQueryWrapper<Negative>().eq(Negative::getInvolveDepartId, departId)
.between(Negative::getCrtTime, beginTime, endTime)
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue())));
List<String> negativeIds = list.stream().map(Negative::getId).toList();
int negativePoliceSize = profileDepartMapper.countByNegativeIdsAndPersonTypes(negativeIds, List.of(PersonTypeEnum.police.getValue()));
profileDepart.getDepartInfo().setNegativePoliceSize(negativePoliceSize);
int negativeAuxSize = profileDepartMapper.countByNegativeIdsAndPersonTypes(negativeIds, List.of(PersonTypeEnum.aux.getValue(), PersonTypeEnum.xj.getValue()));
profileDepart.getDepartInfo().setNegativeAuxSize(negativeAuxSize);
profileDepart.getNegativeInfo().setSize(list.size());
int jcjBusinessSize = businessDepartService.list(new LambdaQueryWrapper<BusinessDepart>()

8
src/main/java/com/biutag/supervision/controller/system/DepartController.java

@ -4,6 +4,7 @@ import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.constants.enums.DepartLevelEnum;
import com.biutag.supervision.pojo.Result;
@ -51,7 +52,10 @@ public class DepartController {
supDepart.setId(String.valueOf(NumberUtil.nullToZero(departService.getMaxId()) + 1));
supDepart.setLevel(parent.getLevel() + 1);
supDepart.setUpdatedAt(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMAT));
return Result.success(departService.save(supDepart));
departService.save(supDepart);
String pathTrace = departService.getPathTrace(supDepart);
departService.update(new LambdaUpdateWrapper<SupDepart>().eq(SupDepart::getId, supDepart.getId()).set(SupDepart::getPathTrace, pathTrace));
return Result.success();
}
@PutMapping
@ -65,6 +69,8 @@ public class DepartController {
SupDepart parent = departService.getById(supDepart.getPid());
supDepart.setLevel(parent.getLevel() + 1);
supDepart.setUpdatedAt(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMAT));
String pathTrace = departService.getPathTrace(supDepart);
supDepart.setPathTrace(pathTrace);
return Result.success(departService.updateById(supDepart));
}

42
src/main/java/com/biutag/supervision/job/DepartJob.java

@ -1,13 +1,55 @@
package com.biutag.supervision.job;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.biutag.supervision.pojo.entity.SupDepart;
import com.biutag.supervision.service.SupDepartPoliceSizeService;
import com.biutag.supervision.service.SupDepartService;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author wxc
* @date 2024/11/4
*/
@RequiredArgsConstructor
@Component
public class DepartJob {
private final SupDepartService departService;
private final SupDepartPoliceSizeService departPoliceSizeService;
@PostConstruct
public void init() {
// updateDepartPath();
}
@Async
public void updateDepartPath() {
List<SupDepart> departs = departService.list();
departs.forEach(item -> {
String pathTrace = departService.getPathTrace(item);
if (!pathTrace.equals(item.getPathTrace())) {
departService.update(new LambdaUpdateWrapper<SupDepart>().eq(SupDepart::getId, item.getId()).set(SupDepart::getPathTrace, pathTrace));
}
});
}
@Async
public void updatePoliceSize() {
List<SupDepart> departs = departService.list();
departs.forEach(item -> {
String pathTrace = departService.getPathTrace(item);
if (!pathTrace.equals(item.getPathTrace())) {
departService.update(new LambdaUpdateWrapper<SupDepart>().eq(SupDepart::getId, item.getId()).set(SupDepart::getPathTrace, pathTrace));
}
});
}
}

5
src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java

@ -2,7 +2,12 @@ package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.NegativeBlame;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface NegativeBlameMapper extends BaseMapper<NegativeBlame> {
}

4
src/main/java/com/biutag/supervision/mapper/ProfileDepartMapper.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.pojo.dto.common.BarItem;
import com.biutag.supervision.pojo.dto.common.PieItem;
import com.biutag.supervision.pojo.model.DepartNegativeModel;
import org.apache.ibatis.annotations.Select;
import java.util.Date;
import java.util.List;
@ -20,4 +21,7 @@ public interface ProfileDepartMapper {
List<BarItem> selectPoliceTop10(String departId, Date beginTime, Date endTime);
List<BarItem> selectProblemType(String departId, Date beginTime, Date endTime);
int countByNegativeIdsAndPersonTypes(List<String> negativeIds, List<String> personTypes);
}

8
src/main/java/com/biutag/supervision/mapper/SupDepartPoliceSizeMapper.java

@ -0,0 +1,8 @@
package com.biutag.supervision.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.biutag.supervision.pojo.entity.SupDepartPoliceSize;
public interface SupDepartPoliceSizeMapper extends BaseMapper<SupDepartPoliceSize> {
}

5
src/main/java/com/biutag/supervision/mapper/SupPoliceMapper.java

@ -7,9 +7,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.supervision.pojo.entity.SupPolice;
import com.biutag.supervision.pojo.model.PoliceModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface SupPoliceMapper extends BaseMapper<SupPolice> {
Page<PoliceModel> queryPage(@Param("page") Page<PoliceModel> page, @Param(Constants.WRAPPER) QueryWrapper<PoliceModel> queryWrapper);
}

27
src/main/java/com/biutag/supervision/pojo/entity/SupDepartPoliceSize.java

@ -0,0 +1,27 @@
package com.biutag.supervision.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class SupDepartPoliceSize {
//
@TableId(value = "depart_id")
private String departId;
// 民警人数
@TableField("police_size")
private Integer policeSize;
// 协警人数
@TableField("aux_size")
private Integer auxSize;
}

11
src/main/java/com/biutag/supervision/service/SupDepartPoliceSizeService.java

@ -0,0 +1,11 @@
package com.biutag.supervision.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.supervision.pojo.entity.SupDepartPoliceSize;
import com.biutag.supervision.mapper.SupDepartPoliceSizeMapper;
import org.springframework.stereotype.Service;
@Service
public class SupDepartPoliceSizeService extends ServiceImpl<SupDepartPoliceSizeMapper, SupDepartPoliceSize> {
}

31
src/main/java/com/biutag/supervision/service/SupDepartService.java

@ -14,11 +14,13 @@ import com.biutag.supervision.pojo.model.UserAuth;
import com.biutag.supervision.pojo.param.DepartQueryParam;
import com.biutag.supervision.pojo.param.DepartTreeListParam;
import com.biutag.supervision.pojo.vo.DepartTree;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.*;
@Slf4j
@Service
public class SupDepartService extends ServiceImpl<SupDepartMapper, SupDepart> {
@ -259,7 +261,7 @@ public class SupDepartService extends ServiceImpl<SupDepartMapper, SupDepart> {
* @param childMap
* @return
*/
private static DepartTree buildTreeRecursive(DepartTree node, Map<String, List<DepartTree>> childMap) {
public static DepartTree buildTreeRecursive(DepartTree node, Map<String, List<DepartTree>> childMap) {
List<DepartTree> children = childMap.get(node.getId());
if (children != null) {
node.getChildren().addAll(children.stream()
@ -269,5 +271,32 @@ public class SupDepartService extends ServiceImpl<SupDepartMapper, SupDepart> {
return node;
}
/**
* 获取部门的 pathTrace
* @param depart
* @return
*/
public String getPathTrace(SupDepart depart) {
List<String> pathTrace = new ArrayList<>();
buildPathTraceRecursive(depart, pathTrace);
return "/" + String.join("/", pathTrace) + "/";
}
public void buildPathTraceRecursive(SupDepart depart, List<String> pathTrace) {
pathTrace.add(0, depart.getId());
if (AppConstants.ROOT_DEPART_ID.equals(depart.getId())) {
return;
}
if (AppConstants.ROOT_DEPART_ID.equals(depart.getPid())) {
pathTrace.add(0, AppConstants.ROOT_DEPART_ID);
} else {
SupDepart parent = getById(depart.getPid());
if (Objects.isNull(parent)) {
log.warn("该部门[{} {}]的父级ID不存在,请核实", depart.getName(), depart.getId());
return;
}
buildPathTraceRecursive(parent, pathTrace);
}
}
}

6
src/main/resources/application-local.yml

@ -19,9 +19,9 @@ spring:
port: 6379
password: 123456
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#mybatis-plus:
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
fdfs:
tracker-list: #TrackerList参数,支持多个

17
src/main/resources/mapper/ProfileDepartMapper.xml

@ -88,4 +88,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by value desc
</select>
<select id="countByNegativeIdsAndPersonTypes">
SELECT
count( p.id )
FROM
sup_police p
LEFT JOIN negative_blame nb ON p.id_code = nb.blameIdCode
WHERE
nb.negativeId IN
<foreach collection="negativeIds" item="negativeId" open="(" separator="," close=")">
#{negativeId}
</foreach>
AND p.person_type IN
<foreach collection="personaTypes" item="personType" open="(" separator="," close=")">
#{personType}
</foreach>
</select>
</mapper>

45
src/test/java/com/biutag/supervision/SupervisionApplicationTests.java

@ -1,15 +1,18 @@
package com.biutag.supervision;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.biutag.supervision.constants.AppConstants;
import com.biutag.supervision.pojo.entity.SupDepart;
import com.biutag.supervision.service.SupDepartService;
import com.github.tobato.fastdfs.service.FastFileStorageClient;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@SpringBootTest
class SupervisionApplicationTests {
@ -23,18 +26,36 @@ class SupervisionApplicationTests {
@Autowired
private TaskScheduler taskScheduler;
@Autowired
SupDepartService departService;
@Test
void contextLoads() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(5);
scheduler.setThreadNamePrefix("scheduled-task-");
scheduler.initialize();
Runnable runnable = () -> {
System.out.println("Executing task at " + LocalDateTime.now());
};
taskRegistrar.setTaskScheduler(scheduler);
taskRegistrar.addTriggerTask(runnable, new CronTrigger("0 2 * * * ?"));
List<SupDepart> departs = departService.list();
departs.forEach(item -> {
String pathTrace = getPathTrace(item);
if (!pathTrace.equals(item.getPathTrace())) {
departService.update(new LambdaUpdateWrapper<SupDepart>().eq(SupDepart::getId, item.getId()).set(SupDepart::getPathTrace, pathTrace));
}
});
}
public String getPathTrace(SupDepart depart) {
List<String> pathTrace = new ArrayList<>();
buildPathTraceRecursive(depart, pathTrace);
return "/" + String.join("/", pathTrace) + "/";
}
public void buildPathTraceRecursive(SupDepart depart, List<String> pathTrace) {
pathTrace.add(0, depart.getId());
if (AppConstants.ROOT_DEPART_ID.equals(depart.getId())) {
return;
}
if (AppConstants.ROOT_DEPART_ID.equals(depart.getPid())) {
pathTrace.add(0, AppConstants.ROOT_DEPART_ID);
} else {
buildPathTraceRecursive(departService.getById(depart.getPid()), pathTrace);
}
}
}

2
src/test/java/com/biutag/supervision/tools/GenCodeTests.java

@ -25,7 +25,7 @@ public class GenCodeTests {
@Test
public void genEntity() throws TemplateException, IOException {
String tableName = "rpc_infringer_result";
String tableName = "sup_depart_police_size";
String tableSchema = "negative";
boolean genMapper = true;
boolean genService = true;

Loading…
Cancel
Save