Commit fcf9c2c8 authored by zhangsen's avatar zhangsen

管网压力等表单字段迁移 -》 mapper、实体、service建立

parent 4ed560ec
package com.yeejoin.equipmanage.common.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author DELL
*/
@Data
@TableName("wl_form_group_column_equip")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "wl_form_group_column_equip对象", description = "分组表")
public class FormGroupColumnEquip extends BaseEntity {
@ApiModelProperty(value = "字段名")
@TableField("field_name")
private String fieldName;
@ApiModelProperty(value = "中文名")
@TableField("field_label")
private String fieldLabel;
@ApiModelProperty(value = "数据类型:文本,数字,枚举,日期")
@TableField("data_type")
private String dataType;
@ApiModelProperty(value = "字段分组主键")
@TableField("group_id")
private Long groupId;
@ApiModelProperty(value = "查询策略;全等,模糊,区间")
@TableField("query_strategy")
private String queryStrategy;
@ApiModelProperty(value = "不能为空")
@TableField("not_null")
private Boolean notNull;
@ApiModelProperty(value = "分组编号")
@TableField("group_code")
private String groupCode;
@ApiModelProperty(value = "创建者")
@TableField("creator_id")
private Long creatorId;
}
package com.yeejoin.equipmanage.common.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author DELL
*/
@Data
@TableName("wl_form_group_equip")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "wl_form_group_equip对象", description = "分组表")
public class FormGroupEquip extends BaseEntity {
@ApiModelProperty(value = "分组名称")
@TableField("group_name")
private String groupName;
@ApiModelProperty(value = "分组编号")
@TableField("group_code")
private String groupCode;
@ApiModelProperty(value = "分组类型(点位图过滤用)")
@TableField("group_type")
private String groupType;
@ApiModelProperty(value = "允许的操作(逗号分隔ids)")
@TableField("allow_operation")
private String allowOperation;
@ApiModelProperty(value = "创建者")
@TableField("creator_id")
private Long creatorId;
}
package com.yeejoin.equipmanage.common.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author DELL
*/
@Data
@TableName("wl_form_instance_equip")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "wl_form_instance_equip", description = "实例表")
public class FormInstanceEquip extends BaseEntity {
@ApiModelProperty(value = "字段名")
@TableField("field_name")
private String fieldName;
@ApiModelProperty(value = "中文名")
@TableField("field_label")
private String fieldLabel;
@ApiModelProperty(value = "数据类型:文本,数字,枚举,日期")
@TableField("data_type")
private String dataType;
@ApiModelProperty(value = "字段分组主键")
@TableField("group_id")
private Long groupId;
@ApiModelProperty(value = "动态配置字段的值")
@TableField("field_value")
private String fieldValue;
@ApiModelProperty(value = "分组类型(冗余字段便于查询)")
@TableField("group_type")
private String groupType;
@ApiModelProperty(value = "设备实例id")
@TableField("instance_id")
private Long instanceId;
@ApiModelProperty(value = "字段定义信息的主键")
@TableField("group_column_id")
private Long groupColumnId;
@ApiModelProperty(value = "查询策略;全等,模糊,区间")
@TableField("query_strategy")
private String queryStrategy;
@ApiModelProperty(value = "分组编号")
@TableField("group_code")
private String groupCode;
@ApiModelProperty(value = "创建者")
@TableField(value = "creator_id",fill = FieldFill.INSERT_UPDATE)
private Long creatorId;
}
package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.equipmanage.common.entity.FormGroupColumnEquip;
/**
* 分组字段表
* @author DELL
*/
public interface FormGroupColumnEquipMapper extends BaseMapper<FormGroupColumnEquip> {
}
package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.equipmanage.common.entity.FormGroupEquip;
/**
* 分组表
* @author DELL
*/
public interface FormGroupEquipMapper extends BaseMapper<FormGroupEquip> {
}
package com.yeejoin.equipmanage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.entity.FormInstanceEquip;
import com.yeejoin.equipmanage.common.entity.dto.BuildIsRiskDTO;
import com.yeejoin.equipmanage.common.entity.dto.BuildSearchDTO;
import com.yeejoin.equipmanage.common.entity.vo.BuildingVideoListVO;
import org.apache.ibatis.annotations.Param;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* 分组字段表
* @author DELL
*/
public interface FormInstanceEquipMapper extends BaseMapper<FormInstanceEquip> {
/**
* 实例基本信息分页查询
* @param page 分页信息
* @param params 查询条件
* @param fieldNames 字段
* @return List<Map<String,Object>>
*/
Page<Map<String,Object>> queryInstancePage(Page page,
@Param("groupCode") String groupCode,
@Param("fieldNames") Map<String,Object> fieldNames,
@Param("params") Map<String,String> params
);
/**
* 不分页查询
* @param groupCode 分组编号
* @param fieldNames 字段
* @param params 查询参数
* @return List<Map<String, Object>>
*/
List<Map<String, Object>> queryForMapList(@Param("groupCode") String groupCode,
@Param("fieldNames") Map<String, Object> fieldNames,
@Param("params") Map<String, String> params);
/**
* 查询指定节点的子
* @param parentId
* @return
*/
List<Map<String,Object>> querySpecialChildrenList(String parentId, String bizOrgCode);
/**
* 查询指定节点的子
* @param parentId
* @return
*/
List<Map<String,Object>> querySpecialChildrenListByName(String parentId, String bizOrgCode, String name);
/**
* 查询指定节点的子
* @param parentId
* @return
*/
List<Map<String,Object>> querySpecialChildrenListByBizOrgCode(@Param("parentId") String parentId, @Param("bizOrgCode") String bizOrgCode);
/**
* @Description 分页查询
* @param dto 查询参数
* @Return List<Map<String,Object>>
* @Date 2020/12/19 11:47
*/
Page queryPage(Page page, @Param("query") BuildSearchDTO dto);
/**
* @Description 不分页
* @param dto 查询参数
* @Return List<Map<String,Object>>
* @Date 2020/12/19 11:47
*/
List<Map<String,Object>> queryPage(@Param("query") BuildSearchDTO dto);
/**
* @Description 分页查询
* @param dto 查询参数
* @Return List<Map<String,Object>>
* @Date 2020/12/19 11:47
*/
Page roomPage(Page page, @Param("query") BuildSearchDTO dto);
/**
* @Description 查询列表
* @param dto 查询参数
* @Return List<Map<String,Object>>
* @Date 2020/12/19 11:47
*/
List<Map<String,Object>> roomPage(@Param("query") BuildSearchDTO dto);
/**
* @Description 根据parentId查询其下资源(楼层、房间)
* @param instanceId
* @Return List<Map<String,Object>>
* @Date 2020/12/19 15:06
*/
List<Map<String,Object>> queryFloorRoom(List<Long> instanceId);
/**
* 根据instanceId、groupType,获取建筑楼层list
* @param dto
* @return
*/
List<BuildSearchDTO> getBuildFloorList(@Param("query") BuildSearchDTO dto);
/**
* 根据instanceId,获取建筑楼层信息
* @param instanceId
* @param fileCategory
* @return
*/
LinkedHashMap<String, Object> findByInstanceId(@Param("instanceId") Long instanceId, @Param("fileCategory") String fileCategory);
List<LinkedHashMap<String, Object>> findDetailByInstanceId(@Param("instanceId") Long instanceId, @Param("fileCategory") String fileCategory);
/**
* 消防建筑视屏监控统计树
* @return
* @param bizOrgCodeList
*/
List<Map<String, Object>> getBuildVideoListCount(@Param("list") List<String> bizOrgCodeList);
/**
* 可乐建筑视屏监控统计树
* @return
*/
List<Map<String, Object>> getColaBuildVideoListCount(@Param("dto") BuildingVideoListVO dto);
/**
* 同步仓库
* @param formKeyMap
* @return
*/
int saveStucture(Map<String, Object> formKeyMap);
Map<String, String> getChildListdate(@Param("id")Long id);
void updateListChild(@Param("value")String value,
@Param("ids") List<String> ids,
@Param("fieldName") String fieldName);
/**
* 获取仓库父类详细位置
* @param id
* @return
*/
String getStuctureName(String id);
String getStuName(String id);
Long getStructureParentId(String id);
/**
* 删除仓库
* @param id
* @return
*/
int deleteStuById(Long id);
/**
* 修改仓库
*/
int updateStr(@Param("id") Long id,@Param("name") String name,@Param("fullName") String fullName,@Param("parentId")String parentId, @Param("code")String code, @Param("bizOrgCode")String bizOrgCode,@Param("bizOrgName")String bizOrgName);
/**
* 修改仓库
*/
int updateStrFullName(@Param("id") Long id,@Param("name") String name,@Param("fullName") String fullName);
/**
* 查询未设置风险区域的子风险区域列表
* @param instanceId
* @return
*/
List<BuildIsRiskDTO> getChildrenNotIsRiskList(@Param("instanceId") String instanceId);
int clearSystemId(@Param("id") Long id );
/**
* 清除绑定关系
* @param instanceId 建筑实例id
*/
void clearRegionBind(Long instanceId);
/*
* 查询id下是否还有子类货位信息
* */
List<Map<String,Object>> getParentId(Long parentId);
Map<String, String> getIdAndType(String id);
Map<String, Object> getFormInstanceById(Long instanceId);
/**
* 获取所有建筑 用于数据字典 // 需求958 导出模板需要列表获取建筑 by kongfm 2021-09-15
* @return
*/
List<LinkedHashMap<String, Object>> getAllBuilding();
Map<String, String> getBuildingToLongitudeAndLatitude(String instanceId);
List<Map<String, Long>> getBuildVideoCount();
int updateFormInstanceByInstanceAndFieldName(String name,String value ,Long instanceId);
/**
* 查询子节点
* @param id
* @return
*/
List<String> selectChildListdate(@Param("id")Long id);
int updateFormFieldValue(@Param("id") Long id, @Param("name") String name, @Param("value") String value);
}
package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.equipmanage.common.entity.FormGroupColumn;
import com.yeejoin.equipmanage.common.entity.FormGroupColumnEquip;
import java.util.List;
import java.util.Map;
/**
* @author DELL
*/
public interface IFormGroupColumnEquipService extends IService<FormGroupColumnEquip> {
/**
* 查询指定分组的字段
* @param groupCode 分组
* @return List<FormGroupColumn>
*/
List<FormGroupColumnEquip> queryByGroup(String groupCode);
/**
* 枚举处理
* @param fieldName 需要处理的字段名
* @param value 需要处理的字段值
* @return Map<String, Map<String, Object>>
*/
Map<String, Map<String, Object>> processEnumData(String fieldName, String value);
}
package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.equipmanage.common.entity.FormGroup;
import com.yeejoin.equipmanage.common.entity.FormGroupEquip;
import java.util.Map;
/**
* @author DELL
*/
public interface IFormGroupEquipService extends IService<FormGroupEquip> {
/**
* @Description 根据groupCode查询
* @param groupCode
* @Return FormGroup
* @Date 2020/12/18 10:01
*/
FormGroupEquip allowOperationByGroupCode(String groupCode);
/**
* 按照唯一主键查询
* @param groupCode 编号
* @return FormGroup
*/
FormGroupEquip getByUniqueKey(String groupCode);
}
package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yeejoin.equipmanage.common.entity.FormInstanceEquip;
/**
* @author DELL
*/
public interface IFormInstanceEquipService extends IService<FormInstanceEquip> {
}
package com.yeejoin.equipmanage.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.yeejoin.equipmanage.common.entity.FormGroupColumnEquip;
import com.yeejoin.equipmanage.mapper.FormGroupColumnEquipMapper;
import com.yeejoin.equipmanage.service.IFormGroupColumnEquipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.component.cache.enumeration.CacheType;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.equipmanage.common.entity.FormGroupColumn;
import com.yeejoin.equipmanage.common.enums.DataOption;
import com.yeejoin.equipmanage.mapper.FormGroupColumnMapper;
import com.yeejoin.equipmanage.service.IFormGroupColumnService;
/**
* @author DELL
*/
@Service
public class FormGroupColumnEquipServiceImpl extends ServiceImpl<FormGroupColumnEquipMapper, FormGroupColumnEquip> implements IFormGroupColumnEquipService {
@Autowired
private RedisUtils redisUtils;
@Override
public List<FormGroupColumnEquip> queryByGroup(String groupCode) {
QueryWrapper<FormGroupColumnEquip> wrapper = new QueryWrapper<>();
wrapper.eq("group_code",groupCode);
return this.baseMapper.selectList(wrapper);
}
@Override
public Map<String, Map<String, Object>> processEnumData(String fieldName, String value) {
Map<String, Map<String, Object>> returnMap = new HashMap<>();
DataOption option = DataOption.getInstance(fieldName);
if (!ValidationUtil.isEmpty(option)) {
try {
String cacheKey = Redis.genKey(CacheType.ERASABLE.name(), "ENUM_DICT_VALUE",option.name());
List<DictionarieValueModel> valueModels = redisUtils.get(cacheKey) == null ? new ArrayList<>() : JSONObject.parseArray(redisUtils.get(cacheKey).toString(),DictionarieValueModel.class);
if (ValidationUtil.isEmpty(valueModels)) {
valueModels = FeignUtil.remoteCall(() -> Systemctl.dictionarieClient.dictValues(option.name()));
redisUtils.set(cacheKey, JSONObject.toJSONString(valueModels),60*60*24);
}
if (!ValidationUtil.isEmpty(valueModels)) {
Map<String, Object> map = new HashMap<>();
Map dictValueMap = Bean.listToMap(valueModels, "dictDataKey", "dictDataValue", DictionarieValueModel.class);
String dictKeys[] = StringUtil.string2Array(value);
for (String dictKey : dictKeys){
map.put(dictKey, dictValueMap.get(dictKey));
}
returnMap.put(fieldName + "_dictValue", map);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new RuntimeException("枚举类型处理失败.");
}
}
return returnMap;
}
}
package com.yeejoin.equipmanage.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.equipmanage.common.entity.FormGroup;
import com.yeejoin.equipmanage.common.entity.FormGroupEquip;
import com.yeejoin.equipmanage.mapper.FormGroupEquipMapper;
import com.yeejoin.equipmanage.mapper.FormGroupMapper;
import com.yeejoin.equipmanage.service.IFormGroupEquipService;
import com.yeejoin.equipmanage.service.IFormGroupService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author DELL
*/
@Service
public class FormGroupEquipServiceImpl extends ServiceImpl<FormGroupEquipMapper, FormGroupEquip> implements IFormGroupEquipService {
@Value("${systemctl.dict.allow-operation}")
private String allowOperation;
/**
* @param groupCode
* @Description 根据groupCode查询
* @Return FormGroup
* @Date 2020/12/18 10:01
*/
@Override
public FormGroupEquip allowOperationByGroupCode(String groupCode) {
FormGroupEquip formGroup = this.getOne(new QueryWrapper<FormGroupEquip>()
.lambda()
.eq(FormGroupEquip::getGroupCode, groupCode));
Optional.ofNullable(formGroup).orElseThrow(() -> new BadRequest("分组CODE查询formGroup不存在"));
return formGroup;
}
@Override
public FormGroupEquip getByUniqueKey(String groupCode) {
QueryWrapper<FormGroupEquip> wrapper = new QueryWrapper<>();
wrapper.eq("group_code", groupCode);
return this.getOne(wrapper);
}
}
package com.yeejoin.equipmanage.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.equipmanage.common.entity.FormInstanceEquip;
import com.yeejoin.equipmanage.mapper.FormInstanceEquipMapper;
import com.yeejoin.equipmanage.service.IFormInstanceEquipService;
import org.springframework.stereotype.Service;
/**
* @author DELL
*/
@Service
public class FormInstanceEquipServiceImpl extends ServiceImpl<FormInstanceEquipMapper, FormInstanceEquip> implements IFormInstanceEquipService {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.equipmanage.mapper.FormGroupColumnEquipMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.equipmanage.mapper.FormGroupEquipMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.equipmanage.mapper.FormInstanceEquipMapper">
<resultMap id="resultMapDTO" type="com.yeejoin.equipmanage.common.entity.dto.BuildSearchDTO">
<result column="instanceId" property="instanceId"/>
<result column="fieldValue" property="fieldValue"/>
<result column="groupType" property="groupType"/>
</resultMap>
<select id="queryInstancePage" resultType="map">
select
d.*
from
(
select
i.INSTANCE_ID instanceId,
i.GROUP_CODE groupCode,
<foreach collection="fieldNames" item="value" index="key" separator=",">
MAX(CASE WHEN i.FIELD_NAME = #{key} THEN i.FIELD_VALUE END) as ${key}
</foreach>
from
wl_form_instance_equip i
where i.GROUP_CODE = #{groupCode}
GROUP by
i.INSTANCE_ID)d
<if test="params != null and params.size() > 0">
where
1=1
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldNames[key] == 'like' and value !=null and value !=''">
and d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldNames[key] == 'eq' and value !=null and value !=''">
and d.${key} = #{value}
</when>
</choose>
</foreach>
</if>
order by instanceId desc
</select>
<select id="getChildListdate" resultType="map">
SELECT getChildListdate ( #{id} ) ids
</select>
<update id="updateListChild" >
UPDATE wl_form_instance_equip set field_value =#{value}
where wl_form_instance_equip.group_type in('building','room','floor')
<if test ="ids != null and ids.size()>0">
and wl_form_instance_equip.instance_id in
<foreach collection="ids" index="index" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
and wl_form_instance_equip.field_name=#{fieldName}
</update>
<select id="queryForMapList" resultType="map">
select
d.*
from
(
select
i.INSTANCE_ID instanceId,
i.GROUP_CODE groupCode
<foreach collection="fieldNames" item="value" open="," index="key" separator=",">
MAX( CASE WHEN i.FIELD_NAME = #{key} THEN i.FIELD_VALUE END) ${key}
</foreach>
from
wl_form_instance_equip i
where i.GROUP_CODE = #{groupCode}
GROUP by
i.INSTANCE_ID)d
<if test="params != null and params.size() > 0">
where
1=1
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldNames[key] == 'like' and value !=null and value !=''">
AND d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldNames[key] == 'eq' and value !=null and value !=''">
AND d.${key} = #{value}
</when>
</choose>
</foreach>
</if>
order by d.instanceId desc
</select>
<select id="querySpecialChildrenList" resultType="hashmap">
SELECT
*
FROM
(
SELECT
a.instance_id as id,
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
wlss.scene_id as sceneId,
MAX( CASE WHEN a.field_name = 'parentId' THEN a.field_value END ) AS parentId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS instanceName,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS name,
MAX( CASE WHEN a.field_name = 'code' THEN a.field_value END ) AS code,
MAX( CASE WHEN a.field_name = 'isRisk' THEN a.field_value END ) AS isRisk,
MAX( CASE WHEN a.field_name = 'address' THEN a.field_value END ) AS address,
MAX( CASE WHEN a.field_name = 'bizOrgCode' THEN a.field_value END ) AS bizOrgCode,
MAX( CASE WHEN a.field_name = 'bizOrgName' THEN a.field_value END ) AS bizOrgName
FROM
`wl_form_instance_equip` a
LEFT JOIN wl_source_scene wlss ON wlss.source_id = a.instance_id
GROUP BY
a.instance_id
) sa
<where>
<if test="parentId != null and parentId !=''">
sa.parentId = #{parentId}
</if>
<if test="bizOrgCode != null and bizOrgCode !=''">
sa.bizOrgCode like CONCAT(#{bizOrgCode},'%')
</if>
</where>
</select>
<select id="querySpecialChildrenListByName" resultType="hashmap">
SELECT
*
FROM
(
SELECT
a.instance_id as id,
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
wlss.scene_id as sceneId,
MAX( CASE WHEN a.field_name = 'parentId' THEN a.field_value END ) AS parentId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS instanceName,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS name,
MAX( CASE WHEN a.field_name = 'code' THEN a.field_value END ) AS code,
MAX( CASE WHEN a.field_name = 'isRisk' THEN a.field_value END ) AS isRisk,
MAX( CASE WHEN a.field_name = 'address' THEN a.field_value END ) AS address,
MAX( CASE WHEN a.field_name = 'bizOrgCode' THEN a.field_value END ) AS bizOrgCode,
MAX( CASE WHEN a.field_name = 'bizOrgName' THEN a.field_value END ) AS bizOrgName
FROM
`wl_form_instance_equip` a
LEFT JOIN wl_source_scene wlss ON wlss.source_id = a.instance_id
GROUP BY
a.instance_id
) sa
<where>
<if test="parentId != null and parentId !=''">
and sa.parentId = #{parentId}
</if>
<if test="bizOrgCode != null and bizOrgCode !=''">
and sa.bizOrgCode like CONCAT(#{bizOrgCode},'%')
</if>
<if test="name != null and name !=''">
and sa.instanceName like CONCAT('%', #{name}, '%')
</if>
</where>
</select>
<select id="queryPage" resultType="hashmap">
select * from (SELECT
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
a.field_value AS fieldValue,
a.field_label AS fieldLabel,
MAX(CASE WHEN a.field_name = 'parentId' THEN a.field_value END) AS parentId,
MAX(CASE WHEN a.field_name = 'name' THEN a.field_value END)AS buildName,
MAX(CASE WHEN a.field_name = 'isRisk' THEN a.field_value END)AS isRisk,
MAX(CASE WHEN a.field_name = 'code' THEN a.field_value END)AS buildCode,
MAX(CASE WHEN a.field_name = 'certificatesPersonNum' THEN a.field_value END)AS certificatesPersonNum,
MAX(CASE WHEN a.field_name = 'dutyUser' THEN a.field_value END)AS dutyUser,
MAX(CASE WHEN a.field_name = 'hasFirePlan' THEN a.field_value END)AS hasFirePlan,
MAX(CASE WHEN a.field_name = 'installLoc' THEN a.field_value END)AS installLoc,
MAX(CASE WHEN a.field_name = 'inwhichBuild' THEN a.field_value END)AS inwhichBuild,
MAX(CASE WHEN a.field_name = 'maintenanceUnit' THEN a.field_value END)AS maintenanceUnit,
MAX(CASE WHEN a.field_name = 'bizOrgCode' THEN a.field_value END)AS bizOrgCode,
MAX(CASE WHEN a.field_name = 'bizOrgName' THEN a.field_value END)AS bizOrgName
FROM
`wl_form_instance_equip` a
GROUP BY
a.instance_id) sa
<where>
sa.parentId in
<foreach item="item" index="index" collection="query.instanceIds" open="(" separator="," close=")">
#{item}
</foreach>
<if test="query.fieldValue != null and query.fieldValue !=''">
AND sa.fieldValue = #{query.fieldValue}
</if>
<if test="query.bizOrgCode != null and query.bizOrgCode !=''">
AND sa.bizOrgCode LIKE CONCAT(#{query.bizOrgCode},'%')
</if>
</where>
ORDER BY sa.instanceId DESC
</select>
<select id="roomPage" resultType="hashmap">
select * from (SELECT
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
a.field_value AS fieldValue,
a.field_label AS fieldLabel,
MAX(CASE WHEN a.field_name = 'parentId' THEN a.field_value END) AS parentId,
MAX(CASE WHEN a.field_name = 'name' THEN a.field_value END)AS buildName,
MAX(CASE WHEN a.field_name = 'isRisk' THEN a.field_value END)AS isRisk
FROM
`wl_form_instance_equip` a
GROUP BY
a.instance_id) sa
<where>
sa.instanceId in
<foreach item="item" index="index" collection="query.instanceIds" open="(" separator="," close=")">
#{item}
</foreach>
<if test="query.fieldValue != null and query.fieldValue !=''">
AND sa.fieldValue = #{query.fieldValue}
</if>
</where>
ORDER BY sa.instanceId DESC
</select>
<select id="queryFloorRoom" resultType="hashmap">
SELECT * FROM (SELECT
a.instance_id AS instanceId,
a.group_type AS groupType,
MAX(
CASE
WHEN a.field_name = 'parentId' THEN
a.field_value
END
) AS parentId
FROM
`wl_form_instance_equip` a
GROUP BY
a.instance_id) sa
WHERE sa.parentId in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getBuildFloorList" resultMap="resultMapDTO">
SELECT
sa.instanceId,
sa.groupType,
sa.fieldValue
FROM
(
SELECT
a.instance_id AS instanceId,
a.group_type AS groupType,
MAX( CASE WHEN a.field_name = 'parentId' THEN a.field_value END ) AS parentId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS fieldValue
FROM
`wl_form_instance_equip` a
GROUP BY
a.instance_id
) sa
<where>
sa.parentId = #{query.instanceId}
<if test="query.groupType != null and query.groupType !=''">
AND sa.groupType = #{query.groupType}
</if>
</where>
ORDER BY
sa.instanceId DESC
</select>
<select id="findDetailByInstanceId" resultType="java.util.LinkedHashMap">
SELECT
a.field_label AS `key`,
a.field_value AS `value`
FROM
`wl_form_instance_equip` a
WHERE
a.instance_id = #{instanceId}
AND
a.field_label != '父级id'
ORDER BY a.group_column_id
</select>
<select id="findByInstanceId" resultType="java.util.LinkedHashMap">
SELECT
fi.NAME AS '建筑名称',
fi.dutyUser AS '负责人',
fi.buildType AS '建筑结构',
fi.dutyUserPhone AS '负责人电话',
fi.buildUseType AS '使用性质',
fi.structureType AS '结构类型',
fi.address AS '详细地址'
FROM
(
SELECT
a.instance_id,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS NAME,
MAX( CASE WHEN a.field_name = 'dutyUser' THEN a.field_value END ) AS dutyUser,
MAX( CASE WHEN a.field_name = 'buildType' THEN a.field_value END ) AS buildType,
MAX( CASE WHEN a.field_name = 'dutyUserPhone' THEN a.field_value END ) AS dutyUserPhone,
MAX( CASE WHEN a.field_name = 'buildUseType' THEN a.field_value END ) AS buildUseType,
MAX( CASE WHEN a.field_name = 'structureType' THEN a.field_value END ) AS structureType,
MAX( CASE WHEN a.field_name = 'address' THEN a.field_value END ) AS address
FROM
`wl_form_instance_equip` a
WHERE
a.instance_id = #{instanceId}
GROUP BY
a.instance_id
) fi
</select>
<select id="getFormInstanceById" resultType="java.util.Map">
SELECT
a.instance_id AS instanceId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS `name`,
MAX( CASE WHEN a.field_name = 'code' THEN a.field_value END ) AS `code`,
MAX( CASE WHEN a.field_name = 'address' THEN a.field_value END ) AS address,
MAX( CASE WHEN a.field_name = 'riskPointId' THEN a.field_value END ) AS riskSourceId
FROM
`wl_form_instance_equip` a
<where>
<if test="instanceId != null">
a.instance_id = #{instanceId}
</if>
</where>
</select>
<!-- 消防建筑视屏监控统计树 -->
<select id="getBuildVideoListCount" resultType="hashmap">
SELECT * FROM(
SELECT
sa.*,
b.total
FROM
(
SELECT
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
MAX( CASE WHEN a.field_name = 'parentId' THEN a.field_value END ) AS parentId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS instanceName,
MAX( CASE WHEN a.field_name = 'biz_org_code' THEN a.field_value END ) AS bizOrgCode
FROM
`wl_form_instance_equip` a
GROUP BY
a.instance_id
) sa
LEFT JOIN ( SELECT wlv.source_id, count( wlv.source_id ) AS total FROM `wl_video_source` wlv GROUP BY wlv.source_id ) b ON b.source_id = sa.instanceId
union all
select
123456789123456789 as instanceId,
'else' as groupCode,
'else' as groupType,
0 as parentId,
'其他' as instanceName,
NULL AS bizOrgCode,
count(1) as total
from
wl_video where id not in (select video_id from wl_video_source)
) tmp
<where>
<if test="list != null and list.size() >0">
AND tmp.bizOrgCode IN
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<select id="getColaBuildVideoListCount" resultType="hashmap">
SELECT
sa.*,
b.total
FROM
(
SELECT
wws.id AS instanceId,
CONCAT(wws.parent_id,'') AS parentId,
wws.name AS instanceName
FROM
`wl_warehouse_structure` wws
GROUP BY
wws.id
) sa
LEFT JOIN (
SELECT
wws.id AS buildId,
COUNT(wws.id) AS total
FROM
wl_stock_detail wsd,
wl_equipment_detail wed,
wl_equipment we,
wl_equipment_category wec,
wl_warehouse_structure wws
WHERE
wsd.equipment_detail_id = wed.id
AND wed.equipment_id = we.id
AND wec.id = we.category_id
AND wws.id = wsd.warehouse_structure_id
and wec.code in
<foreach collection="dto.monitorCodes" item="dto.monitorCodes" index="index" open="(" close=")" separator=",">
#{dto.monitorCodes}
</foreach>
GROUP BY wws.id
) b ON b.buildId = sa.instanceId
</select>
<insert id="saveStucture">
insert into wl_warehouse_structure
(id,
code,
name,
full_name,
parent_id,
warehouse_id,
create_date,
biz_org_code,
biz_org_name,
source_id)
VALUES(
#{instanceId},
#{code},
#{name},
#{address},
#{parentId},
0,
now(),
#{bizOrgCode},
#{bizOrgName},
#{instanceId})
</insert>
<select id="getStuctureName" resultType="String">
select full_name from wl_warehouse_structure
where id = #{id}
</select>
<select id="getStuName" resultType="String">
select name from wl_warehouse_structure
where id = #{id}
</select>
<select id="getStructureParentId" resultType="Long">
select parent_id from wl_warehouse_structure
where id = #{id}
</select>
<delete id="deleteStuById">
DELETE FROM wl_warehouse_structure WHERE id = #{id}
</delete>
<update id="updateStr">
update wl_warehouse_structure
set name = #{name} ,
full_name = #{fullName},
parent_id = #{parentId},
code = #{code},
biz_org_code = #{bizOrgCode},
biz_org_name= #{bizOrgName}
where id = #{id}
</update>
<update id="updateFormFieldValue">
update wl_form_instance_equip
set
field_value = #{value}
where instance_id = #{id} AND field_name = #{name}
</update>
<update id="updateStrFullName">
update wl_warehouse_structure
set full_name=replace(full_name,#{name},#{fullName})
where
id in (
select instance_id from wl_form_instance_equip where field_name = 'parentId' and field_value = #{id}
union all
select instance_id from wl_form_instance_equip where field_name = 'parentId' and field_value in (
select instance_id from wl_form_instance_equip where field_name = 'parentId' and field_value = #{id}
)
)
</update>
<update id="clearSystemId">
update wl_form_instance_equip
set field_value = null
where field_name like '%system%'
and field_value = #{id}
</update>
<select id="getChildrenNotIsRiskList" resultType="com.yeejoin.equipmanage.common.entity.dto.BuildIsRiskDTO">
select * from (SELECT
a.instance_id AS instanceId,
MAX(
CASE
WHEN a.field_name = 'parentId' THEN
a.field_value
END
) AS parentId,
MAX(
CASE
WHEN a.field_name = 'isRisk' THEN
a.field_value
END
) AS isRisk
FROM
`wl_form_instance_equip` a
GROUP BY
a.instance_id) sa where sa.parentId = #{instanceId} and sa.isRisk = 'false' and sa.isRisk is not null
</select>
<update id="clearRegionBind">
UPDATE
wl_form_instance_equip
SET field_value = (
CASE field_name
WHEN 'isRisk' THEN
'false'
WHEN 'riskPointId' THEN
''
END
)
WHERE
instance_id = #{instanceId} and (field_name = 'isRisk' or field_name = 'riskPointId')
</update>
<select id="getParentId" resultType="map">
select
*
from
wl_warehouse_structure
where
parent_id = #{parentId}
</select>
<select id="getIdAndType" resultType="hashmap">
select
ins.field_value as id,
inst.group_code as type,
str.full_name as address
from
wl_form_instance_equip as ins
left join wl_form_instance_equip as inst on ins.field_value = inst.instance_id
left join wl_warehouse_structure as str on ins.instance_id = str.source_id
where ins.instance_id =#{id}
and ins.field_name ='parentId'
group by ins.field_value
</select>
<!-- // 需求958 导出模板需要列表获取建筑 by kongfm 2021-09-15-->
<select id="getAllBuilding" resultType="hashmap">
select * from (SELECT
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
a.field_value AS fieldValue,
a.field_label AS fieldLabel,
MAX(CASE WHEN a.field_name = 'parentId' THEN a.field_value END) AS parentId,
MAX(CASE WHEN a.field_name = 'name' THEN a.field_value END)AS buildName
FROM
`wl_form_instance_equip` a
where a.group_type = 'building'
GROUP BY
a.instance_id) sa
ORDER BY sa.instanceId DESC
</select>
<select id="getBuildingToLongitudeAndLatitude" resultType="hashmap">
SELECT
max(CASe WHEN field_name = 'latitude' THEN field_value end ) AS latitude,
max(CASe WHEN field_name = 'longitude' THEN field_value end ) AS longitude
FROM
wl_form_instance_equip
WHERE
instance_id = #{instanceId}
</select>
<!--<select id="getBuildVideoCount" resultType="hashmap">-->
<!-- SELECT-->
<!-- wlv.source_id AS buildId,-->
<!-- count( wlv.source_id ) AS total-->
<!-- FROM-->
<!-- `wl_video_source` wlv-->
<!-- GROUP BY-->
<!-- wlv.source_id-->
<!--</select>-->
<select id="getBuildVideoCount" resultType="hashmap">
SELECT
b.instanceId AS buildId,
COUNT( vs.video_id ) AS total
FROM
get_building_tree b
JOIN wl_video_source vs ON FIND_IN_SET( b.instanceId, vs.parent_source_ids )
JOIN wl_video v on v.id = vs.video_id
GROUP BY
b.instanceId
</select>
<update id ="updateFormInstanceByInstanceAndFieldName">
UPDATE wl_form_instance_equip
SET field_value = #{value}
WHERE
instance_id =#{instanceId}
AND field_name =#{name}
</update>
<select id="selectChildListdate" resultType="java.lang.String">
SELECT distinct a.instance_id FROM
(select instance_id ,field_value from wl_form_instance_equip where group_type in('building','room','floor') and field_name='parentId') a
WHERE a.field_value = #{id} union all SELECT distinct b.instance_id FROM
(select instance_id ,field_value from wl_form_instance_equip where group_type in('building','room','floor') and field_name='parentId') b
WHERE b.field_value in (SELECT distinct c.instance_id FROM
(select instance_id ,field_value from wl_form_instance_equip where group_type in('building','room','floor') and field_name='parentId') c
WHERE c.field_value = #{id})
</select>
<select id="querySpecialChildrenListByBizOrgCode" resultType="java.util.Map">
SELECT
*
FROM
(
SELECT
a.instance_id as id,
a.instance_id AS instanceId,
a.group_code AS groupCode,
a.group_type AS groupType,
wlss.scene_id as sceneId,
MAX( CASE WHEN a.field_name = 'parentId' THEN a.field_value END ) AS parentId,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS instanceName,
MAX( CASE WHEN a.field_name = 'name' THEN a.field_value END ) AS name,
MAX( CASE WHEN a.field_name = 'code' THEN a.field_value END ) AS code,
MAX( CASE WHEN a.field_name = 'isRisk' THEN a.field_value END ) AS isRisk,
MAX( CASE WHEN a.field_name = 'address' THEN a.field_value END ) AS address,
MAX( CASE WHEN a.field_name = 'bizOrgCode' THEN a.field_value END ) AS bizOrgCode,
MAX( CASE WHEN a.field_name = 'bizOrgName' THEN a.field_value END ) AS bizOrgName
FROM
`wl_form_instance_equip` a
LEFT JOIN wl_source_scene wlss ON wlss.source_id = a.instance_id
GROUP BY
a.instance_id
) sa
<where>
<if test="parentId != null and parentId !=''">
sa.parentId = #{parentId}
</if>
<if test="bizOrgCode != null and bizOrgCode !=''">
and sa.bizOrgCode LIKE CONCAT(#{bizOrgCode},'%')
</if>
</where>
</select>
</mapper>
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