Commit 0ff3f829 authored by 李腾威's avatar 李腾威

消防水源消防队伍改造

parent ac9da698
......@@ -47,7 +47,7 @@ public interface WaterResourceMapper extends BaseMapper<WaterResource> {
*/
Page<WaterResourceDto> getWaterResourcePageByParams(Page<WaterResourceDto> page, String name, String resourceType,
ArrayList<Long> belongBuildingId, Long belongFightingSystemId,
Long sequenceNbr, String equipId,String bizOrgCode);
Long sequenceNbr, String equipId,String bizOrgCode, String equipCateGoryCode);
Map<String, Object> getWaterTypeByBizOrgCode(String bizOrgCode);
List<Map<String, Object>> getWaterTypeByBizOrgCode(String bizOrgCode);
}
......@@ -134,6 +134,7 @@
select * from cb_water_resource where is_delete = 1
<if test="sequenceNbr != null and sequenceNbr != ''">and sequence_nbr = #{sequenceNbr}</if>
<if test="resourceType != null and resourceType != ''">and resource_type = #{resourceType}</if>
<if test="equipCateGoryCode != null and equipCateGoryCode != ''">and equip_category_code = #{equipCateGoryCode}</if>
<if test="equipId != null and equipId != ''">and equip_id = #{equipId}</if>
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="belongFightingSystemId != null">
......@@ -152,12 +153,12 @@
</select>
<select id="getWaterTypeByBizOrgCode" resultType="map">
SELECT
equip_category_code,
equip_category_code type,
COUNT(sequence_nbr) as num
FROM
cb_water_resource
WHERE
is_delete = 0
is_delete = 1
<if test="bizOrgCode != null and bizOrgCode != ''">AND biz_org_code like concat( #{bizOrgCode}, '%')</if>
GROUP BY
equip_category_code
......
......@@ -465,14 +465,15 @@ public class WaterResourceController extends BaseController {
Long belongFightingSystemId, Long sequenceNbr,
String resourceType,
String classifyId,
String bizOrgCode) {
String bizOrgCode,
String equipCateGoryCode) {
Page<WaterResourceDto> page = new Page<>();
page.setCurrent(pageNum);
page.setSize(pageSize);
/*bug 2913 更换保存方式 存储到公共附件表 chenzhao 2021-10-18 start*/
Page<WaterResourceDto> waterResourceDtoPage = waterResourceServiceImpl.queryForWaterResourcePage(page, name, resourceType,
belongBuildingId, belongFightingSystemId, sequenceNbr, classifyId,bizOrgCode);
belongBuildingId, belongFightingSystemId, sequenceNbr, classifyId,bizOrgCode, equipCateGoryCode);
List<WaterResourceDto> records = waterResourceDtoPage.getRecords();
records.forEach(i->{
Map<String, List<AttachmentDto>> attachments = sourceFileService.getAttachments(i.getSequenceNbr());
......
package com.yeejoin.amos.boot.module.common.biz.service.impl;
import static org.hamcrest.CoreMatchers.nullValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Resource;
import com.yeejoin.amos.boot.biz.common.utils.Menu;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
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;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -31,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.constants.BizConstant;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.EnumsUtils;
import com.yeejoin.amos.boot.biz.common.utils.Menu;
import com.yeejoin.amos.boot.module.common.api.dto.RequestData;
import com.yeejoin.amos.boot.module.common.api.dto.WaterResourceCraneDto;
import com.yeejoin.amos.boot.module.common.api.dto.WaterResourceDto;
......@@ -49,6 +28,24 @@ import com.yeejoin.amos.boot.module.common.api.enums.WaterResourceTypeEnum;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.common.api.mapper.WaterResourceMapper;
import com.yeejoin.amos.boot.module.common.api.service.IWaterResourceService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
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;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* 服务实现类
......@@ -78,6 +75,7 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
DataDictionaryServiceImpl dataDictionaryService;
@Autowired
EquipFeignClient equipFeignClient;
/**
* 分页查询
*/
......@@ -88,9 +86,10 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
@Condition(Operator.eq) Long belongFightingSystemId,
@Condition(Operator.eq) Long sequenceNbr,
String equipId,
String bizOrgCode) {
String bizOrgCode,
String equipCateGoryCode) {
return this.waterResourceMapper.getWaterResourcePageByParams(page, name, resourceType, belongBuildingId,
belongFightingSystemId, sequenceNbr, equipId,bizOrgCode);
belongFightingSystemId, sequenceNbr, equipId, bizOrgCode, equipCateGoryCode);
}
/**
......@@ -190,9 +189,9 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
/**
* 导出列表
*/
public List<WaterResourceDto> exportToExcel(Boolean isDelete,String name,
public List<WaterResourceDto> exportToExcel(Boolean isDelete, String name,
String resourceType) {
return waterResourceMapper.exportToExcel(isDelete,name,resourceType);
return waterResourceMapper.exportToExcel(isDelete, name, resourceType);
}
@Override
......@@ -218,24 +217,24 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
waterResourceDto.setRealityImgList(JSONArray.parseArray(waterResourceDto.getRealityImg(), Object.class));
waterResourceDto.setOrientationImgList(JSONArray.parseArray(waterResourceDto.getOrientationImg()));
if(ValidationUtil.isEmpty(waterResourceDto.getContactUser())) {
if (ValidationUtil.isEmpty(waterResourceDto.getContactUser())) {
waterResourceDto.setContactUser("");
}
if(ValidationUtil.isEmpty(waterResourceDto.getContactPhone())) {
if (ValidationUtil.isEmpty(waterResourceDto.getContactPhone())) {
waterResourceDto.setContactPhone("");
}
if(ValidationUtil.isEmpty(waterResourceDto.getManagementUnit())) {
if (ValidationUtil.isEmpty(waterResourceDto.getManagementUnit())) {
waterResourceDto.setManagementUnit("");
}
if(ValidationUtil.isEmpty(waterResourceDto.getSection())) {
if (ValidationUtil.isEmpty(waterResourceDto.getSection())) {
waterResourceDto.setSection("");
}
if(ValidationUtil.isEmpty(waterResourceDto.getWaterSupplyName())) {
if (ValidationUtil.isEmpty(waterResourceDto.getWaterSupplyName())) {
waterResourceDto.setWaterSupplyName("");
}
......@@ -249,7 +248,7 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
waterResourceHydrantService.getOne(new QueryWrapper<WaterResourceHydrant>().eq(
"resource_id",
sequenceNbr));
if(null != waterResourceHydrant) {
if (null != waterResourceHydrant) {
BeanUtils.copyProperties(waterResourceHydrant, waterResourceDto);
}
break;
......@@ -257,7 +256,7 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
WaterResourceCrane waterResourceCrane =
waterResourceCraneService.getOne(new QueryWrapper<WaterResourceCrane>().eq("resource_id",
sequenceNbr));
if(null != waterResourceCrane) {
if (null != waterResourceCrane) {
BeanUtils.copyProperties(waterResourceCrane, waterResourceDto);
}
break;
......@@ -266,7 +265,7 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
waterResourceNaturalService.getOne(new QueryWrapper<WaterResourceNatural>().eq(
"resource_id",
sequenceNbr));
if(null != waterResourceNatural) {
if (null != waterResourceNatural) {
BeanUtils.copyProperties(waterResourceNatural, waterResourceDto);
}
......@@ -275,7 +274,7 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
WaterResourcePool waterResourcePool =
waterResourcePoolService.getOne(new QueryWrapper<WaterResourcePool>().eq("resource_id",
sequenceNbr));
if(null != waterResourcePool) {
if (null != waterResourcePool) {
BeanUtils.copyProperties(waterResourcePool, waterResourceDto);
}
break;
......@@ -285,12 +284,12 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
waterResourceDto.setIsDelete(isDelete);
// 查询物联参数
LambdaQueryWrapper<WaterResourceIndex> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(WaterResourceIndex::getWaterId,waterResourceDto.getSequenceNbr());
queryWrapper.eq(WaterResourceIndex::getWaterId, waterResourceDto.getSequenceNbr());
List<WaterResourceIndex> list = waterResourceIndexServiceImpl.list(queryWrapper);
if(list.size()>0) {
Map<String,Object> map = new HashMap<>();
list.stream().forEach(e->{
map.put(e.getNameKey(),e.getPerfValue());
if (list.size() > 0) {
Map<String, Object> map = new HashMap<>();
list.stream().forEach(e -> {
map.put(e.getNameKey(), e.getPerfValue());
});
waterResourceDto.setWaterResourceIotDto(map);
}
......@@ -330,60 +329,101 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
public List<Menu> getwaterResourceTypeTree(String bizOrgCode) throws Exception {
List<Menu> list = new ArrayList<>();
ResponseModel <Object> response= equipFeignClient.list();
if(response.getStatus() != 200) {
ResponseModel<Object> response = equipFeignClient.list();
if (response.getStatus() != 200) {
return null;
}
Object resultObject = response.getResult();
JSONArray childrenArray = null;
JSONArray waterTypeDetailArray = null;
JSONObject waterTypeDetailJson=null;
JSONObject waterTypeDetailJson = null;
JSONArray resultArray = JSONArray.parseArray(JSONArray.toJSONString(resultObject));
for (Object obj : resultArray) {
JSONObject detailJsonObject= JSONObject.parseObject(JSONObject.toJSONString(obj));
JSONObject detailJsonObject = JSONObject.parseObject(JSONObject.toJSONString(obj));
String codeString = detailJsonObject.getString("code");
if(codeString.equals("90000000")) {
if (codeString.equals("90000000")) {
childrenArray = detailJsonObject.getJSONArray("children");
break;
}
}
if(childrenArray!=null && childrenArray.size()>0) {
if (childrenArray != null && childrenArray.size() > 0) {
for (Object childObject : childrenArray) {
JSONObject detailChildJsonObject= JSONObject.parseObject(JSONObject.toJSONString(childObject));
JSONObject detailChildJsonObject = JSONObject.parseObject(JSONObject.toJSONString(childObject));
String codeStr = detailChildJsonObject.getString("code");
if(codeStr.equals("93000000")) {
waterTypeDetailArray=detailChildJsonObject.getJSONArray("children");
if (codeStr.equals("93000000")) {
waterTypeDetailArray = detailChildJsonObject.getJSONArray("children");
break;
}
}
}
if(waterTypeDetailArray!=null && waterTypeDetailArray.size()>0) {
if (waterTypeDetailArray != null && waterTypeDetailArray.size() > 0) {
for (Object childObject : waterTypeDetailArray) {
JSONObject waterTypeDetail= JSONObject.parseObject(JSONObject.toJSONString(childObject));
JSONObject waterTypeDetail = JSONObject.parseObject(JSONObject.toJSONString(childObject));
String codeStr = waterTypeDetail.getString("code");
if(codeStr.equals("93060000")) {
if (codeStr.equals("93060000")) {
waterTypeDetailJson = waterTypeDetail;
break;
}
}
}
if(waterTypeDetailJson!=null) {
Map<String, Object> map= waterResourceMapper.getWaterTypeByBizOrgCode(bizOrgCode);
int num=0;
if (waterTypeDetailJson != null) {
List<Map<String, Object>> mapList = waterResourceMapper.getWaterTypeByBizOrgCode(bizOrgCode);
Map<String, Object> map = new HashMap<>();
for (Map<String, Object> m : mapList) {
String key = "";
String value = "";
for(Map.Entry<String,Object> entry : m.entrySet()) {
if(entry.getKey().equals("num")) {
value = entry.getValue().toString();
}
if(entry.getKey().equals("type")) {
key = entry.getValue().toString();
}
}
map.put(key,value);
}
int num = 0;
JSONArray waterTypeDetailChildrenArray = waterTypeDetailJson.getJSONArray("children");
JSONArray array = new JSONArray();
for (Object childObject : waterTypeDetailChildrenArray) {
JSONObject detail= JSONObject.parseObject(JSONObject.toJSONString(childObject));
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(childObject));
String codeStr = detail.getString("code");
if(map!=null && map.containsKey(codeStr)) {
num=num+Integer.parseInt( map.get("codeStr").toString());
detail.put("num", Integer.parseInt( map.get("codeStr").toString()));
num=num+Integer.parseInt( map.get(codeStr).toString());
detail.put("num", Integer.parseInt( map.get(codeStr).toString()));
}else {
detail.put("num", 0);
}
Menu menu = new Menu(Long.valueOf(detail.get("id").toString()) ,detail.get("name").toString(),null,Integer.parseInt(detail.get("num").toString()));
// if ("93060100".equals(codeStr) && map.containsKey("pool")
// ) {
// num = num + Integer.parseInt(map.get("pool").toString());
// detail.put("num", Integer.parseInt(map.get("pool").toString()));
// }
//
// if (
// "93060200".equals(codeStr) && map.containsKey("crane")
// ) {
// num = num + Integer.parseInt(map.get("crane").toString());
// detail.put("num", Integer.parseInt(map.get("crane").toString()));
// }
//
// if (
// "93060300".equals(codeStr) && map.containsKey("natural")
// ) {
// num = num + Integer.parseInt(map.get("natural").toString());
// detail.put("num", Integer.parseInt(map.get("natural").toString()));
// }
//
// if (
// "93060400".equals(codeStr) && map.containsKey("hydrant")
// ) {
// num = num + Integer.parseInt(map.get("hydrant").toString());
// detail.put("num", Integer.parseInt(map.get("hydrant").toString()));
// }
Menu menu = new Menu(Long.valueOf(detail.get("code").toString()), detail.get("name").toString(), null, Integer.parseInt(detail.containsKey("num") ? detail.get("num").toString() : "0" ));
list.add(menu);
// if (detail.get("children").toString().length() == 2) {
......@@ -401,52 +441,53 @@ public class WaterResourceServiceImpl extends BaseService<WaterResourceDto, Wate
}
return list;
}
public Object getwaterResourceType() throws Exception {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
ResponseModel <Object> response= equipFeignClient.list();
if(response.getStatus() != 200) {
ResponseModel<Object> response = equipFeignClient.list();
if (response.getStatus() != 200) {
return null;
}
Object resultObject = response.getResult();
JSONArray childrenArray = null;
JSONArray waterTypeDetailArray = null;
JSONObject waterTypeDetailJson=null;
JSONObject waterTypeDetailJson = null;
JSONArray resultArray = JSONArray.parseArray(JSONArray.toJSONString(resultObject));
for (Object obj : resultArray) {
JSONObject detailJsonObject= JSONObject.parseObject(JSONObject.toJSONString(obj));
JSONObject detailJsonObject = JSONObject.parseObject(JSONObject.toJSONString(obj));
String codeString = detailJsonObject.getString("code");
if(codeString.equals("90000000")) {
if (codeString.equals("90000000")) {
childrenArray = detailJsonObject.getJSONArray("children");
break;
}
}
if(childrenArray!=null && childrenArray.size()>0) {
if (childrenArray != null && childrenArray.size() > 0) {
for (Object childObject : childrenArray) {
JSONObject detailChildJsonObject= JSONObject.parseObject(JSONObject.toJSONString(childObject));
JSONObject detailChildJsonObject = JSONObject.parseObject(JSONObject.toJSONString(childObject));
String codeStr = detailChildJsonObject.getString("code");
if(codeStr.equals("93000000")) {
waterTypeDetailArray=detailChildJsonObject.getJSONArray("children");
if (codeStr.equals("93000000")) {
waterTypeDetailArray = detailChildJsonObject.getJSONArray("children");
break;
}
}
}
if(waterTypeDetailArray!=null && waterTypeDetailArray.size()>0) {
if (waterTypeDetailArray != null && waterTypeDetailArray.size() > 0) {
for (Object childObject : waterTypeDetailArray) {
JSONObject waterTypeDetail= JSONObject.parseObject(JSONObject.toJSONString(childObject));
JSONObject waterTypeDetail = JSONObject.parseObject(JSONObject.toJSONString(childObject));
String codeStr = waterTypeDetail.getString("code");
if(codeStr.equals("93060000")) {
if (codeStr.equals("93060000")) {
waterTypeDetailJson = waterTypeDetail;
break;
}
}
}
if(waterTypeDetailJson!=null) {
if (waterTypeDetailJson != null) {
JSONArray waterTypeDetailChildrenArray = waterTypeDetailJson.getJSONArray("children");
for (Object childObject : waterTypeDetailChildrenArray) {
Map<String, Object> map = new LinkedHashMap<>();
JSONObject detail= JSONObject.parseObject(JSONObject.toJSONString(childObject));
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(childObject));
String codeStr = detail.getString("code");
String name = detail.getString("name");
map.put("code", codeStr);
......
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