wzy 2 months ago
parent
commit
9dba9820fd

+ 1 - 1
mjava-huagao/src/main/java/com/malk/huagao/entity/YdUserInput.java

@@ -26,7 +26,7 @@ public class YdUserInput implements Serializable {
       /**
      * 成员
      */
-      private String user;
+      private String userName;
 
       /**
      * 员工id

+ 9 - 1
mjava-huagao/src/main/java/com/malk/huagao/service/impl/HuaGaoServiceImpl.java

@@ -22,6 +22,7 @@ import com.malk.service.aliwork.YDService;
 import com.malk.service.dingtalk.*;
 import com.malk.service.fxiaoke.FXKClient;
 import com.malk.utils.UtilDateTime;
+import com.malk.utils.UtilHttp;
 import com.malk.utils.UtilMap;
 import lombok.extern.slf4j.Slf4j;
 import org.slf4j.MDC;
@@ -86,7 +87,12 @@ public class HuaGaoServiceImpl implements HuaGaoService {
                         String workTime="休息".equals(dataMap.get("82772125"))?
                                 dataMap.get("89349019"): NumberUtil.add(dataMap.get("89349019"),dataMap.get("82772106")).toString();
 
-                        log.info("user:{},date:{},workTime:{},price:{}",user,date,workTime,price);
+                        //查询用户详情
+                        DDR_New ddrNew1 = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/v2/user/get", null, ddClient.initTokenParams(), UtilMap.map("userid", user), DDR_New.class);
+                        Map result1 = (Map) ddrNew1.getResult();
+                        String userName = UtilMap.getString(result1, "name");
+
+                        log.info("user:{},userName:{},date:{},workTime:{},price:{}",user,userName,date,workTime,price);
 
                         saveData(user,date,workTime,price);
 
@@ -98,6 +104,7 @@ public class HuaGaoServiceImpl implements HuaGaoService {
                         YdUserInput ydUserInput = ydUserInputMapper.selectOne(ydUserInputLambdaQueryWrapper);
 
                         if (Objects.nonNull(ydUserInput)){
+                            ydUserInput.setUserName(userName);
                             ydUserInput.setWorkHours(workTime);
                             ydUserInput.setPrice(price);
                             ydUserInput.setTotalPrice(NumberUtil.mul(workTime,price));
@@ -107,6 +114,7 @@ public class HuaGaoServiceImpl implements HuaGaoService {
                             try {
                                 ydUserInput = new YdUserInput();
                                 ydUserInput.setUserId(user);
+                                ydUserInput.setUserName(userName);
                                 SimpleDateFormat formatter = new SimpleDateFormat(UtilDateTime.DATE_TIME_PATTERN);
                                 ydUserInput.setDate(formatter.parse(date));
                                 ydUserInput.setWorkHours(workTime);

+ 12 - 6
mjava-huagao/src/test/java/com/malk/huagao/YyYdTest.java

@@ -9,6 +9,7 @@ import com.malk.huagao.mapper.YdUserInputMapper;
 import com.malk.huagao.service.HuaGaoService;
 import com.malk.server.aliwork.YDConf;
 import com.malk.server.aliwork.YDParam;
+import com.malk.server.dingtalk.DDR_New;
 import com.malk.service.aliwork.YDClient;
 import com.malk.service.aliwork.YDService;
 import com.malk.service.dingtalk.DDClient;
@@ -16,6 +17,7 @@ import com.malk.service.dingtalk.DDClient_Alibtrip;
 import com.malk.service.dingtalk.DDClient_Attendance;
 import com.malk.service.dingtalk.DDClient_Contacts;
 import com.malk.utils.UtilDateTime;
+import com.malk.utils.UtilHttp;
 import com.malk.utils.UtilMap;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
@@ -127,8 +129,8 @@ public class YyYdTest {
 
     @Test
     public void test5(){
-        String stTime="2025-08-21 00:00:00";
-        String edTime="2025-08-22 00:00:00";
+        String stTime="2025-09-25 00:00:00";
+        String edTime="2025-09-26 00:00:00";
         List<Map> list=ydService.queryAllFormData(YDParam.builder().formUuid("FORM-5061F7AE543B429C8241EC730A6F31653NNK").build());
         for(Map map:list){
             Map formData= UtilMap.getMap(map,"formData");
@@ -136,9 +138,6 @@ public class YyYdTest {
             String price=UtilMap.getString(formData,"numberField_m8e4zajw_value");
             List<String> users=ddClient_contacts.listDepartmentUserId(ddClient.getAccessToken(),Long.parseLong(deptId));
             for (String user : users) {
-                if (!user.equals("284156461536271475")){
-                    continue;
-                }
                 List<Map> valList=ddClientAttendance.getAttColumnVal(ddClient.getAccessToken(),user, Arrays.asList("82772106","89349019","82772125"),stTime,edTime);
                 if(valList!=null&&valList.size()==3){
                     Map<String,Map<String,String>> dateMap=toDateMap(valList);
@@ -147,7 +146,12 @@ public class YyYdTest {
                         String workTime="休息".equals(dataMap.get("82772125"))?
                                 dataMap.get("89349019"): NumberUtil.add(dataMap.get("89349019"),dataMap.get("82772106")).toString();
 
-                        log.info("user:{},date:{},workTime:{},price:{}",user,date,workTime,price);
+                        //查询用户详情
+                        DDR_New ddrNew1 = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/v2/user/get", null, ddClient.initTokenParams(), UtilMap.map("userid", user), DDR_New.class);
+                        Map result1 = (Map) ddrNew1.getResult();
+                        String userName = UtilMap.getString(result1, "name");
+
+                        log.info("user:{},userName:{},date:{},workTime:{},price:{}",user,userName,date,workTime,price);
 
                         //同步到数据库
                         LambdaQueryWrapper<YdUserInput> ydUserInputLambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -157,6 +161,7 @@ public class YyYdTest {
                         YdUserInput ydUserInput = ydUserInputMapper.selectOne(ydUserInputLambdaQueryWrapper);
 
                         if (Objects.nonNull(ydUserInput)){
+                            ydUserInput.setUserName(userName);
                             ydUserInput.setWorkHours(workTime);
                             ydUserInput.setPrice(price);
                             ydUserInput.setTotalPrice(NumberUtil.mul(workTime,price));
@@ -166,6 +171,7 @@ public class YyYdTest {
                             try {
                                 ydUserInput = new YdUserInput();
                                 ydUserInput.setUserId(user);
+                                ydUserInput.setUserName(userName);
                                 SimpleDateFormat formatter = new SimpleDateFormat(UtilDateTime.DATE_TIME_PATTERN);
                                 ydUserInput.setDate(formatter.parse(date));
                                 ydUserInput.setWorkHours(workTime);