Parcourir la source

资产档案已使用期数更新

fyz il y a 10 mois
Parent
commit
4543ad5ba7

+ 7 - 2
mjava-lanyun/src/main/java/com/malk/lanyun/service/impl/SyncAssetsImpl.java

@@ -1,5 +1,6 @@
 package com.malk.lanyun.service.impl;
 
+import cn.hutool.core.date.DateBetween;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
@@ -65,6 +66,9 @@ public class SyncAssetsImpl implements SyncAssetsService {
                 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){
                     log.info("metValue:"+metValue);
                     log.info("depreciation:"+depreciation);
@@ -74,17 +78,18 @@ public class SyncAssetsImpl implements SyncAssetsService {
                         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();
-                        long toMonth = DateUtil.beginOfMonth(new Date()).getTime();
                         if (toMonth <= parseTime){
                             count = count + 1;
                         }
                     }
+                    DateBetween dateBetween = new DateBetween(DateUtil.date(buyTime),DateUtil.date(toMonth));
+                    long months = dateBetween.betweenMonth(true);
                     // 更新
                     ydClient.operateData(YDParam.builder()
                             .appType("APP_ERBDTFS82HOVBPL3NFH0")
                             .systemToken("RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP")
                             .formInstanceId((String) dataItem.get("formInstanceId"))
-                            .updateFormDataJson(JSON.toJSONString(UtilMap.map("numberField_lu2ejqd4, numberField_lutjo2dt",updateDepreciation,count)))
+                            .updateFormDataJson(JSON.toJSONString(UtilMap.map("numberField_lu2ejqd4, numberField_lutjo2dt, numberField_m207nu7h",updateDepreciation,count,months)))
                             .build(), YDConf.FORM_OPERATION.update);
                 }