Browse Source

commit no auth api

lihao16 11 months ago
parent
commit
db261ed9a1

+ 4 - 1
inspur-admin/src/main/java/com/inspur/web/controller/system/SysDictDataController.java

@@ -3,6 +3,8 @@ package com.inspur.web.controller.system;
 import java.util.ArrayList;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.inspur.common.annotation.Anonymous;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -27,7 +29,7 @@ import com.inspur.system.service.ISysDictTypeService;
 
 /**
  * 数据字典信息
- * 
+ *
  * @author inspur
  */
 @RestController
@@ -72,6 +74,7 @@ public class SysDictDataController extends BaseController
     /**
      * 根据字典类型查询字典数据信息
      */
+    @Anonymous
     @GetMapping(value = "/type/{dictType}")
     public AjaxResult dictType(@PathVariable String dictType)
     {

+ 32 - 8
inspur-admin/src/main/java/com/inspur/web/controller/system/SysLoginController.java

@@ -2,11 +2,10 @@ package com.inspur.web.controller.system;
 
 import java.util.List;
 import java.util.Set;
+
+import com.inspur.common.annotation.Anonymous;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.inspur.common.constant.Constants;
 import com.inspur.common.core.domain.AjaxResult;
 import com.inspur.common.core.domain.entity.SysMenu;
@@ -19,7 +18,7 @@ import com.inspur.system.service.ISysMenuService;
 
 /**
  * 登录验证
- * 
+ *
  * @author inspur
  */
 @RestController
@@ -36,7 +35,7 @@ public class SysLoginController
 
     /**
      * 登录方法
-     * 
+     *
      * @param loginBody 登录信息
      * @return 结果
      */
@@ -51,9 +50,34 @@ public class SysLoginController
         return ajax;
     }
 
+    /**
+     * 平台对接获取token 授权码
+     *
+     * @return 结果
+     */
+    @GetMapping("/authCode")
+    @Anonymous
+    public AjaxResult authCode()
+    {
+        String authCode = loginService.authCode();
+        return AjaxResult.success(authCode);
+    }
+
+    /**
+     * 平台对接获取token
+     * @param authCode 授权码
+     * @return 结果
+     */
+    @GetMapping("/authToken/{authCode}")
+    @Anonymous
+    public AjaxResult authToken(@PathVariable String authCode)
+    {
+        return loginService.authToken(authCode);
+    }
+
     /**
      * 获取用户信息
-     * 
+     *
      * @return 用户信息
      */
     @GetMapping("getInfo")
@@ -73,7 +97,7 @@ public class SysLoginController
 
     /**
      * 获取路由信息
-     * 
+     *
      * @return 路由信息
      */
     @GetMapping("getRouters")

+ 9 - 4
inspur-admin/src/main/java/com/inspur/web/controller/work/ElevatorInfoController.java

@@ -3,6 +3,7 @@ package com.inspur.web.controller.work;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import com.inspur.common.annotation.Anonymous;
 import com.inspur.domain.ElevatorInfo;
 import com.inspur.service.IElevatorInfoService;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -38,8 +39,9 @@ public class ElevatorInfoController extends BaseController
     /**
      * 查询电梯信息列表
      */
-    @PreAuthorize("@ss.hasPermi('elevator:info:list')")
+    // @PreAuthorize("@ss.hasPermi('elevator:info:list')")
     @GetMapping("/list")
+    @Anonymous
     public TableDataInfo list(ElevatorInfo elevatorInfo)
     {
         startPage();
@@ -63,8 +65,9 @@ public class ElevatorInfoController extends BaseController
     /**
      * 获取电梯信息详细信息
      */
-    @PreAuthorize("@ss.hasPermi('elevator:info:query')")
+    // @PreAuthorize("@ss.hasPermi('elevator:info:query')")
     @GetMapping(value = "/{id}")
+    @Anonymous
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
         return success(elevatorInfoService.selectElevatorInfoById(id));
@@ -73,9 +76,10 @@ public class ElevatorInfoController extends BaseController
     /**
      * 新增电梯信息
      */
-    @PreAuthorize("@ss.hasPermi('elevator:info:add')")
+    // @PreAuthorize("@ss.hasPermi('elevator:info:add')")
     @Log(title = "电梯信息", businessType = BusinessType.INSERT)
     @PostMapping
+    @Anonymous
     public AjaxResult add(@RequestBody ElevatorInfo elevatorInfo)
     {
         return toAjax(elevatorInfoService.insertElevatorInfo(elevatorInfo));
@@ -95,9 +99,10 @@ public class ElevatorInfoController extends BaseController
     /**
      * 删除电梯信息
      */
-    @PreAuthorize("@ss.hasPermi('elevator:info:remove')")
+    // @PreAuthorize("@ss.hasPermi('elevator:info:remove')")
     @Log(title = "电梯信息", businessType = BusinessType.DELETE)
     @DeleteMapping("/{ids}")
+    @Anonymous
     public AjaxResult remove(@PathVariable Long[] ids)
     {
         return toAjax(elevatorInfoService.deleteElevatorInfoByIds(ids));

+ 4 - 2
inspur-admin/src/main/java/com/inspur/web/controller/work/ElevatorWorkNodeController.java

@@ -3,6 +3,7 @@ package com.inspur.web.controller.work;
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
+import com.inspur.common.annotation.Anonymous;
 import com.inspur.domain.ElevatorWorkNode;
 import com.inspur.service.IElevatorWorkNodeService;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -24,7 +25,7 @@ import com.inspur.common.core.page.TableDataInfo;
 
 /**
  * 工单节点信息Controller
- * 
+ *
  * @author inspur
  * @date 2024-09-18
  */
@@ -38,8 +39,9 @@ public class ElevatorWorkNodeController extends BaseController
     /**
      * 查询工单节点信息列表
      */
-    @PreAuthorize("@ss.hasPermi('work:node:list')")
+    // @PreAuthorize("@ss.hasPermi('work:node:list')")
     @GetMapping("/list")
+    @Anonymous
     public TableDataInfo list(ElevatorWorkNode elevatorWorkNode)
     {
         startPage();

+ 5 - 3
inspur-admin/src/main/java/com/inspur/web/controller/work/ElevatorWorkOrderController.java

@@ -27,7 +27,7 @@ import com.inspur.common.core.page.TableDataInfo;
 
 /**
  * 电梯工单信息Controller
- * 
+ *
  * @author inspur
  * @date 2024-09-18
  */
@@ -68,8 +68,9 @@ public class ElevatorWorkOrderController extends BaseController
     /**
      * 获取电梯工单信息详细信息
      */
-    @PreAuthorize("@ss.hasPermi('work:workOrder:query')")
+    // @PreAuthorize("@ss.hasPermi('work:workOrder:query')")
     @GetMapping(value = "/{id}")
+    @Anonymous
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
         return success(elevatorWorkOrderService.selectElevatorWorkOrderById(id));
@@ -100,9 +101,10 @@ public class ElevatorWorkOrderController extends BaseController
     /**
      * 删除电梯工单信息
      */
-    @PreAuthorize("@ss.hasPermi('work:workOrder:remove')")
+    // @PreAuthorize("@ss.hasPermi('work:workOrder:remove')")
     @Log(title = "电梯工单信息", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
+    @Anonymous
     public AjaxResult remove(@PathVariable Long[] ids)
     {
         return toAjax(elevatorWorkOrderService.deleteElevatorWorkOrderByIds(ids));

+ 2 - 1
inspur-admin/src/main/resources/application.yml

@@ -45,6 +45,7 @@ user:
     maxRetryCount: 5
     # 密码锁定时间(默认10分钟)
     lockTime: 10
+    platform: backendApi@123
 
 # Spring配置
 spring:
@@ -98,7 +99,7 @@ token:
   # 令牌密钥
   secret: abcdefghijklmnopqrstuvwxyz
   # 令牌有效期(默认30分钟)
-  expireTime: 30
+  expireTime: 1440
 
 # MyBatis配置
 mybatis:

+ 39 - 4
inspur-framework/src/main/java/com/inspur/framework/web/service/SysLoginService.java

@@ -1,7 +1,14 @@
 package com.inspur.framework.web.service;
 
 import javax.annotation.Resource;
+
+import com.inspur.common.core.domain.AjaxResult;
+import com.inspur.common.core.domain.model.LoginBody;
+import com.inspur.common.utils.uuid.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.authentication.BadCredentialsException;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -29,14 +36,18 @@ import com.inspur.framework.security.context.AuthenticationContextHolder;
 import com.inspur.system.service.ISysConfigService;
 import com.inspur.system.service.ISysUserService;
 
+import java.util.concurrent.TimeUnit;
+
 /**
  * 登录校验方法
- * 
+ *
  * @author inspur
  */
 @Component
 public class SysLoginService
 {
+    private static final Logger log = LoggerFactory.getLogger(SysLoginService.class);
+
     @Autowired
     private TokenService tokenService;
 
@@ -45,16 +56,23 @@ public class SysLoginService
 
     @Autowired
     private RedisCache redisCache;
-    
+
     @Autowired
     private ISysUserService userService;
 
     @Autowired
     private ISysConfigService configService;
 
+    private static final String PLATFORM_AUTH_CODE = "platform:auth:code:";
+
+    @Value(value = "${user.password.platform}")
+    private String adminPwd;
+
+    private static final String BACKEND_API_USER = "backendApiUser";
+
     /**
      * 登录验证
-     * 
+     *
      * @param username 用户名
      * @param password 密码
      * @param code 验证码
@@ -146,7 +164,7 @@ public class SysLoginService
 
     /**
      * 校验验证码
-     * 
+     *
      * @param username 用户名
      * @param code 验证码
      * @param uuid 唯一标识
@@ -222,4 +240,21 @@ public class SysLoginService
         sysUser.setLoginDate(DateUtils.getNowDate());
         userService.updateUserProfile(sysUser);
     }
+
+    public String authCode() {
+        String authCode = UUID.randomUUID().toString().replace("-", "");
+        log.info("platform get authCode:{}", authCode);
+        redisCache.setCacheObject(PLATFORM_AUTH_CODE + authCode, authCode, 60, TimeUnit.SECONDS);
+        return authCode;
+    }
+
+    public AjaxResult authToken(String authCode) {
+        String redisAuthCode = redisCache.getCacheObject(PLATFORM_AUTH_CODE + authCode);
+        if (StringUtils.isEmpty(redisAuthCode)) {
+            return AjaxResult.error("authCode已过期");
+        }
+        // 使用Admin账号登录获取最好权限token
+        String token = login(BACKEND_API_USER,adminPwd);
+        return AjaxResult.success(token);
+    }
 }

+ 1 - 1
inspur-system/src/main/resources/mapper/system/SysMenuMapper.xml

@@ -91,7 +91,7 @@
             left join ELEVATOR_EMERGENCY.sys_role_menu rm on m.menu_id = rm.menu_id
         where rm.role_id = #{roleId}
             <if test="menuCheckStrictly">
-              and m.menu_id not in (select m.parent_id from sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
+              and m.menu_id not in (select m.parent_id from ELEVATOR_EMERGENCY.sys_menu m inner join sys_role_menu rm on m.menu_id = rm.menu_id and rm.role_id = #{roleId})
             </if>
 		order by m.parent_id, m.order_num
 	</select>

+ 16 - 4
inspur-work/src/main/java/com/inspur/domain/ElevatorWorkOrder.java

@@ -30,15 +30,19 @@ public class ElevatorWorkOrder extends BaseEntity {
     private String trappedPersonTel;
 
     /**
-     * 所在地区
+     * 所属区域
      */
-    @Excel(name = "所在地区")
+    @Excel(name = "所属区域")
     private String region;
 
+    /** 所属区域编码 */
+    @Excel(name = "所属区域编码")
+    private String regionCode;
+
     /**
-     * 所在小区
+     * 详细使用地点
      */
-    @Excel(name = "所在小区")
+    @Excel(name = "详细使用地点")
     private String community;
 
     /**
@@ -176,4 +180,12 @@ public class ElevatorWorkOrder extends BaseEntity {
      */
     private Integer failNum;
 
+    /** 设备注册编码 */
+    @Excel(name = "设备注册编码")
+    private String deviceSn;
+
+    /** 设备编码 */
+    @Excel(name = "设备编码")
+    private String deviceNo;
+
 }

+ 20 - 0
inspur-work/src/main/java/com/inspur/domain/HeadCountUpResult.java

@@ -0,0 +1,20 @@
+package com.inspur.domain;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 人数上报结果
+ * @author lihao16
+ */
+@Data
+public class HeadCountUpResult implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private Boolean HeadCount;
+
+    private HeadCountUpResultProperty Properties;
+
+}

+ 16 - 0
inspur-work/src/main/java/com/inspur/domain/HeadCountUpResultProperty.java

@@ -0,0 +1,16 @@
+package com.inspur.domain;
+
+import lombok.Data;
+
+/**
+ * @author lihao16
+ */
+@Data
+public class HeadCountUpResultProperty {
+
+    private String property;
+
+    private String display;
+
+
+}

+ 25 - 0
inspur-work/src/main/java/com/inspur/domain/HeadCountUploadDto.java

@@ -0,0 +1,25 @@
+package com.inspur.domain;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 人流统计
+ * @author lihao16
+ */
+@Data
+public class HeadCountUploadDto implements Serializable {
+
+    private static final long serialVersionUID = 828847877712832849L;
+
+
+    /** 告警ID */
+    private String AlarmId;
+
+    /** 设备标识 */
+    private String BoardId;
+
+    private HeadCountUpResult Reslut;
+
+}

+ 16 - 1
inspur-work/src/main/java/com/inspur/service/impl/ElevatorInfoServiceImpl.java

@@ -9,6 +9,7 @@ import com.inspur.mapper.ElevatorPersonInfoMapper;
 import com.inspur.service.IElevatorInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 /**
  * 电梯信息Service业务层处理
@@ -67,7 +68,21 @@ public class ElevatorInfoServiceImpl implements IElevatorInfoService
     public int insertElevatorInfo(ElevatorInfo elevatorInfo)
     {
         elevatorInfo.setCreateTime(DateUtils.getNowDate());
-        return elevatorInfoMapper.insertElevatorInfo(elevatorInfo);
+        int result = elevatorInfoMapper.insertElevatorInfo(elevatorInfo);
+        Long elevatorId = elevatorInfo.getId();
+        List<ElevatorPersonInfo> personInfos = elevatorInfo.getPersonInfos();
+        if (CollectionUtils.isEmpty(personInfos)) {
+            return result;
+        }
+        for (ElevatorPersonInfo personInfo : personInfos) {
+            personInfo.setElevatorId(elevatorId.toString());
+            personInfo.setUnitName(elevatorInfo.getUnitName());
+            personInfo.setSafeCode(elevatorInfo.getSafeCode());
+            personInfo.setPersonType(2L);
+            personInfo.setCreateTime(DateUtils.getNowDate());
+            elevatorPersonInfoMapper.insertElevatorPersonInfo(personInfo);
+        }
+        return result;
     }
 
     /**

+ 33 - 2
inspur-work/src/main/resources/mapper/work/ElevatorWorkOrderMapper.xml

@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="id"    column="id"    />
         <result property="trappedPersonTel"    column="trapped_person_tel"    />
         <result property="region"    column="region"    />
+        <result property="regionCode"    column="region_code"    />
         <result property="community"    column="community"    />
         <result property="building"    column="building"    />
         <result property="elevatorName"    column="elevator_name"    />
@@ -33,19 +34,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="remark"    column="remark"    />
         <result property="callId"    column="call_id"    />
         <result property="failNum"    column="fail_num"    />
+        <result property="deviceSn"    column="device_sn"    />
+        <result property="deviceNo"    column="device_no"    />
     </resultMap>
 
     <sql id="selectElevatorWorkOrderVo">
         select id, trapped_person_tel, region, community, building, elevator_name, security_code, status, create_date, recording_duration, call_recording, maint_company, maint_frist_person, maintfrist_tel,
                maint_second_person, maint_second_tel, tenement_person, tenement_tel, handler, handle_contact_tel, handle_depart, handle_time, del_flag,
-               create_time, update_time, remark,fail_num,call_id
+               create_time, update_time, remark,fail_num,call_id, device_sn,device_no, region_code
         from ELEVATOR_EMERGENCY.elevator_work_order
     </sql>
 
     <select id="selectElevatorWorkOrderList" parameterType="com.inspur.domain.ElevatorWorkOrder" resultMap="ElevatorWorkOrderResult">
         <include refid="selectElevatorWorkOrderVo"/>
         <where>
-            <if test="elevatorName != null  and elevatorName != ''"> and (elevator_name like concat('%', #{elevatorName}, '%') or security_code like concat('%', #{elevatorName}, '%'))</if>
+            <if test="elevatorName != null  and elevatorName != ''"> and elevator_name like concat('%', #{elevatorName}, '%')</if>
             <if test="securityCode != null  and securityCode != ''"> and security_code like concat('%', #{securityCode}, '%')</if>
             <if test="region != null  and region != ''"> and region like concat('%', #{region}, '%')</if>
             <if test="status != null "> and status = #{status}</if>
@@ -56,6 +59,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createDateEnd != null"><!-- 结束时间检索 -->
                 AND date_format(create_time,'%Y%m%d') &lt;= date_format(#{createDateEnd},'%Y%m%d')
             </if>
+            <if test="deviceSn != null  and deviceSn != ''"> and device_sn = #{deviceSn}</if>
+            <if test="deviceNo != null  and deviceNo != ''"> and device_no = #{deviceNo}</if>
+            <if test="trappedPersonTel != null  and trappedPersonTel != ''"> and trapped_person_tel = #{trappedPersonTel}</if>
+            <if test="regionCode != null  and regionCode != ''"> and region_code = #{regionCode}</if>
+            <if test="community != null  and community != ''"> and community = #{community}</if>
+            <if test="building != null  and building != ''"> and building = #{building}</if>
+            <if test="createDate != null "> and create_date = #{createDate}</if>
+            <if test="recordingDuration != null "> and recording_duration = #{recordingDuration}</if>
+            <if test="callRecording != null  and callRecording != ''"> and call_recording = #{callRecording}</if>
+            <if test="maintCompany != null  and maintCompany != ''"> and maint_company = #{maintCompany}</if>
+            <if test="maintFristPerson != null  and maintFristPerson != ''"> and maint_frist_person = #{maintFristPerson}</if>
+            <if test="maintfristTel != null  and maintfristTel != ''"> and maintfrist_tel = #{maintfristTel}</if>
+            <if test="maintSecondPerson != null  and maintSecondPerson != ''"> and maint_second_person = #{maintSecondPerson}</if>
+            <if test="maintSecondTel != null  and maintSecondTel != ''"> and maint_second_tel = #{maintSecondTel}</if>
+            <if test="tenementPerson != null  and tenementPerson != ''"> and tenement_person = #{tenementPerson}</if>
+            <if test="tenementTel != null  and tenementTel != ''"> and tenement_tel = #{tenementTel}</if>
+            <if test="handler != null  and handler != ''"> and handler = #{handler}</if>
+            <if test="handleContactTel != null  and handleContactTel != ''"> and handle_contact_tel = #{handleContactTel}</if>
+            <if test="handleDepart != null  and handleDepart != ''"> and handle_depart = #{handleDepart}</if>
+            <if test="handleTime != null "> and handle_time = #{handleTime}</if>
         </where>
         order by create_time desc
     </select>
@@ -100,6 +123,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remark != null">remark,</if>
             <if test="callId != null">call_id,</if>
             <if test="failNum != null">fail_num,</if>
+            <if test="deviceSn != null">device_sn,</if>
+            <if test="deviceNo != null">device_no,</if>
+            <if test="regionCode != null">region_code,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="trappedPersonTel != null">#{trappedPersonTel},</if>
@@ -129,6 +155,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remark != null">#{remark},</if>
             <if test="callId != null">#{callId},</if>
             <if test="failNum != null">#{failNum},</if>
+            <if test="deviceSn != null">#{deviceSn},</if>
+            <if test="deviceNo != null">#{deviceNo},</if>
+            <if test="regionCode != null">#{regionCode},</if>
          </trim>
     </insert>
 
@@ -161,6 +190,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="remark != null">remark = #{remark},</if>
             <if test="failNum != null">fail_num = #{failNum},</if>
+            <if test="deviceSn != null">device_sn = #{deviceSn},</if>
+            <if test="deviceNo != null">device_no = #{deviceNo},</if>
         </trim>
         where id = #{id}
     </update>