浏览代码

经办人修改

cuixq 3 年之前
父节点
当前提交
fd9abb21f2

+ 287 - 1
tianhu-system/src/main/java/com/tianhu/system/controller/OwnSysUserController.java

@@ -1,8 +1,11 @@
 package com.tianhu.system.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.keao.tianhu.core.entity.R;
 import com.tianhu.common.core.constant.SalaryConstants;
 import com.tianhu.common.core.utils.CommonUtil;
+import com.tianhu.common.core.utils.DateUtils;
+import com.tianhu.common.core.utils.IdUtils;
 import com.tianhu.common.core.utils.StringUtils;
 import com.tianhu.common.core.utils.poi.ExcelUtil;
 import com.tianhu.common.core.web.controller.BaseController;
@@ -23,7 +26,10 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -59,6 +65,12 @@ public class OwnSysUserController extends BaseController
     @Autowired
     private ISysRoleService roleService;
 
+    @Autowired
+    private IZcHandlerChangeService zcHandlerChangeService;
+
+    @Autowired
+    private IPubFileInfService pubFileInfService;
+
     /**
      * 获取用户列表
      */
@@ -129,7 +141,160 @@ public class OwnSysUserController extends BaseController
         ExcelUtil<OwnSysUser> util = new ExcelUtil<OwnSysUser>(OwnSysUser.class);
         util.exportExcel(response, list, "inf");
     }
+    /**
+     * 安心签用户信息变更申请表
+     */
+    @PostMapping("/apply")
+    public void apply(HttpServletResponse response) throws FileNotFoundException {
+        // 下载本地文件
+        String fileName = "Operator.doc".toString(); // 文件的默认保存名
+        // 读到流中
+        InputStream inStream = OwnSysUserController.class.getClassLoader().getResourceAsStream("安心签用户信息变更申请表.xlsx");
+        // 设置输出的格式
+        response.reset();
+        response.setContentType("bin");
+        response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+        // 循环取出流中的数据
+        byte[] b = new byte[100];
+        int len;
+        try {
+            while ((len = inStream.read(b)) > 0) {
+                response.getOutputStream().write(b, 0, len);
+            }
+            inStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    /**
+     * 安心签开户及管理授权书
+     */
+    @PostMapping("/authorization")
+    public void authorization(HttpServletResponse response) throws FileNotFoundException {
+        // 下载本地文件
+        String fileName = "Operator.doc".toString(); // 文件的默认保存名
+        // 读到流中
+        InputStream inStream = OwnSysUserController.class.getClassLoader().getResourceAsStream("安心签开户及管理授权书(模板).docx");
+
+        // 设置输出的格式
+        response.reset();
+        response.setContentType("bin");
+        response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+        // 循环取出流中的数据
+        byte[] b = new byte[100];
+        int len;
+        try {
+            while ((len = inStream.read(b)) > 0) {
+                response.getOutputStream().write(b, 0, len);
+            }
+            inStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    /**
+     * 安心签用户信息变更申请表
+     */
+    @PostMapping("/jpgApply")
+    public void jpgApply(@RequestBody Map<String,Object> map,HttpServletResponse response) throws MalformedURLException {
+        // 下载网络文件
+        int bytesum = 0;
+        int byteread = 0;
+        LambdaQueryWrapper<ZcHandlerChange> lambdaQueryWrapper = new LambdaQueryWrapper();
+        lambdaQueryWrapper.eq(ZcHandlerChange::getZhcToUserId,map.get("userId"));
+        List<ZcHandlerChange> managementFile = zcHandlerChangeService.findZcHandlerChanges(lambdaQueryWrapper);
+        LambdaQueryWrapper<FileInf> file = new LambdaQueryWrapper();
+        file.eq(FileInf::getPfiFileId,managementFile.get(0).getZhcFile2Id());
+        List<FileInf> fileInf = pubFileInfService.findFileInfs(file);
+        URL url = new URL(fileInf.get(0).getPfiFileUrl());
+
+        try {
+            URLConnection conn = url.openConnection();
+            InputStream inStream = conn.getInputStream();
+            FileOutputStream fs = new FileOutputStream("c:/abc.gif");
+
+            byte[] buffer = new byte[1204];
+            int length;
+            while ((byteread = inStream.read(buffer)) != -1) {
+                bytesum += byteread;
+                System.out.println(bytesum);
+                fs.write(buffer, 0, byteread);
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    /**
+     * 安心签开户及管理授权书
+     */
+    @PostMapping("/jpgAuthorization")
+    public void jpgAuthorization(@RequestBody Map<String,Object> map,HttpServletResponse response) throws MalformedURLException {
+        // 下载网络文件
+        int bytesum = 0;
+        int byteread = 0;
+        LambdaQueryWrapper<ZcHandlerChange> lambdaQueryWrapper = new LambdaQueryWrapper();
+        lambdaQueryWrapper.eq(ZcHandlerChange::getZhcToUserId,map.get("userId"));
+        List<ZcHandlerChange> managementFile = zcHandlerChangeService.findZcHandlerChanges(lambdaQueryWrapper);
+            LambdaQueryWrapper<FileInf> file = new LambdaQueryWrapper();
+            file.eq(FileInf::getPfiFileId,managementFile.get(0).getZhcFile1Id());
+            List<FileInf> fileInf = pubFileInfService.findFileInfs(file);
+        URL url = new URL(fileInf.get(0).getPfiFileUrl());
+
+        try {
+            URLConnection conn = url.openConnection();
+            InputStream inStream = conn.getInputStream();
+            FileOutputStream fs = new FileOutputStream("c:/abc.gif");
 
+            byte[] buffer = new byte[1204];
+            int length;
+            while ((byteread = inStream.read(buffer)) != -1) {
+                bytesum += byteread;
+                System.out.println(bytesum);
+                fs.write(buffer, 0, byteread);
+            }
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    /**
+     * 查询变更图片
+     */
+//    @PreAuthorize(hasPermi = "system:company:details")
+    @GetMapping("details/{userId}")
+    public AjaxResult details(@PathVariable("userId") String userId)throws Exception {
+        Map map = new HashMap<>();
+        LambdaQueryWrapper<ZcHandlerChange> lambdaQueryWrapper = new LambdaQueryWrapper();
+        lambdaQueryWrapper.eq(ZcHandlerChange::getZhcToUserId,userId);
+        List<ZcHandlerChange> managementFile = zcHandlerChangeService.findZcHandlerChanges(lambdaQueryWrapper);
+        List<Map> dailyResult = new ArrayList();
+        for(int i=0;i<managementFile.size();i++){
+            Map pfi =new HashMap();
+            LambdaQueryWrapper<FileInf> file = new LambdaQueryWrapper();
+            file.eq(FileInf::getPfiFileId,managementFile.get(i).getZhcFile1Id());
+            List<FileInf> fileInf = pubFileInfService.findFileInfs(file);
+            LambdaQueryWrapper<FileInf> file1 = new LambdaQueryWrapper();
+            file1.eq(FileInf::getPfiFileId,managementFile.get(i).getZhcFile2Id());
+            List<FileInf> files = pubFileInfService.findFileInfs(file1);
+            if(fileInf.size()>0){
+                pfi.put("uid",fileInf.get(0).getPfiFileId());
+                pfi.put("url",fileInf.get(0).getPfiUrl());
+                pfi.put("fileUrl",fileInf.get(0).getPfiFileUrl());
+            }
+            if(files.size()>0){
+                pfi.put("fileId",fileInf.get(0).getPfiFileId());
+                pfi.put("pfiUrl",fileInf.get(0).getPfiUrl());
+                pfi.put("fileUrl",fileInf.get(0).getPfiFileUrl());
+
+            }
+            dailyResult.add(pfi);
+        }
+        map.put("data",dailyResult);
+        return AjaxResult.success(map);
+    }
     @GetMapping("/listUser/{userId}")
     public AjaxResult listUser(@PathVariable(value = "userId", required = false) Long userId){
         //查询当前操作员
@@ -210,6 +375,104 @@ public class OwnSysUserController extends BaseController
         return AjaxResult.success();
     }
     /**
+     * 申请变更经办人权限
+     * @return
+     */
+    @PreAuthorize(hasPermi = "system:ownUser:handlerChange")
+    @Transactional(rollbackFor=Exception.class)
+    @Log(title = "申请变更经办人权限", businessType = BusinessType.UPDATE)
+    @PostMapping("/handlerChange")
+    public AjaxResult handlerChange(@RequestBody Map<String,Object> map) throws Exception {
+        //查询当前操作员
+        LoginUser userInfo = tokenService.getLoginUser();
+        SysUser use = userInfo.getSysUser();
+        //用户id
+        String userId =CommonUtil.objToString(map.get("userIds"));
+        //开户管理授权书
+        List<Map<String,String>> sfzList = (List<Map<String, String>>) map.get("sfzList");
+        if(sfzList.size()==0){
+            throw new Exception("请上传开户管理授权书");
+        }
+        //用户信息变更申请书
+        List<Map<String,String>> sqsList = (List<Map<String, String>>) map.get("sqsList");
+        if(sqsList.size()==0){
+            throw new Exception("用户信息变更申请书");
+        }
+        //查询经办人
+        LambdaQueryWrapper<SysUserCompanyRel> sysUserCompanyRel = new LambdaQueryWrapper<>();
+        sysUserCompanyRel.eq(SysUserCompanyRel::getSucrUserId,use.getUserId());
+        sysUserCompanyRel.eq(SysUserCompanyRel::getSucrHandler,"1");
+        List<SysUserCompanyRel> userCompanyRels = sysUserCompanyRelService.findSysUserCompanyRels(sysUserCompanyRel);
+        if (userCompanyRels.size()==0){
+            throw new Exception("当前用户无法变更权限!");
+        }
+        ZcHandlerChange zcHandlerChange =new ZcHandlerChange();
+        String  id  =  IdUtils.fastSimpleUUID();
+        zcHandlerChange.setZhcId(id);
+        zcHandlerChange.setZhcCompanyId(use.getCompanyId());
+        zcHandlerChange.setZhcUserId(use.getUserId());
+        zcHandlerChange.setZhcToUserId(Long.valueOf(userId));
+        zcHandlerChange.setZhcFile1Id(sfzList.get(0).get("uid"));
+        zcHandlerChange.setZhcFile2Id(sqsList.get(0).get("uid"));
+        //变更状态(00:待平台处理, 01:平台已处理)
+        zcHandlerChange.setZhcStatus("00");
+        zcHandlerChange.setCreateBy(use.getUserId()+"");
+        zcHandlerChange.setCreateTime(DateUtils.getNowDate());
+        zcHandlerChangeService.createZcHandlerChange(zcHandlerChange);
+        return AjaxResult.success();
+    }
+    /**
+     * 确认变更经办人权限
+     * @return
+     */
+    @PreAuthorize(hasPermi = "system:ownUser:confirmChange")
+    @Transactional(rollbackFor=Exception.class)
+    @Log(title = "确认变更经办人权限", businessType = BusinessType.UPDATE)
+    @PostMapping("/confirmChange/{userId}")
+    public AjaxResult confirmChange(@PathVariable(value = "userId", required = false) Long userId) throws Exception {
+        //查询当前操作员
+        LoginUser userInfo = tokenService.getLoginUser();
+        SysUser use = userInfo.getSysUser();
+        //查询经办人
+        LambdaQueryWrapper<SysUserCompanyRel> sysUserCompanyRel = new LambdaQueryWrapper<>();
+        sysUserCompanyRel.eq(SysUserCompanyRel::getSucrUserId,use.getUserId());
+        sysUserCompanyRel.eq(SysUserCompanyRel::getSucrHandler,"1");
+        List<SysUserCompanyRel> userCompanyRels = sysUserCompanyRelService.findSysUserCompanyRels(sysUserCompanyRel);
+        if (userCompanyRels.size()==0){
+            throw new Exception("当前用户无法变更权限!");
+        }
+        //删除当前用户角色权限
+        sysUserRoleService.deleteSysUserRoleById(use.getUserId());
+        //新增当前用户角色关联
+        SysRole sysRole =new SysRole();
+        sysRole.setIsAuto("0");
+        List<SysRole> role = roleService.selectRoleList(sysRole);
+
+        SysUserRole sysUserRole =new SysUserRole();
+        sysUserRole.setRoleId(role.get(0).getRoleId());
+        sysUserRole.setUserId(use.getUserId());
+        sysUserRoleService.insertSysUserRole(sysUserRole);
+        //删除授权用户角色
+        sysUserRoleService.deleteSysUserRoleById(userId);
+        //新增授权用户角色关联
+        SysRole sysRole1 =new SysRole();
+        sysRole1.setIsAuto("1");
+        List<SysRole> role1 = roleService.selectRoleList(sysRole1);
+
+        SysUserRole sysUserRole1 =new SysUserRole();
+        sysUserRole1.setRoleId(role1.get(0).getRoleId());
+        sysUserRole1.setUserId(userId);
+        sysUserRoleService.insertSysUserRole(sysUserRole1);
+        //修改申请表状态
+        ZcHandlerChange zcHandlerChange =new ZcHandlerChange();
+        //变更状态(00:待平台处理, 01:平台已处理)
+        zcHandlerChange.setZhcStatus("01");
+        zcHandlerChange.setUpdateBy(use.getUserId()+"");
+        zcHandlerChange.setUpdateTime(DateUtils.getNowDate());
+        zcHandlerChangeService.updateZcHandlerChange(zcHandlerChange);
+        return AjaxResult.success();
+    }
+    /**
      * 查询此用户下关联的企业
      * @param userId
      * @return
@@ -231,4 +494,27 @@ public class OwnSysUserController extends BaseController
         return AjaxResult.success(result);
     }
 
+    public static void main(HttpServletResponse response) throws FileNotFoundException {
+        // 下载本地文件
+        String fileName = "Operator.doc".toString(); // 文件的默认保存名
+        // 读到流中
+        InputStream inStream = new FileInputStream("java/resources/安心签开户及管理授权书(模板).docx");// 文件的存放路径
+        // 设置输出的格式
+        response.reset();
+        response.setContentType("bin");
+        response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
+        // 循环取出流中的数据
+        byte[] b = new byte[100];
+        int len;
+        try {
+            while ((len = inStream.read(b)) > 0) {
+                response.getOutputStream().write(b, 0, len);
+            }
+            inStream.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
 }

二进制
tianhu-system/src/main/resources/安心签开户及管理授权书(模板).docx


二进制
tianhu-system/src/main/resources/安心签用户信息变更申请表.xlsx