Przeglądaj źródła

销售计提调整

lfx 1 tydzień temu
rodzic
commit
675f348ceb

+ 3 - 0
mjava-ts/src/main/java/com/malk/taisen/controller/RtrController.java

@@ -41,6 +41,9 @@ public class RtrController {
         if (type.equals("XSJT")) {
             log.info("销售计提, {}", data);
             rtrServer.RtrInsetSAP0020(type,formUuid, instanceId);
+        }else if (type.equals("XSJTNEW")) {
+            log.info("销售计提_新版, {}", data);
+            rtrServer.RtrInsetSAP0020(type,formUuid, instanceId);
         }
         return McR.success();
     }

+ 5 - 0
mjava-ts/src/main/java/com/malk/taisen/service/impl/RtrServerImpl.java

@@ -224,6 +224,8 @@ public class RtrServerImpl implements RtrServer {
     @Override
     public void RtrInsetSAP0020(String type, String formUuid, String InstanceId) {
 
+        boolean isNew = type.equals("XSJTNEW");
+
         DDR_New ddr = ydClient.queryData(YDParam.builder().formInstId(InstanceId).build(), YDConf.FORM_QUERY.retrieve_id);
         Map dataForm = ddr.getFormData();
 
@@ -257,6 +259,9 @@ public class RtrServerImpl implements RtrServer {
             Map row = UtilMap.map("WRBTR, SGTXT, PRCTR, ZUONR, XREF1, XREF2, ARTNR, VKORG, VTWEG, SPART, KDKG4, MAGRV, BZIRK, WWKCG",
                     "numberField_mipgl0w2, textField_mipgl0w4, textField_mjihy3sn, textField_mipgl0w5, textField_mipgl0w6, textField_mipgl0w7, textField_mipgl0w9, textField_mipgl0wa, textField_mipgl0wb, textField_mipgl0wc, textField_mipgl0wd, textField_mipgl0we, textField_mipgl0wf, textField_mipgl0wg",
                     detail);
+            if (isNew){
+                body.put("BUKRS",UtilMap.getString(detail, "textField_mejfj9iw"));
+            }
             row.put("ZUPDNR", referCode);
             try {
                 Map result = this._pushSap(detail, body, row);

+ 109 - 1
mjava-ts/src/test/java/RtrTest.java

@@ -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.utils.UtilDateTime;
+import com.malk.utils.UtilMap;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.Test;
 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.test.context.junit4.SpringRunner;
 
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.*;
+
 @Slf4j
 @RunWith(SpringRunner.class)
 @SpringBootTest(classes = com.malk.kepeida.Boot.class)
@@ -15,8 +29,102 @@ public class RtrTest {
     @Autowired
     private RtrServer rtrServer;
 
+    @Autowired
+    private YDService ydService;
+
+    @Autowired
+    private DDClient_Notice ddClientNotice;
+    @Autowired
+    private DDClient ddClient;
+
     @Test
     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);
+        }
+
     }
 }

+ 24 - 0
mjava/src/main/java/com/malk/controller/TestController.java

@@ -0,0 +1,24 @@
+package com.malk.controller;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.time.LocalDateTime;
+
+@Slf4j
+@RestController
+@RequestMapping("/mc/test")
+public class TestController {
+
+    @Value("spring.profiles.active")
+    String active;
+
+    @GetMapping("test")
+    public String test() {
+        return active + LocalDateTime.now();
+    }
+
+}