|
@@ -38,19 +38,12 @@ import java.util.*;
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
public class HuaGaoServiceImpl implements HuaGaoService {
|
|
public class HuaGaoServiceImpl implements HuaGaoService {
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private YDService ydService;
|
|
private YDService ydService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private YDClient ydClient;
|
|
private YDClient ydClient;
|
|
|
|
|
|
- @Value("${dingtalk.appKey}")
|
|
|
|
- private String appKey;
|
|
|
|
-
|
|
|
|
- @Value("${dingtalk.appSecret}")
|
|
|
|
- private String appSecret;
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private DDClient_Contacts ddClient_contacts;
|
|
private DDClient_Contacts ddClient_contacts;
|
|
|
|
|
|
@@ -59,8 +52,6 @@ public class HuaGaoServiceImpl implements HuaGaoService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private DDClient ddClient;
|
|
private DDClient ddClient;
|
|
- @Autowired
|
|
|
|
- private FXKClient fxkClient;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private YdUserInputMapper ydUserInputMapper;
|
|
private YdUserInputMapper ydUserInputMapper;
|
|
@@ -71,141 +62,6 @@ public class HuaGaoServiceImpl implements HuaGaoService {
|
|
@Autowired
|
|
@Autowired
|
|
private YdProdWorkHoursPriceMapper ydProdWorkHoursPriceMapper;
|
|
private YdProdWorkHoursPriceMapper ydProdWorkHoursPriceMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private static final long DEPT_ID = 971482089L; // 合作加盟校区
|
|
|
|
-
|
|
|
|
- /// 创建企业账号: loginI/userId 都为 SHR 工号
|
|
|
|
-private Map crcreateUser_dingTalk(String name, String randomAccount, String randomPassword) {
|
|
|
|
-
|
|
|
|
- Map param = new HashMap();
|
|
|
|
- param.put("access_token", ddClient.getAccessToken());
|
|
|
|
- Map body = new HashMap();
|
|
|
|
- body.put("exclusive_account", "true");
|
|
|
|
- body.put("exclusive_account_type", "dingtalk");
|
|
|
|
- body.put("login_id", randomAccount);
|
|
|
|
- body.put("init_password", randomPassword);
|
|
|
|
- body.put("name", name);
|
|
|
|
- body.put("userid", randomAccount);
|
|
|
|
- body.put("dept_id_list", DEPT_ID);
|
|
|
|
- Object result = DDR.doPost("https://oapi.dingtalk.com/topapi/v2/user/create", (Map) null, param, body).getResult();
|
|
|
|
- return (Map) result;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 同步钉钉企业账号
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public void syncDingTalk_exclusive() {
|
|
|
|
-
|
|
|
|
- List<Map> dataList = ydService.queryFormData_all(YDParam.builder()
|
|
|
|
- .formUuid("FORM-0086C4597047459BBB37C79E404745C9CK0C")
|
|
|
|
- .build());
|
|
|
|
- log.info("钉钉企业账号同步开始,共{}条数据", dataList.size());
|
|
|
|
- dataList.forEach(data -> {
|
|
|
|
- if ("".equals(UtilMap.getString(data, "textField_m1mw64v4"))) {
|
|
|
|
- String message = "";
|
|
|
|
- String randomAccount = generateRandomAccount();
|
|
|
|
- String randomPassword = generateRandomSixDigitPassword();
|
|
|
|
- try {
|
|
|
|
- Map textField_m21lkesk = this.crcreateUser_dingTalk(UtilMap.getString(data, "textField_m21lkesk"), randomAccount, randomPassword);
|
|
|
|
- System.out.println("");
|
|
|
|
- } catch (McException e) {
|
|
|
|
- message = e.getMessage();
|
|
|
|
- log.error(e.getMessage(), e);
|
|
|
|
- }
|
|
|
|
- ydClient.operateData(YDParam.builder()
|
|
|
|
- .formInstanceId(UtilMap.getString(data, "instanceId"))
|
|
|
|
- .useLatestVersion(true)
|
|
|
|
- .updateFormDataJson(JSON.toJSONString(UtilMap.map("textField_m1mw64v4, textField_m1mw64v5", randomAccount, randomPassword)))
|
|
|
|
- .build(), YDConf.FORM_OPERATION.update);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 重置企业账号密码
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public void resetPwd(Map data) {
|
|
|
|
- ddClient_contacts.updateUser_dingTalk(ddClient.getAccessToken(), UtilMap.getString(data, "userId"), Arrays.asList(DEPT_ID), UtilMap.map("init_password", UtilMap.getString(data, "password")));
|
|
|
|
- }
|
|
|
|
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
- @Override
|
|
|
|
- public void getCheckWorkDateDetails(Map data) {
|
|
|
|
- List<String> users = new ArrayList<>();
|
|
|
|
- users.add("284156461536271475");
|
|
|
|
- String[] strings = users.toArray(new String[0]);
|
|
|
|
- log.info("users:{}", JSON.toJSONString(strings));
|
|
|
|
- List<Map> mapList = ddClientAttendance.getAttColumnVal(ddClient.getAccessToken(appKey, appSecret),"284156461536271475", Arrays.asList("82772106,89349019"),"2025-01-20 08:00:00", "2025-01-21 08:00:00");
|
|
|
|
- System.out.println("====="+mapList);
|
|
|
|
-// mapList.get(0)
|
|
|
|
- String FORMtime = "2025-01-01 00:00:00";
|
|
|
|
- String TOtime = "2025-01-31 00:00:00";
|
|
|
|
-
|
|
|
|
-// dateFormat.format(FORMtime);
|
|
|
|
-// dateFormat.format(TOtime);
|
|
|
|
- //工作时长(实际工时)
|
|
|
|
- // Step 1. 提取原始数据到日期-字段ID-值的映射
|
|
|
|
- Map<String, Map<Long, Double>> dateData = new HashMap<>();
|
|
|
|
-
|
|
|
|
- for (Map<String, Object> element : mapList) {
|
|
|
|
- // 获取字段ID
|
|
|
|
- Map<String, Object> columnVo = (Map<String, Object>) element.get("column_vo");
|
|
|
|
- Long id = ((Number) columnVo.get("id")).longValue();
|
|
|
|
-
|
|
|
|
- // 遍历该字段的所有日期数据
|
|
|
|
- List<Map<String, String>> columnVals = (List<Map<String, String>>) element.get("column_vals");
|
|
|
|
- for (Map<String, String> entry : columnVals) {
|
|
|
|
- String fullDate = entry.get("date");
|
|
|
|
-// System.out.println("fullDate:====="+fullDate);
|
|
|
|
- String date = fullDate.split(" ")[0]; // 提取日期部分
|
|
|
|
- Double value = Double.parseDouble(entry.get("value"));
|
|
|
|
-
|
|
|
|
- // 存储到日期映射中
|
|
|
|
- dateData.computeIfAbsent(date, k -> new HashMap<>())
|
|
|
|
- .put(id, value);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Step 2. 按日期处理业务逻辑
|
|
|
|
- Map<String, Double> finalResult = new LinkedHashMap<>(); // 保持日期顺序
|
|
|
|
-
|
|
|
|
- for (Map.Entry<String, Map<Long, Double>> entry : dateData.entrySet()) {
|
|
|
|
- String date = entry.getKey();
|
|
|
|
- Map<Long, Double> idValues = entry.getValue();
|
|
|
|
-
|
|
|
|
- // 获取目标字段的值
|
|
|
|
- Double targetValue = idValues.get(89349019L); // ID=89349019
|
|
|
|
- Double refValue = idValues.get(82772106L); // ID=82772106
|
|
|
|
-
|
|
|
|
- // 逻辑判断
|
|
|
|
- if (targetValue == null || refValue == null) {
|
|
|
|
- System.err.println("日期 " + date + " 缺少必要字段数据,跳过计算");
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- double result;
|
|
|
|
- if (targetValue >= 8) {
|
|
|
|
- result = targetValue; // 直接返回
|
|
|
|
- } else {
|
|
|
|
- result = targetValue + (refValue / 60); // 组合计算
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- finalResult.put(date, result);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Step 3. 打印最终结果
|
|
|
|
- System.out.println("===== 计算结果 =====");
|
|
|
|
- finalResult.forEach((date, value) -> {
|
|
|
|
- System.out.printf("日期: %s \t 结果值: %.1f%n", date, value);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void syncKqData(LocalDateTime startTime, LocalDateTime endTime) {
|
|
public void syncKqData(LocalDateTime startTime, LocalDateTime endTime) {
|
|
String stTime=UtilDateTime.formatLocal(startTime,UtilDateTime.DATE_TIME_PATTERN);
|
|
String stTime=UtilDateTime.formatLocal(startTime,UtilDateTime.DATE_TIME_PATTERN);
|
|
@@ -389,44 +245,4 @@ private Map crcreateUser_dingTalk(String name, String randomAccount, String rand
|
|
.searchCondition(JSONObject.toJSONString(UtilMap.map("employeeField_m8cu0g58, dateField_m8e53oef", userId,Arrays.asList(dateTime,dateTime))))
|
|
.searchCondition(JSONObject.toJSONString(UtilMap.map("employeeField_m8cu0g58, dateField_m8e53oef", userId,Arrays.asList(dateTime,dateTime))))
|
|
.formDataJson(JSONObject.toJSONString(saveMap)).build(), YDConf.FORM_OPERATION.upsert);
|
|
.formDataJson(JSONObject.toJSONString(saveMap)).build(), YDConf.FORM_OPERATION.upsert);
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 生成一个由大写字母和数字组成的八位随机账号。
|
|
|
|
- *
|
|
|
|
- * @return 生成的随机账号字符串
|
|
|
|
- */
|
|
|
|
- public static String generateRandomAccount() {
|
|
|
|
- // 可选字符集合:大写字母A-Z和数字0-9
|
|
|
|
- final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
|
|
- final int LENGTH = 8; // 账号长度
|
|
|
|
-
|
|
|
|
- Random random = new Random();
|
|
|
|
- StringBuilder sb = new StringBuilder(LENGTH);
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < LENGTH; i++) {
|
|
|
|
- // 随机选择一个字符
|
|
|
|
- int index = random.nextInt(CHARS.length());
|
|
|
|
- char randomChar = CHARS.charAt(index);
|
|
|
|
- sb.append(randomChar);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return sb.toString();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 生成一个六位数的随机密码。
|
|
|
|
- *
|
|
|
|
- * @return 生成的随机密码字符串
|
|
|
|
- */
|
|
|
|
- public static String generateRandomSixDigitPassword() {
|
|
|
|
- Random random = new Random();
|
|
|
|
- int min = 100000; // 六位数最小值
|
|
|
|
- int max = 999999; // 六位数最大值
|
|
|
|
-
|
|
|
|
- // 生成一个介于[min, max]之间的随机数
|
|
|
|
- int randomNumber = random.nextInt(max - min + 1) + min;
|
|
|
|
-
|
|
|
|
- // 将生成的随机数转换为字符串
|
|
|
|
- return String.valueOf(randomNumber);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|