张晓波
2023-10-30 1b3a14a25d8f5013158ef2842e9be0e24240f2b5
人脸
缓存同步菜单
已修改12个文件
已添加2个文件
270 ■■■■■ 文件已修改
hd/pipe/StaffManage/src/main/java/com/thhy/staff/config/StartListener.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/face/controller/FaceController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/face/controller/GetUserTask.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/face/service/FaceServer.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/face/service/impl/FaceServerImpl.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/entity/PlatUser.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/mapper/PlatUserMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/StaffManage/src/main/resources/mapping/PlatUserMapper.xml 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/UserCore/src/main/java/com/thhy/usercore/modules/sys/sysmenu/controller/SysMenusController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/UserCore/src/main/java/com/thhy/usercore/modules/sys/sysmenu/mapper/SysMenusMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/UserCore/src/main/java/com/thhy/usercore/modules/sys/sysmenu/service/ISysMenusService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/UserCore/src/main/java/com/thhy/usercore/modules/sys/sysmenu/service/impl/SysMenusServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/UserCore/src/main/resources/mapping/SysMenusMapper.xml 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/common/src/main/java/com/thhy/general/config/InsertAop.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hd/pipe/StaffManage/src/main/java/com/thhy/staff/config/StartListener.java
对比新文件
@@ -0,0 +1,25 @@
package com.thhy.staff.config;
import com.thhy.staff.modules.biz.face.controller.GetUserTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import java.util.Timer;
@Configuration
public class StartListener implements ApplicationRunner {
    @Value("${file.vfprefix}")
    private String vfPrefix;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        GetUserTask gutask = new GetUserTask(vfPrefix);
        Timer timer = new Timer();
        timer.schedule(gutask,1000,300000);
    }
}
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/face/controller/FaceController.java
@@ -112,5 +112,15 @@
        }
    }
    @RequestMapping("/allPerson")
    public JSONObject allPerson(@RequestBody String mess){
        faceServer.allPerson(mess);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code",0);
        jsonObject.put("msg","OK");
        jsonObject.put("success",true);
        return jsonObject;
    }
}
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/face/controller/GetUserTask.java
对比新文件
@@ -0,0 +1,45 @@
package com.thhy.staff.modules.biz.face.controller;
import com.alibaba.fastjson.JSONObject;
import com.thhy.general.utils.SpringContextUtils;
import com.thhy.staff.config.EmqxConfig;
import com.thhy.staff.modules.biz.face.mapper.FaceDeviceMapper;
import com.thhy.staff.utils.MqUtils;
import java.util.List;
import java.util.TimerTask;
public class GetUserTask extends TimerTask {
    private String prefix;
    private FaceDeviceMapper faceDeviceMapper;
    public FaceDeviceMapper getFaceDeviceMapper() {
        return SpringContextUtils.getBean(FaceDeviceMapper.class);
    }
    private EmqxConfig emqxConfig;
    public EmqxConfig getEmqxConfig() {
        return SpringContextUtils.getBean(EmqxConfig.class);
    }
    public GetUserTask(String urlPrefix) {
        this.prefix = urlPrefix;
    }
    @Override
    public void run() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("method","get_person_all");
        JSONObject dataJson = new JSONObject();
        dataJson.put("path",prefix+"allPerson");
        jsonObject.put("data",dataJson);
        jsonObject.put("params",new JSONObject());
        EmqxConfig emqxConfig = getEmqxConfig();
        FaceDeviceMapper faceDeviceMapper = getFaceDeviceMapper();
        List<String> sns = faceDeviceMapper.queryDevSn();
        MqUtils.createClient(emqxConfig,sns,jsonObject.toJSONString());
    }
}
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/face/service/FaceServer.java
@@ -20,4 +20,6 @@
    void removeNotify(String mess);
    String queryOriStrById(String id);
    void allPerson(String mess);
}
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/face/service/impl/FaceServerImpl.java
@@ -12,6 +12,7 @@
import com.thhy.staff.modules.biz.face.mapper.FaceDeviceMapper;
import com.thhy.staff.modules.biz.face.service.FaceServer;
import com.thhy.staff.modules.biz.platuser.entity.DoorLis;
import com.thhy.staff.modules.biz.platuser.entity.PlatUser;
import com.thhy.staff.modules.biz.platuser.mapper.PlatUserMapper;
import com.thhy.staff.utils.MqUtils;
import org.checkerframework.checker.units.qual.A;
@@ -172,6 +173,23 @@
        return userMapper.queryOriStrById(id);
    }
    @Override
    public void allPerson(String mess) {
        JSONObject jsonObject = JSONObject.parseObject(mess);
        JSONArray jsonArray = jsonObject.getJSONArray("person_list");
        for(Object obj : jsonArray){
            JSONObject personJson = JSON.parseObject(obj.toString());
            String faceId = personJson.getString("person_id");
            int count = userMapper.countByFaceId(faceId);
            if(count>0)continue;
            PlatUser platUser = new PlatUser();
            platUser.setFaceId(faceId);
            platUser.setIdNo(personJson.getString("id_card"));
            platUser.setRealName(personJson.getString("name"));
            userMapper.insertSamplePlatUser(platUser);
        }
    }
    public static void main(String[] args) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("method","delete_person");
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/entity/PlatUser.java
@@ -144,4 +144,6 @@
    private Integer isLogin;
    private String phone;
    private String faceId;
}
hd/pipe/StaffManage/src/main/java/com/thhy/staff/modules/biz/platuser/mapper/PlatUserMapper.java
@@ -115,4 +115,8 @@
    void syncFail(@Param("userId") String userId,@Param("syncFailReason")String syncFailReason);
    String queryOriStrById(String id);
    int countByFaceId(String faceId);
    void insertSamplePlatUser(PlatUser platUser);
}
hd/pipe/StaffManage/src/main/resources/mapping/PlatUserMapper.xml
@@ -930,4 +930,40 @@
        update sys_plat_user set sync_success = 2,sync_fail_reason = #{syncFailReason} where user_id = #{userId}
    </update>
    <select id="countByFaceId" resultType="int">
        select count(user_id) from sys_plat_user where face_id = #{faceId}
    </select>
    <insert id="insertSamplePlatUser">
        insert into sys_plat_user
        <trim prefix="(" suffixOverrides="," suffix=")">
            <if test="userId != null and userId != ''">
                user_id,
            </if>
            <if test="realName != null and realName != ''">
                real_name,
            </if>
            <if test="faceId != null and faceId != ''">
                face_id,
            </if>
            <if test="idNo != null and idNo != ''">
                id_no,
            </if>
        </trim>
        <trim prefix="values (" suffixOverrides="," suffix=")">
            <if test="userId != null and userId != ''">
                #{userId},
            </if>
            <if test="realName != null and realName != ''">
                #{realName},
            </if>
            <if test="faceId != null and faceId != ''">
                #{faceId},
            </if>
            <if test="idNo != null and idNo != ''">
                #{idNo},
            </if>
        </trim>
    </insert>
</mapper>
hd/pipe/UserCore/src/main/java/com/thhy/usercore/modules/sys/sysmenu/controller/SysMenusController.java
@@ -1,6 +1,9 @@
package com.thhy.usercore.modules.sys.sysmenu.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.JSONToken;
import com.github.pagehelper.PageInfo;
import com.thhy.general.utils.PagingUtils;
import com.thhy.general.common.BasicResult;
@@ -17,7 +20,7 @@
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -74,6 +77,24 @@
        return BasicResult.success(sysMenusList);
    }
    @RequestMapping("syncMenu")
    public BasicResult syncMenu(){
        String value = "";
        try {
            InputStream ins = new FileInputStream(new File("D:\\dd.txt"));
            byte[] bytes = new byte[ins.available()];
            ins.read(bytes);
            value = new String(bytes,"UTF-8");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        List<MenuTreeVo> sysMenusList = JSONArray.parseArray(value,MenuTreeVo.class);
        sysMenusService.syncMenu(sysMenusList);
        return BasicResult.success(sysMenusList);
    }
    @RequestMapping("allRoleMenu")
    public BasicResult allRoleMenu(@RequestBody MenuDto menuDto){
        menuDto.setParentId("0");
hd/pipe/UserCore/src/main/java/com/thhy/usercore/modules/sys/sysmenu/mapper/SysMenusMapper.java
@@ -28,6 +28,8 @@
    void insert(SysMenus sysmenus);
    void insertVo(MenuTreeVo menuTreeVo);
    void update(SysMenus sysmenus);
    int deletelogic(Serializable menuId);
hd/pipe/UserCore/src/main/java/com/thhy/usercore/modules/sys/sysmenu/service/ISysMenusService.java
@@ -1,5 +1,6 @@
package com.thhy.usercore.modules.sys.sysmenu.service;
import com.alibaba.fastjson.JSONObject;
import com.thhy.usercore.modules.sys.sysmenu.entity.*;
import com.thhy.usercore.modules.sys.sysmenubutton.entity.MenuButtonVo;
@@ -34,6 +35,8 @@
    List<MenuTreeVo> findAllTree(MenuDto menuDto);
    void syncMenu(List<MenuTreeVo> sysMenusList);
    List<MenuButtonTreeVo> allRoleMenu(MenuDto menuDto);
    List<MenuButtonVo> MenuEnableButtons(MenuButtonDto menuButtonDto);
hd/pipe/UserCore/src/main/java/com/thhy/usercore/modules/sys/sysmenu/service/impl/SysMenusServiceImpl.java
@@ -1,5 +1,8 @@
package com.thhy.usercore.modules.sys.sysmenu.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.thhy.general.utils.UserInfoUtils;
import com.thhy.general.common.BasicStatus;
import com.thhy.general.exception.BasicException;
@@ -138,6 +141,19 @@
    }
    @Override
    @Transactional
    public void syncMenu(List<MenuTreeVo> sysMenusList) {
        for(MenuTreeVo tree : sysMenusList){
            sysMenusMapper.insertVo(tree);
            if(tree.getChildrens().size()>0){
                syncMenu(tree.getChildrens());
            }
        }
    }
    @Override
    public List<MenuButtonTreeVo> allRoleMenu(MenuDto menuDto) {
        List<MenuButtonTreeVo> sysMenusList = sysMenusMapper.menuRoleTree(menuDto);
        for(MenuButtonTreeVo mv : sysMenusList){
hd/pipe/UserCore/src/main/resources/mapping/SysMenusMapper.xml
@@ -195,7 +195,86 @@
        </trim>
    </insert>
    <insert id="insertVo">
        insert into sys_menus
        <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="menuId != null">
                menu_id,
            </if>
            <if test="isUse != null">
                is_use,
            </if>
            <if test="path != null">
                path,
            </if>
            <if test="name != null">
                name,
            </if>
            <if test="hidden != null">
                hidden,
            </if>
            <if test="redirect != null">
                redirect,
            </if>
            <if test="parentId != null">
                parent_id,
            </if>
            <if test="title != null">
                title,
            </if>
            <if test="icon != null">
                icon,
            </if>
            <if test="component != null">
                component,
            </if>
            <if test="level != null">
                level,
            </if>
            <if test="isDefault != null">
                is_default,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
            <if test="menuId != null">
                #{menuId},
            </if>
            <if test="isUse != null">
                #{isUse},
            </if>
            <if test="path != null">
                #{path},
            </if>
            <if test="name != null">
                #{name},
            </if>
            <if test="hidden != null">
                #{hidden},
            </if>
            <if test="redirect != null">
                #{redirect},
            </if>
            <if test="parentId != null">
                #{parentId},
            </if>
            <if test="title != null">
                #{title},
            </if>
            <if test="icon != null">
                #{icon},
            </if>
            <if test="component != null">
                #{component},
            </if>
            <if test="level != null">
                #{level},
            </if>
            <if test="isDefault != null">
                #{isDefault},
            </if>
        </trim>
    </insert>
    <!--更新操作-->
    <update id="update">
        update sys_menus
hd/pipe/common/src/main/java/com/thhy/general/config/InsertAop.java
@@ -26,7 +26,7 @@
    @Around("pointcut()")
    public Object invoke(ProceedingJoinPoint invocation) throws Throwable {
        String methodName = invocation.getSignature().getName();
        /*String methodName = invocation.getSignature().getName();
        if(methodName.contains("insert")||methodName.contains("Insert")){
            Object j = invocation.getArgs()[0];
@@ -65,7 +65,8 @@
            return invocation.proceed();
        }else{
            return invocation.proceed();
        }
        }*/
        return invocation.proceed();
    }