Commit 84701c36 authored by 韩桐桐's avatar 韩桐桐

使用单位检验结果录入

parent 55b48338
package com.yeejoin.amos.boot.module.jyjc.api.enums;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author Administrator
*/
......@@ -13,10 +19,29 @@ public enum ResultTypeEnum {
/**
* 集成方式
*/
INPUT("录入","input"),
INTEGRATED("集成","integrated");
INPUT("检验机构录入", "input"),
INTEGRATED("检验机构对接", "integrated"),
USEUNITENTRY("使用单位录入", "useUnitEntry");
private final String name;
private final String code;
private static final Map<String, String> CODE_NAME_MAP;
static {
CODE_NAME_MAP = Arrays.stream(ResultTypeEnum.values())
.collect(Collectors.toMap(ResultTypeEnum::getCode, ResultTypeEnum::getName));
}
private String name;
public static List<JSONObject> All() {
return Arrays.stream(ResultTypeEnum.values())
.map(item -> new JSONObject()
.fluentPut("code", item.getCode())
.fluentPut("name", item.getName()))
.collect(Collectors.toList());
}
private String code;
public static String getNameByCode(String code) {
return CODE_NAME_MAP.getOrDefault(code, "");
}
}
......@@ -187,4 +187,10 @@ public class JyjcInspectionResultModel extends BaseModel {
* 管理方式: single-单台(套)报检;batch-批量报检
*/
private String manageType;
/**
* 结果来源 ,来源于ResultTypeEnum枚举
*/
@ApiModelProperty(value = "结果来源")
private String sourceResult;
}
......@@ -211,6 +211,9 @@
<if test="jyjcInspectionResultModel.applicationDate!=null">
AND res.application_date = #{jyjcInspectionResultModel.applicationDate}
</if>
<if test="jyjcInspectionResultModel.sourceResult!=null">
AND res.result_type = #{jyjcInspectionResultModel.sourceResult}
</if>
<if test="jyjcInspectionResultModel.inspectionType != '' and jyjcInspectionResultModel.inspectionType != null">
and res.inspection_type = #{jyjcInspectionResultModel.inspectionType}
</if>
......@@ -260,6 +263,9 @@
<if test="jyjcInspectionResultModel.applicationDate!=null">
AND res.application_date = #{jyjcInspectionResultModel.applicationDate}
</if>
<if test="jyjcInspectionResultModel.sourceResult!=null">
AND res.result_type = #{jyjcInspectionResultModel.sourceResult}
</if>
<if test="jyjcInspectionResultModel.inspectionType != '' and jyjcInspectionResultModel.inspectionType != null">
and res.inspection_type = #{jyjcInspectionResultModel.inspectionType}
</if>
......
......@@ -264,6 +264,36 @@ public class JyjcInspectionApplicationController extends BaseController {
return ResponseHelper.buildResponse(jyjcInspectionApplicationServiceImpl.queryForEquipmentRegisterPage(jsonObject));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "设备注册信息分页查询-所有设备-使用单位检验结果录入过滤设备使用", notes = "设备注册信息分页查询-所有设备-使用单位检验结果录入过滤设备使用")
@GetMapping(value = "/equip/all")
public ResponseModel<Page<JSONObject>> getAllEquipList(@RequestParam Map<String, Object> map) {
JSONObject jsonObject = new JSONObject(map);
return ResponseHelper.buildResponse(jyjcInspectionApplicationServiceImpl.getAllEquipListPage(jsonObject));
}
/**
* 查询单位下的所有工程装置(父ID为空)的数据
*
* @param useUnitCreditCode 使用单位统一信用代码
* @param current 当前页
* @param size 每页数
* @return page
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/jgAllProConPage")
@ApiOperation(value = "查询单位下的所有工程装置(父ID为空)的数据")
public ResponseModel<IPage<IdxBizJgProjectContraption>> getJgAllProConPage(@RequestParam(value = "useUnitCreditCode") String useUnitCreditCode,
@RequestParam(value = "projectContraption",required = false) String projectContraption,
@RequestParam(value = "current") int current,
@RequestParam(value = "size") int size) {
Page<IdxBizJgProjectContraption> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
IPage<IdxBizJgProjectContraption> re = jyjcInspectionApplicationServiceImpl.getJgAllProConPage(useUnitCreditCode, projectContraption, page);
return ResponseHelper.buildResponse(re);
}
/**
* 查询检验检测机构列表(基本信息及联系人)-工作台专用
*
......
package com.yeejoin.amos.boot.module.jyjc.biz.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jyjc.api.enums.ResultTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionResultDataModel;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionResultModel;
import com.yeejoin.amos.boot.module.jyjc.biz.service.impl.JyjcInspectionResultServiceImpl;
......@@ -153,6 +155,13 @@ public class JyjcInspectionResultController extends BaseController {
return ResponseHelper.buildResponse(jyjcInspectionResultServiceImpl.queryForPageList(page, model, sort));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/sourceResult")
@ApiOperation(httpMethod = "GET", value = "列表筛选项-结果来源", notes = "列表筛选项-结果来源")
public ResponseModel<List<JSONObject>> sourceResult() {
return ResponseHelper.buildResponse(ResultTypeEnum.All());
}
/**
......@@ -206,4 +215,31 @@ public class JyjcInspectionResultController extends BaseController {
Assert.hasText(ids,"未选择导出数据");
jyjcInspectionResultServiceImpl.Export(response, Arrays.asList(ids.split(",")));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/useUnitEntryWithSave")
@ApiOperation(httpMethod = "POST", value = "使用单位录入检验结果-保存", notes = "使用单位录入检验结果-保存")
public ResponseModel<Boolean> useUnitEntryWithSave(@RequestBody Map<String, Object> entryData) {
return ResponseHelper.buildResponse(jyjcInspectionResultServiceImpl.useUnitEntryWithSave(entryData,getSelectedOrgInfo()));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PostMapping(value = "/useUnitEntryWithUpdate")
@ApiOperation(httpMethod = "POST", value = "使用单位录入检验结果-更新", notes = "使用单位录入检验结果-更新")
public ResponseModel<Boolean> useUnitEntryWithUpdate(@RequestBody Map<String, Object> entryData) {
return ResponseHelper.buildResponse(jyjcInspectionResultServiceImpl.useUnitEntryWithUpdate(entryData,getSelectedOrgInfo()));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getUseUnitEntryDetail/{sequenceNbr}")
@ApiOperation(httpMethod = "GET", value = "使用单位录入检验结果-详情", notes = "使用单位录入检验结果-详情")
public ResponseModel<JSONObject> getUseUnitEntryDetail(@PathVariable(value = "sequenceNbr") Long resultSeq) {
return ResponseHelper.buildResponse(jyjcInspectionResultServiceImpl.getUseUnitEntryDetail(resultSeq));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@DeleteMapping(value = "/delUseUnitEntry")
@ApiOperation(httpMethod = "DELETE", value = "使用单位录入检验结果-单条删除", notes = "使用单位录入检验结果-单条删除")
public ResponseModel<Boolean> delUseUnitEntry(@RequestParam(value = "sequenceNbr")String resultSeq) {
return ResponseHelper.buildResponse(jyjcInspectionResultServiceImpl.delUseUnitEntry(Long.valueOf(resultSeq)));
}
}
......@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
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.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
......@@ -64,6 +66,9 @@ public class CommonServiceImpl {
@Autowired
JyjcBaseMapper jyjcBaseMapper;
@Autowired
private DataDictionaryServiceImpl dictionaryService;
/**
* @return ReginParams
......@@ -252,4 +257,17 @@ public class CommonServiceImpl {
}
return sb.toString();
}
/**
* 数据质量等级枚举转名称描述
*
* @param dataQualityScore 等级枚举
* @param isIntoManagement 是否纳管
* @return 名称描述
*/
public String castDataQualityScore2Name(String dataQualityScore, Boolean isIntoManagement) {
DataDictionary dataDictionary = dictionaryService.getByCode("DATA_QUALITY_SCORE", dataQualityScore);
String name = Optional.ofNullable(dataDictionary).map(DataDictionary::getName).orElse(null);
return name == null ? (isIntoManagement == null || !isIntoManagement) ? "Ⅱ级" : "Ⅲ级" : name;
}
}
......@@ -128,7 +128,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
@Autowired
JyjcOpeningApplicationServiceImpl jyjcOpeningApplicationService;
@Autowired
WorkflowFeignService workflowFeignService;
IdxBizJgProjectContraptionMapper jgProjectContraptionMapper;
@Autowired
CommonServiceImpl commonService;
@Autowired
......@@ -1263,6 +1263,129 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
/**
* 设备查询-所有设备-未做业务限制
*
* @param map 查询参数
* @return 设备分页
*/
public Page<JSONObject> getAllEquipListPage(JSONObject map) {
int pageNumber = ObjectUtils.isEmpty(map.getInteger("number")) ? 1 : map.getInteger("number");
int size = ObjectUtils.isEmpty(map.getInteger("size")) ? 20 : map.getInteger("size");
Page<JSONObject> result = new Page<>(pageNumber, size);
SearchRequest request = new SearchRequest();
request.indices("idx_biz_view_jg_all");
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 获取当前登录人单位类型
JSONObject company = getCompanyType();
if (ValidationUtil.isEmpty(company)) {
result.setRecords(new ArrayList<>());
result.setTotal(0);
return result;
}
String companyCode = company.getString("companyCode").contains("_") ? company.getString("companyCode").split("_")[1] : company.getString("companyCode");
String type = company.getString("companyType");
// 根据当前登录用户类型及管辖机构筛选条件添加对应参数
if (!ValidationUtil.isEmpty(type) && type.contains("使用单位")) {
if (ValidationUtil.isEmpty(map.getString("USE_UNIT_CREDIT_CODE"))) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
}
}
if (!ValidationUtil.isEmpty(type) && type.contains("安装改造维修单位")) {
map.put("USC_UNIT_CREDIT_CODE", companyCode);
}
if (!ValidationUtil.isEmpty(type) && type.contains("个人主体")) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
}
// 使用单位 //安装改造维修单位
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE")) && !ObjectUtils.isEmpty(map.getString("USC_UNIT_CREDIT_CODE"))) {
BoolQueryBuilder ubuilder = QueryBuilders.boolQuery();
String useCode = QueryParser.escape(map.getString("USE_UNIT_CREDIT_CODE"));
useCode = useCode.contains("_") ? useCode.split("_")[0] : useCode;
ubuilder.should(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE", useCode));
String uscCode = QueryParser.escape(map.getString("USC_UNIT_CREDIT_CODE")).toLowerCase();
ubuilder.should(QueryBuilders.wildcardQuery("USC_UNIT_CREDIT_CODE", "*" + uscCode + "*"));
ubuilder.minimumShouldMatch(1);
boolMust.must(ubuilder);
} else {
if (!ObjectUtils.isEmpty(map.getString("USE_UNIT_CREDIT_CODE")) || !ObjectUtils.isEmpty(map.getString("useUnitCreditCode"))) {
String uucc = !ValidationUtil.isEmpty(map.getString("USE_UNIT_CREDIT_CODE")) ? map.getString("USE_UNIT_CREDIT_CODE") : map.getString("useUnitCreditCode");
String param = QueryParser.escape(uucc);
param = param.contains("_") ? param.split("_")[0] : param;
boolMust.must(QueryBuilders.matchQuery("USE_UNIT_CREDIT_CODE", param));
}
if (!ObjectUtils.isEmpty(map.getString("USC_UNIT_CREDIT_CODE"))) {
String uscCode = QueryParser.escape(map.getString("USC_UNIT_CREDIT_CODE")).toLowerCase();
boolMust.must(QueryBuilders.wildcardQuery("USC_UNIT_CREDIT_CODE", "*" + uscCode + "*"));
}
}
// 监管码
if (!ObjectUtils.isEmpty(map.getString("SUPERVISORY_CODE"))) {
String supervisoryCode = map.getString("SUPERVISORY_CODE");
boolMust.must(QueryBuilders.wildcardQuery("SUPERVISORY_CODE", "*" + supervisoryCode + "*"));
}
// 设备种类编码
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
boolMust.must(QueryBuilders.termsQuery("EQU_LIST_CODE", QueryParser.escape(map.getString("EQU_LIST_CODE"))));
}
// 设备类别
if (!ObjectUtils.isEmpty(map.getString("EQU_CATEGORY_CODE"))) {
boolMust.must(QueryBuilders.termQuery("EQU_CATEGORY_CODE", QueryParser.escape(map.getString("EQU_CATEGORY_CODE"))));
}
// 设备类别编码
if (!ObjectUtils.isEmpty(map.getString("EQU_DEFINE_CODE"))) {
boolMust.must(QueryBuilders.matchPhraseQuery("EQU_DEFINE_CODE", QueryParser.escape(map.getString("EQU_DEFINE_CODE"))));
}
// 设备代码模糊查询
if (!ObjectUtils.isEmpty(map.getString(EQU_CODE))) {
String test = QueryParser.escape(map.getString(EQU_CODE));
boolMust.must(QueryBuilders.wildcardQuery(EQU_CODE, "*" + test.toLowerCase() + "*"));
}
// 单位内部编号模糊查询
if (!ObjectUtils.isEmpty(map.getString("USE_INNER_CODE"))) {
String test = QueryParser.escape(map.getString("USE_INNER_CODE"));
boolMust.must(QueryBuilders.matchPhraseQuery("USE_INNER_CODE", test));
}
builder.query(boolMust);
builder.sort("REC_DATE", SortOrder.DESC);
builder.from((pageNumber - 1) * size);
builder.size(size);
request.source(builder);
List<JSONObject> list = new LinkedList<>();
long totle = 0;
if (log.isDebugEnabled()) {
log.debug("查询es 的查询条件: {}", request);
}
try {
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
for (SearchHit hit : response.getHits().getHits()) {
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(hit);
JSONObject dto2 = jsonObject.getJSONObject("sourceAsMap");
if (!ValidationUtil.isEmpty(dto2.get(EQU_STATE))) {
Integer integer = Integer.valueOf(dto2.get(EQU_STATE).toString());
String status = EquimentEnum.getName.get(integer);
dto2.put(EQU_STATE, status);
}
dto2.put("record", dto2.get(SEQUENCE_NBR));
list.add(dto2);
}
// 填充地址
fillAddress(list);
totle = response.getInternalResponse().hits().getTotalHits().value;
result.setRecords(list);
result.setTotal(totle);
} catch (IOException e) {
throw new RuntimeException(e);
}
return result;
}
/**
* 设备过滤查询-显示未提交的设备、未使用的设备,流程中的设备不显示
*
* @param map 查询参数
......@@ -1561,4 +1684,28 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
private String getDetailAddress(IdxBizJgProjectContraption projectContraption) {
return trimIfNull(projectContraption.getProvinceName()) + trimIfNull(projectContraption.getCityName()) + trimIfNull(projectContraption.getCountyName()) + trimIfNull(projectContraption.getStreetName() + trimIfNull(projectContraption.getAddress()));
}
/**
* 查询单位下的所有工程装置(父ID为空)的数据
* @param useUnitCreditCode
* @param page
* @return
*/
public IPage<IdxBizJgProjectContraption> getJgAllProConPage(String useUnitCreditCode, String projectContraption, Page<IdxBizJgProjectContraption> page) {
// 兼容个人业务
if (useUnitCreditCode.contains("_")) {
useUnitCreditCode = useUnitCreditCode.split("_")[1];
}
// 查询已纳管且使用登记证编号不为空的装置
LambdaQueryWrapper<IdxBizJgProjectContraption> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizJgProjectContraption::getUseUnitCreditCode, useUnitCreditCode);
wrapper.eq(StringUtils.isNotBlank(projectContraption), IdxBizJgProjectContraption::getProjectContraption, projectContraption);
wrapper.eq(IdxBizJgProjectContraption::getEquCategory, "8300");
wrapper.eq(IdxBizJgProjectContraption::getIsFirstMerge, false);
wrapper.isNull(IdxBizJgProjectContraption::getProjectContraptionParentId);
wrapper.last("and (length(use_registration_code) = 0 or use_registration_code is null) order by rec_date desc");
IPage<IdxBizJgProjectContraption> projectContraptionPage = jgProjectContraptionMapper.selectPage(page, wrapper);
projectContraptionPage.getRecords().forEach(pro -> pro.setDataQualityScore(commonService.castDataQualityScore2Name(pro.getDataQualityScore(), pro.getIsIntoManagement())));
return projectContraptionPage;
}
}
\ No newline at end of file
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