Commit df1904dd authored by zhangsen's avatar zhangsen

巡检新需求

parent 28f0998f
......@@ -7,12 +7,12 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import com.yeejoin.equipmanage.common.enums.SourceTypeEnum;
import com.yeejoin.equipmanage.common.utils.SpringUtils;
import com.yeejoin.equipmanage.mapper.EquipmentCategoryMapper;
import com.yeejoin.equipmanage.service.ISourceStatistics;
import com.yeejoin.equipmanage.service.impl.SourcesStatisticsImpl;
import org.apache.commons.lang3.StringUtils;
......@@ -88,6 +88,9 @@ public class EquipmentCategoryController extends AbstractBaseController {
@Value("${redis_equip_type_count}")
private String equipTypeAndCount;
@Autowired
private EquipmentCategoryMapper equipmentCategoryMapper;
private static final String equipmentTreeListAll = "equipmentTreeListAll";
private static final String equipmentTreeListIndustry = "equipmentTreeListIndustry";
// 装备redis缓存key前缀
......@@ -378,6 +381,153 @@ public class EquipmentCategoryController extends AbstractBaseController {
}
/**
* 消防设施分类定义树
*
* @return
*/
@RequestMapping(value = "/equipAndFireAllTree", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "消防设施分类定义树组合消防装备树", notes = "消防设施分类定义树组合消防装备树")
public ResponseModel<List<EquipmentCategory>> equipAndFireAllTree() {
Double countAll = 0.0;
List<EquipmentCategory> result = new ArrayList<>();
List<EquipmentCategory> listFireCategories = listFirePrivate();
if (listFireCategories.size() == 2) {
countAll = listFireCategories.get(0).getCount() + listFireCategories.get(1).getCount();
}
List<EquipmentCategory> listEquipCategories = listEquipPrivate();
if (listEquipCategories.size() == 1) {
countAll = countAll + listEquipCategories.get(0).getCount();
}
List<EquipmentCategory> treeListByCustom = getTreeListByCustom();
if (treeListByCustom.size() == 2) {
countAll = countAll + treeListByCustom.get(0).getCount() + treeListByCustom.get(1).getCount();
}
Integer countAllInteger = (int) Math.ceil(countAll);
listFireCategories.addAll(listEquipCategories);
listFireCategories.addAll(treeListByCustom);
EquipmentCategory equipmentCategory = new EquipmentCategory();
equipmentCategory.setChildren(listFireCategories);
equipmentCategory.setCode("-3");
equipmentCategory.setName("全部类型" + "(" + countAllInteger + ")");
equipmentCategory.setId(-3L);
equipmentCategory.setHasLowerClassification(true);
result.add(equipmentCategory);
return CommonResponseUtil.success(result);
}
/**
* 自定义和重点部位组装
* @return
*/
private List<EquipmentCategory> getTreeListByCustom() {
List<EquipmentCategory> result = new ArrayList<>();
EquipmentCategory equipmentCategory = new EquipmentCategory();
int keyPartsTypeCount = equipmentCategoryMapper.countByKeyPartsType();
equipmentCategory.setCode("-4");
equipmentCategory.setName("重点部位" + "(" + keyPartsTypeCount + ")");
equipmentCategory.setCount((double) keyPartsTypeCount);
equipmentCategory.setId(-4L);
equipmentCategory.setParentId(-3L);
equipmentCategory.setHasLowerClassification(false);
result.add(equipmentCategory);
EquipmentCategory equipmentCategory2 = new EquipmentCategory();
int customTypeCount = equipmentCategoryMapper.countByCustomType();
equipmentCategory2.setCode("-5");
equipmentCategory2.setName("自定义巡查点" + "(" + customTypeCount + ")");
equipmentCategory2.setCount((double) customTypeCount);
equipmentCategory2.setId(-5L);
equipmentCategory2.setParentId(-3L);
equipmentCategory2.setHasLowerClassification(false);
result.add(equipmentCategory2);
return result;
}
private List<EquipmentCategory> listFirePrivate() {
List<EquipmentCategory> equipmentCategorys = this.iEquipmentCategoryService
.getEquipmentCategoryListByFacilities(Integer.valueOf(equipmentCategoryLeftTypeCode));
List<EquipmentCategory> list = new ArrayList<>();
List<EquipmentCategory> result = new ArrayList<>();
Map<String, List<EquipmentCategory>> tmpMap = new HashMap<String, List<EquipmentCategory>>();
final Double[] countAll = {0.0};
equipmentCategorys.forEach(action -> {
String subCode = action.getCode().replaceAll("0+$", "");
int count = equipmentCategoryMapper.countByCategoryCode(subCode);
action.setName(action.getName() + "(" + count + ")");
countAll[0] = count + countAll[0];
if (action.getName().equals("消防设施") ||action.getName().equals("消防系统")) {
action.setCount((double) count);
list.add(action);
} else {
if (tmpMap.get(action.getParentId().toString()) == null) {
ArrayList<EquipmentCategory> tmplist = new ArrayList<EquipmentCategory>();
tmplist.add(action);
tmpMap.put(action.getParentId().toString(), tmplist);
} else {
if (!tmpMap.get(action.getParentId().toString()).contains(action)) {
tmpMap.get(action.getParentId().toString()).add(action);
}
}
}
});
getChildren(list, tmpMap);
EquipmentCategory equipmentCategory = new EquipmentCategory();
equipmentCategory.setChildren(list);
equipmentCategory.setCode("-1");
equipmentCategory.setName("消防设施(" + countAll[0] + ")");
equipmentCategory.setCount(countAll[0]);
equipmentCategory.setId(-1L);
equipmentCategory.setHasLowerClassification(true);
equipmentCategory.setParentId(-3L);
result.add(equipmentCategory);
return result;
}
private List<EquipmentCategory> listEquipPrivate() {
List<EquipmentCategory> equipmentCategorys = this.iEquipmentCategoryService
.getEquipmentCategoryListNotFacilities(Integer.valueOf(equipmentCategoryLeftTypeCode));
List<EquipmentCategory> list = new ArrayList<>();
List<EquipmentCategory> result = new ArrayList<>();
Map<String, List<EquipmentCategory>> tmpMap = new HashMap<String, List<EquipmentCategory>>();
final Integer[] countAll = {0};
equipmentCategorys.forEach(action -> {
String subCode = action.getCode().replaceAll("0+$", "");
int count = equipmentCategoryMapper.countByCategoryCode(subCode);
countAll[0] = countAll[0] + count;
action.setName(action.getName() + "(" + count + ")");
if (action.getParentId() == null) {
action.setCount((double) count);
list.add(action);
} else {
if (tmpMap.get(action.getParentId().toString()) == null) {
ArrayList<EquipmentCategory> tmplist = new ArrayList<EquipmentCategory>();
tmplist.add(action);
tmpMap.put(action.getParentId().toString(), tmplist);
} else {
if (!tmpMap.get(action.getParentId().toString()).contains(action)) {
tmpMap.get(action.getParentId().toString()).add(action);
}
}
}
});
getChildren(list, tmpMap);
EquipmentCategory equipmentCategory = new EquipmentCategory();
equipmentCategory.setChildren(list);
equipmentCategory.setCode("-2");
equipmentCategory.setName("消防装备");
equipmentCategory.setId(-2L);
equipmentCategory.setCount((double)countAll[0]);
equipmentCategory.setHasLowerClassification(true);
equipmentCategory.setParentId(-3L);
result.add(equipmentCategory);
return result;
}
/**
*
* 获取子节点
**/
......
......@@ -57,6 +57,22 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> {
List<EquipmentCategory> getEquipmentCategoryListByFacilities(Integer head);
int countByCategoryCode(@Param("code") String code);
/**
* 重点部位数量
* @return
*/
int countByKeyPartsType();
/**
* 自定义数量
* @return
*/
int countByCustomType();
List<EquipmentCategory> getEquipmentCategoryCarList();
List<EquipmentCategory> getEquipmentCategoryEquipmentList();
......
......@@ -6,11 +6,14 @@ import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.patrol.business.dao.mapper.InputItemMapper;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -67,6 +70,11 @@ public class InputItemController extends AbstractBaseController {
IInputItemDao inputItemDao;
@Autowired
JcsFeignClient jcsFeignClient;
@Autowired
InputItemMapper inputItemMapper;
@Value("${equipment.hierarchy}")
private String hierarchy;
/**
......@@ -78,7 +86,40 @@ public class InputItemController extends AbstractBaseController {
@RequestMapping(value = "/queryItemByPageNew", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryItemByPageNew(
@ApiParam(value = "组合查询条件", required = false, defaultValue = "[]") @RequestBody(required = false) InputItemPageParam criterias,
@ApiParam(value = "分页参数", required = false, defaultValue = "current=0&pageSize=10或pageNumber0&pageSize=10") CommonPageable pageable) {
@ApiParam(value = "分页参数", required = false, defaultValue = "current=0&pageSize=10或pageNumber0&pageSize=10") CommonPageable pageable,
@ApiParam(value = "树code")@RequestParam(required = false) String treeId) {
int inhierarchy = 1;
String subCode = "";
if (StringUtil.isNotEmpty(treeId)) {
String[] result = hierarchy.split(",");
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < result.length; i++) {
map.put(i, Integer.valueOf(result[i]));
}
Map<String, String> equipmentCategory = inputItemMapper.getCategoryByCode(treeId, "2");
if (equipmentCategory == null) {
throw new RuntimeException("装备定义code有误");
}
for (int i = 0; i < result.length + 1; i++) {
//进来先判断是否默认就是空,如果为空第一层
if (!StringUtil.isNotEmpty(equipmentCategory.get("parentId"))) {
//判断是否是最下面的子节点
if (i >= 4) {
inhierarchy = 8;
} else {
inhierarchy = map.get(i);
}
break;
} else {
//查找到循环几次为空
equipmentCategory = inputItemMapper.getCategoryById(equipmentCategory.get("parentId"));
}
}
subCode = treeId.substring(0, inhierarchy);
}
ReginParams reginParams = getSelectedOrgInfo();
//查询向上查询所属单位的bizOrgCode
String bizOrgCode = reginParams.getPersonIdentity().getCompanyBizOrgCode();
......@@ -87,8 +128,9 @@ public class InputItemController extends AbstractBaseController {
criterias.setPageNumber(pageable.getPageNumber()-1);
criterias.setPageSize(pageable.getPageSize());
}
criterias.setTreeId(treeId);
criterias.setInhierarchy(inhierarchy);
criterias.setSubCode(subCode);
Page<InputItemVo> page = inputItemService.queryInputItemByPageNew(criterias);
return CommonResponseUtil.success(page);
}
......@@ -471,8 +513,9 @@ public class InputItemController extends AbstractBaseController {
if (param.getEquipmentType() == null && param.getCustomType() == null&&param.getFacilitiesType() == null&&param.getKeyPartsType() == null){
throw new BadRequest("适用类型至少需选择一项");
}
//如果为1则为否,顺应机场逻辑
param.setCustomType("1".equals(param.getCustomType()) ? null : param.getCustomType());
param.setKeyPartsType("1".equals(param.getKeyPartsType()) ? null : param.getKeyPartsType());
AgencyUserModel user = getUserInfo();
if (ObjectUtils.isEmpty(user)) {
return CommonResponseUtil.failure("用户session过期");
......
......@@ -22,8 +22,14 @@ public interface InputItemMapper extends BaseMapper {
* */
public long countInputItemInfoDataNew(InputItemPageParam param);
Map<String, String> getCategoryByCode(@Param("code") String code, @Param("industryCode") String industryCode);
Map<String, String> getCategoryById(@Param("id") String id);
public List<InputItemVo> getInputItemInfoNew(InputItemPageParam param);
Map<Long, Long> getAllCountInfo();
Map<String,String> getEquipParentCode(String code);
Map<String,String> getSystemParentCode(String id);
......
......@@ -23,6 +23,37 @@ public class InputItemPageParam extends CommonPageable{
private String itemType;
private List<Long> catalogIds;
private Integer inhierarchy;
private String subCode;
public Integer getInhierarchy() {
return inhierarchy;
}
public void setInhierarchy(Integer inhierarchy) {
this.inhierarchy = inhierarchy;
}
public String getSubCode() {
return subCode;
}
public void setSubCode(String subCode) {
this.subCode = subCode;
}
//查询页面左侧树ID
private String treeId;
public String getTreeId() {
return treeId;
}
public void setTreeId(String treeId) {
this.treeId = treeId;
}
public String getBizOrgCode() {
return bizOrgCode;
}
......
......@@ -357,7 +357,8 @@
FROM wl_equipment_category ec
left join wl_industry i on ec.industry_code = i.code
WHERE
(ec.code LIKE CONCAT ('92','%') and ec.parent_id = '1302863809086623746') or (ec.code LIKE CONCAT ('92','%') and ec.parent_id = '846')
<!-- (ec.code LIKE CONCAT ('92','%') and ec.parent_id = '1302863809086623746') or (ec.code LIKE CONCAT ('92','%') and ec.parent_id = '846')-->
ec.code like CONCAT ('92', '%')
</select>
......@@ -498,4 +499,19 @@
AND wl_equipment_category.industry_code = #{industryCode}
</if>
</select>
<select id="countByCategoryCode" resultType="int">
select count(*) from p_input_item
where equipment_type like concat(#{code}, '%') or facilities_type like concat(#{code}, '%')
</select>
<select id="countByKeyPartsType" resultType="int">
select count(*) from p_input_item
where key_parts_type is not null
</select>
<select id="countByCustomType" resultType="int">
select count(*) from p_input_item
where custom_type is not null
</select>
</mapper>
......@@ -59,3 +59,5 @@ jcs.fegin.name=JCS
emergency.command.section.id=1418223840361709569
management.endpoints.enabled-by-default=false
equipment.hierarchy=1,2,4,6
\ No newline at end of file
......@@ -269,6 +269,24 @@
<if test="bizOrgCode!=null and bizOrgCode!=''">
and a.biz_org_code LIKE CONCAT (#{bizOrgCode} ,'%')
</if>
<if test="treeId != null and treeId != '' and treeId == -1">
and a.facilities_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId == -2">
and a.equipment_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId == -4">
and a.key_parts_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId == -5">
and a.custom_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId != -3 and treeId != -1 and treeId != -2 and treeId != -4 and treeId != -5">
and (a.facilities_type = #{treeId} or a.equipment_type = #{treeId})
</if>
<if test="subCode!=null and subCode!='' and subCode!=' ' and treeId != null and treeId != '' and treeId != -3 and treeId != -1 and treeId != -2 and treeId != -4 and treeId != -5">
and ((LEFT (a.facilities_type, #{inhierarchy}) = #{subCode}) or (LEFT (a.facilities_type, #{inhierarchy}) = #{subCode}))
</if>
<choose>
<when test="level == '-0' ">and a.level is null</when>
<when test="level!=null and level != '-0'">and a.level = #{level}</when>
......@@ -276,6 +294,14 @@
order by a.id desc
</select>
<select id="getCategoryByCode" resultType="java.util.Map">
select ifnull(parent_id, '') as parentId from wl_equipment_category where code = #{code} and industry_code = #{industryCode}
</select>
<select id="getCategoryById" resultType="java.util.Map">
select ifnull(parent_id, '') as parentId from wl_equipment_category where id = #{id}
</select>
<select id="getInputItemInfoNew" resultMap="inputItemMap">
SELECT
a.id,
......@@ -316,6 +342,24 @@
<if test="bizOrgCode!=null and bizOrgCode!=''">
and a.biz_org_code LIKE CONCAT (#{bizOrgCode},'%')
</if>
<if test="treeId != null and treeId != '' and treeId == -1">
and a.facilities_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId == -2">
and a.equipment_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId == -4">
and a.key_parts_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId == -5">
and a.custom_type is not null
</if>
<if test="treeId != null and treeId != '' and treeId != -3 and treeId != -1 and treeId != -2 and treeId != -4 and treeId != -5">
and (a.facilities_type = #{treeId} or a.equipment_type = #{treeId})
</if>
<if test="subCode!=null and subCode!='' and subCode!=' ' and treeId != null and treeId != '' and treeId != -3 and treeId != -1 and treeId != -2 and treeId != -4 and treeId != -5">
and ((LEFT (a.facilities_type, #{inhierarchy}) = #{subCode}) or (LEFT (a.facilities_type, #{inhierarchy}) = #{subCode}))
</if>
<choose>
<when test="level == '-0' ">and a.level is null</when>
<when test="level!=null and level != '-0'">and a.level = #{level}</when>
......@@ -339,7 +383,39 @@
select * from wl_equipment_category where id = #{parentId}
</select>
<select id="getAllCountInfo" resultType="java.util.Map">
SELECT
IF
( equipment_type = - 1, - 2, equipment_type ) AS myId,
count( equipment_type ) AS count
FROM
p_input_item
WHERE
equipment_type IS NOT NULL
GROUP BY
equipment_type UNION ALL
SELECT
facilities_type AS myId,
count( facilities_type ) AS count
FROM
p_input_item
WHERE
facilities_type IS NOT NULL
GROUP BY
facilities_type UNION ALL
SELECT
- 5 AS myId,
count(*) AS count
FROM
p_input_item
WHERE
custom_type IS NOT NULL UNION ALL
SELECT
- 4 AS myId,
count(*) AS count
FROM
p_input_item
WHERE
key_parts_type IS NOT NULL
</select>
</mapper>
\ No newline at end of file
......@@ -333,7 +333,7 @@
ELSE
'移动点'
END) fixed,
p.charge_person_id userName,
p.charge_person_name userName,
p.charge_dept_id depid,
IFNULL(p.risk_source_id, '') as buildingId,
p.remark,
......
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