|
@@ -6,10 +6,13 @@ import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.malk.core.McProject;
|
|
|
+import com.malk.mc.service.McYdService;
|
|
|
import com.malk.server.aliwork.YDConf;
|
|
|
import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.aliwork.YDSearch;
|
|
|
import com.malk.server.dingtalk.DDR_New;
|
|
|
import com.malk.service.aliwork.YDClient;
|
|
|
import com.malk.service.aliwork.YDService;
|
|
@@ -243,4 +246,139 @@ public class YyYdTest {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /***
|
|
|
+ * 客户档案最终用户回刷
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void test5(){
|
|
|
+ MDC.put("MDC_KEY_PID","1013");
|
|
|
+ YDParam ydParam=YDParam.builder().formUuid("FORM-E83C9E307FFB4A978E0CB8DE1B899E9DXTXB").build();
|
|
|
+ float pageSize = (float)YDConf.PAGE_SIZE_LIMIT;
|
|
|
+ ydParam.setPageSize(1);
|
|
|
+ long totalCount = this.ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
+ ydParam.setCurrentPage(1);
|
|
|
+ ydParam.setPageSize((int)pageSize);
|
|
|
+ for(int page = 1; (double)page <= Math.ceil((double)((float)totalCount / pageSize)); ++page) {
|
|
|
+ ydParam.setCurrentPage(page);
|
|
|
+ List<Map> datalist=(List)this.ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+ for (int i = 0; i < datalist.size(); i++) {
|
|
|
+ Map data=datalist.get(i);
|
|
|
+ log.info("第{}页,第{}条数据:{}",page,i+1,data.get("formInstanceId"));
|
|
|
+// Map formData=UtilMap.getMap(data,"formData");
|
|
|
+// if(PublicUtil.isNull(formData,"textField_m7txzt1j")){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// List<Map> table=UtilMap.getList(formData,"tableField_lvuku8m3");
|
|
|
+// List<String> s1=new ArrayList<>(); // 省
|
|
|
+// List<String> s2=new ArrayList<>(); // 市
|
|
|
+// List<String> s3=new ArrayList<>(); // 最终用户
|
|
|
+// List<String> s4=new ArrayList<>(); // 医院等级
|
|
|
+// for (Map item:table) {
|
|
|
+// String name=UtilMap.getString(item,"selectField_lw4jf0ys");
|
|
|
+// Map khMap=getData(name);
|
|
|
+// Map ddMap=JSONObject.parseObject(String.valueOf(khMap.get("addressField_lugff49g")),Map.class);
|
|
|
+// if(ddMap==null||!ddMap.containsKey("regionText")){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// List<Map> regionText=UtilMap.getList(ddMap,"regionText");
|
|
|
+// item.put("textField_m7lccg50",UtilMap.getString(regionText.get(0),"zh_CN"));
|
|
|
+// item.put("textField_m7lccg51",UtilMap.getString(regionText.get(1),"zh_CN"));
|
|
|
+// item.put("textField_m1ajkyj0",UtilMap.getString(khMap,"selectField_m72yft63"));
|
|
|
+// s1.add(UtilMap.getString(regionText.get(0),"zh_CN"));
|
|
|
+// s2.add(UtilMap.getString(regionText.get(1),"zh_CN"));
|
|
|
+// s3.add(name);
|
|
|
+// s4.add(UtilMap.getString(khMap,"selectField_m72yft63"));
|
|
|
+//
|
|
|
+// }
|
|
|
+// Map upMap=UtilMap.map("tableField_lvuku8m3, textField_m7txzt1j, textField_m7txzt1k, textField_m7txsvfu, textField_m7txsvfv",
|
|
|
+// table,String.join("/",s1),String.join("/",s2),String.join("/",s3),String.join("/",s4));
|
|
|
+ Map upMap=UtilMap.map("textField_m7txzt1j, textField_m7txzt1k, textField_m7txsvfu, textField_m7txsvfv","","","","");
|
|
|
+ ydClient.operateData(YDParam.builder().formInstanceId(String.valueOf(data.get("formInstanceId"))).updateFormDataJson(JSONObject.toJSONString(upMap))
|
|
|
+ .useLatestVersion(false).build(), YDConf.FORM_OPERATION.update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,Map> KH_LIST=new HashMap();
|
|
|
+
|
|
|
+ public Map getData(String name){
|
|
|
+ if(KH_LIST.containsKey(name)){
|
|
|
+ return KH_LIST.get(name);
|
|
|
+ }
|
|
|
+ List<Map> datalist=(List) ydClient.queryData(YDParam.builder().formUuid("FORM-4020139BCB3341349EE81F5332085D35C294")
|
|
|
+ .searchFieldJson(JSONObject.toJSONString(Arrays.asList(new YDSearch("textField_lr60luaz",name,"textField_lr60luaz", YDSearch.Type.TEXT_FIELD,YDSearch.Operator.EQ))))//精准匹配
|
|
|
+ .build(), YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+ if(datalist!=null&&datalist.size()>0){
|
|
|
+ KH_LIST.put(name,UtilMap.getMap(datalist.get(0),"formData"));
|
|
|
+ return UtilMap.getMap(datalist.get(0),"formData");
|
|
|
+ }else return new HashMap<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void test4(){
|
|
|
+ MDC.put("MDC_KEY_PID","1013");
|
|
|
+ YDParam ydParam=YDParam.builder().formUuid("FORM-4020139BCB3341349EE81F5332085D35C294").build();
|
|
|
+ float pageSize = (float)YDConf.PAGE_SIZE_LIMIT;
|
|
|
+ ydParam.setPageSize(1);
|
|
|
+ long totalCount = this.ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
+ ydParam.setCurrentPage(1);
|
|
|
+ ydParam.setPageSize((int)pageSize);
|
|
|
+ for(int page = 1; (double)page <= Math.ceil((double)((float)totalCount / pageSize)); ++page) {
|
|
|
+ ydParam.setCurrentPage(page);
|
|
|
+ List<Map> datalist=(List)this.ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+ for (int i = 0; i < datalist.size(); i++) {
|
|
|
+ Map data=datalist.get(i);
|
|
|
+ log.info("第{}页,第{}条数据:{}",page,i+1,data.get("formInstanceId"));
|
|
|
+ Map formData=UtilMap.getMap(data,"formData");
|
|
|
+ if(formData.containsKey("textField_m7u2p5n8")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map ddMap=JSONObject.parseObject(String.valueOf(formData.get("addressField_lugff49g")),Map.class);
|
|
|
+ if(ddMap==null||!ddMap.containsKey("regionText")){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<Map> regionText=UtilMap.getList(ddMap,"regionText");
|
|
|
+ Map upMap=UtilMap.map("textField_m7u2p5n8, textField_m7u2p5nd",UtilMap.getString(regionText.get(0),"zh_CN"),UtilMap.getString(regionText.get(1),"zh_CN"));
|
|
|
+ ydClient.operateData(YDParam.builder().formInstanceId(String.valueOf(data.get("formInstanceId"))).updateFormDataJson(JSONObject.toJSONString(upMap))
|
|
|
+ .useLatestVersion(true).build(), YDConf.FORM_OPERATION.update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void test6(){
|
|
|
+ MDC.put("MDC_KEY_PID","1013");
|
|
|
+ JSONArray jsonArray=(JSONArray) ydClient.queryData(YDParam.builder().processInstanceId("e3736942-fc06-426c-9000-53fe8c7c56b7").build(),YDConf.FORM_QUERY.retrieve_approval_record).getResult();
|
|
|
+ List<String> userIds = new ArrayList<>();
|
|
|
+ extractOperatorIds(jsonArray,userIds);
|
|
|
+ log.info("{}",userIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void extractOperatorIds(JSONArray array, List<String> result) {
|
|
|
+ for (Object item : array) {
|
|
|
+ JSONObject obj = (JSONObject) item;
|
|
|
+
|
|
|
+ // 提取当前层级的 operatorUserId 或 operator
|
|
|
+ String userId = obj.getString("operatorUserId");
|
|
|
+ if (userId == null) userId = obj.getString("operator"); // 处理 domainList 中的字段
|
|
|
+ if (userId != null) result.add(userId);
|
|
|
+
|
|
|
+ // 递归处理 domainList
|
|
|
+ JSONArray domainList = obj.getJSONArray("domainList");
|
|
|
+ if (domainList != null && !domainList.isEmpty()) {
|
|
|
+ extractOperatorIds(domainList, result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private McYdService mcYdService;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void test7(){
|
|
|
+ mcYdService.saveApproverToForm(UtilMap.map("formInstId, key","7fa8fd99-c513-4b7a-b74d-7466e3051e01","employeeField_m7vdpfgm"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|