diff --git a/src/main/java/com/biutag/supervision/controller/datav/DatavRightsComfortController.java b/src/main/java/com/biutag/supervision/controller/datav/DatavRightsComfortController.java index 7dff98c..edeee4c 100644 --- a/src/main/java/com/biutag/supervision/controller/datav/DatavRightsComfortController.java +++ b/src/main/java/com/biutag/supervision/controller/datav/DatavRightsComfortController.java @@ -1,20 +1,10 @@ package com.biutag.supervision.controller.datav; -import cn.hutool.core.util.NumberUtil; -import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.biutag.supervision.constants.enums.CaseVerifProblemNatureEnum; -import com.biutag.supervision.constants.enums.DepartGroupEnum; -import com.biutag.supervision.mapper.DataRightsComfortMapper; -import com.biutag.supervision.mapper.RpcApplyMapper; import com.biutag.supervision.pojo.Result; -import com.biutag.supervision.pojo.dto.CaseVerifDepart; -import com.biutag.supervision.pojo.dto.common.PieItem; -import com.biutag.supervision.pojo.entity.DataCaseVerif; -import com.biutag.supervision.pojo.entity.DataRightsComfort; -import com.biutag.supervision.pojo.entity.RpcApply; +import com.biutag.supervision.pojo.model.DataRightsComfortModel; import com.biutag.supervision.service.DataRightsComfortService; import com.biutag.supervision.service.RpcApplyService; +import com.biutag.supervision.service.RpcInfringerResultService; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.web.bind.annotation.GetMapping; @@ -22,9 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.math.BigDecimal; import java.util.Date; -import java.util.List; @RequestMapping("datav/rightsComfort") @RequiredArgsConstructor @@ -33,47 +21,34 @@ public class DatavRightsComfortController { private final RpcApplyService rpcApplyService; - private final RpcApplyMapper rpcApplyMapper; + private final DataRightsComfortService dataRightsComfortService; + private final RpcInfringerResultService rpcInfringerResultService; @GetMapping - public Result rightsComfort(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { + public Result rightsComfort(@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { + DataRightsComfortModel result = new DataRightsComfortModel(); + // 维权案件总数 + + // 受侵害人数 + // 抚慰人数 - long total = rpcApplyService.count(new LambdaQueryWrapper().between(RpcApply::getApplyDate, beginTime, endTime)); - long confirmed = 0; - JSONObject overview = new JSONObject() - // 抚慰人数 - .fluentPut("total", total); - /* // 维权案件总数 - .fluentPut("confirmed", 0) - // 受侵害人数 - .fluentPut("investigateAndPunish", 0) - // 打击处理人数 - .fluentPut("accountablePeopleNumber", 0) - // 抚慰金额(万元) - .fluentPut("accountableDepartNumber", 0) - // 查实率 - .fluentPut("confirmedRate", total == 0 ? 0 : BigDecimal.valueOf(NumberUtil.div(confirmed, total) * 100).intValue()); - // 分县市局排名 - List fxsjBarList = dataCaseVerifMapper.selectDepartStatistic(DepartGroupEnum.COUNTY_CITY_BUREAUS.getId(), beginTime, endTime); - // 局属单位排名 - List jsdwBarList = dataCaseVerifMapper.selectDepartStatistic(DepartGroupEnum.BUREAU_AFFILIATED.getId(), beginTime, endTime); - // 执法办案 - List zfbaPieList = dataCaseVerifMapper.selectInvolveProblemGroupByBusinessTypeName(CaseVerifProblemNatureEnum.ZFBA.getLaebl(), beginTime, endTime); - // 服务管理 - List fwglPieList = dataCaseVerifMapper.selectInvolveProblemGroupByBusinessTypeName(CaseVerifProblemNatureEnum.FWGL.getLaebl(), beginTime, endTime); - // 警察纪警规 - List jjjgPieList = dataCaseVerifMapper.selectInvolveProblemGroupByBusinessTypeName(CaseVerifProblemNatureEnum.JJJG.getLaebl(), beginTime, endTime); - // 案件来源占比 - List ajlyPieList = dataCaseVerifMapper.selectGroupByProblemSources(beginTime, endTime); + result.setComfortPersonNumber(dataRightsComfortService.countComfortPersonNumber(beginTime, endTime)); + // 打击处理人数 + result.setHitPersonNumber(dataRightsComfortService.countHitPersonNumber(beginTime, endTime)); + // 抚慰金额(万元) + result.setComfortMoney(dataRightsComfortService.countComfortMoney(beginTime, endTime)); + // 维权案件情况 + + // 案件类别占比 + + // 打处情况 + result.setPunishmentSituation(dataRightsComfortService.selectPunishmentSituation(beginTime, endTime)); + // 抚慰情况 + result.setComfortSituation(dataRightsComfortService.selectComfortSituation(beginTime, endTime)); + // 民辅警受伤情况 + + // 发案情况占比 - JSONObject data = new JSONObject().fluentPut("overview", overview) - .fluentPut("fxsjBarList", fxsjBarList) - .fluentPut("jsdwBarList", jsdwBarList) - .fluentPut("zfbaPieList", zfbaPieList) - .fluentPut("fwglPieList", fwglPieList) - .fluentPut("jjjgPieList", jjjgPieList) - .fluentPut("ajlyPieList", ajlyPieList); - return Result.success(data);*/ - return null; + return Result.success(result); } } diff --git a/src/main/java/com/biutag/supervision/controller/system/PoliceController.java b/src/main/java/com/biutag/supervision/controller/system/PoliceController.java index 6886f37..5d93851 100644 --- a/src/main/java/com/biutag/supervision/controller/system/PoliceController.java +++ b/src/main/java/com/biutag/supervision/controller/system/PoliceController.java @@ -2,27 +2,35 @@ package com.biutag.supervision.controller.system; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelReader; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.read.listener.ReadListener; +import com.alibaba.excel.read.metadata.ReadSheet; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.biutag.supervision.constants.enums.DepartLevelEnum; +import com.biutag.supervision.constants.enums.InitialPetition; import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.domain.PoliceAuth; -import com.biutag.supervision.pojo.entity.NegDepartAuthority; -import com.biutag.supervision.pojo.entity.NegSourceAuthority; -import com.biutag.supervision.pojo.entity.SupDepart; -import com.biutag.supervision.pojo.entity.SupPolice; +import com.biutag.supervision.pojo.dto.PoliceImport; +import com.biutag.supervision.pojo.entity.*; import com.biutag.supervision.pojo.model.PoliceModel; import com.biutag.supervision.pojo.param.PoliceQueryParam; -import com.biutag.supervision.service.NegDepartAuthorityService; -import com.biutag.supervision.service.NegSourceAuthorityService; -import com.biutag.supervision.service.SupDepartService; -import com.biutag.supervision.service.SupPoliceService; +import com.biutag.supervision.service.*; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validator; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; -import java.util.Date; -import java.util.List; -import java.util.Objects; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; @RequestMapping("police") @RequiredArgsConstructor @@ -37,6 +45,8 @@ public class PoliceController { private final NegSourceAuthorityService negSourceAuthorityService; + private final Validator validator; + @GetMapping public Result> list(PoliceQueryParam param) { return Result.success(policeService.page(param)); @@ -105,4 +115,138 @@ public class PoliceController { return Result.success(); } + private final BaseUserService userService; + private final BaseAccountService accountService; + private final SupDictProblemSourceService dictProblemSourceService; + + @PostMapping("import") + public Result> importExcel(@RequestPart("file") MultipartFile file) throws IOException { + String fileNameType = FileUtil.extName(file.getOriginalFilename()); + if (!"xls".equals(fileNameType) && !"xlsx".equals(fileNameType)) { + throw new RuntimeException("仅支持 xls/xlsx 格式文件的导入"); + } + List list = new ArrayList<>(); + List problemSources = dictProblemSourceService.list(); + ExcelReader excelReader = EasyExcel.read(file.getInputStream(), PoliceImport.class, new ReadListener() { + @Override + public void invoke(PoliceImport data, AnalysisContext analysisContext) { + Set> validate = validator.validate(data); + if (!validate.isEmpty()) { + String message = validate.stream().map(ConstraintViolation::getMessage).collect(Collectors.joining("\n")); + throw new RuntimeException(String.format("第%s条数据的异常:%s", list.size() + 1, message)); + } + list.add(data); + } + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + } + }).build(); + ReadSheet sheet = EasyExcel.readSheet(0).build(); + excelReader.read(sheet); + excelReader.close(); + for (int i = 0; i < list.size(); i++) { + PoliceImport police = list.get(i); + SupDepart depart; + if (StrUtil.isBlank(police.getThirdDepartName())) { + depart = departService.getOne(new LambdaQueryWrapper().eq(SupDepart::getShortName, police.getSecondDepartName()).eq(SupDepart::getLevel, 2)); + } else { + SupDepart secondDepart = departService.getOne(new LambdaQueryWrapper().eq(SupDepart::getShortName, police.getSecondDepartName()).eq(SupDepart::getLevel, 2)); + depart = departService.getOne(new LambdaQueryWrapper().eq(SupDepart::getPid, secondDepart.getId()) + .eq(SupDepart::getShortName, police.getThirdDepartName()).eq(SupDepart::getLevel, 3)); + } + SupPolice supPolice = policeService.getByIdCode(list.get(i).getIdCode()); + if (supPolice == null) { + supPolice = new SupPolice(); + supPolice.setName(police.getName()); + supPolice.setIdCode(police.getIdCode()); + supPolice.setEmpNo(police.getEmpNo()); + supPolice.setOrgId(depart.getId()); + if (police.getEmpNo().contains("A")) { + supPolice.setPersonType("3"); + } else { + supPolice.setPersonType("1"); + } + policeService.save(supPolice); + + } else { + supPolice.setName(police.getName()); + supPolice.setIdCode(police.getIdCode()); + supPolice.setEmpNo(police.getEmpNo()); + supPolice.setOrgId(depart.getId()); + if (police.getEmpNo().contains("A")) { + supPolice.setPersonType("3"); + } else { + supPolice.setPersonType("1"); + } + policeService.updateById(supPolice); + } + if ("三级机构专班".equals(police.getRole()) || "二级机构专班".equals(police.getRole())) { + String userId = saveOrUpdateUser(police); + // 角色 + addRoleUser(userId, police.getRole()); + // 权限 + addAuth(police.getIdCode(), supPolice.getOrgId(), problemSources); + } + + } + return Result.success(list); + } + + public String saveOrUpdateUser(PoliceImport police) { + BaseUser user = userService.getByUserName(police.getIdCode()); + if (user != null) { + return user.getUserId(); + } + BaseUser baseUser = new BaseUser(); + baseUser.setUserName(police.getIdCode()); + baseUser.setNickName(police.getName()); + baseUser.setUserType("admin"); + baseUser.setCreateTime(LocalDateTime.now()); + baseUser.setUpdateTime(LocalDateTime.now()); + userService.save(baseUser); + BaseAccount account = new BaseAccount(); + account.setAccount(police.getIdCode()); + account.setUserId(baseUser.getUserId()); + account.setAccountType("username"); + account.setDomain("@admin.com"); + account.setPassword("$2a$10$q0NbHH1fbkDotxJ1dT7PbOcV4G47R8n15uVxz2.imTiDqdCwAJYBC"); + account.setDomain("@admin.com"); + account.setCreateTime(LocalDateTime.now()); + account.setUpdateTime(LocalDateTime.now()); + accountService.save(account); + return baseUser.getUserId(); + } + + private final BaseRoleUserService roleUserService; + public void addRoleUser(String userId, String role) { + roleUserService.remove(new LambdaQueryWrapper().eq(BaseRoleUser::getUserId, userId)); + BaseRoleUser baseRoleUser = new BaseRoleUser(); + baseRoleUser.setUserId(userId); + if ("三级机构专班".equals(role)) { + baseRoleUser.setRoleId("5"); + } + if ("二级机构专班".equals(role)) { + baseRoleUser.setRoleId("4"); + } + baseRoleUser.setCreateTime(LocalDateTime.now()); + baseRoleUser.setUpdateTime(LocalDateTime.now()); + roleUserService.save(baseRoleUser); + } + + public void addAuth(String idCode, String orgId, List problemSources) { + negDepartAuthorityService.remove(new LambdaQueryWrapper().eq(NegDepartAuthority::getIdCode, idCode)); + NegDepartAuthority authority = new NegDepartAuthority(); + authority.setDepartId(orgId); + authority.setIdCode(idCode); + negDepartAuthorityService.save(authority); + negSourceAuthorityService.remove(new LambdaQueryWrapper().eq(NegSourceAuthority::getIdCode, idCode)); + + List list = problemSources.stream().map(item -> { + NegSourceAuthority sourceAuthority = new NegSourceAuthority(); + sourceAuthority.setIdCode(idCode); + sourceAuthority.setSource(item.getId()); + return sourceAuthority; + }).toList(); + negSourceAuthorityService.saveBatch(list); + } } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/mapper/ModelClueDataMapper.java b/src/main/java/com/biutag/supervision/mapper/ModelClueDataMapper.java index 555f43d..d7a8a46 100644 --- a/src/main/java/com/biutag/supervision/mapper/ModelClueDataMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/ModelClueDataMapper.java @@ -17,4 +17,6 @@ public interface ModelClueDataMapper extends BaseMapper { @Select("${newSql}") List> selectByUniqueKeys(@org.apache.ibatis.annotations.Param("newSql") String newSql); + @Select("SELECT XM, JH FROM dwd_ry_zfba_baryxx WHERE ZJ = #{barID}") + Map selectBAR(String barID); } diff --git a/src/main/java/com/biutag/supervision/mapper/ModelClueTaskMapper.java b/src/main/java/com/biutag/supervision/mapper/ModelClueTaskMapper.java index 3274a9f..5574098 100644 --- a/src/main/java/com/biutag/supervision/mapper/ModelClueTaskMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/ModelClueTaskMapper.java @@ -1,8 +1,16 @@ package com.biutag.supervision.mapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.toolkit.Constants; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.biutag.supervision.pojo.entity.ModelClueTask; +import com.biutag.supervision.pojo.model.ModelClueTaskModel; +import com.biutag.supervision.pojo.model.NegativeWorkModel; +import org.apache.ibatis.annotations.Param; public interface ModelClueTaskMapper extends BaseMapper { + Page queryPage(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); + } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/mapper/RpcApplyMapper.java b/src/main/java/com/biutag/supervision/mapper/RpcApplyMapper.java index de061dc..293a8e0 100644 --- a/src/main/java/com/biutag/supervision/mapper/RpcApplyMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/RpcApplyMapper.java @@ -1,8 +1,37 @@ package com.biutag.supervision.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.biutag.supervision.pojo.dto.common.PieItem; import com.biutag.supervision.pojo.entity.RpcApply; +import com.biutag.supervision.pojo.entity.RpcInfringerResult; +import org.apache.ibatis.annotations.Select; + +import java.util.Date; +import java.util.List; public interface RpcApplyMapper extends BaseMapper { + @Select("SELECT COUNT(a.rpc_id) FROM rpc_apply_person a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2") + Integer countComfortPersonNumber(Date beginTime, Date endTime); + + @Select("SELECT a.tort_name FROM rpc_infringer_result a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2") + List getHitPeople(Date beginTime, Date endTime); + + @Select("SELECT SUM(a.provide_relief) FROM rpc_apply_person a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2") + Double countComfortMoney(Date beginTime, Date endTime); + + @Select("select tort_name, defend_handle_way_name from rpc_infringer_result a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2") + List selectPunishmentSituation(Date beginTime, Date endTime); + + @Select("SELECT c.job name, COUNT(c.job) value FROM sup_police c JOIN " + + "(SELECT a.emp_no FROM rpc_apply_person a LEFT JOIN rpc_apply b ON a.rpc_id = b.rpc_id " + + "WHERE b.apply_date BETWEEN #{beginTime} AND #{endTime} AND b.type = 2) d on c.emp_no = d.emp_no " + + "GROUP BY c.job") + List selectComfortSituation(Date beginTime, Date endTime); + + } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java b/src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java index e06405f..1ab38d0 100644 --- a/src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/SupExternalDepartMapper.java @@ -10,7 +10,7 @@ import java.util.Map; public interface SupExternalDepartMapper extends BaseMapper { @Select("