|
@@ -1,4 +1,14 @@
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
|
|
+import com.malk.server.aliwork.YDSearch;
|
|
|
|
|
+import com.malk.service.aliwork.YDClient;
|
|
|
|
|
+import com.malk.service.aliwork.YDService;
|
|
|
|
|
+import com.malk.service.dingtalk.DDClient;
|
|
|
|
|
+import com.malk.service.dingtalk.DDClient_Notice;
|
|
|
import com.malk.taisen.service.RtrServer;
|
|
import com.malk.taisen.service.RtrServer;
|
|
|
|
|
+import com.malk.utils.UtilDateTime;
|
|
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
import org.junit.runner.RunWith;
|
|
@@ -6,6 +16,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@RunWith(SpringRunner.class)
|
|
@RunWith(SpringRunner.class)
|
|
|
@SpringBootTest(classes = com.malk.kepeida.Boot.class)
|
|
@SpringBootTest(classes = com.malk.kepeida.Boot.class)
|
|
@@ -15,8 +29,102 @@ public class RtrTest {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RtrServer rtrServer;
|
|
private RtrServer rtrServer;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private YDService ydService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDClient_Notice ddClientNotice;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DDClient ddClient;
|
|
|
|
|
+
|
|
|
@Test
|
|
@Test
|
|
|
public void RtrTest(){
|
|
public void RtrTest(){
|
|
|
- rtrServer.RtrInsetSAP0005("YWJT","FORM-0401740B8E6F4DF8894498F0D8783B13QIPI", instanceId);
|
|
|
|
|
|
|
+ rtrServer.RtrInsetSAP0005("YWJT","FORM-66A4F00A1E0E4E67B607D4119B88CEF6FBP6", "365c44b2-2ff5-49f7-ab5c-84e271c0566d");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void RtrTestAuto(){
|
|
|
|
|
+ // 获取当前时间
|
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
|
+ // 获取当月第一天 00:00:00
|
|
|
|
|
+ LocalDateTime firstDayOfMonth = now.withDayOfMonth(1).atStartOfDay();
|
|
|
|
|
+ // 获取当月最后一天 23:59:59.999999999
|
|
|
|
|
+ LocalDateTime lastDayOfMonth = now.withDayOfMonth(now.lengthOfMonth())
|
|
|
|
|
+ .atTime(23, 59, 59, 999999999);
|
|
|
|
|
+ // 转换为时间戳(毫秒)
|
|
|
|
|
+ long startTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(firstDayOfMonth);
|
|
|
|
|
+ long endTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(lastDayOfMonth);
|
|
|
|
|
+ YDSearch yidaSearch=new YDSearch("selectField_miwh5y55","待自动过账","状态", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ);
|
|
|
|
|
+ YDSearch yidaSearch2=new YDSearch("dateField_miwh5y85",Arrays.asList(startTimestamp,endTimestamp),"时间", YDSearch.Type.DATE_FIELD,YDSearch.Operator.BETWEEN);
|
|
|
|
|
+ List<Map> list=ydService.queryFormData_all(YDParam.builder().formUuid("FORM-E8E54176A4D446C182EB6A3C012A0284AGQN")
|
|
|
|
|
+ .searchFieldJson(JSONObject.toJSONString(Arrays.asList(yidaSearch,yidaSearch2))).build());
|
|
|
|
|
+ for(Map map:list){
|
|
|
|
|
+ System.out.println(map.get("instanceId"));
|
|
|
|
|
+ rtrServer.RtrInsetSAP0005("YWJT","FORM-E8E54176A4D446C182EB6A3C012A0284AGQN", String.valueOf(map.get("instanceId")));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void RtrTestMsg(){
|
|
|
|
|
+ String url="https://tysonchina.aliwork.com/APP_N9NPHVTQLPBPO8MR6WFG/formDetail/FORM-E8E54176A4D446C182EB6A3C012A0284AGQN?formInstId=";
|
|
|
|
|
+ // 获取当前时间
|
|
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
|
|
+ // 获取当月第一天 00:00:00
|
|
|
|
|
+ LocalDateTime firstDayOfMonth = now.withDayOfMonth(1).atStartOfDay();
|
|
|
|
|
+ // 获取当月最后一天 23:59:59.999999999
|
|
|
|
|
+ LocalDateTime lastDayOfMonth = now.withDayOfMonth(now.lengthOfMonth())
|
|
|
|
|
+ .atTime(23, 59, 59, 999999999);
|
|
|
|
|
+ // 转换为时间戳(毫秒)
|
|
|
|
|
+ long startTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(firstDayOfMonth);
|
|
|
|
|
+ long endTimestamp = UtilDateTime.getLocalDateTimeTimeStamp(lastDayOfMonth);
|
|
|
|
|
+ YDSearch yidaSearch=new YDSearch("selectField_miwh5y55","待手动过账","状态", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ);
|
|
|
|
|
+ YDSearch yidaSearch2=new YDSearch("dateField_miwh5y85",Arrays.asList(startTimestamp,endTimestamp),"时间", YDSearch.Type.DATE_FIELD,YDSearch.Operator.BETWEEN);
|
|
|
|
|
+ List<Map> list=ydService.queryFormData_all(YDParam.builder().formUuid("FORM-E8E54176A4D446C182EB6A3C012A0284AGQN")
|
|
|
|
|
+ .searchFieldJson(JSONObject.toJSONString(Arrays.asList(yidaSearch,yidaSearch2))).build());
|
|
|
|
|
+ for(Map map:list){
|
|
|
|
|
+ System.out.println(UtilMap.getList(map,"employeeField_mejfoon1_id").get(0));
|
|
|
|
|
+// sendMsg("15362032421245878","手动推送提醒","单据【"+map.get("textField_miwh5y6z")+"】前往推送凭证",url+map.get("instanceId"));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void sendMsg(String uid,String title,String text,String messageUrl){
|
|
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
|
|
+ map.put("picUrl","@lALOACZwe2Rk");
|
|
|
|
|
+ map.put("title",title);
|
|
|
|
|
+ map.put("text",text);
|
|
|
|
|
+ map.put("messageUrl",messageUrl);
|
|
|
|
|
+ JSONObject msgMap=new JSONObject().fluentPut("msgtype","link").fluentPut("link",map);
|
|
|
|
|
+ System.out.println(msgMap);
|
|
|
|
|
+ ddClientNotice.sendNotification(ddClient.getAccessToken(),Arrays.asList("15362032421245878"),null,false,
|
|
|
|
|
+ msgMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private YDClient ydClient;
|
|
|
|
|
+
|
|
|
|
|
+ private static String FORM_UUID_NO = "FORM-A9ED8621AD1743F1A89F9F79F6A31B842TA2";
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void ydtest(){
|
|
|
|
|
+ String prefix="TS6850202601";
|
|
|
|
|
+ YDSearch yidaSearch=new YDSearch("textField_mi74h0k3",prefix,"前缀", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ);
|
|
|
|
|
+ List<Map> list= (List<Map>) ydClient.queryData(YDParam.builder().formUuid(FORM_UUID_NO)
|
|
|
|
|
+ .searchFieldJson(JSONObject.toJSONString(Arrays.asList(yidaSearch))).build(), YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
|
|
+ if(list.size()>0){
|
|
|
|
|
+ // 累加
|
|
|
|
|
+ Map formData=UtilMap.getMap(list.get(0),"formData");
|
|
|
|
|
+ String formInstId=UtilMap.getString(list.get(0),"formInstId");
|
|
|
|
|
+ int no = UtilMap.getInt(formData,"numberField_mgxc3w3s");
|
|
|
|
|
+ System.out.println(no+1);
|
|
|
|
|
+ ydClient.operateData(YDParam.builder().formInstId(formInstId).updateFormDataJson(JSONObject.toJSONString(
|
|
|
|
|
+ UtilMap.map("numberField_mgxc3w3s",no+1)
|
|
|
|
|
+ )).build(), YDConf.FORM_OPERATION.update);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ // 新增
|
|
|
|
|
+ ydClient.operateData(YDParam.builder().formUuid(FORM_UUID_NO).formDataJson(JSONObject.toJSONString(
|
|
|
|
|
+ UtilMap.map("numberField_mgxc3w3s, textField_mi74h0k3",1,prefix)
|
|
|
|
|
+ )).build(), YDConf.FORM_OPERATION.create);
|
|
|
|
|
+ System.out.println(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|