|
@@ -69,51 +69,104 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
) {
|
|
|
|
|
|
CustomApiResult<Boolean> result = new CustomApiResult<>();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
- if(!"1".equals(billData.get("contracttype"))) {
|
|
|
- result.setMessage("合同类型不是1,星瀚不接收");
|
|
|
+
|
|
|
+ if(!"1".equals(billData.get("contracttype"))) {
|
|
|
+ result.setMessage("合同类型不是1,星瀚不接收");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ String fapplierid = (String)billData.get("applierid");
|
|
|
+ if (StringUtils.isEmpty(fapplierid)) {
|
|
|
+ result.setMessage("经办人fapplierid未传值");
|
|
|
+ result.setStatus(false);
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
- 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)});
|
|
|
+ DynamicObject applicatuser = BusinessDataServiceHelper.loadSingle("bos_user","id,name,number,phone",new QFilter[]{new QFilter("number",QCP.equals,gonghao)});
|
|
|
+ if (applicatuser == null) {
|
|
|
+ result.setMessage("经办人工号未在星瀚系统出现");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ String fcontractcode = (String)billData.get("contractcode");
|
|
|
+ if (StringUtils.isEmpty(fapplierid)) {
|
|
|
+ result.setMessage("经办人fapplierid未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- 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");
|
|
|
+ if (StringUtils.isEmpty(fdescription)) {
|
|
|
+ result.setMessage("合同说明description未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- String fbizdate = (String)billData.get("bizdate");
|
|
|
String fsigndate = (String)billData.get("signdate");
|
|
|
+ if (StringUtils.isEmpty(fsigndate)) {
|
|
|
+ result.setMessage("签订日期fsigndate未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ String fbizdate = (String)billData.get("bizdate");
|
|
|
String fstartdate = (String)billData.get("startdate");
|
|
|
String fenddate = (String)billData.get("enddate");
|
|
|
|
|
|
String contractcurrency = (String)billData.get("contractcurrency");
|
|
|
-
|
|
|
+ if (StringUtils.isEmpty(contractcurrency)) {
|
|
|
+ result.setMessage("币种contractcurrency未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
String projectower = (String)billData.get("projectower");
|
|
|
-
|
|
|
+ if (StringUtils.isEmpty(projectower)) {
|
|
|
+ result.setMessage("合同干系人projectower未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
String fjiafangxinyongcode = (String)billData.get("jiafangxinyongcode");
|
|
|
+ if (StringUtils.isEmpty(fjiafangxinyongcode)) {
|
|
|
+ result.setMessage("甲方统一社会信用代码jiafangxinyongcode未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
String fjiafangcontactperson = (String)billData.get("jiafangcontactperson");
|
|
|
-
|
|
|
+ if (StringUtils.isEmpty(fjiafangcontactperson)) {
|
|
|
+ result.setMessage("甲方联系人fjiafangcontactperson未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ String nckd_sources = (String)billData.get("nckd_sources");
|
|
|
+ if (StringUtils.isEmpty(nckd_sources)) {
|
|
|
+ result.setMessage("合同来源nckd_sources未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
JSONArray contractpartyAry = (JSONArray) billData.get("contractparty");
|
|
|
+ if (contractpartyAry == null || contractpartyAry.size() == 0) {
|
|
|
+ result.setMessage("签约方contractparty未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
JSONArray fukuanplanAry = (JSONArray) billData.get("fukuanplan");
|
|
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
-
|
|
|
- String nckd_sources = (String)billData.get("nckd_sources");
|
|
|
-
|
|
|
|
|
|
- String entityNumber = "er_contractbill";
|
|
|
+ String entityNumber = "er_contractbill";
|
|
|
QFilter qFilter = new QFilter("contractcode", QCP.equals,fcontractcode);
|
|
|
DynamicObject dynamicObject = null;
|
|
|
if(QueryServiceHelper.exists(entityNumber,new QFilter[]{qFilter})){
|
|
|
-
|
|
|
+
|
|
|
dynamicObject = BusinessDataServiceHelper.loadSingle(entityNumber,new QFilter[]{qFilter});
|
|
|
String contractcodenewhistory = dynamicObject.getString("nckd_contractcodenew");
|
|
|
if (!StringUtils.isEmpty(nckd_contractcodenew)) {
|
|
@@ -129,7 +182,7 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
-
|
|
|
+
|
|
|
dynamicObject = BusinessDataServiceHelper.newDynamicObject(entityNumber);
|
|
|
dynamicObject.set("id", ID.genLongId());
|
|
|
|
|
@@ -141,8 +194,9 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
BillEntityType dataEntityType = (BillEntityType) dynamicObject.getDataEntityType();
|
|
|
String appId = dataEntityType.getAppId();
|
|
|
|
|
|
- dynamicObject.set("billstatus","A");
|
|
|
+ dynamicObject.set("billstatus","E");
|
|
|
|
|
|
+ dynamicObject.set("tel",applicatuser.getString("phone"));
|
|
|
|
|
|
DynamicObject company = BusinessDataServiceHelper.loadSingle("bos_org","id,name",new QFilter[]{new QFilter("uniformsocialcreditcode",QCP.equals,fjiafangxinyongcode)});
|
|
|
dynamicObject.set("company",company);
|
|
@@ -160,16 +214,30 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
dynamicObject.set("costcompany",company);
|
|
|
try {
|
|
|
dynamicObject.set("signdate",sdf.parse(fsigndate));
|
|
|
- dynamicObject.set("startdate",sdf.parse(fstartdate));
|
|
|
- dynamicObject.set("enddate",sdf.parse(fenddate));
|
|
|
|
|
|
+ if (StringUtils.isEmpty(fbizdate)) {
|
|
|
+ dynamicObject.set("bizdate",sdf.parse(fsigndate));
|
|
|
+ } else {
|
|
|
+ dynamicObject.set("bizdate",sdf.parse(fbizdate));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(fstartdate)) {
|
|
|
+ dynamicObject.set("startdate",sdf.parse(fsigndate));
|
|
|
+ } else {
|
|
|
+ dynamicObject.set("startdate",sdf.parse(fstartdate));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(fenddate)) {
|
|
|
+ dynamicObject.set("enddate",sdf.parse(fsigndate));
|
|
|
+ } else {
|
|
|
+ dynamicObject.set("enddate",sdf.parse(fenddate));
|
|
|
+ }
|
|
|
} catch (ParseException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
dynamicObject.set("changedate",new Date());
|
|
|
dynamicObject.set("description",fdescription);
|
|
|
-
|
|
|
dynamicObject.set("partbtype","bd_supplier");
|
|
|
|
|
|
dynamicObject.set("iscurrency",true);
|
|
@@ -223,7 +291,7 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
|
|
|
DynamicObject newEntry = new DynamicObject(newColl.getDynamicObjectType());
|
|
|
newEntry.set("signcontract", "0");
|
|
|
- newEntry.set("partytype", "bos_org");
|
|
|
+ newEntry.set("partytype", "bos_org");
|
|
|
newEntry.set("contractparty", company);
|
|
|
newEntry.set("contactperson", fjiafangcontactperson);
|
|
|
newColl.add(newEntry);
|
|
@@ -231,13 +299,33 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
for (Object item : contractpartyAry) {
|
|
|
JSONObject jsb = (JSONObject)item;
|
|
|
String signcontract = jsb.getString("signcontract");
|
|
|
+ if (StringUtils.isEmpty(signcontract)) {
|
|
|
+ result.setMessage("乙方签约方signcontract未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
String fxinyongcode = jsb.getString("xinyongcode");
|
|
|
+ if (StringUtils.isEmpty(fxinyongcode)) {
|
|
|
+ result.setMessage("乙方统一社会信用代码xinyongcode未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
String fcontactperson = jsb.getString("contactperson");
|
|
|
+ if (StringUtils.isEmpty(fcontactperson)) {
|
|
|
+ result.setMessage("乙方联系人contactperson未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
DynamicObject newEntry2 = new DynamicObject(newColl.getDynamicObjectType());
|
|
|
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);
|
|
|
+ if (supplier == null) {
|
|
|
+ result.setMessage("乙方统一社会信用代码" + fxinyongcode + "未在星瀚供应商中查询到");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ newEntry2.set("contractparty", supplier);
|
|
|
newEntry2.set("contactperson", fcontactperson);
|
|
|
newColl.add(newEntry2);
|
|
|
}
|
|
@@ -250,8 +338,17 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
for (Object item : fukuanplanAry) {
|
|
|
JSONObject jsb = (JSONObject)item;
|
|
|
String fpayterms = jsb.getString("payterms");
|
|
|
+ if (StringUtils.isEmpty(fpayterms)) {
|
|
|
+ result.setMessage("付款条件payterms未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
BigDecimal fexpapplyamount = jsb.getBigDecimal("expapplyamount");
|
|
|
- String std_project = jsb.getString("projectid");
|
|
|
+ if (fexpapplyamount == null) {
|
|
|
+ result.setMessage("含税金额expapplyamount未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
DynamicObject newEntry3 = new DynamicObject(plannewColl.getDynamicObjectType());
|
|
|
DynamicObject fukuantype = BusinessDataServiceHelper.loadSingle("cas_paymentbilltype","id,name",new QFilter[]{new QFilter("number",QCP.equals,"201")});
|
|
@@ -272,9 +369,10 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
hetongjinetotalfist = hetongjinetotalfist.add(fexpapplyamount);
|
|
|
|
|
|
newEntry3.set("exchangerate",huilv);
|
|
|
-
|
|
|
+
|
|
|
+ String std_project = jsb.getString("projectid");
|
|
|
DynamicObject project = BusinessDataServiceHelper.loadSingle("bd_project","id,name",new QFilter[]{new QFilter("number",QCP.equals,std_project)});
|
|
|
- newEntry3.set("std_project",project);
|
|
|
+ newEntry3.set("std_project",project);
|
|
|
|
|
|
newEntry3.set("entrycurrency",bizhong);
|
|
|
|
|
@@ -326,30 +424,38 @@ public class ContractbillApiPlugin implements Serializable {
|
|
|
}
|
|
|
|
|
|
|
|
|
- Map<String, Object> attachmentInfos = new HashMap<>();
|
|
|
- for (Map.Entry<String, List<Map<String,Object>>> entry : allAttachmentsData.entrySet()) {
|
|
|
- if ("attachmentpanel".equals(entry.getKey())) {
|
|
|
-
|
|
|
- List<Map<String, Object>> fileList = entry.getValue();
|
|
|
- List<Map<String, Object>> attachments = new ArrayList<>();
|
|
|
- for (int i= 0; i < fileList.size(); i++) {
|
|
|
- Map<String, Object> map = fileList.get(i);
|
|
|
- StringBuffer uid = new StringBuffer();
|
|
|
- uid.append("rc-upload-").append(new Date().getTime()).append("-");
|
|
|
- Map<String,Object> attachmentInfo = new HashMap<>();
|
|
|
- attachmentInfo.put("entityNumber", entityNumber);
|
|
|
- attachmentInfo.put("name", map.get("fileName"));
|
|
|
- attachmentInfo.put("url", map.get("tempurl"));
|
|
|
- attachmentInfo.put("size", map.get("size"));
|
|
|
- attachmentInfo.put("status", map.get("status"));
|
|
|
- attachmentInfo.put("uid", uid.toString() + i);
|
|
|
- attachments.add(attachmentInfo);
|
|
|
+ if (allAttachmentsData != null) {
|
|
|
+ Map<String, Object> attachmentInfos = new HashMap<>();
|
|
|
+ for (Map.Entry<String, List<Map<String,Object>>> entry : allAttachmentsData.entrySet()) {
|
|
|
+ if ("attachmentpanel".equals(entry.getKey())) {
|
|
|
+
|
|
|
+ List<Map<String, Object>> fileList = entry.getValue();
|
|
|
+ List<Map<String, Object>> attachments = new ArrayList<>();
|
|
|
+ for (int i= 0; i < fileList.size(); i++) {
|
|
|
+ Map<String, Object> map = fileList.get(i);
|
|
|
+ StringBuffer uid = new StringBuffer();
|
|
|
+ uid.append("rc-upload-").append(new Date().getTime()).append("-");
|
|
|
+ Map<String,Object> attachmentInfo = new HashMap<>();
|
|
|
+ attachmentInfo.put("entityNumber", entityNumber);
|
|
|
+ attachmentInfo.put("name", map.get("fileName"));
|
|
|
+ if (StringUtils.isEmpty((String)map.get("tempurl"))) {
|
|
|
+ result.setMessage("文件服务器临时路径tempurl未传值");
|
|
|
+ result.setStatus(false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ attachmentInfo.put("url", map.get("tempurl"));
|
|
|
+ attachmentInfo.put("size", map.get("size"));
|
|
|
+ attachmentInfo.put("status", map.get("status"));
|
|
|
+ attachmentInfo.put("uid", uid.toString() + i);
|
|
|
+ attachments.add(attachmentInfo);
|
|
|
+ }
|
|
|
+ attachmentInfos.put("attachmentpanel",attachments);
|
|
|
}
|
|
|
- attachmentInfos.put("attachmentpanel",attachments);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- AttachmentServiceHelper.saveTempAttachments(entityNumber, pkid, appId, attachmentInfos);
|
|
|
+ AttachmentServiceHelper.saveTempAttachments(entityNumber, pkid, appId, attachmentInfos);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
result.setMessage("成功");
|
|
|
return result;
|