|
@@ -1,11 +1,16 @@
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.malk.lanyun.Boot;
|
|
|
import com.malk.lanyun.entity.Budget;
|
|
|
import com.malk.lanyun.listener.BudgetListener;
|
|
|
import com.malk.lanyun.listener.BudgetListenerForProject;
|
|
|
+import com.malk.server.aliwork.YDConf;
|
|
|
+import com.malk.server.aliwork.YDParam;
|
|
|
import com.malk.service.aliwork.YDClient;
|
|
|
+import com.malk.utils.UtilMap;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
@@ -13,6 +18,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
@Slf4j
|
|
|
@RunWith(SpringRunner.class)
|
|
|
@SpringBootTest(classes = Boot.class)
|
|
@@ -25,18 +34,66 @@ public class ysTest {
|
|
|
public void test(){
|
|
|
String id= UUID.randomUUID().toString();
|
|
|
String fileName = "/home/"+id+".xlsx";
|
|
|
- String url=ydClient.convertTemporaryUrl("/ossFileHandle?appType=APP_ERBDTFS82HOVBPL3NFH0&fileName=APP_ERBDTFS82HOVBPL3NFH0_MDk1MzU4MDE2Ni0xNDE2MzIxNDg1X01IRDY2VTgxVEsyUjdQWk9FSU9NSzVSSUtBSEkyS1gxUk1RNE1PNw$$.xlsx&instId=&type=download");
|
|
|
+ String url=ydClient.convertTemporaryUrl("/ossFileHandle?appType=APP_ERBDTFS82HOVBPL3NFH0&fileName=APP_ERBDTFS82HOVBPL3NFH0_MDMwNzU4MDUxOTMwNzc4MDM3XzNXODY2N0QxTExJUkhEM1JFMTEyMERLT1EyREQyTzFITFZCNU1XNw$$.xlsx&instId=&type=download");
|
|
|
HttpUtil.downloadFile(url,fileName);
|
|
|
- EasyExcel.read(fileName, Budget.class, new BudgetListener(ydClient,"信息技术部","2024","1704038400000")).sheet().headRowNumber(3).doRead();
|
|
|
+ EasyExcel.read(fileName, Budget.class, new BudgetListener(ydClient,"工程部(机关)","2025","1735660800000","")).sheet().headRowNumber(3).doRead();
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
public void test2(){
|
|
|
String id= UUID.randomUUID().toString();
|
|
|
+ // "{\"importType\":\"预算\",\"yearStr\":\"2025\",\"year\":1735660800000,\"type\":\"(苏州·吴江)MAX科技园\",\"url\":\"\"}"
|
|
|
String fileName = "/home/"+id+".xlsx";
|
|
|
- String url=ydClient.convertTemporaryUrl("/ossFileHandle?appType=APP_ERBDTFS82HOVBPL3NFH0&fileName=APP_ERBDTFS82HOVBPL3NFH0_MDk1MzU4MDE2Ni0xNDE2MzIxNDg1X01IRDY2VTgxVEsyUjdQWk9FSU9NSzVSSUtBSEkyS1gxUk1RNE1PNw$$.xlsx&instId=&type=download");
|
|
|
+ String url=ydClient.convertTemporaryUrl("/ossFileHandle?appType=APP_ERBDTFS82HOVBPL3NFH0&fileName=APP_ERBDTFS82HOVBPL3NFH0_MDMwNzU4MDUxOTMwNzc4MDM3XzJZODY2WTcxRVVJUjFCRkZDMjROUkFVVzc4M0MyVEMyUDJGNU1DQw$$.xlsx&instId=&type=download");
|
|
|
HttpUtil.downloadFile(url,fileName);
|
|
|
- EasyExcel.read(fileName, Budget.class, new BudgetListenerForProject(ydClient,"PM00177","2024")).sheet().headRowNumber(3).doRead();
|
|
|
+ EasyExcel.read(fileName, Budget.class, new BudgetListenerForProject(ydClient,"PM00408","2025")).sheet().headRowNumber(3).doRead();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void at(){
|
|
|
+ List<Map> list=(List<Map>) ydClient.queryData(YDParam.builder().formUuid("FORM-DCBC92CE004244569BC22A759FB7D2853GEA").appType("APP_ERBDTFS82HOVBPL3NFH0")
|
|
|
+ .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP").searchCondition(JSONObject.toJSONString(UtilMap.map("selectField_m5f4hrlq","待导入")))
|
|
|
+ .pageSize(1).build(),
|
|
|
+ YDConf.FORM_QUERY.retrieve_list_all).getData();
|
|
|
+ for (Map map:list){
|
|
|
+ System.out.println(map);
|
|
|
+ Map formData=UtilMap.getMap(map,"formData");
|
|
|
+ boolean isUpdateDe=UtilMap.getString(formData,"selectField_m4cbvkth").equals("是");
|
|
|
+ String formInstanceId=UtilMap.getString(map,"formInstanceId");
|
|
|
+ String id= UUID.randomUUID().toString();
|
|
|
+ String fileName = "/home/"+id+".xlsx";
|
|
|
+ Map upMap=UtilMap.map("selectField_m5f4hrlq, selectField_m5f4hrlr","导入中",(isUpdateDe?"导入中":"无需处理"));
|
|
|
+ updateState(formInstanceId,upMap);
|
|
|
+ upMap=new HashMap();
|
|
|
+ String url=ydClient.convertTemporaryUrl(UtilMap.getString(formData,"textField_m4718ynv"));
|
|
|
+ HttpUtil.downloadFile(url,fileName);
|
|
|
+ try {
|
|
|
+ EasyExcel.read(fileName, Budget.class, new BudgetListener(ydClient,UtilMap.getString(formData,"textField_lw8vg19m"),
|
|
|
+ UtilMap.getString(formData,"textField_lw7sg8ho"),UtilMap.getString(formData,"dateField_lvxkipwr"),formInstanceId)).sheet().headRowNumber(3).doRead();
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ upMap.put("selectField_m5f4hrlq","导入失败");
|
|
|
+ upMap.put("textField_m5f4hrlv","导入出错!错误信息:"+e.getMessage());
|
|
|
+ }
|
|
|
+ if(isUpdateDe){
|
|
|
+ try {
|
|
|
+ EasyExcel.read(fileName, Budget.class, new BudgetListenerForProject(ydClient,UtilMap.getString(formData,"textField_lrr3rg6h"),UtilMap.getString(formData,"textField_lw7sg8ho"))).sheet().headRowNumber(3).doRead();
|
|
|
+ upMap.put("selectField_m5f4hrlr","导入成功");
|
|
|
+ upMap.put("textField_m5f4hrlw","导入完成");
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ upMap.put("selectField_m5f4hrlr","导入失败");
|
|
|
+ upMap.put("textField_m5f4hrlw","导入出错!错误信息:"+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateState(formInstanceId,upMap);
|
|
|
+ FileUtil.del(fileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateState(String formInstanceId,Map upMap){
|
|
|
+ ydClient.operateData(YDParam.builder().formInstanceId(formInstanceId).appType("APP_ERBDTFS82HOVBPL3NFH0")
|
|
|
+ .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP").updateFormDataJson(JSONObject.toJSONString(upMap)).build(), YDConf.FORM_OPERATION.update);
|
|
|
}
|
|
|
|
|
|
|