Commit 74235268 authored by 高建强's avatar 高建强

item:新增设备状态统计接口

parent de333899
......@@ -19,6 +19,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -54,4 +55,23 @@ public class ConfigureController extends AbstractBaseController {
return CommonResponseUtil.success(list);
}
@RequestMapping(value = "/equipStatusCount", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "系统设备状态统计", produces = "application/json;charset=UTF-8", notes = "系统设备状态统计")
public ResponseModel equipStatusCount(@RequestParam(required = false) String systemCode) {
HashMap<String, Object> hashMap = new HashMap<>();
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
String bizOrgCode = personIdentity.getBizOrgCode();
if (StringUtils.isNotBlank(bizOrgCode)) {
hashMap.put("bizOrgCode", bizOrgCode);
}
}
if (StringUtils.isNotBlank(systemCode)) {
hashMap.put("systemCode", systemCode);
}
return CommonResponseUtil.success(equipmentSpecificAlarmService.equipStatusCount(hashMap));
}
}
......@@ -197,4 +197,6 @@ public interface EquipmentSpecificAlarmMapper extends BaseMapper<EquipmentSpecif
* @return
*/
int selectCountByIotCode(@Param("iotCode") String iotCode, @Param("indexKey") String indexKey, @Param("indexValue") String indexValue);
List<Map<String, Object>> equipStatusCount(HashMap<String, Object> hashMap);
}
......@@ -15,6 +15,7 @@ import com.yeejoin.equipmanage.common.vo.TopographyAlarmVo;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
......@@ -83,4 +84,5 @@ public interface IEquipmentSpecificAlarmService extends IService<EquipmentSpecif
*/
List<EquipmentSpecificAlarm> getEquipListBySpecific(Boolean status, Long equipmentSpecificId);
LinkedList<Map<String, Object>> equipStatusCount(HashMap<String, Object> hashMap);
}
......@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import javax.servlet.http.HttpServletResponse;
......@@ -653,4 +654,18 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
return equipmentSpecificAlarmMapper.getEquipListBySpecific(status, equipmentSpecificId);
}
@Override
public LinkedList<Map<String, Object>> equipStatusCount(HashMap<String, Object> hashMap) {
LinkedList<Map<String, Object>> linkedList = new LinkedList<>();
List<Map<String, Object>> list = equipmentSpecificAlarmMapper.equipStatusCount(hashMap);
if (!CollectionUtils.isEmpty(list)) {
HashMap<String, Object> map = new HashMap<>();
map.put("name", "正常");
map.put("value", Integer.parseInt(list.get(0).get("value").toString()) - Integer.parseInt(list.get(1).get("value").toString()));
linkedList.add(map);
linkedList.add(list.get(1));
}
return linkedList;
}
}
......@@ -1140,4 +1140,37 @@
AND equipment_specific_index_key = #{indexKey,jdbcType=VARCHAR}
and `status` = 1
</select>
<select id="equipStatusCount" parameterType="java.util.HashMap" resultType="java.util.Map">
SELECT
'总数' AS `name`,
COUNT( DISTINCT wles.id ) AS `value`
FROM
`wl_equipment_specific` `wles`
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, wles.system_id )
<where>
<if test="systemCode != null and systemCode != ''">
AND fs.code = #{systemCode}
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wles.biz_org_code like concat (#{bizOrgCode},'%')
</if>
</where>
union all
SELECT
'异常' AS `name`,
COUNT( wlesa.equipment_specific_index_value = 'true' ) AS `value`
FROM
wl_equipment_specific_alarm wlesa
LEFT JOIN `wl_equipment_specific` `wles` ON `wlesa`.`equipment_specific_id` = `wles`.`id`
LEFT JOIN f_fire_fighting_system fs ON FIND_IN_SET( fs.id, wles.system_id )
<where>
wlesa.equipment_specific_index_value = 'true'
<if test="systemCode != null and systemCode != ''">
AND fs.code = #{systemCode}
</if>
<if test="bizOrgCode != null and bizOrgCode != ''">
AND wles.biz_org_code like concat (#{bizOrgCode},'%')
</if>
</where>
</select>
</mapper>
\ 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