|
@@ -10,6 +10,7 @@ import com.malk.server.aliwork.YDConf;
|
|
|
import com.malk.server.aliwork.YDParam;
|
|
|
import com.malk.server.dingtalk.DDConf;
|
|
|
import com.malk.service.aliwork.YDClient;
|
|
|
+import com.malk.service.aliwork.YDService;
|
|
|
import com.malk.service.dingtalk.DDClient;
|
|
|
import com.malk.service.dingtalk.DDClient_Contacts;
|
|
|
import com.malk.utils.UtilDateTime;
|
|
@@ -32,66 +33,102 @@ public class SyncAssetsImpl implements SyncAssetsService {
|
|
|
@Autowired
|
|
|
private YDClient ydClient;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private YDService ydService;
|
|
|
+
|
|
|
//同步资产档案净值
|
|
|
@Override
|
|
|
public void SynAssetsItem() {
|
|
|
|
|
|
YDParam ydParam = new YDParam();
|
|
|
+// ydParam = YDParam.builder()
|
|
|
+// .appType("APP_ERBDTFS82HOVBPL3NFH0")
|
|
|
+// .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
|
|
|
+// .formUuid("FORM-F3695066AABE41F6AF241489F8558ACA78OI") //资产档案
|
|
|
+// .searchFieldJson(JSON.toJSONString(UtilMap.map("selectField_lu2eb47g","否")))
|
|
|
+// .build();
|
|
|
+// //pagesize设为1获取总数
|
|
|
+// ydParam.setPageSize(1);
|
|
|
+// long totalCount = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
+// float pageSize = 50;
|
|
|
+// ydParam.setCurrentPage(1);
|
|
|
+// ydParam.setPageSize((int) pageSize);
|
|
|
+ List<Map> dataList = new ArrayList<>();
|
|
|
+// for (int page = 1; page <= Math.ceil(totalCount / pageSize); page++) {
|
|
|
+// ydParam.setCurrentPage(page);
|
|
|
+// // 1次获取50条
|
|
|
+// dataList = (List<Map>) ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
+// dataList.forEach(dataItem -> {
|
|
|
+// Map formMap = (Map) dataItem.get("formData");
|
|
|
+// //资产状态
|
|
|
+// String status = formMap.get("selectField_lty0oyvd").toString();
|
|
|
+// if (!"报废".equals(status)){
|
|
|
+// //净值
|
|
|
+// float metValue = UtilMap.getFloat((Map) formMap,"numberField_lu2ejqd4");
|
|
|
+// //月折旧额
|
|
|
+// float depreciation = UtilMap.getFloat((Map) formMap,"numberField_lu2eb47d");
|
|
|
+// //已计提期数
|
|
|
+// int count = UtilMap.getInt((Map) formMap,"numberField_lutjo2dt");
|
|
|
+// long toMonth = DateUtil.beginOfMonth(new Date()).getTime();
|
|
|
+// //购入日期
|
|
|
+// long buyTime = Long.parseLong(formMap.get("dateField_lty0oyv9").toString());
|
|
|
+// if (metValue > 0 && depreciation > 0 && buyTime < toMonth){
|
|
|
+// log.info("metValue:"+metValue);
|
|
|
+// log.info("depreciation:"+depreciation);
|
|
|
+// float updateDepreciation = (metValue - depreciation) >0 ? (metValue - depreciation) : 0;
|
|
|
+// if (ObjectUtil.isNotEmpty(formMap.get("dateField_lty0oyva"))){
|
|
|
+// //折旧截止日
|
|
|
+// long endTime = Long.parseLong(formMap.get("dateField_lty0oyva").toString());
|
|
|
+// String endDate = DateUtil.date(endTime).toString("yyyy-MM");
|
|
|
+// long parseTime = DateUtil.beginOfMonth(DateUtil.parse(endDate, "yyyy-MM")).getTime();
|
|
|
+// if (toMonth <= parseTime){
|
|
|
+// count = count + 1;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// DateBetween dateBetween = new DateBetween(DateUtil.date(buyTime),DateUtil.date(toMonth));
|
|
|
+// long months = dateBetween.betweenMonth(true) + 1;
|
|
|
+// // 更新
|
|
|
+// ydClient.operateData(YDParam.builder()
|
|
|
+// .appType("APP_ERBDTFS82HOVBPL3NFH0")
|
|
|
+// .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
|
|
|
+// .formInstanceId((String) dataItem.get("formInstanceId"))
|
|
|
+// .updateFormDataJson(JSON.toJSONString(UtilMap.map("numberField_lu2ejqd4, numberField_lutjo2dt, numberField_m207nu7h",updateDepreciation,count,months)))
|
|
|
+// .build(), YDConf.FORM_OPERATION.update);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
ydParam = YDParam.builder()
|
|
|
.appType("APP_ERBDTFS82HOVBPL3NFH0")
|
|
|
.systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
|
|
|
- .formUuid("FORM-F3695066AABE41F6AF241489F8558ACA78OI") //资产档案
|
|
|
-// .formInstId("FINST-UG866OB1I1BOKW6T8TGPKCW3TK9S2OQ2WVZ1M56S2")
|
|
|
- .searchFieldJson(JSON.toJSONString(UtilMap.map("selectField_lu2eb47g","否")))//护理对象暂停和正常、月度计划创建只查询正常的护理计划
|
|
|
+ .formUuid("FORM-49A0FBD20AD74EFA88CA1565CDAD40D1H5PW") //租赁资产档案
|
|
|
+ .searchFieldJson(JSON.toJSONString(UtilMap.map("selectField_lty0oyvd","正常")))
|
|
|
.build();
|
|
|
//pagesize设为1获取总数
|
|
|
ydParam.setPageSize(1);
|
|
|
- long totalCount = ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getTotalCount();
|
|
|
- float pageSize = 50;
|
|
|
- ydParam.setCurrentPage(1);
|
|
|
- ydParam.setPageSize((int) pageSize);
|
|
|
- List<Map> dataList = new ArrayList<>();
|
|
|
- for (int page = 1; page <= Math.ceil(totalCount / pageSize); page++) {
|
|
|
- ydParam.setCurrentPage(page);
|
|
|
- // 1次获取50条
|
|
|
- dataList = (List<Map>) ydClient.queryData(ydParam, YDConf.FORM_QUERY.retrieve_search_form).getData();
|
|
|
- dataList.forEach(dataItem -> {
|
|
|
- Map formMap = (Map) dataItem.get("formData");
|
|
|
- //资产状态
|
|
|
- String status = formMap.get("selectField_lty0oyvd").toString();
|
|
|
- if (!"报废".equals(status)){
|
|
|
- //净值
|
|
|
- float metValue = UtilMap.getFloat((Map) formMap,"numberField_lu2ejqd4");
|
|
|
- //月折旧额
|
|
|
- float depreciation = UtilMap.getFloat((Map) formMap,"numberField_lu2eb47d");
|
|
|
- //已计提期数
|
|
|
- int count = UtilMap.getInt((Map) formMap,"numberField_lutjo2dt");
|
|
|
+ dataList = ydService.queryFormData_all(ydParam);
|
|
|
+ if (ObjectUtil.isNotNull(dataList)&&dataList.size()>0){
|
|
|
+ dataList.forEach(e->{
|
|
|
+ if (ObjectUtil.isNotNull(e.get("dateField_lty0oyv9"))){
|
|
|
long toMonth = DateUtil.beginOfMonth(new Date()).getTime();
|
|
|
- //购入日期
|
|
|
- long buyTime = Long.parseLong(formMap.get("dateField_lty0oyv9").toString());
|
|
|
- if (metValue > 0 && depreciation > 0 && buyTime < toMonth){
|
|
|
- log.info("metValue:"+metValue);
|
|
|
- log.info("depreciation:"+depreciation);
|
|
|
- float updateDepreciation = (metValue - depreciation) >0 ? (metValue - depreciation) : 0;
|
|
|
- if (ObjectUtil.isNotEmpty(formMap.get("dateField_lty0oyva"))){
|
|
|
- //折旧截止日
|
|
|
- long endTime = Long.parseLong(formMap.get("dateField_lty0oyva").toString());
|
|
|
- String endDate = DateUtil.date(endTime).toString("yyyy-MM");
|
|
|
- long parseTime = DateUtil.beginOfMonth(DateUtil.parse(endDate, "yyyy-MM")).getTime();
|
|
|
- if (toMonth <= parseTime){
|
|
|
- count = count + 1;
|
|
|
- }
|
|
|
- }
|
|
|
- DateBetween dateBetween = new DateBetween(DateUtil.date(buyTime),DateUtil.date(toMonth));
|
|
|
- long months = dateBetween.betweenMonth(true) + 1;
|
|
|
- // 更新
|
|
|
- ydClient.operateData(YDParam.builder()
|
|
|
- .appType("APP_ERBDTFS82HOVBPL3NFH0")
|
|
|
- .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
|
|
|
- .formInstanceId((String) dataItem.get("formInstanceId"))
|
|
|
- .updateFormDataJson(JSON.toJSONString(UtilMap.map("numberField_lu2ejqd4, numberField_lutjo2dt, numberField_m207nu7h",updateDepreciation,count,months)))
|
|
|
- .build(), YDConf.FORM_OPERATION.update);
|
|
|
+ //起租日期
|
|
|
+ long buyTime = Long.parseLong(e.get("dateField_lty0oyv9").toString());
|
|
|
+ DateBetween dateBetween = new DateBetween(DateUtil.date(buyTime),DateUtil.date(toMonth));
|
|
|
+ //累计租期数
|
|
|
+ long months = dateBetween.betweenMonth(true) + 1;
|
|
|
+ double cost = 0f;
|
|
|
+ if (ObjectUtil.isNotNull(e.get("numberField_lu2eb47d"))){
|
|
|
+ cost = Double.parseDouble(e.get("numberField_lu2eb47d").toString());
|
|
|
}
|
|
|
+ cost = cost * months;
|
|
|
+ // 更新
|
|
|
+ ydClient.operateData(YDParam.builder()
|
|
|
+ .appType("APP_ERBDTFS82HOVBPL3NFH0")
|
|
|
+ .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
|
|
|
+ .formInstanceId((String) e.get("formInstanceId"))
|
|
|
+ .useLatestVersion(true)
|
|
|
+ .updateFormDataJson(JSON.toJSONString(UtilMap.map("numberField_lutjo2dt, numberField_lty0oyv8",months,cost)))
|
|
|
+ .build(), YDConf.FORM_OPERATION.update);
|
|
|
}
|
|
|
});
|
|
|
}
|