14 changed files with 447 additions and 36 deletions
@ -0,0 +1,155 @@
|
||||
package com.biutag.supervision.controller.sensitivePerception; |
||||
|
||||
import cn.hutool.core.date.DateUtil; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.biutag.supervision.constants.enums.BusinessTypeEnum; |
||||
import com.biutag.supervision.constants.enums.InspectCaseEnum; |
||||
import com.biutag.supervision.constants.enums.ProblemSourcesEnum; |
||||
import com.biutag.supervision.mapper.ProfilePoliceMapper; |
||||
import com.biutag.supervision.pojo.Result; |
||||
import com.biutag.supervision.pojo.domain.ProfileDepart; |
||||
import com.biutag.supervision.pojo.domain.ProfilePolice; |
||||
import com.biutag.supervision.pojo.dto.common.PieItem; |
||||
import com.biutag.supervision.pojo.entity.BusinessDepart; |
||||
import com.biutag.supervision.pojo.entity.BusinessPolice; |
||||
import com.biutag.supervision.pojo.entity.Negative; |
||||
import com.biutag.supervision.pojo.entity.NegativeBlame; |
||||
import com.biutag.supervision.pojo.model.PoliceNegativeModel; |
||||
import com.biutag.supervision.pojo.param.DepartPoliceQueryParam; |
||||
import com.biutag.supervision.service.*; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.time.LocalDate; |
||||
import java.time.format.DateTimeFormatter; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 单位/个人画像 |
||||
* @author wxc |
||||
* @date 2024/10/31 |
||||
*/ |
||||
@RequiredArgsConstructor |
||||
@RequestMapping("profile/police") |
||||
@RestController |
||||
public class ProfilePoliceController { |
||||
|
||||
private final ProfilePoliceMapper profilePoliceMapper; |
||||
private final SupPoliceService policeService; |
||||
|
||||
private final BusinessPoliceService businessPoliceService; |
||||
|
||||
private final NegativeBlameService negativeBlameService; |
||||
private final NegativeService negativeService; |
||||
|
||||
|
||||
@GetMapping |
||||
public Result<Page<PoliceNegativeModel>> list(DepartPoliceQueryParam param) { |
||||
Date beginTime = DateUtil.parse("1949", "YYYY"); |
||||
Date endTime = new Date(); |
||||
if (Objects.nonNull(param.getCrtTime()) && !param.getCrtTime().isEmpty()) { |
||||
beginTime = param.getCrtTime().get(0); |
||||
endTime = param.getCrtTime().get(1); |
||||
} |
||||
Page<PoliceNegativeModel> page = profilePoliceMapper.queryPoliceNegative(Page.of(param.getCurrent(), param.getSize()), beginTime, endTime, param.getName(),param.getEmpNo(), param.getDepartId()); |
||||
return Result.success(page); |
||||
} |
||||
|
||||
@GetMapping("{idCode}") |
||||
public Result<ProfilePolice> profile(@PathVariable String idCode, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date beginTime, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) { |
||||
if (Objects.isNull(beginTime)) { |
||||
beginTime = DateUtil.parse("1949", "YYYY"); |
||||
} |
||||
if (Objects.isNull(endTime)) { |
||||
endTime = new Date(); |
||||
} |
||||
ProfilePolice profilePolice = new ProfilePolice(); |
||||
profilePolice.setPoliceInfo(policeService.getByIdCode(idCode)); |
||||
|
||||
int jcjBusinessSize = businessPoliceService.list(new LambdaQueryWrapper<BusinessPolice>() |
||||
.between(BusinessPolice::getDate, beginTime, endTime) |
||||
.eq(BusinessPolice::getBusinessType, BusinessTypeEnum.JCJ_110.getValue()) |
||||
.eq(BusinessPolice::getPoliceIdCode, idCode)) |
||||
.stream().mapToInt(BusinessPolice::getNumber).sum(); |
||||
|
||||
Set<String> negativeIds = negativeBlameService.list(new LambdaQueryWrapper<NegativeBlame>().eq(NegativeBlame::getBlameIdCode, idCode)).stream().map(NegativeBlame::getNegativeId).collect(Collectors.toSet()); |
||||
int jcjSize = negativeIds.isEmpty() ? 0 : negativeService.list(new LambdaQueryWrapper<Negative>() |
||||
.between(Negative::getCrtTime, beginTime, endTime) |
||||
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.JCJ_110.getValue()) |
||||
.in(Negative::getId, negativeIds) |
||||
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size(); |
||||
int zfbaBusinessSize = businessPoliceService.list(new LambdaQueryWrapper<BusinessPolice>() |
||||
.between(BusinessPolice::getDate, beginTime, endTime) |
||||
.eq(BusinessPolice::getBusinessType, BusinessTypeEnum.ZFBA.getValue()) |
||||
.eq(BusinessPolice::getPoliceIdCode, idCode)) |
||||
.stream().mapToInt(BusinessPolice::getNumber).sum(); |
||||
int zfbaSize = negativeIds.isEmpty() ? 0 : negativeService.list(new LambdaQueryWrapper<Negative>() |
||||
.between(Negative::getCrtTime, beginTime, endTime) |
||||
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.ZFBA.getValue()) |
||||
.in(Negative::getId, negativeIds) |
||||
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))).size(); |
||||
profilePolice.getNegativeInfo().setJcjBusinessSize(jcjBusinessSize).setJcjSize(jcjSize).setZfbaBusinessSize(zfbaBusinessSize).setZfbaSize(zfbaSize); |
||||
|
||||
List<Negative> list = negativeIds.isEmpty() ? new ArrayList<>() : negativeService.list(new LambdaQueryWrapper<Negative>() |
||||
.between(Negative::getCrtTime, beginTime, endTime) |
||||
.eq(Negative::getBusinessTypeCode, BusinessTypeEnum.JCJ_110.getValue()) |
||||
.in(Negative::getId, negativeIds) |
||||
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))); |
||||
// 问题来源占比
|
||||
Map<String, List<Negative>> problemSourcesGroup = list.stream().collect(Collectors.groupingBy(Negative::getProblemSourcesCode)); |
||||
List<PieItem> problemSourcesList = problemSourcesGroup.keySet().stream().map(key -> new PieItem(ProblemSourcesEnum.get(key).getLabel(), problemSourcesGroup.get(key).size())).toList(); |
||||
profilePolice.setProblemSourcesList(problemSourcesList); |
||||
// 业务类型占比
|
||||
Map<String, List<Negative>> businessTypeGroup = list.stream().collect(Collectors.groupingBy(Negative::getBusinessTypeCode)); |
||||
List<PieItem> businessTypeList = businessTypeGroup.keySet().stream().map(key -> new PieItem(BusinessTypeEnum.get(key).getLabel(), businessTypeGroup.get(key).size())).toList(); |
||||
profilePolice.setBusinessTypeList(businessTypeList); |
||||
return Result.success(profilePolice); |
||||
} |
||||
|
||||
@GetMapping("{idCode}/negative") |
||||
public Result<Page<Negative>> profile(@PathVariable String idCode, Page<Negative> page, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date beginTime, @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) { |
||||
if (Objects.isNull(beginTime)) { |
||||
beginTime = DateUtil.parse("1949", "YYYY"); |
||||
} |
||||
if (Objects.isNull(endTime)) { |
||||
endTime = new Date(); |
||||
} |
||||
Set<String> negativeIds = negativeBlameService.list(new LambdaQueryWrapper<NegativeBlame>().eq(NegativeBlame::getBlameIdCode, idCode)).stream().map(NegativeBlame::getNegativeId).collect(Collectors.toSet()); |
||||
if (negativeIds.isEmpty()) { |
||||
return Result.success(new Page<Negative>().setRecords(new ArrayList<>()).setTotal(0)); |
||||
} |
||||
Page<Negative> pageData = negativeService.page(page, new LambdaQueryWrapper<Negative>() |
||||
.between(Negative::getCrtTime, beginTime, endTime) |
||||
.in(Negative::getId, negativeIds) |
||||
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue()))); |
||||
return Result.success(pageData); |
||||
} |
||||
|
||||
@GetMapping("{idCode}/month") |
||||
public Result<JSONObject> listByMonth(@PathVariable String idCode) { |
||||
LocalDate now = LocalDate.now(); |
||||
List<String> months = new ArrayList<>(); |
||||
List<Long> values = new ArrayList<>(); |
||||
Set<String> negativeIds = negativeBlameService.list(new LambdaQueryWrapper<NegativeBlame>().eq(NegativeBlame::getBlameIdCode, idCode)).stream().map(NegativeBlame::getNegativeId).collect(Collectors.toSet()); |
||||
|
||||
for (int i = 11; i >= 0; i--) { |
||||
String month = now.minusMonths(i).format(DateTimeFormatter.ofPattern("yyyy年MM月")); |
||||
months.add(month); |
||||
long value = negativeIds.isEmpty() ? 0 : negativeService.count(new LambdaQueryWrapper<Negative>() |
||||
.in(Negative::getId, negativeIds) |
||||
.in(Negative::getCheckStatus, List.of(InspectCaseEnum.TRUE.getValue(), InspectCaseEnum.PARTIALLY_TRUE.getValue())) |
||||
.apply(" DATE_FORMAT(crtTime, '%Y年%m月') = '" + month + "'")); |
||||
values.add(value); |
||||
} |
||||
JSONObject jsonObject = new JSONObject().fluentPut("months", months).fluentPut("values", values); |
||||
return Result.success(jsonObject); |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,19 @@
|
||||
package com.biutag.supervision.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.biutag.supervision.pojo.model.DepartNegativeModel; |
||||
import com.biutag.supervision.pojo.model.PoliceNegativeModel; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2024/11/1 |
||||
*/ |
||||
public interface ProfilePoliceMapper { |
||||
|
||||
Page<PoliceNegativeModel> queryPoliceNegative(Page<PoliceNegativeModel> page, Date beginTime, Date endTime, String name, String empNo, String departId); |
||||
|
||||
|
||||
} |
||||
@ -0,0 +1,23 @@
|
||||
package com.biutag.supervision.pojo.domain; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import lombok.experimental.Accessors; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2024/11/3 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
@Accessors(chain = true) |
||||
public class NegativeInfo { |
||||
|
||||
private long size; |
||||
// 接处警
|
||||
private Integer jcjBusinessSize; |
||||
private Integer jcjSize; |
||||
// 执法办案
|
||||
private Integer zfbaBusinessSize; |
||||
private Integer zfbaSize; |
||||
} |
||||
@ -0,0 +1,23 @@
|
||||
package com.biutag.supervision.pojo.domain; |
||||
|
||||
import com.biutag.supervision.pojo.dto.common.PieItem; |
||||
import com.biutag.supervision.pojo.entity.SupPolice; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2024/11/3 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class ProfilePolice { |
||||
|
||||
private SupPolice policeInfo = new SupPolice(); |
||||
private NegativeInfo negativeInfo = new NegativeInfo(); |
||||
private List<PieItem> problemSourcesList = new ArrayList<>(); |
||||
private List<PieItem> businessTypeList = new ArrayList<>(); |
||||
} |
||||
@ -0,0 +1,18 @@
|
||||
package com.biutag.supervision.pojo.dto.common; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2024/10/29 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
@AllArgsConstructor |
||||
public class BarItem { |
||||
|
||||
private String label; |
||||
private Integer value; |
||||
} |
||||
@ -0,0 +1,29 @@
|
||||
package com.biutag.supervision.pojo.model; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.time.LocalDate; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2024/11/1 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class PoliceNegativeModel { |
||||
|
||||
private String name; |
||||
private String empNo; |
||||
private String IdCode; |
||||
private String position; |
||||
// 入职日期
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd") |
||||
private LocalDate employmentDate; |
||||
|
||||
// 查实问题数
|
||||
private Integer verifySize; |
||||
private String departName; |
||||
private String parentDepartName; |
||||
} |
||||
@ -0,0 +1,24 @@
|
||||
package com.biutag.supervision.pojo.param; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author wxc |
||||
* @date 2024/11/1 |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class DepartPoliceQueryParam extends BasePage { |
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private List<Date> crtTime = new ArrayList<>(); |
||||
private String name; |
||||
private String empNo; |
||||
private String departId; |
||||
} |
||||
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper |
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.biutag.supervision.mapper.ProfilePoliceMapper"> |
||||
|
||||
<select id="queryPoliceNegative" resultType="com.biutag.supervision.pojo.model.PoliceNegativeModel"> |
||||
SELECT |
||||
p.id_code, |
||||
p.NAME, |
||||
p.emp_no, |
||||
p.position, |
||||
p.employment_date, |
||||
d.short_name depart_name, |
||||
d1.short_name parent_depart_name, |
||||
count( DISTINCT n.id ) verify_size |
||||
FROM |
||||
sup_police p |
||||
LEFT JOIN sup_depart d ON p.org_id = d.id |
||||
LEFT JOIN sup_depart d1 ON d.pid = d1.id and d1.level = 2 |
||||
LEFT JOIN negative_blame nb ON p.id_code = nb.blameIdCode |
||||
LEFT JOIN negative n ON nb.negativeId = n.id |
||||
AND n.checkStatus IN ( '1', '2' ) |
||||
AND n.crtTime BETWEEN #{beginTime} AND #{endTime} |
||||
WHERE |
||||
1 = 1 |
||||
<if test="name != null and name != ''"> |
||||
AND p.name like concat('%', #{name}, '%') |
||||
</if> |
||||
<if test="empNo != null and empNo != ''"> |
||||
AND p.emp_no like concat('%', #{empNo}, '%') |
||||
</if> |
||||
<if test="departId != null and departId != ''"> |
||||
AND p.org_id = #{departId} |
||||
</if> |
||||
GROUP BY |
||||
p.id_code, |
||||
p.NAME, |
||||
p.emp_no, |
||||
p.employment_date, |
||||
d.short_name, |
||||
d1.short_name |
||||
ORDER BY |
||||
verify_size DESC |
||||
</select> |
||||
|
||||
|
||||
</mapper> |
||||
Loading…
Reference in new issue