Commit 293f68ec authored by zhangsen's avatar zhangsen

组态3小API 消防车辆和消防队伍 redis存入用户个人信息

parent 40e45b1f
package com.yeejoin.equipmanage.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.equipmanage.fegin.JcsFeign;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.ResponseBody;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import java.util.Map;
/**
* @author DELL
*/
@Aspect
@Component
@ResponseBody
@Order(value = 1)
public class PersonIdentifyAspect {
@Autowired
RedisUtils redisUtils;
@Autowired
private JcsFeign jcsFeignClient;
@Pointcut("execution(public * com.yeejoin.amos.*.business.controller..*(..))")
public void userDate() {
}
@Before("userDate()")
public void personIdentity(JoinPoint joinPoint) {
ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (reginParam != null) {
if (reginParam.getPersonIdentity() == null) {
String userId = reginParam.getUserModel().getUserId();
if (userId != null) {
FeignClientResult responseModel = jcsFeignClient.selectById(userId);
if (ObjectUtils.isEmpty(responseModel.getResult()) || responseModel.getStatus() != HttpStatus.OK.value()) {
throw new RuntimeException(responseModel.getDevMessage());
}
ReginParams.PersonIdentity personIdentity = (ReginParams.PersonIdentity) Bean.mapToBean((Map<String, Object>) responseModel.getResult(), ReginParams.PersonIdentity.class);
reginParam.setPersonIdentity(personIdentity);
redisUtils.set(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()), JSONObject.toJSONString(reginParam));
}
}
}
}
}
...@@ -130,5 +130,22 @@ public class ConfigureController extends AbstractBaseController { ...@@ -130,5 +130,22 @@ public class ConfigureController extends AbstractBaseController {
return CommonResponseUtil.success(fireFightingSystemMapper.getEquipAlarmInfoNum(bizOrgCode)); return CommonResponseUtil.success(fireFightingSystemMapper.getEquipAlarmInfoNum(bizOrgCode));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取消防力量信息(队伍值班等)")
@GetMapping("/getFireTeamInfo")
public ResponseModel getFireTeamInfo() {
ReginParams reginParams = getSelectedOrgInfo();
String bizOrgCode = !ValidationUtil.isEmpty(reginParams.getPersonIdentity()) && StringUtil.isNotEmpty(reginParams.getPersonIdentity().getBizOrgCode()) ? reginParams.getPersonIdentity().getBizOrgCode() : null;
return CommonResponseUtil.success(fireFightingSystemMapper.getFireTeamInfo(bizOrgCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "消防车辆信息")
@GetMapping("/getFireCarInfo")
public ResponseModel getFireCarInfo() {
ReginParams reginParams = getSelectedOrgInfo();
String bizOrgCode = !ValidationUtil.isEmpty(reginParams.getPersonIdentity()) && StringUtil.isNotEmpty(reginParams.getPersonIdentity().getBizOrgCode()) ? reginParams.getPersonIdentity().getBizOrgCode() : null;
return CommonResponseUtil.success(fireFightingSystemMapper.getFireCarInfo(bizOrgCode));
}
} }
...@@ -182,4 +182,12 @@ public interface JcsFeign { ...@@ -182,4 +182,12 @@ public interface JcsFeign {
@GetMapping(value = "/org-usr/listCompanyTree") @GetMapping(value = "/org-usr/listCompanyTree")
FeignClientResult<List<OrgUsrDto>> getlistCompanyTree( @RequestParam(required = false) String orgType); FeignClientResult<List<OrgUsrDto>> getlistCompanyTree( @RequestParam(required = false) String orgType);
/**
* 查询用户单位信息
* @param userId 用户id
* @return ResponseModel<ReginParams.PersonIdentity>
*/
@GetMapping(value = "/org-person/getUser/{id}")
FeignClientResult selectById(@PathVariable String id);
} }
...@@ -240,4 +240,8 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE ...@@ -240,4 +240,8 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
List<Map<String, Object>> getSystemAlarmInfo(@Param("bizOrgCode") String bizOrgCode); List<Map<String, Object>> getSystemAlarmInfo(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getEquipAlarmInfoNum(@Param("bizOrgCode") String bizOrgCode); List<Map<String, Object>> getEquipAlarmInfoNum(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getFireTeamInfo(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getFireCarInfo(@Param("bizOrgCode") String bizOrgCode);
} }
...@@ -2418,4 +2418,64 @@ ...@@ -2418,4 +2418,64 @@
</where> </where>
) AS unConfirmInfoNum ) AS unConfirmInfoNum
</select> </select>
<select id="getFireTeamInfo" resultType="java.util.Map">
SELECT
ifnull( count( 0 ), 0 ) AS `total`,
ifnull( sum(( SELECT count( 0 ) FROM `d_duty_details` `duty` WHERE ( `duty`.`user_id` = `cou`.`sequence_nbr` ))), 0 ) AS `on_duty`,
'志愿消防队'
FROM
( SELECT * FROM `cb_org_usr` WHERE `cb_org_usr`.`is_firefighters` = 1 AND `cb_org_usr`.`type_code` = 117
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND biz_org_code = #{bizOrgCode,jdbcType=VARCHAR}
</if> ) `cou` UNION ALL
SELECT
ifnull( count( 0 ), 0 ) AS `total`,
ifnull( sum(( SELECT count( 0 ) FROM `d_duty_details` `duty` WHERE ( `duty`.`user_id` = `cou`.`sequence_nbr` ))), 0 ) AS `on_duty`,
'专职驻站消防队'
FROM
( SELECT * FROM `cb_org_usr` WHERE `cb_org_usr`.`is_firefighters` = 1 AND `cb_org_usr`.`type_code` = 116
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND biz_org_code = #{bizOrgCode,jdbcType=VARCHAR}
</if> ) `cou`
</select>
<select id="getFireCarInfo" resultType="java.util.Map">
SELECT
IFNULL( sum( a.carStartState ), 0 ) AS carStartNum,
IFNULL( sum( a.carCloseState ), 0 ) AS carCloseNum
FROM
(
SELECT
`wc`.`id` AS `id`,
`wc`.`name` AS `name`,
max(
CASE
WHEN ( `wcp`.`equipment_index_key` = 'FireCar_Start' AND `wcp`.`value` = 'true' ) THEN
1
WHEN ( `wcp`.`equipment_index_key` = 'FireCar_Start' AND `wcp`.`value` = 'false' ) THEN
0
END
) AS `carStartState`,
max(
CASE
WHEN ( `wcp`.`equipment_index_key` = 'FireCar_Start' AND `wcp`.`value` = 'true' ) THEN
0
WHEN ( `wcp`.`equipment_index_key` = 'FireCar_Start' AND `wcp`.`value` = 'false' ) THEN
1
END
) AS `carCloseState`
FROM
`wl_car` `wc`
LEFT JOIN `wl_car_property` `wcp` ON `wcp`.`car_id` = `wc`.`id`
<where>
1=1
<if test="bizOrgCode!=null and bizOrgCode!=''">
AND wc.biz_org_code = #{bizOrgCode,jdbcType=VARCHAR}
</if>
</where>
) a
</select>
</mapper> </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