Browse Source

工时成本统计按照项目查看增加项目筛选

yurk 2 years ago
parent
commit
a284696b3f

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -219,8 +219,8 @@ public class ProjectController {
      * 获取查询者所在公司每个项目的工时成本
      */
     @RequestMapping("/getTimeCost")
-    public HttpRespMsg getTimeCost(String startDate, String endDate, String userIds) {
-        return projectService.getTimeCost(startDate, endDate, userIds, request);
+    public HttpRespMsg getTimeCost(String startDate, String endDate, String userIds,Integer projectId) {
+        return projectService.getTimeCost(startDate, endDate, userIds,projectId, request);
     }
 
     /**

+ 13 - 14
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskController.java

@@ -95,7 +95,7 @@ public class TaskController {
 
     @RequestMapping("/save")
     @Transactional
-    public HttpRespMsg save(Task task) {
+    public HttpRespMsg save(Task task) throws Exception {
         String userId = request.getHeader("Token");
         String executorListStr = task.getExecutorListStr();
 
@@ -277,19 +277,18 @@ public class TaskController {
                 } else if (recpUserList.get(0).getCorpwxUserid() != null) {
                     //企业微信用户
                     WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
-                    recpUserList.forEach(ru->{
-                        String corpUid = ru.getCorpwxUserid();
-                        JSONObject json=new JSONObject();
-                        JSONArray dataJson=new JSONArray();
-                        JSONObject jsonObj=new JSONObject();
-                        jsonObj.put("key", "任务内容");
-                        jsonObj.put("value",task.getName());
-                        dataJson.add(jsonObj);
-                        json.put("template_id","tty9TkCAAAovv416zsWtn0e06CJ635HA");
-                        json.put("url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=task#wechat_redirect");
-                        json.put("content_item",dataJson);
-                        wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo, corpUid, json);
-                    });
+                    String corpUid = recpUserList.stream().map(User::getCorpwxUserid).distinct().collect(Collectors.joining("|"));
+                    JSONObject json=new JSONObject();
+                    JSONArray dataJson=new JSONArray();
+                    JSONObject jsonObj=new JSONObject();
+                    jsonObj.put("key", "任务内容");
+                    jsonObj.put("value",task.getName());
+                    dataJson.add(jsonObj);
+                    json.put("template_id","tty9TkCAAAovv416zsWtn0e06CJ635HA");
+                    json.put("url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=task#wechat_redirect");
+                    json.put("content_item",dataJson);
+                    //todo:发送消息提醒任务
+                    wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo, corpUid, json);
                 }
             }
         }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java

@@ -51,7 +51,7 @@ public interface ProjectService extends IService<Project> {
 
     HttpRespMsg deleteProject(Integer id, Integer force);
 
-    HttpRespMsg getTimeCost(String startDate, String endDate, String userIds, HttpServletRequest request);
+    HttpRespMsg getTimeCost(String startDate, String endDate, String userIds,Integer projectId, HttpServletRequest request);
 
     HttpRespMsg getProjectCost(String startDate, String endDate, Integer projectId,Integer stateKey, HttpServletRequest request);
 

+ 2 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -1042,7 +1042,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
     //获取查询者所在公司每个项目的工时成本
     @Override
-    public HttpRespMsg getTimeCost(String startDate, String endDate, String userIds, HttpServletRequest request) {
+    public HttpRespMsg getTimeCost(String startDate, String endDate, String userIds,Integer projectId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             //根据系统配置的员工成本计算方式,按固定时薪还是固定月薪,分情况计算。
@@ -1090,7 +1090,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 String[] split = userIds.split(",");
                 userIdList = Arrays.asList(split);
             }
-            List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userIdList,deptIds,null, deptRelatedProjectIds);
+            List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userIdList,deptIds,null, deptRelatedProjectIds);
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             for (Map<String, Object> map : list) {
                 if (!map.containsKey("cost")) {

+ 47 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.gson.JsonObject;
 import com.management.platform.controller.WeiXinCorpController;
 import com.management.platform.entity.*;
 import com.management.platform.mapper.*;
@@ -74,6 +75,13 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
     //获取企业管理员列表
     public static final String GET_ADMIN_LIST = "https://qyapi.weixin.qq.com/cgi-bin/service/get_admin_list?suite_access_token=SUITE_ACCESS_TOKEN";
 
+    //创建日历
+    public static final String ADD_CALENDAR = "https://qyapi.weixin.qq.com/cgi-bin/oa/calendar/add?access_token=ACCESS_TOKEN";
+
+    //获取日程
+    public static final String ADD_SCHEDULE = " https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/add?access_token=ACCESS_TOKEN";
+
+
     public static final int TEXT_CARD_MSG_BUSTRIP_WAITING_AUDIT = 0;//出差待审核
     public static final int TEXT_CARD_MSG_BUSTRIP_AGREE = 1;//出差审核通过
     public static final int TEXT_CARD_MSG_BUSTRIP_DENY = 2;//出差审核驳回
@@ -1868,4 +1876,43 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         result.put("dept",dept);
         return result;
     }
+
+    public String addCalendar(WxCorpInfo wxCorpInfo,String targetUsers, String description) throws Exception {
+        String result="";
+        String url = ADD_CALENDAR.replace("ACCESS_TOKEN",getCorpAccessToken(wxCorpInfo));
+        HttpHeaders headers = new HttpHeaders();
+        RestTemplate restTemplate = new RestTemplate();
+        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
+        headers.setContentType(type);
+        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
+        JSONObject requestMap = new JSONObject();
+        JSONObject calendar=new JSONObject();
+        JSONArray shares=new JSONArray();
+        String[] split = targetUsers.split("\\|");
+        List<String> userList = Arrays.asList(split);
+        for (String s : userList) {
+            JSONObject user=new JSONObject();
+            user.put("userid",s);
+            shares.add(user);
+        }
+        calendar.put("admins",split);
+        calendar.put("summary","工时管家任务");
+        calendar.put("color","#0000FF");
+        calendar.put("description",description);
+        calendar.put("is_public",0);
+        calendar.put("shares",shares);
+        calendar.put("is_corp_calendar",0);
+        requestMap.put("calendar", calendar);
+        requestMap.put("agentid", wxCorpInfo.getAgentid());
+        HttpEntity<JSONObject> entity = new HttpEntity<>(requestMap, headers);
+        ResponseEntity<String> ResponseEntity = restTemplate.postForEntity(url, entity, String.class);
+        if (ResponseEntity.getStatusCode() == HttpStatus.OK) {
+            String resp = ResponseEntity.getBody();
+            JSONObject respJson = JSONObject.parseObject(resp);
+            if (respJson.getInteger("errcode")==0){
+                result+=respJson.getString("cal_id");
+            }
+        }
+        return result;
+    }
 }

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -299,6 +299,7 @@ public class TimingTask {
             /*jsonObject.put("startDate",startDate);
             jsonObject.put("endDate",endDate);*/
             jsonObject.put("workDate",startDate);
+            /*jsonObject.put("gmtFinished",startDate);*/
             String jsonString = jsonObject.toJSONString();
             List<UserFvTime> userFvTimeList=new ArrayList<>();
             List<LeaveSheet> leaveSheetList=new ArrayList<>();