瀏覽代碼

插单派工的报工问题

seyason 1 年之前
父節點
當前提交
af351eabc2

+ 208 - 250
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/WeiXinCorpController.java

@@ -1305,72 +1305,6 @@ public class WeiXinCorpController {
         return userlist;
     }
 
-    private JSONArray getDeptUserInfo(String accessToken, int deptId) {
-        String url = GET_DEPARTMENT_USER_DETAIL_URL.replace("ACCESS_TOKEN", accessToken).replace("DEPARTMENT_ID", ""+deptId);
-        String result = restTemplate.getForObject(url, String.class);
-        System.out.println("第三方应用获取部门人员详情:"+result);
-        JSONObject obj = JSONObject.parseObject(result);
-        JSONArray userlist = obj.getJSONArray("userlist");
-        return userlist;
-    }
-
-    private JSONArray getTransDeptUserInfo(String accessToken, int deptId) {
-        String url = GET_DEPARTMENT_USER_DETAIL_URL.replace("ACCESS_TOKEN", accessToken).replace("DEPARTMENT_ID", ""+deptId);
-        String result = restTemplate.getForObject(url, String.class);
-        System.out.println("中转服务获取部门人员详情:"+result);
-        JSONObject obj = JSONObject.parseObject(result);
-        JSONArray userlist = obj.getJSONArray("userlist");
-
-        return userlist;
-    }
-
-    //企业通讯录获取到的userid转化为open_userid
-    private JSONArray convertUserIdToOpenUserId(String accessToken, List<String> userIdList) throws Exception {
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(MediaType.APPLICATION_JSON);
-        JSONObject reqParam = new JSONObject();
-        reqParam.put("userid_list",  userIdList);
-
-        HttpEntity<String> requestEntity = new HttpEntity<String>(reqParam.toJSONString(), headers);
-        String url = POST_CONVERT_USERID.replaceAll("ACCESS_TOKEN", accessToken);
-        ResponseEntity<String> responseEntity = this.restTemplate.exchange(url,
-                HttpMethod.POST, requestEntity, String.class);
-        if (responseEntity.getStatusCode() == HttpStatus.OK) {
-            String resp = responseEntity.getBody();
-            System.out.println(resp);
-
-            JSONObject obj = JSONObject.parseObject(resp);
-            if (obj.getIntValue("errcode") == 0) {
-                JSONArray openUseridList = obj.getJSONArray("open_userid_list");
-                return openUseridList;
-            } else {
-                //抛出异常
-                throw new Exception(obj.getString("errmsg"));
-            }
-        }
-        return null;
-    }
-
-    private JSONObject getDepartments(String accessToken) {
-        String url = GET_DEPARTMENT_URL.replace("ACCESS_TOKEN", accessToken);
-        String result = restTemplate.getForObject(url, String.class);
-        log.info("部门列表:"+result);
-        JSONObject obj = JSONObject.parseObject(result);
-
-        return obj;
-    }
-
-    //获取部门详情
-    private JSONObject getDeptDetail(String accessToken, int deptId) {
-        String url = GET_DEPARTMENT_DETAIL_URL.replace("ACCESS_TOKEN", accessToken).replace("ID", ""+deptId);
-        String result = restTemplate.getForObject(url, String.class);
-        log.info("部门详情:"+result);
-        JSONObject obj = JSONObject.parseObject(result);
-        return obj;
-    }
-
-
-
     private JSONObject getAllDepartments(String accessToken) {
         String url = GET_ALL_DEPARTMENT_URL.replace("ACCESS_TOKEN", accessToken);
         String result = restTemplate.getForObject(url, String.class);
@@ -1437,54 +1371,6 @@ public class WeiXinCorpController {
         return SUITE_ACCESS_TOKEN;
     }
 
-    @RequestMapping(value = "/bindCorpWeiXin")
-    public ModelAndView bindCorpWeiXin(String code, String userId, Integer state) {
-        Map<String,Object> reqParam = new HashMap<String,Object>(16);
-        String userAgent = request.getHeader("User-Agent");
-        //获取设备类型
-        String deviceType = UserAgentUtils.getDeviceType(userAgent);
-        boolean isMobile = "MOBILE".equals(deviceType);
-        String redirecUrl = null;
-        if (isMobile) {
-            redirecUrl = "http://mobworktime.ttkuaiban.com";
-        } else {
-            redirecUrl = "http://worktime.ttkuaiban.com";
-        }
-        User curUser = userMapper.selectById(userId);
-        //https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE
-        if (curUser == null) {
-            //msg.setError("该用户不存在,请退出重新登录");
-            System.out.println("该用户不存在,请退出重新登录");
-            reqParam.put("errorMsg",MessageUtils.message("user.notExists"));
-        } else {
-            String url = null;
-            try {
-                url = GET_CORP_USERINFO_URL.replace("SUITE_ACCESS_TOKEN", getSuiteAccessToken()).replace("CODE", code);
-                String forObject = this.restTemplate.getForObject(url, String.class);
-                JSONObject obj = JSONObject.parseObject(forObject);
-                System.out.println("获取授权的用户身份信息:"+obj.toString());
-                String wxUserId = obj.getString("open_userid");
-                String realUserId = obj.getString("UserId");
-                if (userId == null) {
-                    //msg.setError("该用户企业未授权");
-                    System.out.println("该用户企业未授权");
-                    reqParam.put("errorMsg",MessageUtils.message("access.grant"));
-                } else {
-                    curUser.setCorpwxRealUserid(realUserId);
-                    curUser.setCorpwxUserid(wxUserId);
-                    userMapper.updateById(curUser);
-                }
-            } catch (Exception exception) {
-                exception.printStackTrace();
-                reqParam.put("errorMsg",exception.getMessage());
-            }
-        }
-
-        ModelAndView modelAndView = new ModelAndView(
-                new RedirectView(redirecUrl), reqParam);
-
-        return modelAndView;
-    }
 
     //企业微信用户登录
     @RequestMapping(value = "/corpWeiXinLogin", method = RequestMethod.GET)
@@ -1706,141 +1592,6 @@ public class WeiXinCorpController {
         return msg;
     }
 
-    @RequestMapping("/syncMembByCardTime")
-    public HttpRespMsg syncMembByCardTime(Integer companyId) {
-        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
-        Company company = companyMapper.selectOne(new QueryWrapper<Company>().eq("id", companyId));
-        Integer employeeCnt = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active",1));
-        if (employeeCnt > company.getStaffCountMax()){
-            HttpRespMsg msg = new HttpRespMsg();
-            //公司人员已达上限,请联系客服提高人数上限。
-            msg.setError(MessageUtils.message("wx.employeeFull"));
-            return msg;
-        }
-        if (wxCorpInfo == null) {
-            HttpRespMsg msg = new HttpRespMsg();
-            //msg.setError("仅企业微信用户支持该操作");
-            msg.setError(MessageUtils.message("wx.noWXUser"));
-            return msg;
-        }
-        String curCorpAccessToken = null;
-        try {
-            curCorpAccessToken = getCorpAccessToken(wxCorpInfo);
-        } catch (Exception exception) {
-            exception.printStackTrace();
-        }
-        if (wxCorpInfo.getAuthMode() == 0) {
-            //修正: 获取企业的人员授权范围
-            JSONArray allowUserList = null;
-            JSONArray allowPartyList = null;
-            try {
-                String url = GET_AUTH_INFO.replaceAll("SUITE_ACCESS_TOKEN", getSuiteAccessToken());
-                JSONObject map = new JSONObject();
-                map.put("auth_corpid",wxCorpInfo.getCorpid());
-                map.put("permanent_code",wxCorpInfo.getPermanentCode());
-                HttpHeaders headers = new HttpHeaders();
-                headers.setContentType(MediaType.APPLICATION_JSON);
-                HttpEntity<JSONObject> detailEntity = new HttpEntity<>(map, headers);
-                ResponseEntity<String> detailResponseEntity = restTemplate.postForEntity(url, detailEntity, String.class);
-                JSONObject json = JSONObject.parseObject(detailResponseEntity.getBody());
-                System.out.println("获取企业授权返回:"+json.toJSONString());
-                if (json.containsKey("auth_corp_info")){
-                    JSONArray jsonArray = json.getJSONObject("auth_info").getJSONArray("agent");
-                    for (int i=0;i<jsonArray.size(); i++) {
-                        JSONObject jsonObject = jsonArray.getJSONObject(i);
-//                        if (jsonObject.getString("name").equals("工时管家")) {
-//                            System.out.println(jsonObject);
-                            JSONObject privilege = jsonObject.getJSONObject("privilege");
-                            allowUserList = privilege.getJSONArray("allow_user");
-                            allowPartyList = privilege.getJSONArray("allow_party");
-//                            break;
-//                        }
-                    }
-                }
-            } catch (Exception exception) {
-                exception.printStackTrace();
-            }
-            //管理员授权模式下,获取部门人员
-            SysRole defaultRole = sysRoleMapper.selectOne(
-                    new QueryWrapper<SysRole>().eq("company_id", companyId).eq("is_default", 1));
-            //单独授权的人员,获取人员详情进行处理
-            for (int i=0;i<allowUserList.size(); i++) {
-                String allowUserId = allowUserList.getString(i);
-                JSONObject userJson = getUserInfo(curCorpAccessToken, allowUserId);
-                String curUserid = userJson.getString("userid");
-                String openUserid = userJson.getString("open_userid");
-                //跳过非激活状态的员工
-                if (userJson.getInteger("status") != 1) continue;
-                //不存在的人员, 进行插入
-                User user = new User();
-                JSONArray userDeptArray = userJson.getJSONArray("department");
-                //取最末级的,也就是最大的deptId
-                int maxDeptId = 1;
-                for (int m=0;m<userDeptArray.size(); m++) {
-                    int curId = userDeptArray.getInteger(m);
-                    if (curId > maxDeptId) maxDeptId = curId;
-                }
-                System.out.println("userid="+curUserid+", name=" + userJson.getString("name")+", mobile="+userJson.getString("mobile"));
-                //不存在的人员, 进行插入
-                user.setId(SnowFlake.nextId()+"")
-                        .setRoleId(defaultRole.getId())//默认组员
-                        .setRoleName(defaultRole.getRolename())
-                        .setCompanyId(companyId)
-                        .setName(userJson.getString("name"))
-                        .setCorpwxUserid(curUserid)
-                        .setColor(ColorUtil.randomColor())
-                        .setInductionDate(LocalDate.now());
-                //检查用户是否已经存在
-                if (userMapper.selectCount(new QueryWrapper<User>().eq("corpwx_userid", curUserid)) == 0) {
-                    userMapper.insert(user);
-                    System.out.println("新用户==="+user.getName());
-                }
-            }
-
-            //获取部门
-            JSONObject deptObj = getAllDepartments(curCorpAccessToken);
-            JSONArray deptObjJSONArray = deptObj.getJSONArray("department");
-            for (int i=0;i<deptObjJSONArray.size(); i++) {
-                int deptId = deptObjJSONArray.getJSONObject(i).getIntValue("id");
-
-                JSONArray userList = getDeptUserSimple(curCorpAccessToken, deptId);
-                System.out.println("该部门下用户数量:"+userList.size());
-                for (int m=0;m<userList.size(); m++) {
-                    JSONObject userJson = userList.getJSONObject(m);
-                    String curUserid = userJson.getString("userid");
-                    System.out.println("userid="+curUserid+", name=" + userJson.getString("name")+", mobile="+userJson.getString("mobile"));
-                    //不存在的人员, 进行插入
-                    User user = new User();
-
-                    user.setId(SnowFlake.nextId()+"")
-                            .setRoleId(defaultRole.getId())//默认组员
-                            .setRoleName(defaultRole.getRolename())
-                            .setCompanyId(companyId)
-                            .setDepartmentId(0)
-                            .setName(userJson.getString("name"))
-                            .setCorpwxUserid(curUserid)
-                            .setColor(ColorUtil.randomColor());
-
-                    //检查用户是否已经存在
-                    if (userMapper.selectCount(new QueryWrapper<User>().eq("corpwx_userid", curUserid).eq("company_id", companyId)) == 0) {
-                        userMapper.insert(user);
-                    } else {
-                        User curUser = userMapper.selectOne(new QueryWrapper<User>().eq("corpwx_userid", curUserid).eq("company_id", companyId));
-                        System.out.println("找到用户:"+curUser.getName());
-                        if (curUser.getDepartmentId() != null) {
-                            Department dept = departmentMapper.selectById(curUser.getDepartmentId());
-                            if (dept != null) {
-                                System.out.println("部门:"+dept.getDepartmentName());
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        return wxCorpInfoService.syncMembByCardTime(wxCorpInfo);
-    }
-
     //改造老版的接口,从平台获取客户通讯录
     @RequestMapping("/getCorpMembsFromPlatform")
     public HttpRespMsg getCorpMembsFromPlatform(Integer companyId) {
@@ -2346,6 +2097,213 @@ public class WeiXinCorpController {
         }
         return view;
     }
+
+    /**
+     * 同步企业内部应用的通讯录组织架构
+     * @param companyId
+     * @return
+     */
+    @RequestMapping("/syncInsideCorpMembs")
+    public HttpRespMsg syncInsideCorpMembs(Integer companyId) {
+        Company company = companyMapper.selectById(companyId);
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
+        String corpid = wxCorpInfo.getCorpid();
+        if (wxCorpInfo != null) {
+            Integer employeeCnt = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active",1));
+            if (employeeCnt > company.getStaffCountMax()){
+                HttpRespMsg msg = new HttpRespMsg();
+                //公司人员已达上限,请联系客服提高人数上限。
+                msg.setError(MessageUtils.message("wx.employeeFull"));
+                return msg;
+            }
+            if (wxCorpInfo == null) {
+                HttpRespMsg msg = new HttpRespMsg();
+                //msg.setError("仅企业微信用户支持该操作");
+                msg.setError(MessageUtils.message("wx.noWXUser"));
+                return msg;
+            }
+            String accessToken = null;
+            try {
+                accessToken = wxCorpInfoService.getCorpAgentAccessToken(wxCorpInfo);
+                //获取组织架构 同步部门
+                String departmentInfoResp = wxCorpInfoService.getDepartmentInfoWithApplication(accessToken);
+                JSONObject departmentInfoOb = JSONObject.parseObject(departmentInfoResp);
+                JSONArray departmentInfoArrays = departmentInfoOb.getJSONArray("department");
+                System.out.println(departmentInfoOb.toJSONString());
+                for (int i = 0; i < departmentInfoArrays.size(); i++) {
+                    JSONObject ob = departmentInfoArrays.getJSONObject(i);
+                    String departmentName = String.valueOf(ob.get("name"));
+                    System.out.println("synchronizationDP========="+departmentName);
+                    Integer departmentId = ob.getInteger("id");
+                    Integer departmentParentId =ob.getInteger("parentid");
+                    Integer cut = departmentWxMapper.selectCount(new QueryWrapper<DepartmentWx>().eq("corpid",corpid).eq("wx_deptid",departmentId));
+                    if(cut==0&&departmentId!=1){
+                        System.out.println("join===========");
+                        DepartmentWx departmentWx=new DepartmentWx();
+                        departmentWx.setCorpid(corpid)
+                                .setName(departmentName)
+                                .setWxParentid(departmentParentId)
+                                .setWxDeptid(departmentId);
+                        Department department = new Department();
+                        department.setCompanyId(company.getId());
+                        department.setDepartmentName(departmentName);
+                        department.setCorpwxDeptid(departmentId);
+                        departmentMapper.insert(department);
+                        departmentWx.setSysDeptid(department.getDepartmentId());
+                        departmentWxMapper.insert(departmentWx);
+                    }
+                }
+                SysRole role = sysRoleMapper.selectOne(new QueryWrapper<SysRole>().eq("company_id", company.getId()).eq("rolename","组员"));
+                List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", company.getId()));
+                List<DepartmentWx> departmentWxList = departmentWxMapper.selectList(new QueryWrapper<DepartmentWx>().eq("corpid", corpid));
+                List<User> userList=new ArrayList<>();
+                for (DepartmentWx departmentWx : departmentWxList) {
+                    Optional<Department> first = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(departmentWx.getSysDeptid())).findFirst();
+                    //获取到当前部门的上级部门
+                    Optional<DepartmentWx> wx = departmentWxList.stream().filter(dl -> dl.getWxDeptid().equals(departmentWx.getWxParentid())).findFirst();
+                    if(first.isPresent()){
+                        if(wx.isPresent()){
+                            Optional<Department> dp = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(wx.get().getSysDeptid())).findFirst();
+                            if(dp.isPresent()){
+                                first.get().setSuperiorId(dp.get().getDepartmentId());
+                                departmentMapper.updateById(first.get());
+                            }
+                        }
+                    }
+                    //处理部门下的人员
+                    String resp=wxCorpInfoService.getUserInfoWithDepartment(accessToken,departmentWx.getWxDeptid());
+                    System.out.println("userList======"+resp);
+                    JSONObject userOb = JSONObject.parseObject(resp);
+                    JSONArray jsonArray = userOb.getJSONArray("userlist");
+                    for (int m=0;m<jsonArray.size(); m++) {
+                        JSONObject userJson = jsonArray.getJSONObject(m);
+                        String curUserid = userJson.getString("userid");
+                        String openUserid = userJson.getString("open_userid");
+                        int status = userJson.getIntValue("status");
+                        if(status!=1){
+                            continue;
+                        }
+                        List<Integer> departments = (List<Integer>) userJson.get("department");
+                        System.out.println("user info======:"+userJson.toString());
+                        //不存在的人员, 进行插入
+                        User user = new User();
+                        //在当前部门下的员工
+                        user.setId(SnowFlake.nextId()+"")
+                                .setRoleId(role.getId())//默认组员
+                                .setRoleName(role.getRolename())
+                                .setCompanyId(company.getId())
+                                .setName(userJson.getString("name"))
+                                .setCorpwxUserid(openUserid)
+                                .setCorpwxRealUserid(curUserid)
+                                .setColor(ColorUtil.randomColor())
+                                .setJobNumber(curUserid)
+                                .setPassword(MD5Util.getPassword("000000"))
+                                .setCorpwxDeptid(departmentWx.getWxDeptid());
+                        Integer max = Collections.max(departments);
+                        Optional<DepartmentWx> dpWx = departmentWxList.stream().filter(dl -> dl.getWxDeptid().equals(max)).findFirst();
+                        if(dpWx.isPresent()){
+                            Optional<Department> dp = departmentList.stream().filter(dl -> dl.getDepartmentId().equals(dpWx.get().getSysDeptid())).findFirst();
+                            if (dp.isPresent()) {
+                                user.setDepartmentName(dp.get().getDepartmentName());
+                                user.setDepartmentId(dp.get().getDepartmentId());
+                                user.setDepartmentCascade(convertDepartmentIdToCascade(dp.get().getDepartmentId(),departmentList));
+                            }
+                        }
+                        boolean b = userList.stream().anyMatch(ul ->ul.getCorpwxUserid()!=null&&ul.getCorpwxUserid().equals(user.getCorpwxUserid()));
+                        if(!b){
+                            userList.add(user);
+                        }
+                    }
+                }
+                String url = GET_APPLICATION_INFO.replace("ACCESS_TOKEN",accessToken).replace("AGENTID",String.valueOf(wxCorpInfo.getAgentid()));
+                HttpHeaders headers = new HttpHeaders();
+                headers.setContentType(MediaType.APPLICATION_JSON);
+                ResponseEntity<String> responseEntity = this.restTemplate.getForEntity(url,String.class);
+                if (responseEntity.getStatusCode() == HttpStatus.OK) {
+                    String resp = responseEntity.getBody();
+                    JSONObject json = JSONObject.parseObject(resp);
+                    if (json.getIntValue("errcode") == 0) {
+                        System.out.println("this is agentinfo========"+resp);
+                        String allow_userinfos = json.getString("allow_userinfos");
+                        JSONObject jsonObject = JSONObject.parseObject(allow_userinfos);
+                        JSONArray userInfo = jsonObject.getJSONArray("user");
+                        for (int i = 0; i < userInfo.size(); i++) {
+                            JSONObject object = userInfo.getJSONObject(i);
+                            String corpWxuserid = object.getString("userid");
+                            int status = object.getIntValue("status");
+                            if(status!=1){
+                                continue;
+                            }
+                            String userInfoResp=wxCorpInfoService.getUserInfoWithApplication(accessToken,corpWxuserid);
+                            System.out.println("this is userinfo======="+userInfoResp);
+                            JSONObject userInfoOb = JSONObject.parseObject(userInfoResp);
+                            //跳过非激活状态的员工
+                            if (userInfoOb.getInteger("status") != 1) continue;
+                            String userName = String.valueOf(userInfoOb.get("name"));
+//                                String phone = String.valueOf(userInfoOb.get("phone"));
+                            String openUserid = userInfoOb.getString("open_userid");
+                            List<Integer> departments = (List<Integer>) userInfoOb.get("department");
+                            Integer deptId = departments.get(0);
+                            User user=new User();
+                            user.setId(String.valueOf(SnowFlake.nextId()));
+                            user.setCompanyId(company.getId());
+                            System.out.println("now dept id is ==="+deptId);
+                            for (Integer department : departments) {
+                                Optional<DepartmentWx> first = departmentWxList.stream().filter(dl -> dl.getWxDeptid().equals(department)).findFirst();
+                                if(first.isPresent()){
+                                    if(department.equals(deptId)){
+                                        user.setDepartmentId(first.get().getSysDeptid());
+                                        user.setDepartmentName(first.get().getName());
+                                        user.setCorpwxDeptid(first.get().getWxDeptid());
+                                        user.setDepartmentCascade(convertDepartmentIdToCascade(first.get().getSysDeptid(), departmentList));
+                                    }
+                                }
+                            }
+                            user.setCorpwxUserid(corpWxuserid)
+                                    .setName(userName)
+                                    .setRoleName(role.getRolename())
+                                    .setRoleId(role.getId())
+//                                    .setPhone(phone)
+                                    .setCorpwxRealUserid(corpWxuserid)
+                                    .setColor(ColorUtil.randomColor())
+                                    .setPassword(MD5Util.getPassword("000000"))
+                                    .setJobNumber(corpWxuserid);
+                            boolean b = userList.stream().anyMatch(ul -> ul.getCorpwxUserid().equals(user.getCorpwxUserid()));
+                            if(!b){
+                                userList.add(user);
+                            }
+                        }
+                    } else {
+                        throw new Exception(json.toJSONString());
+                    }
+                }
+                System.out.println("resutlList========="+userList);
+                userService.saveBatch(userList);
+                employeeCnt = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active",1));
+                ContactSyncLog contactSyncLog = new ContactSyncLog();
+                contactSyncLog.setCompanyId(companyId);
+                if (employeeCnt > company.getStaffCountMax()){
+                    contactSyncLog.setResult(0);
+                    //contactSyncLog.setMsg("公司人员已达上限,请联系客服提高人数上限。");
+                    contactSyncLog.setMsg(MessageUtils.message("wx.employeeFull"));
+                    contactSyncLogMapper.insert(contactSyncLog);
+                }else {
+                    contactSyncLog.setResult(1);
+                    //contactSyncLog.setMsg("同步成功");
+                    contactSyncLog.setMsg(MessageUtils.message("wx.synSuccess"));
+                    contactSyncLogMapper.insert(contactSyncLog);
+                }
+            } catch (Exception exception) {
+                exception.printStackTrace();
+            }
+            return new HttpRespMsg();
+        } else {
+            HttpRespMsg msg = new HttpRespMsg();
+            msg.setError("该企业不存在");
+            return msg;
+        }
+    }
+
     /**
      * 初始化内部应用的系统数据
      * @return
@@ -2393,7 +2351,7 @@ public class WeiXinCorpController {
 //                    String accessToken = getCorpConcactAccessToken(wxCorpInfo);
                     String accessToken = wxCorpInfoService.getCorpAgentAccessToken(wxCorpInfo);
                     //获取组织架构 同步部门
-                    String departmentInfoResp=wxCorpInfoService.getDepartmentInfoWithApplication(accessToken);
+                    String departmentInfoResp = wxCorpInfoService.getDepartmentInfoWithApplication(accessToken);
                     JSONObject departmentInfoOb = JSONObject.parseObject(departmentInfoResp);
                     JSONArray departmentInfoArrays = departmentInfoOb.getJSONArray("department");
                     System.out.println(departmentInfoOb.toJSONString());

+ 1 - 0
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/PlanProcedureTotalServiceImpl.java

@@ -82,6 +82,7 @@ public class PlanProcedureTotalServiceImpl extends ServiceImpl<PlanProcedureTota
             procedureMap.put("checker_name", map.get("checker_name"));
             procedureMap.put("checker_id", map.get("checker_id"));
             procedureMap.put("check_type", map.get("check_type"));
+            procedureMap.put("plan_check_type", map.get("plan_check_type"));
             procedureList.add(procedureMap);
         }
 

+ 14 - 7
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -117,13 +117,18 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         LocalDate today = LocalDate.now();
         report.setCreateDate(today);
         report.setCompanyId(companyId);
-        Product product = productMapper.selectById(report.getProductId());
-        if (product == null) {
-            httpRespMsg.setError("产品不存在,无法报工");
-            return httpRespMsg;
+        Plan plan = planMapper.selectById(report.getPlanId());
+        if (plan.getPlanType() == 0) {
+            //普通计划检查产品是否存在
+            Product product = productMapper.selectById(report.getProductId());
+            if (product == null) {
+                httpRespMsg.setError("产品不存在,无法报工");
+                return httpRespMsg;
+            }
         }
+
         //检查今日该员工的该工序是否已经有报工
-        Report existReport = reportMapper.selectOne(new QueryWrapper<Report>().eq("creator_id", token).eq("prod_procedure_id", report.getProdProcedureId()).eq("create_date", today));
+        Report existReport = reportMapper.selectOne(new QueryWrapper<Report>().eq("creator_id", token).eq("user_procedure_team_id", report.getUserProcedureTeamId()).eq("create_date", today));
         //计算工作时长
         ProdProcedureTeam prodProcedureTeam = prodProcedureTeamMapper.selectById(report.getUserProcedureTeamId());
         double curReportTime = 0.0;
@@ -140,9 +145,11 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         }
 
         report.setWorkingTime(curReportTime);//本次报工的工时数
-        Plan plan = planMapper.selectById(report.getPlanId());
         report.setDeptId(plan.getStationId());
-        report.setProductId(plan.getProductId());
+        if (plan.getPlanType() == 0) {
+            report.setProductId(plan.getProductId());
+        }
+
         if (report.getProgress() == 100) {
             //设置质检人
             if (report.getCheckType() == 0) {

+ 2 - 2
fhKeeper/formulahousekeeper/management-workshop/src/main/resources/mapper/ProdProcedureTeamMapper.xml

@@ -24,7 +24,7 @@
 
     <select id="getReportForWorkList" resultType="java.util.HashMap" >
         SELECT a.*, plan_procedure_total.plan_id, plan_procedure_total.prod_procedure_id, date_format(plan.`start_date`,'%Y-%m-%d') as start_date, date_format(plan.`end_date`,'%Y-%m-%d') as end_date, plan.`plan_type`, plan.`product_scheduling_num`,plan.task_type_name,plan.task_name,plan.task_change_notice_num,
-               product.`name` AS product_name,prod_procedure.name AS procedure_name, prod_procedure.check_type
+               product.`name` AS product_name,prod_procedure.name AS procedure_name, prod_procedure.check_type, plan.check_type as plan_check_type
         FROM prod_procedure_team a
                  left join plan_procedure_total on plan_procedure_total.id = a.plan_procedure_id
                  LEFT JOIN plan ON plan.id = plan_procedure_total.plan_id
@@ -36,7 +36,7 @@
 
     <select id="getFillProcedureDetail" resultType="java.util.HashMap" >
         SELECT a.*, plan_procedure_total.plan_id, plan_procedure_total.prod_procedure_id, date_format(plan.`start_date`,'%Y-%m-%d') as start_date, date_format(plan.`end_date`,'%Y-%m-%d') as end_date, plan.`plan_type`, plan.`product_scheduling_num`,plan.task_type_name,plan.task_name,plan.task_change_notice_num,
-               product.`name` AS product_name,prod_procedure.name AS procedure_name, prod_procedure.check_type,plan.station_id
+               product.`name` AS product_name,prod_procedure.name AS procedure_name, if(plan.plan_type=0,prod_procedure.check_type, plan.check_type) as check_type, plan.station_id
         FROM prod_procedure_team a
             left join plan_procedure_total on plan_procedure_total.id = a.plan_procedure_id
                  LEFT JOIN plan ON plan.id = plan_procedure_total.plan_id

+ 3 - 2
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/workView/fillReport.vue

@@ -10,7 +10,8 @@
     <van-form @submit="onSubmit">
       <van-cell-group inset>
 
-        <van-cell title="工序" :value="reportForm.procedure_name" />
+        <van-cell v-if="reportForm.plan_type==0" title="工序" :value="reportForm.procedure_name" />
+        <van-cell v-else title="任务变更通知号" :value="reportForm.task_change_notice_num" />
         <van-cell title="进度(%)"   >
           <template>
             <van-stepper v-model="reportForm.progress" step="10" :min="0" :max="100"/>
@@ -21,7 +22,7 @@
         </van-cell>
       </van-cell-group>
       <div style="margin: 16px;">
-        <van-button round block type="primary" native-type="submit" :loading = "saving">
+        <van-button round block type="primary" native-type="submit" :loading = "saving" :disabled="reportForm.progress==0">
           提交
         </van-button>
       </div>

+ 4 - 4
fhKeeper/formulahousekeeper/timesheet-workshop-h5/src/views/workView/workView.vue

@@ -6,14 +6,14 @@
       <van-empty v-if="myPlanProcedureList.length==0">暂无待报工任务</van-empty>
       <div v-for="(prod, prodIndex) in myPlanProcedureList">
           <div class="distribution_header">
-            <div>{{prod.product_name}}</div>
-            <div>{{prod.plan_type == 0? prod.product_scheduling_num:prod.task_change_notice_num}}</div>
+            <div>{{prod.plan_type == 0?prod.product_name:prod.task_name}}</div>
+            <div v-if="prod.plan_type == 0">{{prod.product_scheduling_num}}</div>
             <div>{{prod.start_date}}至{{prod.end_date}}</div>
           </div>
           <div class="distribution_box" v-for="item,index in prod.procedureList" :key="index" @click="reportItem(item)">
             <div>
               <van-row >
-                <van-col span="20">{{ item.procedure_name }}</van-col>
+                <van-col span="20">{{ prod.plan_type == 0?item.procedure_name : prod.task_change_notice_num}}</van-col>
                 <van-col span="4"><span style="color:goldenrod;font-size:16px;">{{ item.work_time }}</span> h</van-col>
               </van-row>
               <div style="margin-top:10px;text-align: center;">
@@ -28,7 +28,7 @@
                   </van-col>
                   <van-col span="8">
                     <div class="valueCls">
-                        {{checkTypeTxt[item.check_type]}}
+                        {{checkTypeTxt[prod.plan_type == 0?item.check_type:item.plan_check_type]}}
                       </div>
                       <div class="labelCls">
                         质检方式