Commit a023a242 authored by xinglei's avatar xinglei

*)增加生成监察指令书编码接口

parent 4306404a
package com.yeejoin.amos.boot.module.tzs.flc.api.dto;
import lombok.Data;
import java.util.List;
/**
* @Author: xl
* @Description:
* @Date: 2022/7/21 16:51
*/
@Data
public class BizRecordCount {
String title;
String fieldKey;
String fieldValue;
String tableName;
String expression;
List<BizRecordItem> bizRecordItems;
@Data
public static class BizRecordItem {
String tableName;
String columnPrefix;
Integer columnIndex;
String columnValue;
}
}
......@@ -27,6 +27,9 @@ public class TaskDto extends BaseDto {
@ApiModelProperty(value = "内容")
private String content;
@ApiModelProperty(value = "任务类型")
private String taskType;
@ApiModelProperty(value = "描述")
private String description;
......
......@@ -35,6 +35,12 @@ public class Task extends BaseEntity {
private String content;
/**
* 内容
*/
@TableField("task_type")
private String taskType;
/**
* 描述
*/
@TableField("description")
......
package com.yeejoin.amos.boot.module.tzs.flc.api.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.BizRecordCount;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.IdxUjer;
import java.util.List;
import java.util.Map;
public interface InspectionService {
IPage<IdxUjer> bizDetailList(String dimensionTableId, String selectValue, String bizType, int current, int size);
List<Map<String, Object>> bizRecordCountByField(List<BizRecordCount> bizRecordCountList);
JSONObject getSafetySupervisionCode(String bizTable);
JSONObject getSafetySupervisionInfo();
}
package com.yeejoin.amos.boot.module.tzs.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.BizRecordCount;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.IdxUjer;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.InspectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/Inspection")
@Api(value = "双重预防 监察处置分析")
@Api(value = "监察处置分析")
public class InspectionController {
@Autowired
InspectionService inspectionService;
/**
* 双重预防
* @param dimensionTableId
* @param selectValue
* @param bizType
* @param current
* @param size
* @return
*/
@GetMapping("/bizDetailList")
@ApiOperation(value = "检察任务填报详情")
@TycloudOperation(ApiLevel = UserType.AGENCY)
......@@ -36,4 +47,39 @@ public class InspectionController {
IPage<IdxUjer> page = inspectionService.bizDetailList(dimensionTableId, selectValue, bizType, current, size);
return ResponseHelper.buildResponse(page);
}
/**
* 生产、使用环节
* @param bizRecordCountList
* @return
*/
@PostMapping("/safetySupervision")
@ApiOperation(value = "安全监察统计")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel<List<Map<String, Object>>> safetySupervisionList(@RequestBody List<BizRecordCount> bizRecordCountList) {
return ResponseHelper.buildResponse(inspectionService.bizRecordCountByField(bizRecordCountList));
}
/**
* 生成安全监察指令书编号
* @param bizTable
* @return
*/
@GetMapping("/getSafetySupervisionCode")
@ApiOperation(value = "生成安全监察指令书编号")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel<JSONObject> getSafetySupervisionCode(@RequestParam String bizTable) {
return ResponseHelper.buildResponse(inspectionService.getSafetySupervisionCode(bizTable));
}
/**
* 查询行政复议机构和行政诉讼机构
* @return
*/
@GetMapping("/getSafetySupervisionInfo")
@ApiOperation(value = "查询行政复议机构和行政诉讼机构")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel<JSONObject> getSafetySupervisionInfo() {
return ResponseHelper.buildResponse(inspectionService.getSafetySupervisionInfo());
}
}
package com.yeejoin.amos.boot.module.tzs.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.JsonValueUtils;
import com.yeejoin.amos.boot.module.tzs.api.mapper.IdxUjerMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.dto.BizRecordCount;
import com.yeejoin.amos.boot.module.tzs.flc.api.entity.IdxUjer;
import com.yeejoin.amos.boot.module.tzs.flc.api.feign.IdxFeignService;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.InspectionService;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.apache.commons.lang.text.StrSubstitutor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import java.util.List;
import java.util.*;
@Service
public class InspectionServiceImpl implements InspectionService {
......@@ -24,6 +37,10 @@ public class InspectionServiceImpl implements InspectionService {
@Autowired
IdxUjerMapper idxUjerMapper;
@Autowired
JdbcTemplate bizJdbcTemplate;
@Override
public IPage<IdxUjer> bizDetailList(
String dimensionTableId,
String selectValue,
......@@ -33,4 +50,126 @@ public class InspectionServiceImpl implements InspectionService {
IPage<IdxUjer> idxUjerPage = new Page<>(current, size);
return idxUjerMapper.getPage(idxUjerPage, ids, bizType);
}
@Override
public List<Map<String, Object>> bizRecordCountByField(List<BizRecordCount> bizRecordCountList) {
List<Map<String, Object>> result = new ArrayList<>();
for (BizRecordCount requestData : bizRecordCountList) {
Map map = JSONObject.parseObject(JSONObject.toJSONString(requestData), Map.class);
StrSubstitutor ss = new StrSubstitutor(map);
String selectSql = "SELECT ";
if (!ValidationUtil.isEmpty(requestData.getBizRecordItems())) {
requestData.setExpression(buildBizRecordItems(requestData.getBizRecordItems()));
}
if (!ValidationUtil.isEmpty(requestData.getExpression())) {
selectSql += requestData.getExpression() + " as count";
} else {
selectSql += "COUNT(*) count";
}
if (!ValidationUtil.isEmpty(requestData.getTableName())) {
selectSql = selectSql + " FROM ${tableName}";
}
if (!ValidationUtil.isEmpty(requestData.getFieldKey())) {
selectSql = selectSql + (selectSql.contains("WHERE") ? " AND" : " WHERE") + " ${fieldKey}='${fieldValue}'";
}
selectSql = ss.replace(selectSql);
Map<String, Object> queryResult = bizJdbcTemplate.queryForMap(selectSql);
HashMap<String, Object> item = new HashMap<>();
item.put("key", requestData.getTitle());
item.put("value", queryResult.get("count"));
result.add(item);
}
return result;
}
@Override
public JSONObject getSafetySupervisionCode(String bizTable) {
String safetySupervisionCode = "(%s)市监特令中[%s]第 %s 号";
AgencyUserModel agencyUserModel = Privilege.agencyUserClient.getme().getResult();
Object reginSeq = JsonValueUtils.getValueByKey(JSONObject.parse(JSON.toJSONString(agencyUserModel)), "companys", "companys.0.regionSeq");
String region = "";
if (!ValidationUtil.isEmpty(reginSeq)) {
List<RegionModel> result = Systemctl.regionClient.queryDeptByIds(reginSeq.toString()).getResult();
for (int i = 0; i < result.size(); i++) {
RegionModel regionModel = result.get(i);
String regionName = regionModel.getRegionName();
if (regionName.contains("市") || regionName.contains("区") || regionName.contains("县")) {
region = region + regionName.substring(0, 1);
}
}
}
String countSql = "SELECT count(1) FROM " + bizTable;
Long count = bizJdbcTemplate.queryForObject(countSql, Long.class);
int year = DateUtils.getYear(DateUtils.getDateNow());
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", String.format(safetySupervisionCode, region, year, count + 1));
return jsonObject;
}
@Override
public JSONObject getSafetySupervisionInfo() {
AgencyUserModel agencyUserModel = Privilege.agencyUserClient.getme().getResult();
Object companyId = JsonValueUtils.getValueByKey(JSONObject.parse(JSON.toJSONString(agencyUserModel)), "companys", "companys.0.sequenceNbr");
Collection<CompanyModel> result = Privilege.companyClient.queryAgencyTree(null).getResult();
JSONObject jsonObject = getParentCompanyName(JSONArray.parseArray(JSONArray.toJSONString(result)), companyId);
if (!ValidationUtil.isEmpty(jsonObject)){
String parentCompanyName = jsonObject.getString("companyName");
jsonObject.clear();
jsonObject.put("reconsiderOrgName", parentCompanyName + "/" + parentCompanyName.substring(0, parentCompanyName.indexOf("区") + 1) + "人民政府");
jsonObject.put("lawsuitOrgName", parentCompanyName.substring(0, parentCompanyName.indexOf("区") + 1) + "人员法院");
} else {
jsonObject = new JSONObject();
jsonObject.put("reconsiderOrgName", "");
jsonObject.put("lawsuitOrgName", "");
}
return jsonObject;
}
private String buildBizRecordItems(List<BizRecordCount.BizRecordItem> bizRecordItems) {
String sql = "";
for (BizRecordCount.BizRecordItem item : bizRecordItems) {
StringJoiner whereSql = new StringJoiner(" OR ");
for (int i = 1; i <= item.getColumnIndex(); i++) {
whereSql.add(String.format("%s%s='%s'", item.getColumnPrefix(), i, item.getColumnValue()));
}
sql = ValidationUtil.isEmpty(sql) ? "" : "+" + String.format("(SELECT count(*) FROM %s WHERE %s)", item.getTableName(), whereSql);
}
return sql;
}
private static JSONObject getParentCompanyName(JSONArray companyModels, Object companyId) {
for (int i = 0; i < companyModels.size(); i++) {
JSONObject jsonObject = findCompanyById(companyModels.getJSONObject(i), companyId);
if (!ValidationUtil.isEmpty(jsonObject)) {
return findCompanyById(companyModels.getJSONObject(i), jsonObject.getString("parentId"));
}
}
return null;
}
private static JSONObject findCompanyById(JSONObject treeNode, Object companyId) {
if (treeNode.getString("sequenceNbr").equals(companyId)) {
return treeNode;
} else {
JSONArray children = treeNode.getJSONArray("children");
if (!ValidationUtil.isEmpty(children)) {
for (int i = 0; i < children.size(); i++) {
JSONObject result = findCompanyById(children.getJSONObject(i), companyId);
if (!ValidationUtil.isEmpty(result)) {
return result;
}
}
}
return null;
}
}
}
......@@ -109,11 +109,15 @@ public class TaskController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "任务表分页查询", notes = "任务表分页查询")
public ResponseModel<Page<TaskDto>> queryForPage(@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size,
@RequestParam(value = "status", required = false) String status) {
@RequestParam(value = "sendTimeStart", required = false) String sendTimeStart,
@RequestParam(value = "sendTimeEnd", required = false) String sendTimeEnd,
@RequestParam(value = "taskType", required = false) String taskType,
@RequestParam(value = "status", required = false) String status,
@RequestParam(value = "content", required = false) String content) {
Page<TaskDto> page = new Page<TaskDto>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(taskServiceImpl.queryForTaskPageByStatus(page, RequestContext.getExeUserId(), status));
return ResponseHelper.buildResponse(taskServiceImpl.queryForTaskPageByParams(page, RequestContext.getExeUserId(), sendTimeStart, sendTimeEnd, taskType, status, content));
}
/**
......
......@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.module.tzs.flc.api.enums.TaskStatusEnum;
import com.yeejoin.amos.boot.module.tzs.flc.api.mapper.TaskMapper;
import com.yeejoin.amos.boot.module.tzs.flc.api.service.ITaskService;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -32,9 +33,15 @@ public class TaskServiceImpl extends BaseService<TaskDto, Task, TaskMapper> impl
this.updateWithModel(taskDto);
}
public Page<TaskDto> queryForTaskPageByStatus(Page<TaskDto> page, String userId, String status) {
public Page<TaskDto> queryForTaskPageByParams(Page<TaskDto> page, String userId, String sendTimeStart, String sendTimeEnd, String taskType, String status, String content) {
List<Integer> statusList = getStatus(status);
return this.queryForTaskPage(page, userId, statusList);
if (!ValidationUtil.isEmpty(sendTimeStart) && !ValidationUtil.isEmpty(sendTimeEnd)){
Date[] createDate = new Date[2];
createDate[0] = DateUtils.getCurrentDayStartTime(DateUtils.longStr2Date(sendTimeStart));
createDate[1] = DateUtils.getCurrentDayEndTime(DateUtils.longStr2Date(sendTimeEnd));
return this.queryForTaskPageByCreateDate(page, userId, createDate, taskType, statusList, content);
}
return this.queryForTaskPage(page, userId, taskType,statusList, content);
}
public JSONObject queryCountForMap(String userId){
......@@ -61,8 +68,16 @@ public class TaskServiceImpl extends BaseService<TaskDto, Task, TaskMapper> impl
/**
* 分页查询
*/
public Page<TaskDto> queryForTaskPage(Page<TaskDto> page, String userId, @Condition(Operator.in) List<Integer> status) {
return this.queryForPage(page, "rec_date", false, userId, status);
public Page<TaskDto> queryForTaskPage(Page<TaskDto> page, String userId, String taskType, @Condition(Operator.in) List<Integer> status, @Condition(Operator.like) String content) {
return this.queryForPage(page, "rec_date", false, userId, taskType, status, content);
}
/**
* 分页查询(含日期)
*/
public Page<TaskDto> queryForTaskPageByCreateDate(Page<TaskDto> page, String userId, @Condition(Operator.between) Date[] createDate, String taskType, @Condition(Operator.in) List<Integer> status, @Condition(Operator.like) String content) {
return this.queryForPage(page, "rec_date", false, userId, createDate, taskType, status, content);
}
/**
......
......@@ -1495,5 +1495,15 @@
</sql>
</changeSet>
<changeSet author="xl" id="2022-06-27-01">
<preConditions onFail="MARK_RAN">
<tableExists tableName="tz_task"/>
</preConditions>
<comment>modify table tz_task add task_type columns</comment>
<sql>
ALTER TABLE `tz_task` add task_type varchar(255) DEFAULT NULL COMMENT '任务类型';
</sql>
</changeSet>
</databaseChangeLog>
......@@ -24,5 +24,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment