Commit effb3b94 authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_register' of…

Merge branch 'develop_tzs_register' of http://39.100.92.250:5000/moa/amos-boot-biz into develop_tzs_register
parents 6f74f827 39bd6f44
......@@ -162,7 +162,8 @@ public class JgChangeRegistrationNameController extends BaseController {
dto.setUseUnitCreditCode(getSelectedOrgInfo().getCompany().getCompanyCode());
}
}
dto.setCertificateStatus("已登记");
// 错误注使用销业务导出后续业务无法做,故放开限制 @2025-06-27
// dto.setCertificateStatus("已登记");
dto.setIsDoBusiness("1");
return ResponseHelper.buildResponse(jgChangeRegistrationNameService.getTableData(dto));
}
......
......@@ -203,8 +203,11 @@ public class JgChangeRegistrationReformController extends BaseController {
if (!ObjectUtils.isEmpty(transferType)) {
dto.setIsScrap("0");
}
// 错误注使用销业务导出后续业务无法做,故放开限制 @2025-06-27
if (!ValidationUtil.isEmpty(transferType) && "1".equals(transferType)) {
//区外移装查询已注销状态的证
dto.setCertificateStatus("1".equals(transferType) ? "已注销" : "已登记");
dto.setCertificateStatus("已注销");
}
dto.setIsDoBusiness("1");//默认可以做业务
return ResponseHelper.buildResponse(jgChangeRegistrationReformServiceImpl.getUseRegistrationCodeData(page, dto));
}
......
......@@ -263,7 +263,7 @@ public class JgTableDataExportController extends BaseController {
@GetMapping(value = "/enterpriseInformationExport")
@ApiOperation(httpMethod = "GET", value = "基础设置-企业信息列表数据导出", notes = "基础设置-企业信息列表数据导出")
public ResponseModel<String> managePipe(@RequestParam(value = "ids", required = false) String ids,
@RequestParam Map<String, String> map) {
@RequestParam Map<String, Object> map) {
String uuid = UUID.randomUUID().toString();
iJgTableDataExportService.startDownLoadMsg("企业信息列表", uuid);
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
......@@ -279,7 +279,7 @@ public class JgTableDataExportController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "基础设置-企业-人员信息列表数据导出", notes = "基础设置-企业-人员信息列表数据导出")
public ResponseModel<String> userInfoExport(@RequestParam(value = "ids", required = false) String ids,
@RequestParam(value = "sort", required = false) String sort,
@RequestParam Map<String, String> map) {
@RequestParam Map<String, Object> map) {
String uuid = UUID.randomUUID().toString();
iJgTableDataExportService.startDownLoadMsg("人员信息列表", uuid);
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
......@@ -294,7 +294,7 @@ public class JgTableDataExportController extends BaseController {
@PostMapping(value = "/userInfoExportWithAdmin")
@ApiOperation(httpMethod = "POST", value = "基础设置-监管单位-人员信息列表数据导出", notes = "基础设置-监管单位-人员信息列表数据导出")
public ResponseModel<String> userInfoExportWithAdmin(@RequestParam(value = "ids", required = false) String ids,
@RequestBody Map<String, String> map) {
@RequestBody Map<String, Object> map) {
String uuid = UUID.randomUUID().toString();
iJgTableDataExportService.startDownLoadMsg("人员信息列表", uuid);
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
......
......@@ -21,6 +21,6 @@ public interface JczsServiceFeignClient {
ResponseModel<Page<Map<String, String>>> page(@RequestParam("current") int current,
@RequestParam("size") int size,
@RequestParam("keyword") String keyword,
@RequestParam Map<String, String> map);
@RequestParam Map<String, Object> map);
}
......@@ -20,13 +20,13 @@ public interface TcmServiceFeignClient {
ResponseModel<Page<Map<String, String>>> page(@RequestParam(value = "current") String current,
@RequestParam(value = "size") String size,
@RequestParam(value = "sort", required = false) String sort,
@RequestParam Map<String, String> dto);
@RequestParam Map<String, Object> dto);
@RequestMapping(value = "/userInfo/permission-page", method = RequestMethod.POST)
ResponseModel<Page<Map<String, String>>> getUserByPermission(@RequestParam(value = "current") long current,
@RequestParam(value = "size") long size,
@RequestParam(value = "sort", required = false) String sort,
@RequestParam(required = false, defaultValue = "all") String type,
@RequestBody Map<String, String> map);
@RequestBody Map<String, Object> map);
}
......@@ -59,9 +59,9 @@ public interface IJgTableDataExportService {
void unregulatedPipe(String uuid, Map<String, String> params, String sort, ReginParams reginParams);
void enterpriseInformationExport(String uuid, String ids, Map<String, String> map);
void enterpriseInformationExport(String uuid, String ids, Map<String, Object> map);
void userInfoExport(String uuid, String ids, Map<String, String> map);
void userInfoExport(String uuid, String ids, Map<String, Object> map);
void userInfoExportWithAdmin(String uuid, String ids, Map<String, String> map);
void userInfoExportWithAdmin(String uuid, String ids, Map<String, Object> map);
}
......@@ -148,6 +148,8 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
public static final String EQU_CATEGORY_CODE = "EQU_CATEGORY_CODE";
public static final String EQU_LIST_CODE = "EQU_LIST_CODE";
public static final String PROJECT_CONTRAPTION = "PROJECT_CONTRAPTION";// 工程装置名称
public static final String CREATE_DATE_RANGE = "CREATE_DATE_RANGE";// 创建时间范围查询
public static final String CREATE_DATE = "CREATE_DATE";// 创建时间范围查询
/**
* 业务类型 0:单个新增 1:批量导入
*/
......@@ -2397,7 +2399,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
if (map.containsKey("flag") && !map.containsKey("USE_UNIT_CREDIT_CODE")) {
return new Page<>();
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Integer pageNumber = ObjectUtils.isEmpty(map.getInteger("number")) ? 1 : map.getInteger("number");
Integer size = ObjectUtils.isEmpty(map.getInteger("size")) ? 20 : map.getInteger("size");
Page<JSONObject> result = new Page<>(pageNumber, size);
......@@ -2769,6 +2771,37 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(map.getString("ORG_BRANCH_CODE")) + "*"));
}
}
// 创建时间范围查询
if (!ObjectUtils.isEmpty(map.getString(CREATE_DATE_RANGE))) {
String createDateRangeObj = map.getString(CREATE_DATE_RANGE);
String[] split = createDateRangeObj.replace("[", "").replace("]", "").split(",");
String startDateStr = split[0];
String endDateStr = split[1];
try {
Date startDate = sdf.parse(startDateStr);
Date endDate = sdf.parse(endDateStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(endDate);
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 999);
endDate = calendar.getTime();
long startDateMillis = startDate.getTime();
long endDateMillis = endDate.getTime();
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
pBuilder.must(QueryBuilders.rangeQuery("CREATE_DATE")
.gte(startDateMillis) // 大于等于开始日期的时间戳
.lte(endDateMillis) // 小于等于结束日期的时间戳
);
boolMust.must(pBuilder);
} catch (Exception e) {
log.error("日期转化异常:{}", e.getMessage());
e.printStackTrace();
}
}
// 字段排序
if (!ObjectUtils.isEmpty(map.get("sort"))){
String[] sorts = Objects.toString(map.get("sort")).split(",");
......@@ -2860,6 +2893,11 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
item.put("REC_DATE", Instant.ofEpochMilli(Long.parseLong(item.getString("REC_DATE")))
.atZone(ZoneId.systemDefault())
.toLocalDate());
if (!ValidationUtil.isEmpty(item.getString(CREATE_DATE))){
item.put(CREATE_DATE, Instant.ofEpochMilli(Long.parseLong(item.getString(CREATE_DATE)))
.atZone(ZoneId.systemDefault())
.toLocalDate());
}
String fullAddress = equAddressMap.get(item.getString(SEQUENCE_NBR));
item.put("ADDRESS", !ValidationUtil.isEmpty(fullAddress) ? fullAddress : "");
item.put("CAN_EDIT", this.checkEquipIsCanEdit(item.getString(SEQUENCE_NBR)));
......
......@@ -757,7 +757,7 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
.fluentPut("time", new Date().getTime()));
}
private List<String> getEnterSeqs(String ids, Map<String, String> map) {
private List<String> getEnterSeqs(String ids, Map<String, Object> map) {
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
List<String> idsList = new ArrayList<>();
if (StringUtils.isEmpty(ids)) {
......@@ -803,7 +803,7 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
* @param ids
*/
@Override
public void enterpriseInformationExport(String uuid, String ids, Map<String, String> map) {
public void enterpriseInformationExport(String uuid, String ids, Map<String, Object> map) {
ObjectMapper objectMapper = new ObjectMapper();
List<String> enterSeqs = getEnterSeqs(ids, map);
List<Map<String, String>> enterInfoWithExport = tzBaseEnterpriseInfoMapper.getEnterInfoWithExport(enterSeqs);
......@@ -835,7 +835,7 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
.fluentPut("time", new Date().getTime()));
}
private List<String> getUserInfoSeqs(boolean isAdmin, String ids, Map<String, String> map) {
private List<String> getUserInfoSeqs(boolean isAdmin, String ids, Map<String, Object> map) {
RequestContextWrapper contextWrapper = RequestContextWrapper.capture();
List<String> idsList = new ArrayList<>();
if (StringUtils.isEmpty(ids)) {
......@@ -881,7 +881,7 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
@Override
public void userInfoExport(String uuid, String ids, Map<String, String> map) {
public void userInfoExport(String uuid, String ids, Map<String, Object> map) {
List<String> userInfoSeqs = getUserInfoSeqs(false, ids, map);
List<Map<String, String>> enterInfoWithExport = tzsUserInfoMapper.getUserInfoWithExport(userInfoSeqs);
List<UserInfoVo> exportData = JSON.parseArray(JSON.toJSONString(enterInfoWithExport), UserInfoVo.class);
......@@ -897,7 +897,7 @@ public class JgTableDataExportServiceImpl implements IJgTableDataExportService {
}
@Override
public void userInfoExportWithAdmin(String uuid, String ids, Map<String, String> map) {
public void userInfoExportWithAdmin(String uuid, String ids, Map<String, Object> map) {
List<String> userInfoSeqs = getUserInfoSeqs(true, ids, map);
List<Map<String, String>> enterInfoWithExport = tzsUserInfoMapper.getUserInfoWithExport(userInfoSeqs);
List<UserInfoVo> exportData = JSON.parseArray(JSON.toJSONString(enterInfoWithExport), UserInfoVo.class);
......
......@@ -50,8 +50,9 @@ public enum AdvanceSearchEnum {
JSONArray jsonArray = new JSONArray();
for (AdvanceSearchEnum item : values()) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", item.name);
jsonObject.put("code", item.code);
jsonObject.put("label", item.name);
jsonObject.put("value", item.code);
jsonObject.put("key", item.code);
jsonObject.put("paramType", item.paramType);
jsonObject.put("isMulti", false);
if(TechnicalParameter.ParamType.BIG_DECIMAL.equals(item.paramType)){
......
package com.yeejoin.amos.boot.module.statistics.api.enums;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
......@@ -35,4 +37,16 @@ public enum UnitTypeEnum {
getCode.put(e.name, e.code);
}
}
public static JSONArray getAll(){
JSONArray jsonArray = new JSONArray();
for (UnitTypeEnum e : UnitTypeEnum.values()) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("label",e.name);
jsonObject.put("value",e.code);
jsonObject.put("key",e.code);
jsonArray.add(jsonObject);
}
return jsonArray;
}
}
......@@ -53,7 +53,7 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/select/queryEquipmentSearchData")
@ApiOperation(httpMethod = "POST", value = "查询设备查询条件", notes = "查询设备查询条件")
public ResponseModel<JSONObject> queryEquipmentSearchData(@RequestBody JSONObject jsonObject) {
public ResponseModel<JSONArray> queryEquipmentSearchData(@RequestBody JSONObject jsonObject) {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryEquipmentSearchData(jsonObject.getString("value")));
}
......@@ -62,10 +62,76 @@ public class ComprehensiveStatisticalAnalysisController extends BaseController {
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/select/queryAdvancedSearch")
@GetMapping(value = "/select/queryAdvancedSearch/{type}")
@ApiOperation(httpMethod = "GET", value = "查询高级筛选", notes = "查询高级筛选")
public ResponseModel<JSONArray> query() {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryAdvancedSearch());
public ResponseModel<JSONArray> query(@PathVariable String type) {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryAdvancedSearch(type));
}
/**
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/select/queryCompanySearchData")
@ApiOperation(httpMethod = "GET", value = "查询企业条件", notes = "查询企业条件")
public ResponseModel<JSONObject> queryCompanySearchData() {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryCompanySearchData());
}
/**
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/select/queryPersonSearchData")
@ApiOperation(httpMethod = "GET", value = "查询个人条件", notes = "查询个人条件")
public ResponseModel<JSONObject> queryPersonSearchData() {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryPersonSearchData());
}
/**
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/select/queryUnitType")
@ApiOperation(httpMethod = "GET", value = "查询单位类型", notes = "查询单位类型")
public ResponseModel<JSONArray> queryUnitType() {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryUnitType());
}
/**
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/select/queryXK")
@ApiOperation(httpMethod = "GET", value = "查询许可", notes = "查询许可")
public ResponseModel<JSONArray> queryXK(@RequestParam(required = false) String type) {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryXK(type));
}
/**
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/select/queryRYLX")
@ApiOperation(httpMethod = "GET", value = "查询人员类型", notes = "查询人员类型")
public ResponseModel<JSONArray> queryRYLX(@RequestParam(required = false) String type) {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryRYLX(type));
}
/**
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/select/queryZZZT")
@ApiOperation(httpMethod = "GET", value = "查询资质状态", notes = "查询资质状态")
public ResponseModel<JSONArray> queryZZZT() {
return ResponseHelper.buildResponse(statisticalAnalysisService.queryZZZT());
}
/**
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.annotation.TechnicalParameter;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
......@@ -17,9 +18,12 @@ import com.yeejoin.amos.boot.module.statistcs.biz.utils.MinioUtils;
import com.yeejoin.amos.boot.module.statistics.api.enums.AdvanceSearchEnum;
import com.yeejoin.amos.boot.module.statistics.api.enums.ConditionEnum;
import com.yeejoin.amos.boot.module.statistics.api.enums.StatisticalAnalysisEnum;
import com.yeejoin.amos.boot.module.statistics.api.enums.UnitTypeEnum;
import com.yeejoin.amos.boot.module.statistics.api.mapper.TzsCustomFilterMapper;
import com.yeejoin.amos.boot.module.statistics.api.vo.EquipInfoVo;
import com.yeejoin.amos.boot.module.ymt.api.dto.EquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.lucene.search.join.ScoreMode;
......@@ -27,11 +31,14 @@ import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.*;
import org.elasticsearch.script.Script;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.NestedQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermsQueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
......@@ -73,6 +80,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private final String DOWNLOAD_TOPIC = "/topic/download/excel/%s";
private final String BUCKET_NAME = "upload";
private final String UPLOAD_PATH = "/tzs/excelTempFile";
@Autowired
EquipmentCategoryMapper equipmentCategoryMapper;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
public List<Map<String, Object>> queryEquipmentCategory(String key) {
......@@ -87,9 +98,9 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
return list;
}
public JSONObject queryEquipmentSearchData(String value) {
public JSONArray queryEquipmentSearchData(String value) {
List<TechParamItem> paramMetaList = TechParamUtil.getParamMetaList(value);
ArrayList<JSONObject> list = new ArrayList<>();
JSONArray list = new JSONArray();
for (int i = 0; i < paramMetaList.size(); i++) {
JSONObject object = new JSONObject();
object.put("key", paramMetaList.get(i).getParamKey());
......@@ -112,9 +123,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
object.put("skillConfig", skillConfig);
list.add(object);
}
JSONObject result = new JSONObject();
result.put("techParam", list);
return result;
return list;
}
private JSONArray getData(String dictCode) {
......@@ -125,6 +134,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONObject object = new JSONObject();
object.put("label", dictionary.getName());
object.put("value", dictionary.getCode());
object.put("key", dictionary.getCode());
jsonArray.add(object);
}
return jsonArray;
......@@ -134,8 +144,15 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
return ConditionEnum.getByCode(ValidationUtil.isEmpty(dictCode) ? value : null);
}
public JSONArray queryAdvancedSearch() {
JSONArray all = AdvanceSearchEnum.getAll();
public JSONArray queryAdvancedSearch(String type) {
JSONArray all = new JSONArray();
if ("equip".equals(type)) {
all = AdvanceSearchEnum.getAll();
} else if ("company".equals(type)) {
} else if ("person".equals(type)) {
}
return all;
}
......@@ -196,21 +213,75 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust.must(QueryBuilders.existsQuery(field));
TermsQueryBuilder termsQuery = QueryBuilders.termsQuery(field, (JSONArray) v);
boolMust.must(termsQuery);
} else if (k.equals("licenses")) {
} else if (k.equals("certNo") || k.equals("expiryDate") || k.equals("permissionLevel") || k.equals("certType") || k.equals("jobItem") || k.equals("issueDate")) {
String path = "licenses";
((JSONArray) v).forEach(item -> {
String compareString = "doc['" + k + "'].length" + (item.equals("1") ? " > 0" : "= 0");
// 检查嵌套字段存在且长度大于0
Script script = new Script(compareString);
ScriptQueryBuilder scriptQuery = QueryBuilders.scriptQuery(script);
NestedQueryBuilder nestedExistsQuery = QueryBuilders.nestedQuery(
k,
scriptQuery,
ScoreMode.None
String nestedField = path + "." + k;
// 根据证书编号判断有无资质
if (k.equals("certNo")) {
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.existsQuery(nestedField),
ScoreMode.Avg
);
if (item.equals("1")) {
boolMust.must(nestedQuery);
} else {
boolMust.mustNot(nestedQuery);
}
} else if (k.equals("expiryDate")) {
if (item.equals("overdue")) {
// 超期:小于当前日期
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(nestedField).lt(LocalDate.now().format(formatter))),
ScoreMode.Avg
);
boolMust.must(nestedQuery);
} else if (item.equals("near")) {
// 临期:小于等于当前日期加上30天
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(nestedField).lte(LocalDate.now().plusDays(30).format(formatter))),
ScoreMode.Avg
);
boolMust.must(nestedQuery);
} else if (item.equals("normal")) {
// 正常:大于当前日期加上30天
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(nestedField).gt(LocalDate.now().plusDays(30).format(formatter))),
ScoreMode.Avg
);
boolMust.must(nestedQuery);
} else {
// 无资质要求
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.existsQuery(nestedField),
ScoreMode.Avg
);
boolMust.mustNot(nestedQuery);
}
} else if (k.equals("certType") || k.equals("permissionLevel") || k.equals("jobItem")) {
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().must(QueryBuilders.termsQuery(nestedField, (JSONArray) v)),
ScoreMode.Avg
);
BoolQueryBuilder query = QueryBuilders.boolQuery()
.must(nestedExistsQuery);
boolMust.must(query);
boolMust.must(nestedQuery);
}
});
} else if (k.equals("issueDate")) {
JSONArray issueDates = (JSONArray) v;
String startDate = DateUtils.convertDateToString(issueDates.getDate(0), DateUtils.DATE_PATTERN);
String endDate = DateUtils.convertDateToString(issueDates.getDate(1), DateUtils.DATE_PATTERN);
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
"licenses",
QueryBuilders.rangeQuery("issueDate").gte(startDate).lte(endDate),
ScoreMode.Avg
);
boolMust.filter(nestedQuery);
}
} else {
//todo 高级筛选
......@@ -290,22 +361,46 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust.must(QueryBuilders.existsQuery(field));
TermsQueryBuilder termsQuery = QueryBuilders.termsQuery(field, (JSONArray) v);
boolMust.must(termsQuery);
} else if (k.equals("itemCode") || k.equals("subItemCode")) {
} else if (k.equals("itemCode") || k.equals("subItemCode") || k.equals("permitStatus")) {
String path = "licenses";
((JSONArray) v).forEach(item -> {
String nestedField = path + "." + k + ".keyword";
String nestedField = path + "." + (k.equals("permitStatus") ? "expiryDate" : k + ".keyword");
if (k.equals("permitStatus")) {
if (item.equals("overdue")) {
// 超期:小于当前日期
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(nestedField).lt(LocalDate.now().format(formatter))),
ScoreMode.Avg
);
boolMust.must(nestedQuery);
} else if (item.equals("near")) {
// 临期:小于等于当前日期加上30天
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(nestedField).lte(LocalDate.now().plusDays(30).format(formatter)).gte(LocalDate.now().format(formatter))),
ScoreMode.Avg
);
boolMust.must(nestedQuery);
} else if (item.equals("normal")) {
// 正常:大于当前日期加上30天
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery().filter(QueryBuilders.rangeQuery(nestedField).gt(LocalDate.now().plusDays(30).format(formatter))),
ScoreMode.Avg
);
boolMust.must(nestedQuery);
}
} else {
// 创建嵌套查询
NestedQueryBuilder nestedQuery = QueryBuilders.nestedQuery(
path,
QueryBuilders.boolQuery()
.must(QueryBuilders.termQuery(nestedField, v)),
QueryBuilders.termsQuery(nestedField, item),
ScoreMode.Avg
);
boolMust.must(nestedQuery);
System.out.println(boolMust.toString());
}
});
} else if (k.equals("permitStatus")) {
}
}
}
......@@ -417,8 +512,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust.filter(QueryBuilders.rangeQuery(finalField).lt(LocalDate.now().minusYears(5).format(formatter)));
}
});
} else if (k.equals("IS_SUPERVISORY")) {
String finalField = "SUPERVISORY_CODE";
} else if (k.equals("IS_SUPERVISORY_CODE")) {
String finalField = "IS_SUPERVISORY_CODE";
((JSONArray) v).forEach(item -> {
if (item.equals("1")) {
boolMust.must(QueryBuilders.existsQuery(finalField));
......@@ -429,8 +524,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
});
} else if (k.equals("createDate")) {
JSONArray createDates = (JSONArray) v;
String startDate = DateUtils.convertDateToString(createDates.getDate(0), "yyyy-MM-dd HH:mm:ss");
String endDate = DateUtils.convertDateToString(createDates.getDate(1), "yyyy-MM-dd HH:mm:ss");
String startDate = DateUtils.convertDateToString(createDates.getDate(0), DateUtils.DATE_TIME_PATTERN);
String endDate = DateUtils.convertDateToString(createDates.getDate(1), DateUtils.DATE_TIME_PATTERN);
boolMust.filter(QueryBuilders.rangeQuery("createDate").gte(startDate.replace(" ", "T")).lte(endDate.replace(" ", "T")));
} else if (k.equals("EQU_LIST") || k.equals("EQU_CATEGORY") || k.equals("EQU_DEFINE") || k.equals("EQU_STATE") || k.equals("DATA_QUALITY_SCORE") || k.equals("DATA_SOURCE")) {
if (k.equals("EQU_LIST")) {
......@@ -535,6 +630,121 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
}
}
result.put("statics", statics);
return result;
}
public JSONArray queryUnitType() {
return UnitTypeEnum.getAll();
}
public JSONObject queryCompanySearchData() {
JSONObject result = new JSONObject();
//获取企业类型
result.put("UNIT_TYPE", UnitTypeEnum.getAll());
//获取企业等级
result.put("regulatoryLabels", deployDictionary(dataDictionaryService.getByType("QYBQ")));
//行业主管部门
result.put("industrySupervisor", deployDictionary(dataDictionaryService.getByType("HYZGBM")));
//经营状态
result.put("operatingStatus", deployDictionary(dataDictionaryService.getByType("jyzt")));
//许可状态
JSONArray permitStatusData = new JSONArray();
for (int i = 0; i < 3; i++) {
JSONObject object = new JSONObject();
if (0 == i) {
object.put("key", "0");
object.put("value", "0");
object.put("label", "超期");
} else if (1 == i) {
object.put("key", "1");
object.put("value", "1");
object.put("label", "临期");
} else {
object.put("key", "2");
object.put("value", "2");
object.put("label", "正常");
}
permitStatusData.add(object);
}
result.put("permitStatus", permitStatusData);
//监管设备类型
List<EquipmentCategoryDto> equipmentCategoryDtos = equipmentCategoryMapper.selectClassify();
JSONArray equipCategoryData = new JSONArray();
for (int i = 0; i < equipmentCategoryDtos.size(); i++) {
JSONObject object = new JSONObject();
object.put("key", equipmentCategoryDtos.get(i).getCode());
object.put("value", equipmentCategoryDtos.get(i).getCode());
object.put("label", equipmentCategoryDtos.get(i).getName());
equipCategoryData.add(object);
}
result.put("equipList", equipCategoryData);
return result;
}
public JSONObject queryPersonSearchData() {
JSONObject result = new JSONObject();
return result;
}
public JSONArray deployDictionary(List<DataDictionary> list) {
JSONArray result = new JSONArray();
for (int i = 0; i < list.size(); i++) {
JSONObject object = new JSONObject();
object.put("key", list.get(i).getCode());
object.put("value", list.get(i).getCode());
object.put("label", list.get(i).getName());
result.add(object);
}
return result;
}
public JSONArray queryXK(String type) {
JSONArray result = new JSONArray();
if (ValidationUtil.isEmpty(type)) {
List<DataDictionary> xkxm = dataDictionaryService.lambdaQuery().like(DataDictionary::getType, "XKXM").eq(BaseEntity::getIsDelete, false).list();
result = deployDictionary(xkxm);
} else {
List<DataDictionary> childrenxkxm = dataDictionaryService.lambdaQuery().eq(DataDictionary::getTypeDesc, type).eq(BaseEntity::getIsDelete, false).list();
result = deployDictionary(childrenxkxm);
}
return result;
}
public JSONArray queryRYLX(String type) {
JSONArray result = new JSONArray();
if (ValidationUtil.isEmpty(type)) {
List<String> typeList = new ArrayList<>(Arrays.asList(
"QYRYGW",
"QYRYGW-SYDW",
"QYRYGW-SCDW",
"QYRYGW-INSTALL",
"QYRYGW-INSPECTION"
));
result = deployDictionary(dataDictionaryService.lambdaQuery()
.select(DataDictionary::getName, DataDictionary::getCode)
.eq(DataDictionary::getIsDelete, false)
.isNull(DataDictionary::getParent)
.in(DataDictionary::getType, typeList)
.list());
} else {
List<DataDictionary> childrenrylx = dataDictionaryService.lambdaQuery()
.in(DataDictionary::getParent, type)
.like(DataDictionary::getType, "QYRYGW")
.orderByAsc(DataDictionary::getSortNum)
.list();
;
result = deployDictionary(childrenrylx);
}
return result;
}
......@@ -589,4 +799,10 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
.fluentPut("url", urlString)
.fluentPut("time", new Date().getTime()));
}
public JSONArray queryZZZT() {
JSONArray array = new JSONArray();
return null;
}
}
\ No newline at end of file
......@@ -382,7 +382,7 @@ public class TzsUserInfoController extends BaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/company/import")
@PostMapping(value = "/company/import", produces = "application/json;charset=UTF-8")
@ApiOperation(value = "企业人员导入", httpMethod = "POST", notes = "企业人员导入")
public ResponseModel<?> importCompanyUser(@RequestBody MultipartFile file) {
return tzsUserInfoService.importCompanyUser(file, getSelectedOrgInfo());
......
......@@ -51,6 +51,7 @@ import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.GroupModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.ehcache.impl.internal.concurrent.ConcurrentHashMap;
......@@ -58,11 +59,13 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -76,6 +79,8 @@ import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -116,6 +121,8 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
private TzsUserQualificationsServiceImpl tzsUserQualificationsService;
@Autowired
private TzsUserPermissionServiceImpl tzsUserPermissionServiceImpl;
@Autowired
private EmqKeeper emqKeeper;
@Autowired
private RegUnitInfoServiceImpl regUnitInfoService;
......@@ -1345,6 +1352,56 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
return errors;
}
private final String DOWN_LOAD_START_TEMP = "{\"id\":\"%s\",\"status\":\"starting\",\"fileName\":\"%s\",\"time\":\"%s\"}";
private final String DOWNLOAD_TOPIC = "/topic/download/excel/%s";
private final String BUCKET_NAME = "upload";
private final String UPLOAD_PATH = "/tzs/excelTempFile";
/**
* 开始下载 发送消息
*/
public void startDownLoadMsg(String fileName, String uuid) {
try {
emqKeeper.getMqttClient().publish(String.format(DOWNLOAD_TOPIC, RequestContext.getToken()),
String.format(DOWN_LOAD_START_TEMP, uuid, fileName, new Date().getTime()).getBytes(StandardCharsets.UTF_8),
2, false);
} catch (Exception e) {
log.error(e.getMessage());
}
}
/**
* 发送主题消息,给企业推送excel 结束下载提醒
*
* @param topic 主体格式为: /download/excel/${token}
* @param jsonObject 文件名称 + excel文件路径(minio)
*/
public void sendDownLoadExcelMsg(String topic, JSONObject jsonObject) {
try {
emqKeeper.getMqttClient().publish(topic, JSONObject.toJSONString(jsonObject).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (Exception e) {
log.error(e.getMessage());
}
}
/**
* 上传excel文件到minio服务器
*
* @param templateExcelFile 文件
* @return minio文件路径
*/
private String uploadExcelFile(MultipartFile templateExcelFile) {
FeignClientResult<Map<String, String>> uploadResult = Systemctl.fileStorageClient.updateBucketFile(templateExcelFile, BUCKET_NAME, UPLOAD_PATH);
String urlString = "";
if (uploadResult != null && uploadResult.getResult() != null) {
for (String s : uploadResult.getResult().keySet()) {
urlString = s;
}
}
return urlString;
}
/**
* 企业人员导入
*
......@@ -1356,7 +1413,7 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
public ResponseModel<?> importCompanyUser(MultipartFile multipartFile, ReginParams reginParams) {
CompanyBo company = reginParams.getCompany();
List<CompanyUserImportDto> dataList = new ArrayList<>();
JSONArray resultError = new JSONArray();
ArrayList<String> sheetError = new ArrayList();
// 用于手机号唯一判断 key:姓名-身份证号 value :手机号
// key保证数据唯一性
Map<String, String> phoneOnly = new HashMap<>();
......@@ -1372,7 +1429,6 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
if (sheetName.contains("企业人员录入限制")) {
continue;
}
ArrayList<String> sheetError = new ArrayList<>();
// 人员信息 sheet页
if (sheetName.contains("人员信息")) {
EasyExcel.read(multipartFile.getInputStream(), CompanyUserImportDto.class, new AnalysisEventListener<CompanyUserImportDto>() {
......@@ -1383,9 +1439,6 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (!ValidationUtil.isEmpty(sheetError)) {
resultError.add(sheetError);
}
}
}).headRowNumber(2).sheet(sheetNo, sheetName).doRead();
}
......@@ -1400,9 +1453,6 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (!ValidationUtil.isEmpty(sheetError)) {
resultError.add(sheetError);
}
}
}).headRowNumber(2).sheet(sheetNo, sheetName).doRead();
}
......@@ -1417,9 +1467,6 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (!ValidationUtil.isEmpty(sheetError)) {
resultError.add(sheetError);
}
}
}).headRowNumber(2).sheet(sheetNo, sheetName).doRead();
}
......@@ -1434,16 +1481,32 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (!ValidationUtil.isEmpty(sheetError)) {
resultError.add(sheetError);
}
}
}).headRowNumber(2).sheet(sheetNo, sheetName).doRead();
}
}
// 存在检验不通过的数据则返回错误信息,不在向下写入库
if (!resultError.isEmpty()) {
return ResponseHelper.buildResponse(resultError);
if (!sheetError.isEmpty()) {
// 发送错误文件
String uuid = UUID.randomUUID().toString();
startDownLoadMsg("人员导入错误文件", uuid);
File tempFile = File.createTempFile("errors", ".txt");
try (FileWriter writer = new FileWriter(tempFile)) {
for (String error : sheetError) {
writer.write(error + System.lineSeparator());
}
}
byte[] fileContent = Files.readAllBytes(tempFile.toPath());
MultipartFile mockMultipartFile = new MockMultipartFile("errors.txt", "errors.txt", "text/plain", fileContent);
String urlString = this.uploadExcelFile(mockMultipartFile);
sendDownLoadExcelMsg(String.format(DOWNLOAD_TOPIC, RequestContext.getToken()), new JSONObject()
.fluentPut("id", uuid)
.fluentPut("status", "done")
.fluentPut("fileName", "人员导入错误文件")
.fluentPut("url", urlString)
.fluentPut("time", new Date().getTime()));
tempFile.delete();
throw new BadRequest("校验出错,请查看错误文件!");
}
// 3.数据入库
dataList.forEach(data -> {
......
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