Commit 959c820d authored by zhangsen's avatar zhangsen

巡检优化

parent eb5e3bdb
......@@ -10,8 +10,11 @@ import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.equipmanage.common.enums.SourceTypeEnum;
import com.yeejoin.equipmanage.common.utils.SpringUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.config.PersonIdentify;
import com.yeejoin.equipmanage.mapper.EquipmentCategoryMapper;
import com.yeejoin.equipmanage.service.ISourceStatistics;
import com.yeejoin.equipmanage.service.impl.SourcesStatisticsImpl;
......@@ -28,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -96,6 +100,8 @@ public class EquipmentCategoryController extends AbstractBaseController {
// 装备redis缓存key前缀
private static final String prefix = "equipmentTreeList";
private static final String EQUIP_AND_FIRE_TREE = "EQUIP_AND_FIRE_TREE:";
/**
* 新增装备分类
*
......@@ -385,33 +391,32 @@ public class EquipmentCategoryController extends AbstractBaseController {
*
* @return
*/
@PersonIdentify
@RequestMapping(value = "/equipAndFireAllTree", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "消防设施分类定义树组合消防装备树", notes = "消防设施分类定义树组合消防装备树")
public ResponseModel<List<EquipmentCategory>> equipAndFireAllTree() {
Integer countAll = 0;
List<EquipmentCategory> result = new ArrayList<>();
List<EquipmentCategory> listFireCategories = listFirePrivate();
if (listFireCategories.size() == 2) {
countAll = listFireCategories.get(0).getPatrolNum() + listFireCategories.get(1).getPatrolNum();
}
List<EquipmentCategory> listEquipCategories = listEquipPrivate();
if (listEquipCategories.size() == 1) {
countAll = countAll + listEquipCategories.get(0).getPatrolNum();
}
List<EquipmentCategory> treeListByCustom = getTreeListByCustom();
if (treeListByCustom.size() == 2) {
countAll = countAll + treeListByCustom.get(0).getPatrolNum() + treeListByCustom.get(1).getPatrolNum();
public ResponseModel equipAndFireAllTree() {
ReginParams reginParams = getSelectedOrgInfo();
String bizOrgCode = !ValidationUtil.isEmpty(reginParams.getPersonIdentity()) && StringUtil.isNotEmpty(reginParams.getPersonIdentity().getBizOrgCode()) ? reginParams.getPersonIdentity().getBizOrgCode() : "";
if (redisUtils.hasKey(EQUIP_AND_FIRE_TREE + bizOrgCode)) {
return CommonResponseUtil.success(redisUtils.get(EQUIP_AND_FIRE_TREE + bizOrgCode));
}
List<EquipmentCategory> result = new ArrayList<>();
List<EquipmentCategory> listFireCategories = listFirePrivate(bizOrgCode);
List<EquipmentCategory> listEquipCategories = listEquipPrivate(bizOrgCode);
List<EquipmentCategory> treeListByCustom = getTreeListByCustom(bizOrgCode);
listFireCategories.addAll(listEquipCategories);
listFireCategories.addAll(treeListByCustom);
EquipmentCategory equipmentCategory = new EquipmentCategory();
equipmentCategory.setChildren(listFireCategories);
equipmentCategory.setCode("-3");
int countAll = StringUtils.isNotEmpty(bizOrgCode) ? equipmentCategoryMapper.countAll(bizOrgCode) : 0;
equipmentCategory.setName("全部类型" + "(" + countAll + ")");
equipmentCategory.setId(-3L);
equipmentCategory.setHasLowerClassification(true);
result.add(equipmentCategory);
//默认设置两天,新增修改删除数据时清除此缓存
redisUtils.set(EQUIP_AND_FIRE_TREE + bizOrgCode, result, 172800);
return CommonResponseUtil.success(result);
}
......@@ -419,11 +424,11 @@ public class EquipmentCategoryController extends AbstractBaseController {
* 自定义和重点部位组装
* @return
*/
private List<EquipmentCategory> getTreeListByCustom() {
private List<EquipmentCategory> getTreeListByCustom(String bizOrgCode) {
List<EquipmentCategory> result = new ArrayList<>();
EquipmentCategory equipmentCategory = new EquipmentCategory();
int keyPartsTypeCount = equipmentCategoryMapper.countByKeyPartsType();
int keyPartsTypeCount = StringUtils.isNotEmpty(bizOrgCode) ? equipmentCategoryMapper.countByKeyPartsType(bizOrgCode) : 0;
equipmentCategory.setCode("-4");
equipmentCategory.setName("重点部位" + "(" + keyPartsTypeCount + ")");
equipmentCategory.setPatrolNum(keyPartsTypeCount);
......@@ -432,7 +437,7 @@ public class EquipmentCategoryController extends AbstractBaseController {
equipmentCategory.setHasLowerClassification(false);
result.add(equipmentCategory);
EquipmentCategory equipmentCategory2 = new EquipmentCategory();
int customTypeCount = equipmentCategoryMapper.countByCustomType();
int customTypeCount = StringUtils.isNotEmpty(bizOrgCode) ? equipmentCategoryMapper.countByCustomType(bizOrgCode) : 0;
equipmentCategory2.setCode("-5");
equipmentCategory2.setName("自定义巡查点" + "(" + customTypeCount + ")");
equipmentCategory2.setPatrolNum(customTypeCount);
......@@ -443,7 +448,7 @@ public class EquipmentCategoryController extends AbstractBaseController {
return result;
}
private List<EquipmentCategory> listFirePrivate() {
private List<EquipmentCategory> listFirePrivate(String bizOrgCode) {
List<EquipmentCategory> equipmentCategorys = this.iEquipmentCategoryService
.getEquipmentCategoryListByFacilities(Integer.valueOf(equipmentCategoryLeftTypeCode));
List<EquipmentCategory> list = new ArrayList<>();
......@@ -453,7 +458,7 @@ public class EquipmentCategoryController extends AbstractBaseController {
equipmentCategorys.forEach(action -> {
String beginName = action.getName();
String subCode = action.getCode().replaceAll("0+$", "");
int count = equipmentCategoryMapper.countByCategoryCode(subCode);
int count = StringUtils.isNotEmpty(bizOrgCode)? equipmentCategoryMapper.countByCategoryCode(subCode, bizOrgCode) : 0;
action.setName(action.getName() + "(" + count + ")");
countAll[0] = count + countAll[0];
if (beginName.equals("消防设施") || beginName.equals("消防系统")) {
......@@ -486,7 +491,7 @@ public class EquipmentCategoryController extends AbstractBaseController {
}
private List<EquipmentCategory> listEquipPrivate() {
private List<EquipmentCategory> listEquipPrivate(String bizOrgCode) {
List<EquipmentCategory> equipmentCategorys = this.iEquipmentCategoryService
.getEquipmentCategoryListNotFacilities(Integer.valueOf(equipmentCategoryLeftTypeCode));
List<EquipmentCategory> list = new ArrayList<>();
......@@ -495,7 +500,7 @@ public class EquipmentCategoryController extends AbstractBaseController {
final Integer[] countAll = {0};
equipmentCategorys.forEach(action -> {
String subCode = action.getCode().replaceAll("0+$", "");
int count = equipmentCategoryMapper.countByCategoryCode(subCode);
int count = StringUtils.isNotEmpty(bizOrgCode)? equipmentCategoryMapper.countByCategoryCode(subCode, bizOrgCode) : 0;
countAll[0] = countAll[0] + count;
action.setName(action.getName() + "(" + count + ")");
if (action.getParentId() == null) {
......
......@@ -57,21 +57,26 @@ public interface EquipmentCategoryMapper extends BaseMapper<EquipmentCategory> {
List<EquipmentCategory> getEquipmentCategoryListByFacilities(Integer head);
int countByCategoryCode(@Param("code") String code);
int countByCategoryCode(@Param("code") String code, @Param("bizOrgCode") String bizOrgCode);
/**
* 重点部位数量
* @return
*/
int countByKeyPartsType();
int countByKeyPartsType(@Param("bizOrgCode") String bizOrgCode);
/**
* 自定义数量
* @return
*/
int countByCustomType();
int countByCustomType(@Param("bizOrgCode") String bizOrgCode);
/**
* 所有数量
* @return
*/
int countAll(@Param("bizOrgCode") String bizOrgCode);
List<EquipmentCategory> getEquipmentCategoryCarList();
List<EquipmentCategory> getEquipmentCategoryEquipmentList();
......
......@@ -8,6 +8,7 @@ import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.patrol.business.dao.mapper.InputItemMapper;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import org.apache.commons.lang3.StringUtils;
......@@ -78,6 +79,14 @@ public class InputItemController extends AbstractBaseController {
@Value("${equipment.hierarchy}")
private String hierarchy;
@Autowired
private RedisUtils redisUtils;
/**
* 检查项列表左侧树缓存Key
*/
private static final String EQUIP_AND_FIRE_TREE = "EQUIP_AND_FIRE_TREE:";
/**
* 新加接口*****************************************************************************
......@@ -298,11 +307,13 @@ public class InputItemController extends AbstractBaseController {
public CommonResponse batchDelItem(
@ApiParam(value = "巡检项ID(检查项id以英文半角逗号分割。如: 1,2)") @RequestParam(required = true) String itemIDs) {
try {
ReginParams reginParams = getSelectedOrgInfo();
if (ObjectUtils.isEmpty(itemIDs)) {
return CommonResponseUtil.failure("请选择要删除的检查项");
}
String[] ids = itemIDs.split(",");
inputItemService.batchDelInputItem(ids);
redisUtils.del(EQUIP_AND_FIRE_TREE + (reginParams.getPersonIdentity().getBizOrgCode() == null? "" :reginParams.getPersonIdentity().getBizOrgCode()));
return CommonResponseUtil.success();
} catch (Exception e) {
return CommonResponseUtil.failure("检查项新增失败: " + e.getMessage());
......@@ -613,7 +624,7 @@ public class InputItemController extends AbstractBaseController {
inputItem.setId(param.getId());
inputItemService.updateInputItem(inputItem);
}
redisUtils.del(EQUIP_AND_FIRE_TREE + (reginParams.getPersonIdentity().getBizOrgCode() == null? "" :reginParams.getPersonIdentity().getBizOrgCode()));
return CommonResponseUtil.success();
} catch (Exception e) {
return CommonResponseUtil.failure("检查项新增失败: " + e.getMessage());
......
......@@ -502,16 +502,33 @@
<select id="countByCategoryCode" resultType="int">
select count(*) from p_input_item
where equipment_type like concat(#{code}, '%') or facilities_type like concat(#{code}, '%')
where (equipment_type like concat(#{code}, '%') or facilities_type like concat(#{code}, '%'))
AND biz_org_code like concat(#{bizOrgCode}, '%')
AND is_delete = '0'
AND input_type!='1'
</select>
<select id="countByKeyPartsType" resultType="int">
select count(*) from p_input_item
where key_parts_type is not null
AND biz_org_code like concat(#{bizOrgCode}, '%')
AND is_delete = '0'
AND input_type!='1'
</select>
<select id="countByCustomType" resultType="int">
select count(*) from p_input_item
where custom_type is not null
AND biz_org_code like concat(#{bizOrgCode}, '%')
AND is_delete = '0'
AND input_type!='1'
</select>
<select id="countAll" resultType="int">
select count(*) from p_input_item
where
biz_org_code like concat(#{bizOrgCode}, '%')
AND is_delete = '0'
AND input_type!='1'
</select>
</mapper>
......@@ -286,7 +286,7 @@
and a.custom_type is not null
</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}))
and ((LEFT (a.facilities_type, #{inhierarchy}) = #{subCode}) or (LEFT (a.equipment_type, #{inhierarchy}) = #{subCode}))
</if>
<choose>
<when test="level == '-0' ">and a.level is null</when>
......@@ -359,7 +359,7 @@
and a.custom_type is not null
</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}))
and ((LEFT (a.facilities_type, #{inhierarchy}) = #{subCode}) or (LEFT (a.equipment_type, #{inhierarchy}) = #{subCode}))
</if>
<choose>
<when test="level == '-0' ">and a.level is null</when>
......@@ -393,6 +393,8 @@
p_input_item
WHERE
equipment_type IS NOT NULL
AND a.is_delete = '0'
AND a.input_type!='1'
GROUP BY
equipment_type UNION ALL
SELECT
......@@ -402,6 +404,8 @@
p_input_item
WHERE
facilities_type IS NOT NULL
AND a.is_delete = '0'
AND a.input_type!='1'
GROUP BY
facilities_type UNION ALL
SELECT
......@@ -410,7 +414,10 @@
FROM
p_input_item
WHERE
custom_type IS NOT NULL UNION ALL
custom_type IS NOT NULL
AND a.is_delete = '0'
AND a.input_type!='1'
UNION ALL
SELECT
- 4 AS myId,
count(*) AS count
......@@ -418,6 +425,8 @@
p_input_item
WHERE
key_parts_type IS NOT NULL
AND a.is_delete = '0'
AND a.input_type!='1'
</select>
<select id="getAllCategoryName" resultType="java.util.Map">
......
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