|
@@ -2,12 +2,15 @@ package nckd.jimin.jyyy.fi.webapi;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.kingdee.util.StringUtils;
|
|
|
import kd.bos.cache.CacheFactory;
|
|
|
import kd.bos.cache.TempFileCache;
|
|
|
import kd.bos.dataentity.OperateOption;
|
|
|
import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
|
|
+import kd.bos.dataentity.metadata.dynamicobject.DynamicObjectType;
|
|
|
import kd.bos.entity.BillEntityType;
|
|
|
+import kd.bos.entity.EntityMetadataCache;
|
|
|
import kd.bos.entity.operate.result.OperationResult;
|
|
|
import kd.bos.id.ID;
|
|
|
import kd.bos.openapi.common.custom.annotation.ApiController;
|
|
@@ -67,31 +70,33 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
|
|
|
CustomApiResult<Boolean> result = new CustomApiResult<>();
|
|
|
|
|
|
- if(!"1".equals(billData.get("fcontracttype"))) {
|
|
|
+ if(!"1".equals(billData.get("contracttype"))) {
|
|
|
result.setMessage("合同类型不是1,星瀚不接收");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- String fapplierid = (String)billData.get("fapplierid");
|
|
|
+ String fapplierid = (String)billData.get("applierid");
|
|
|
String gonghao = fapplierid.split("_")[0];
|
|
|
DynamicObject applicatuser = BusinessDataServiceHelper.loadSingle("bos_user","id,name,number",new QFilter[]{new QFilter("number",QCP.equals,gonghao)});
|
|
|
|
|
|
- String fcontractcode = (String)billData.get("fcontractcode");
|
|
|
- String fcontractcodenew = (String)billData.get("fcontractcodenew");
|
|
|
- String fcontractname = (String)billData.get("fcontractname");
|
|
|
- String fdescription = (String)billData.get("fdescription");
|
|
|
+ String fcontractcode = (String)billData.get("contractcode");
|
|
|
+ String nckd_contractcodenew = (String)billData.get("nckd_contractcodenew");
|
|
|
+ String fcontractname = (String)billData.get("contractname");
|
|
|
+ String fdescription = (String)billData.get("description");
|
|
|
|
|
|
- String fbizdate = (String)billData.get("fbizdate");
|
|
|
- String fsigndate = (String)billData.get("fsigndate");
|
|
|
- String fstartdate = (String)billData.get("fstartdate");
|
|
|
- String fenddate = (String)billData.get("fenddate");
|
|
|
+ String fbizdate = (String)billData.get("bizdate");
|
|
|
+ String fsigndate = (String)billData.get("signdate");
|
|
|
+ String fstartdate = (String)billData.get("startdate");
|
|
|
+ String fenddate = (String)billData.get("enddate");
|
|
|
|
|
|
String contractcurrency = (String)billData.get("contractcurrency");
|
|
|
|
|
|
+ String projectower = (String)billData.get("projectower");
|
|
|
+
|
|
|
|
|
|
- String fjiafangxinyongcode = (String)billData.get("fjiafangxinyongcode");
|
|
|
+ String fjiafangxinyongcode = (String)billData.get("jiafangxinyongcode");
|
|
|
|
|
|
- String fjiafangcontactperson = (String)billData.get("fjiafangcontactperson");
|
|
|
+ String fjiafangcontactperson = (String)billData.get("jiafangcontactperson");
|
|
|
|
|
|
|
|
|
JSONArray contractpartyAry = (JSONArray) billData.get("contractparty");
|
|
@@ -101,6 +106,8 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
+ String nckd_sources = (String)billData.get("nckd_sources");
|
|
|
+
|
|
|
|
|
|
String entityNumber = "er_contractbill";
|
|
|
QFilter qFilter = new QFilter("contractcode", QCP.equals,fcontractcode);
|
|
@@ -108,7 +115,20 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
if(QueryServiceHelper.exists(entityNumber,new QFilter[]{qFilter})){
|
|
|
|
|
|
dynamicObject = BusinessDataServiceHelper.loadSingle(entityNumber,new QFilter[]{qFilter});
|
|
|
- }else {
|
|
|
+ String contractcodenewhistory = dynamicObject.getString("nckd_contractcodenew");
|
|
|
+ if (!StringUtils.isEmpty(nckd_contractcodenew)) {
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(contractcodenewhistory)) {
|
|
|
+
|
|
|
+ dynamicObject.set("nckd_contractcodenew",nckd_contractcodenew);
|
|
|
+ } else {
|
|
|
+ String[] invoshuzu = contractcodenewhistory.split(",");
|
|
|
+ Set<String> linkedHashSet = new LinkedHashSet<>(Arrays.asList(invoshuzu));
|
|
|
+ linkedHashSet.add(nckd_contractcodenew);
|
|
|
+ dynamicObject.set("nckd_contractcodenew",String.join(",",linkedHashSet));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
|
|
|
dynamicObject = BusinessDataServiceHelper.newDynamicObject(entityNumber);
|
|
|
dynamicObject.set("id", ID.genLongId());
|
|
@@ -121,7 +141,6 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
BillEntityType dataEntityType = (BillEntityType) dynamicObject.getDataEntityType();
|
|
|
String appId = dataEntityType.getAppId();
|
|
|
|
|
|
- dynamicObject.set("billno",billData.get("billno"));
|
|
|
dynamicObject.set("billstatus","A");
|
|
|
|
|
|
|
|
@@ -158,17 +177,28 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
DynamicObject bizhong = BusinessDataServiceHelper.loadSingle("bd_currency","id,name",new QFilter[]{new QFilter("number",QCP.equals,contractcurrency)});
|
|
|
dynamicObject.set("contractcurrency",bizhong);
|
|
|
|
|
|
- DynamicObject CNY = BusinessDataServiceHelper.loadSingle("bd_currency","id,name",new QFilter[]{new QFilter("number",QCP.equals,"CNY")});
|
|
|
-
|
|
|
-
|
|
|
- DynamicObject[] huilvAry = BusinessDataServiceHelper.load("bd_exrate_tree","id,orgcur,cur,excval,effectdate",
|
|
|
- new QFilter[]{new QFilter("orgcur",QCP.equals,bizhong.getLong("id"))
|
|
|
- .and("cur",QCP.equals,CNY.getLong("id"))
|
|
|
- .and("enable",QCP.equals,'1')},"effectdate desc");
|
|
|
-
|
|
|
- BigDecimal huilv = new BigDecimal(0);
|
|
|
- if(huilvAry.length > 0) {
|
|
|
- huilv = huilvAry[0].getBigDecimal("excval");
|
|
|
+ BigDecimal huilv = new BigDecimal(0);
|
|
|
+ if ("CNY".equals(contractcurrency)) {
|
|
|
+
|
|
|
+ huilv = new BigDecimal(1);
|
|
|
+ dynamicObject.set("changerate",1);
|
|
|
+ } else {
|
|
|
+ DynamicObject CNY = BusinessDataServiceHelper.loadSingle("bd_currency","id,name",new QFilter[]{new QFilter("number",QCP.equals,"CNY")});
|
|
|
+
|
|
|
+
|
|
|
+ DynamicObject[] huilvAry = BusinessDataServiceHelper.load("bd_exrate_tree","id,orgcur,cur,excval,effectdate",
|
|
|
+ new QFilter[]{new QFilter("orgcur",QCP.equals,bizhong.getLong("id"))
|
|
|
+ .and("cur",QCP.equals,CNY.getLong("id"))
|
|
|
+ .and("enable",QCP.equals,'1')},"effectdate desc");
|
|
|
+
|
|
|
+
|
|
|
+ if(huilvAry.length > 0) {
|
|
|
+ huilv = huilvAry[0].getBigDecimal("excval");
|
|
|
+ } else {
|
|
|
+ result.setMessage("星瀚系统未维护" + contractcurrency + "币别与人民币的汇率");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
dynamicObject.set("changerate",huilv);
|
|
|
|
|
@@ -177,6 +207,13 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
dynamicObject.set("applier",applicatuser);
|
|
|
dynamicObject.set("modifier",applicatuser);
|
|
|
dynamicObject.set("modifytime",new Date());
|
|
|
+ dynamicObject.set("nckd_sources",nckd_sources);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
DynamicObjectCollection newColl = dynamicObject.getDynamicObjectCollection("contractpartyentry");
|
|
@@ -191,10 +228,11 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
|
|
|
for (Object item : contractpartyAry) {
|
|
|
JSONObject jsb = (JSONObject)item;
|
|
|
- String fxinyongcode = jsb.getString("fxinyongcode");
|
|
|
- String fcontactperson = jsb.getString("fcontactperson");
|
|
|
+ String signcontract = jsb.getString("signcontract");
|
|
|
+ String fxinyongcode = jsb.getString("xinyongcode");
|
|
|
+ String fcontactperson = jsb.getString("contactperson");
|
|
|
DynamicObject newEntry2 = new DynamicObject(newColl.getDynamicObjectType());
|
|
|
- newEntry2.set("signcontract", "1");
|
|
|
+ newEntry2.set("signcontract", signcontract);
|
|
|
newEntry2.set("partytype", "bd_supplier");
|
|
|
DynamicObject supplier = BusinessDataServiceHelper.loadSingle("bd_supplier","id,name",new QFilter[]{new QFilter("societycreditcode",QCP.equals,fxinyongcode)});
|
|
|
newEntry2.set("contractparty", supplier);
|
|
@@ -209,9 +247,9 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
BigDecimal hetongjinetotalfist = new BigDecimal(0);
|
|
|
for (Object item : fukuanplanAry) {
|
|
|
JSONObject jsb = (JSONObject)item;
|
|
|
- String fpayterms = jsb.getString("fpayterms");
|
|
|
- BigDecimal fexpapplyamount = jsb.getBigDecimal("fexpapplyamount");
|
|
|
- String std_project = jsb.getString("fprojectid");
|
|
|
+ String fpayterms = jsb.getString("payterms");
|
|
|
+ BigDecimal fexpapplyamount = jsb.getBigDecimal("expapplyamount");
|
|
|
+ String std_project = jsb.getString("projectid");
|
|
|
|
|
|
DynamicObject newEntry3 = new DynamicObject(plannewColl.getDynamicObjectType());
|
|
|
DynamicObject fukuantype = BusinessDataServiceHelper.loadSingle("cas_paymentbilltype","id,name",new QFilter[]{new QFilter("number",QCP.equals,"201")});
|
|
@@ -224,8 +262,8 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
}
|
|
|
newEntry3.set("entrycostdept",company);
|
|
|
newEntry3.set("entrycostcompany",company);
|
|
|
-
|
|
|
- DynamicObject feiyongproject = BusinessDataServiceHelper.loadSingle("er_expenseitemedit","id,name",new QFilter[]{new QFilter("number",QCP.equals,"FYXM0001")});
|
|
|
+
|
|
|
+ DynamicObject feiyongproject = BusinessDataServiceHelper.loadSingle("er_expenseitemedit","id,name",new QFilter[]{new QFilter("number",QCP.equals,"FYXM99.01")});
|
|
|
newEntry3.set("expenseitem",feiyongproject);
|
|
|
newEntry3.set("expenseamount",fexpapplyamount);
|
|
|
newEntry3.set("orientryamount",fexpapplyamount);
|
|
@@ -240,16 +278,31 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
|
|
|
plannewColl.add(newEntry3);
|
|
|
}
|
|
|
- dynamicObject.set("expenseentryentity", plannewColl);
|
|
|
|
|
|
- dynamicObject.set("contractamount", hetongjinetotalfist);
|
|
|
- dynamicObject.set("oriapplyamount", hetongjinetotalfist);
|
|
|
- dynamicObject.set("originalamount", hetongjinetotalfist);
|
|
|
- dynamicObject.set("orinotpayamount", hetongjinetotalfist);
|
|
|
+
|
|
|
+ if (hetongjinetotalfist.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ dynamicObject.set("frameworkcontract",true);
|
|
|
+ plannewColl.clear();
|
|
|
+ } else {
|
|
|
+ dynamicObject.set("frameworkcontract",false);
|
|
|
+ dynamicObject.set("contractamount", hetongjinetotalfist);
|
|
|
+ dynamicObject.set("oriapplyamount", hetongjinetotalfist);
|
|
|
+ dynamicObject.set("originalamount", hetongjinetotalfist);
|
|
|
+ dynamicObject.set("orinotpayamount", hetongjinetotalfist);
|
|
|
+
|
|
|
+ dynamicObject.set("expenseentryentity", plannewColl);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
OperationResult opResult = SaveServiceHelper.saveOperate(entityNumber, new DynamicObject[]{dynamicObject}, OperateOption.create());
|
|
|
|
|
|
+ if (!opResult.isSuccess()) {
|
|
|
+
|
|
|
+ result.setMessage(opResult.getMessage());
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments(entityNumber, dynamicObject.getPkValue(),"attachmentpanel");
|
|
|
if (atts.size() > 0) {
|