lc/lc123/cloud/app/plugin/operate/pm/PurApplySubmitToFwPlugin.java

810 lines
40 KiB
Java
Raw Normal View History

package tqq9.lc123.cloud.app.plugin.operate.pm;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.operate.result.OperationResult;
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
import kd.bos.entity.plugin.args.AfterOperationArgs;
import kd.bos.servicehelper.AttachmentServiceHelper;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.SaveServiceHelper;
import org.apache.commons.lang3.StringUtils;
import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
import tqq9.lc123.cloud.app.plugin.utils.FWRestfulUtils;
import tqq9.lc123.cloud.app.plugin.utils.FWUtils;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 采购申请单
* 提交推送到泛微
*/
public class PurApplySubmitToFwPlugin extends AbstractOperationServicePlugIn {
@Override
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
super.afterExecuteOperationTransaction(e);
OperationResult operationResult = this.getOperationResult();
List<Object> successPkIds = operationResult.getSuccessPkIds();
for (Object successPkId : successPkIds) {
DynamicObject bill = BusinessDataServiceHelper.loadSingle(successPkId, "pm_purapplybill");
String tqq9_fwrequestid = bill.getString("tqq9_fwrequestid");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String lcbh = bill.getString("billno");
String sqr = null;
DynamicObject bizuser = bill.getDynamicObject("bizuser");
if (bizuser != null) {
bizuser = BusinessDataServiceHelper.loadSingle(bizuser.getPkValue(), "bos_user", "tqq9_fwuserid,id,name,number");
sqr = bizuser.getString("tqq9_fwuserid");
}
String bm = null;
DynamicObject tqq9_dept = bill.getDynamicObject("tqq9_dept");
if (tqq9_dept != null) {
String number = tqq9_dept.getString("number");
bm = FWUtils.getFwOrgNumberByKdOrgNumber(number);
}
DynamicObject org = bill.getDynamicObject("org");
String orgnumber = org.getString("number");
String ywgz = FWUtils.getFwOrgNumberByKdOrgNumber(orgnumber);
String sqrq = null;
Date biztime = bill.getDate("biztime");
if (biztime != null) {
sqrq = sdf.format(biztime);
}
String jczz = "";
String tqq9_jczz = bill.getString("tqq9_jczz");
if(StringUtils.isNotBlank(tqq9_jczz)){
if (tqq9_jczz.contains("SHLC")) {
jczz = jczz + ",0";
}
if (tqq9_jczz.contains("BJLC")) {
jczz = jczz + ",1";
}
if (tqq9_jczz.contains("GZLC")) {
jczz = jczz + ",2";
}
}
if (StringUtils.isNotBlank(jczz)) {
jczz = jczz.substring(1);
}
String djlx = "标准采购申请单";
String ywlx = "物料类采购";
String coin = null;
DynamicObject currency = bill.getDynamicObject("currency");
if (currency != null) {
coin = currency.getString("number");
}
String sfhs = null;
boolean istax = bill.getBoolean("istax");
if (istax) {
sfhs = "0";
} else {
sfhs = "1";
}
BigDecimal zkqjshj = BigDecimal.ZERO;
BigDecimal jshj = bill.getBigDecimal("totalallamount");
String bz = bill.getString("comment");
//上海
String cjgys_sh = null;
DynamicObject tqq9_sup_sh = bill.getDynamicObject("tqq9_sup_sh");
if (tqq9_sup_sh != null) {
cjgys_sh = tqq9_sup_sh.getString("number");
}
String gysqyzz_sh = null;
String tqq9_suparea_sh = bill.getString("tqq9_suparea_sh");
if ("B".equals(tqq9_suparea_sh)) {
gysqyzz_sh = "0";
}else if ("A".equals(tqq9_suparea_sh)) {
gysqyzz_sh = "1";
}else if ("C".equals(tqq9_suparea_sh)) {
gysqyzz_sh = "2";
}
String shck_sh = null;
DynamicObject tqq9_rewares_sh = bill.getDynamicObject("tqq9_rewares_sh");
if (tqq9_rewares_sh != null) {
shck_sh = tqq9_rewares_sh.getString("number");
}
String fktj_sh = null;
DynamicObject tqq9_paycondition_sh = bill.getDynamicObject("tqq9_paycondition_sh");
if (tqq9_paycondition_sh != null) {
String number = tqq9_paycondition_sh.getString("number");
if ("003".equals(number)) {
fktj_sh = "0";
} else if ("002".equals(number)) {
fktj_sh = "1";
} else if ("001".equals(number)) {
fktj_sh = "2";
} else if ("004".equals(number)) {
fktj_sh = "3";
}
}
String jsfs_sh = null;
DynamicObject tqq9_settletype_sh = bill.getDynamicObject("tqq9_settletype_sh");
if (tqq9_settletype_sh != null) {
String number = tqq9_settletype_sh.getString("number");
if ("JSFS01".equals(number)) {
jsfs_sh = "0";
} else if ("JSFS04".equals(number)) {
jsfs_sh = "1";
}
}
BigDecimal yhje_sh = bill.getBigDecimal("tqq9_discountamt_sh");
BigDecimal cgsl_sh = bill.getBigDecimal("tqq9_purqty_sh");
BigDecimal yfje_sh = bill.getBigDecimal("tqq9_payamount_sh");
String bz_sh = bill.getString("tqq9_remark_sh");
String hf_sh = null;
boolean tqq9_sfsyhf_sh = bill.getBoolean("tqq9_sfsyhf_sh");
if (tqq9_sfsyhf_sh) {
hf_sh = "0";
} else {
hf_sh = "1";
}
String hshfsygz_sh = null;
String tqq9_hshfsygs_sh = bill.getString("tqq9_hshfsygs_sh");
if ("B".equals(tqq9_hshfsygs_sh)) {
hshfsygz_sh = "0";
} else if ("A".equals(tqq9_hshfsygs_sh)) {
hshfsygz_sh = "1";
}
BigDecimal hshfsyje_sh = bill.getBigDecimal("tqq9_hshfsyje_sh");
BigDecimal hshfzje_sh = bill.getBigDecimal("tqq9_hshfzje_sh");
BigDecimal hshfkyje_sh = bill.getBigDecimal("tqq9_hshfkyje_sh");
BigDecimal hshfsysl_sh = BigDecimal.ZERO;
DynamicObject tqq9_hshfsysl_sh = bill.getDynamicObject("tqq9_hshfsysl_sh");
if (tqq9_hshfsysl_sh != null){
tqq9_hshfsysl_sh = BusinessDataServiceHelper.loadSingle(tqq9_hshfsysl_sh.getPkValue(), tqq9_hshfsysl_sh.getDynamicObjectType().getName());
hshfsysl_sh = tqq9_hshfsysl_sh.getBigDecimal("taxrate");
}
String xf_sh = null;
boolean tqq9_sfsyxf_sh = bill.getBoolean("tqq9_sfsyxf_sh");
if(tqq9_sfsyxf_sh){
xf_sh = "0";
}else {
xf_sh = "1";
}
String hsxfsygz_sh = null;
boolean tqq9_hsxfsygs_sh = bill.getBoolean("tqq9_hsxfsygs_sh");
if (tqq9_hsxfsygs_sh){
hsxfsygz_sh = "0";
}else{
hsxfsygz_sh = "1";
}
BigDecimal hsxfsyje_sh = bill.getBigDecimal("tqq9_hsxfsyje_sh");
BigDecimal hsxfzje_sh = bill.getBigDecimal("tqq9_hsxfzje_sh");
BigDecimal hsxfkyje_sh = bill.getBigDecimal("tqq9_hsxfkyje_sh");
BigDecimal hsxfsysl_sh = BigDecimal.ZERO;
DynamicObject tqq9_hsxfsysl_sh = bill.getDynamicObject("tqq9_hsxfsysl_sh");
if (tqq9_hsxfsysl_sh != null){
tqq9_hsxfsysl_sh = BusinessDataServiceHelper.loadSingle(tqq9_hsxfsysl_sh.getPkValue(), tqq9_hsxfsysl_sh.getDynamicObjectType().getName());
hshfsysl_sh = tqq9_hsxfsysl_sh.getBigDecimal("taxrate");
}
//北京
String cjgys_bj = null;
DynamicObject tqq9_sup_bj = bill.getDynamicObject("tqq9_sup_bj");
if (tqq9_sup_bj != null) {
cjgys_bj = tqq9_sup_bj.getString("number");
}
String gysqyzz_bj = null;
String tqq9_suparea_bj = bill.getString("tqq9_suparea_bj");
if ("B".equals(tqq9_suparea_bj)) {
gysqyzz_bj = "0";
}else if ("A".equals(tqq9_suparea_bj)) {
gysqyzz_bj = "1";
}else if ("C".equals(tqq9_suparea_bj)) {
gysqyzz_bj = "2";
}
String shck_bj = null;
DynamicObject tqq9_rewares_bj = bill.getDynamicObject("tqq9_rewares_bj");
if (tqq9_rewares_bj != null) {
shck_bj = tqq9_rewares_bj.getString("number");
}
String fktj_bj = null;
DynamicObject tqq9_paycondition_bj = bill.getDynamicObject("tqq9_paycondition_bj");
if (tqq9_paycondition_bj != null) {
String number = tqq9_paycondition_bj.getString("number");
if ("003".equals(number)) {
fktj_bj = "0";
} else if ("002".equals(number)) {
fktj_bj = "1";
} else if ("001".equals(number)) {
fktj_bj = "2";
} else if ("004".equals(number)) {
fktj_bj = "3";
}
}
String jsfs_bj = null;
DynamicObject tqq9_settletype_bj = bill.getDynamicObject("tqq9_settletype_bj");
if (tqq9_settletype_bj != null) {
String number = tqq9_settletype_bj.getString("number");
if ("JSFS01".equals(number)) {
jsfs_bj = "0";
} else if ("JSFS04".equals(number)) {
jsfs_bj = "1";
}
}
BigDecimal yhje_bj = bill.getBigDecimal("tqq9_discountamt_bj");
BigDecimal cgsl_bj = bill.getBigDecimal("tqq9_purqty_bj");
BigDecimal yfje_bj = bill.getBigDecimal("tqq9_payamount_bj");
String bz_bj = bill.getString("tqq9_remark_bj");
String hf_bj = null;
boolean tqq9_sfsyhf_bj = bill.getBoolean("tqq9_sfsyhf_bj");
if (tqq9_sfsyhf_bj) {
hf_bj = "0";
} else {
hf_bj = "1";
}
String hshfsygz_bj = null;
String tqq9_hshfsygs_bj = bill.getString("tqq9_hshfsygs_bj");
if ("B".equals(tqq9_hshfsygs_bj)) {
hshfsygz_bj = "0";
} else if ("A".equals(tqq9_hshfsygs_bj)) {
hshfsygz_bj = "1";
}
BigDecimal hshfsyje_bj = bill.getBigDecimal("tqq9_hshfsyje_bj");
BigDecimal hshfzje_bj = bill.getBigDecimal("tqq9_hshfzje_bj");
BigDecimal hshfkyje_bj = bill.getBigDecimal("tqq9_hshfkyje_bj");
BigDecimal hshfsysl_bj = BigDecimal.ZERO;
DynamicObject tqq9_hshfsysl_bj = bill.getDynamicObject("tqq9_hshfsysl_bj");
if (tqq9_hshfsysl_bj != null){
tqq9_hshfsysl_bj = BusinessDataServiceHelper.loadSingle(tqq9_hshfsysl_bj.getPkValue(), tqq9_hshfsysl_bj.getDynamicObjectType().getName());
hshfsysl_bj = tqq9_hshfsysl_bj.getBigDecimal("taxrate");
}
String xf_bj = null;
boolean tqq9_sfsyxf_bj = bill.getBoolean("tqq9_sfsyxf_bj");
if(tqq9_sfsyxf_bj){
xf_bj = "0";
}else {
xf_bj = "1";
}
String hsxfsygz_bj = null;
boolean tqq9_hsxfsygs_bj = bill.getBoolean("tqq9_hsxfsygs_bj");
if (tqq9_hsxfsygs_bj){
hsxfsygz_bj = "0";
}else{
hsxfsygz_bj = "1";
}
BigDecimal hsxfsyje_bj = bill.getBigDecimal("tqq9_hsxfsyje_bj");
BigDecimal hsxfzje_bj = bill.getBigDecimal("tqq9_hsxfzje_bj");
BigDecimal hsxfkyje_bj = bill.getBigDecimal("tqq9_hsxfkyje_bj");
BigDecimal hsxfsysl_bj = BigDecimal.ZERO;
DynamicObject tqq9_hsxfsysl_bj = bill.getDynamicObject("tqq9_hsxfsysl_bj");
if (tqq9_hsxfsysl_bj != null){
tqq9_hsxfsysl_bj = BusinessDataServiceHelper.loadSingle(tqq9_hsxfsysl_bj.getPkValue(), tqq9_hsxfsysl_bj.getDynamicObjectType().getName());
hsxfsysl_bj = tqq9_hsxfsysl_bj.getBigDecimal("taxrate");
}
//广州
String cjgys_gz = null;
DynamicObject tqq9_sup_gz = bill.getDynamicObject("tqq9_sup_gz");
if (tqq9_sup_gz != null) {
cjgys_gz = tqq9_sup_gz.getString("number");
}
String gysqyzz_gz = null;
String tqq9_suparea_gz = bill.getString("tqq9_suparea_gz");
if ("B".equals(tqq9_suparea_gz)) {
gysqyzz_gz = "0";
}else if ("A".equals(tqq9_suparea_gz)) {
gysqyzz_gz = "1";
}else if ("C".equals(tqq9_suparea_gz)) {
gysqyzz_gz = "2";
}
String shck_gz = null;
DynamicObject tqq9_rewares_gz = bill.getDynamicObject("tqq9_rewares_gz");
if (tqq9_rewares_gz != null) {
shck_gz = tqq9_rewares_gz.getString("number");
}
String fktj_gz = null;
DynamicObject tqq9_paycondition_gz = bill.getDynamicObject("tqq9_paycondition_gz");
if (tqq9_paycondition_gz != null) {
String number = tqq9_paycondition_gz.getString("number");
if ("003".equals(number)) {
fktj_gz = "0";
} else if ("002".equals(number)) {
fktj_gz = "1";
} else if ("001".equals(number)) {
fktj_gz = "2";
} else if ("004".equals(number)) {
fktj_gz = "3";
}
}
String jsfs_gz = null;
DynamicObject tqq9_settletype_gz = bill.getDynamicObject("tqq9_settletype_gz");
if (tqq9_settletype_gz != null) {
String number = tqq9_settletype_gz.getString("number");
if ("JSFS01".equals(number)) {
jsfs_gz = "0";
} else if ("JSFS04".equals(number)) {
jsfs_gz = "1";
}
}
BigDecimal yhje_gz = bill.getBigDecimal("tqq9_discountamt_gz");
BigDecimal cgsl_gz = bill.getBigDecimal("tqq9_purqty_gz");
BigDecimal yfje_gz = bill.getBigDecimal("tqq9_payamount_gz");
String bz_gz = bill.getString("tqq9_remark_gz");
String hf_gz = null;
boolean tqq9_sfsyhf_gz = bill.getBoolean("tqq9_sfsyhf_gz");
if (tqq9_sfsyhf_bj) {
hf_gz = "0";
} else {
hf_gz = "1";
}
String hshfsygz_gz = null;
String tqq9_hshfsygs_gz = bill.getString("tqq9_hshfsygs_gz");
if ("B".equals(tqq9_hshfsygs_gz)) {
hshfsygz_gz = "0";
} else if ("A".equals(tqq9_hshfsygs_gz)) {
hshfsygz_gz = "1";
}
BigDecimal hshfsyje_gz = bill.getBigDecimal("tqq9_hshfsyje_gz");
BigDecimal hshfzje_gz = bill.getBigDecimal("tqq9_hshfzje_gz");
BigDecimal hshfkyje_gz = bill.getBigDecimal("tqq9_hshfkyje_gz");
BigDecimal hshfsysl_gz = BigDecimal.ZERO;
DynamicObject tqq9_hshfsysl_gz = bill.getDynamicObject("tqq9_hshfsysl_gz");
if (tqq9_hshfsysl_gz != null){
tqq9_hshfsysl_gz = BusinessDataServiceHelper.loadSingle(tqq9_hshfsysl_gz.getPkValue(), tqq9_hshfsysl_bj.getDynamicObjectType().getName());
hshfsysl_gz = tqq9_hshfsysl_gz.getBigDecimal("taxrate");
}
String xf_gz = null;
boolean tqq9_sfsyxf_gz = bill.getBoolean("tqq9_sfsyxf_gz");
if(tqq9_sfsyxf_gz){
xf_gz = "0";
}else {
xf_gz = "1";
}
String hsxfsygz_gz = null;
boolean tqq9_hsxfsygs_gz = bill.getBoolean("tqq9_hsxfsygs_gz");
if (tqq9_hsxfsygs_gz){
hsxfsygz_gz = "0";
}else{
hsxfsygz_gz = "1";
}
BigDecimal hsxfsyje_gz = bill.getBigDecimal("tqq9_hsxfsyje_gz");
BigDecimal hsxfzje_gz = bill.getBigDecimal("tqq9_hsxfzje_gz");
BigDecimal hsxfkyje_gz = bill.getBigDecimal("tqq9_hsxfkyje_gz");
BigDecimal hsxfsysl_gz = BigDecimal.ZERO;
DynamicObject tqq9_hsxfsysl_gz = bill.getDynamicObject("tqq9_hsxfsysl_gz");
if (tqq9_hsxfsysl_gz != null){
tqq9_hsxfsysl_gz = BusinessDataServiceHelper.loadSingle(tqq9_hsxfsysl_gz.getPkValue(), tqq9_hsxfsysl_gz.getDynamicObjectType().getName());
hsxfsysl_gz = tqq9_hsxfsysl_gz.getBigDecimal("taxrate");
}
//处理明细
JSONObject detail_sh = new JSONObject();
JSONArray recordsArr_sh = new JSONArray();
JSONObject detail_bj = new JSONObject();
JSONArray recordsArr_bj = new JSONArray();
JSONObject detail_gz = new JSONObject();
JSONArray recordsArr_gz = new JSONArray();
DynamicObjectCollection billentries = bill.getDynamicObjectCollection("billentry");
for (DynamicObject billentry : billentries) {
DynamicObject entryrecorg = billentry.getDynamicObject("entryrecorg");
String orgNumber = entryrecorg.getString("number");
String shzz = FWUtils.getFwOrgNumberByKdOrgNumber(orgNumber);
BigDecimal jshj_e = billentry.getBigDecimal("amountandtax");
DynamicObject material = billentry.getDynamicObject("material");
DynamicObject masterid = material.getDynamicObject("masterid");
masterid = BusinessDataServiceHelper.loadSingle(masterid.getPkValue(), masterid.getDynamicObjectType().getName());
String wlmc = masterid.getString("number");
String wlbm = masterid.getString("number");
DynamicObject tqq9_brand = masterid.getDynamicObject("tqq9_brand");
String pp = null;
if(tqq9_brand != null){
pp = tqq9_brand.getString("name");
}
String ggxh = masterid.getString("modelnum");
DynamicObject unit = billentry.getDynamicObject("unit");
String jldw = null;
if(unit != null){
jldw = unit.getString("name");
}
BigDecimal sl = billentry.getBigDecimal("applyqty");
BigDecimal hsdj = billentry.getBigDecimal("priceandtax");
BigDecimal tax_rate = billentry.getBigDecimal("taxrate");
BigDecimal zkqjshj_e = billentry.getBigDecimal("tqq9_amount");
zkqjshj = zkqjshj.add(zkqjshj_e);
BigDecimal yhzkje = billentry.getBigDecimal("tqq9_disamount");
BigDecimal zkhjshj = billentry.getBigDecimal("tqq9_taxamount");
BigDecimal hfsyje = billentry.getBigDecimal("tqq9_hfamount");
BigDecimal xfsyje = billentry.getBigDecimal("tqq9_xfamount");
BigDecimal zkhflhjshj = billentry.getBigDecimal("tqq9_yfje");
BigDecimal cb = billentry.getBigDecimal("tqq9_costprice");
BigDecimal yjxssjy = billentry.getBigDecimal("tqq9_expectsaletime");
String bz_e = billentry.getString("entrycomment");
String shck = null;
DynamicObject warehouse = billentry.getDynamicObject("warehouse");
if (warehouse != null) {
shck = warehouse.getString("number");
}
String gys = null;
DynamicObject supplier = billentry.getDynamicObject("supplier");
if (supplier != null) {
gys = supplier.getString("number");
}
JSONObject e2 = new JSONObject();
e2.put("fieldName", "wlbm");
e2.put("fieldValue", wlbm);
JSONObject e3 = new JSONObject();
e3.put("fieldName", "pp");
e3.put("fieldValue", pp);
JSONObject e4 = new JSONObject();
e4.put("fieldName", "ggxh");
e4.put("fieldValue", ggxh);
JSONObject e5 = new JSONObject();
e5.put("fieldName", "jldw");
e5.put("fieldValue", jldw);
JSONObject e6 = new JSONObject();
e6.put("fieldName", "sl");
e6.put("fieldValue", sl!=null&&sl.compareTo(BigDecimal.ZERO)!=0?sl.toBigInteger().intValue():0);
JSONObject e7 = new JSONObject();
e7.put("fieldName", "hsdj");
e7.put("fieldValue", hsdj!=null&&hsdj.compareTo(BigDecimal.ZERO)!=0?hsdj:0);
JSONObject e8 = new JSONObject();
e8.put("fieldName", "tax_rate");
e8.put("fieldValue", tax_rate!=null&&tax_rate.compareTo(BigDecimal.ZERO)!=0?tax_rate:0);
JSONObject e9 = new JSONObject();
e9.put("fieldName", "zkqjshj");
e9.put("fieldValue", zkqjshj_e!=null&&zkqjshj_e.compareTo(BigDecimal.ZERO)!=0?zkqjshj_e:0);
JSONObject e10 = new JSONObject();
e10.put("fieldName", "yhzkje");
e10.put("fieldValue", yhzkje!=null&&yhzkje.compareTo(BigDecimal.ZERO)!=0?yhzkje:0);
JSONObject e11 = new JSONObject();
e11.put("fieldName", "zkhjshj");
e11.put("fieldValue", zkhjshj!=null&&zkhjshj.compareTo(BigDecimal.ZERO)!=0?zkhjshj:0);
JSONObject e12 = new JSONObject();
e12.put("fieldName", "hfsyje");
e12.put("fieldValue", hfsyje!=null&&hfsyje.compareTo(BigDecimal.ZERO)!=0?hfsyje:0);
JSONObject e13 = new JSONObject();
e13.put("fieldName", "xfsyje");
e13.put("fieldValue", xfsyje!=null&&xfsyje.compareTo(BigDecimal.ZERO)!=0?xfsyje:0);
JSONObject e14 = new JSONObject();
e14.put("fieldName", "zkhflhjshj");
e14.put("fieldValue", zkhflhjshj!=null&&zkhflhjshj.compareTo(BigDecimal.ZERO)!=0?zkhflhjshj:0);
JSONObject e15 = new JSONObject();
e15.put("fieldName", "cb");
e15.put("fieldValue", cb!=null&&cb.compareTo(BigDecimal.ZERO)!=0?cb:0);
JSONObject e16 = new JSONObject();
e16.put("fieldName", "yjxssjy");
e16.put("fieldValue", yjxssjy!=null&&yjxssjy.compareTo(BigDecimal.ZERO)!=0?yjxssjy:0);
JSONObject e17 = new JSONObject();
e17.put("fieldName", "bz");
e17.put("fieldValue", bz_e);
JSONObject e18 = new JSONObject();
e18.put("fieldName", "shck");
e18.put("fieldValue", shck);
JSONObject e19 = new JSONObject();
e19.put("fieldName", "shzz");
e19.put("fieldValue", shzz);
JSONObject e20 = new JSONObject();
e20.put("fieldName", "gys");
e20.put("fieldValue", gys);
JSONObject e21 = new JSONObject();
e21.put("fieldName", "wlmc");
e21.put("fieldValue", wlmc);
List<JSONObject> elist = Arrays.asList(e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21);
JSONArray recordsArr = new JSONArray();
recordsArr.addAll(elist);
JSONObject recordObj = new JSONObject();
recordObj.put("recordOrder", 0);
recordObj.put("workflowRequestTableFields", recordsArr);
if("SHLC".equals(orgNumber)){
recordsArr_sh.add(recordObj);
}else if("BJLC".equals(orgNumber)){
recordsArr_bj.add(recordObj);
}else if("GZLC".equals(orgNumber)){
recordsArr_gz.add(recordObj);
}
}
detail_sh.put("tableDBName", "formtable_main_119_dt1");
detail_sh.put("workflowRequestTableRecords", recordsArr_sh);
detail_bj.put("tableDBName", "formtable_main_119_dt2");
detail_bj.put("workflowRequestTableRecords", recordsArr_bj);
detail_gz.put("tableDBName", "formtable_main_119_dt3");
detail_gz.put("workflowRequestTableRecords", recordsArr_gz);
if(StringUtils.isNotBlank(tqq9_fwrequestid)){
detail_sh.put("deleteAll", "1");
detail_bj.put("deleteAll", "1");
detail_gz.put("deleteAll", "1");
}
JSONArray detailRootArr = new JSONArray();
detailRootArr.add(detail_sh);
detailRootArr.add(detail_bj);
detailRootArr.add(detail_gz);
//组装单头参数
JSONObject m1 = new JSONObject();
m1.put("fieldName", "KDBillType");
m1.put("fieldValue", "pm_purapplybill");
JSONObject m2 = new JSONObject();
m2.put("fieldName", "sqr");
m2.put("fieldValue", sqr);
JSONObject m3 = new JSONObject();
m3.put("fieldName", "bm");
m3.put("fieldValue", bm);
JSONObject m4 = new JSONObject();
m4.put("fieldName", "sqrq");
m4.put("fieldValue", sqrq);
JSONObject m5 = new JSONObject();
m5.put("fieldName", "ywgz");
m5.put("fieldValue", "4");
JSONObject m6 = new JSONObject();
m6.put("fieldName", "lcbh");
m6.put("fieldValue", lcbh);
JSONObject m7 = new JSONObject();
m7.put("fieldName", "jczz");
m7.put("fieldValue", jczz);
JSONObject m8 = new JSONObject();
m8.put("fieldName", "djlx");
m8.put("fieldValue", djlx);
JSONObject m9 = new JSONObject();
m9.put("fieldName", "ywlx");
m9.put("fieldValue", ywlx);
JSONObject m10 = new JSONObject();
m10.put("fieldName", "coin");
m10.put("fieldValue", coin);
JSONObject m11 = new JSONObject();
m11.put("fieldName", "sfhs");
m11.put("fieldValue", sfhs);
JSONObject m12 = new JSONObject();
m12.put("fieldName", "zkqjshj");
m12.put("fieldValue", zkqjshj!=null&&zkqjshj.compareTo(BigDecimal.ZERO)!=0?zkqjshj:0);
JSONObject m13 = new JSONObject();
m13.put("fieldName", "jshj");
m13.put("fieldValue", jshj!=null&&jshj.compareTo(BigDecimal.ZERO)!=0?jshj:0);
JSONObject m14 = new JSONObject();
m14.put("fieldName", "bz");
m14.put("fieldValue", bz);
JSONObject m15 = new JSONObject();
m15.put("fieldName", "cjgys_sh");
m15.put("fieldValue", cjgys_sh);
JSONObject m16 = new JSONObject();
m16.put("fieldName", "gysqyzz_sh");
m16.put("fieldValue", gysqyzz_sh);
JSONObject m17 = new JSONObject();
m17.put("fieldName", "shck_sh");
m17.put("fieldValue", shck_sh);
JSONObject m18 = new JSONObject();
m18.put("fieldName", "fktj_sh");
m18.put("fieldValue", fktj_sh);
JSONObject m19 = new JSONObject();
m19.put("fieldName", "jsfs_sh");
m19.put("fieldValue", jsfs_sh);
JSONObject m20 = new JSONObject();
m20.put("fieldName", "yhje_sh");
m20.put("fieldValue", yhje_sh!=null&&yhje_sh.compareTo(BigDecimal.ZERO)!=0?yhje_sh:0);
JSONObject m21 = new JSONObject();
m21.put("fieldName", "cgsl_sh");
m21.put("fieldValue", cgsl_sh==null||cgsl_sh.compareTo(BigDecimal.ZERO)==0?0:cgsl_sh.toBigInteger().intValue());
JSONObject m22 = new JSONObject();
m22.put("fieldName", "yfje_sh");
m22.put("fieldValue", yfje_sh==null||yfje_sh.compareTo(BigDecimal.ZERO)==0?0:yfje_sh);
JSONObject m23 = new JSONObject();
m23.put("fieldName", "bz_sh");
m23.put("fieldValue", bz_sh);
JSONObject m24 = new JSONObject();
m24.put("fieldName", "hf_sh");
m24.put("fieldValue", hf_sh);
JSONObject m25 = new JSONObject();
m25.put("fieldName", "hshfsygz_sh");
m25.put("fieldValue", hshfsygz_sh);
JSONObject m26 = new JSONObject();
m26.put("fieldName", "hshfsyje_sh");
m26.put("fieldValue", hshfsyje_sh==null||hshfsyje_sh.compareTo(BigDecimal.ZERO)==0?0:hshfsyje_sh);
JSONObject m27 = new JSONObject();
m27.put("fieldName", "hshfzje_sh");
m27.put("fieldValue", hshfzje_sh==null||hshfzje_sh.compareTo(BigDecimal.ZERO)==0?0:hshfzje_sh);
JSONObject m28 = new JSONObject();
m28.put("fieldName", "hshfkyje_sh");
m28.put("fieldValue", hshfkyje_sh==null||hshfkyje_sh.compareTo(BigDecimal.ZERO)==0?0:hshfkyje_sh);
JSONObject m29 = new JSONObject();
m29.put("fieldName", "hshfsysl_sh");
m29.put("fieldValue", hshfsysl_sh==null||hshfsysl_sh.compareTo(BigDecimal.ZERO)==0?0:hshfsysl_sh);
JSONObject m30 = new JSONObject();
m30.put("fieldName", "xf_sh");
m30.put("fieldValue", xf_sh);
JSONObject m31 = new JSONObject();
m31.put("fieldName", "hsxfsygz_sh");
m31.put("fieldValue", hsxfsygz_sh);
JSONObject m32 = new JSONObject();
m32.put("fieldName", "hsxfsyje_sh");
m32.put("fieldValue", hsxfsyje_sh==null||hsxfsyje_sh.compareTo(BigDecimal.ZERO)==0?0:hsxfsyje_sh);
JSONObject m33 = new JSONObject();
m33.put("fieldName", "hsxfzje_sh");
m33.put("fieldValue", hsxfzje_sh==null||hsxfzje_sh.compareTo(BigDecimal.ZERO)==0?0:hsxfzje_sh);
JSONObject m34 = new JSONObject();
m34.put("fieldName", "hsxfkyje_sh");
m34.put("fieldValue", hsxfkyje_sh==null||hsxfkyje_sh.compareTo(BigDecimal.ZERO)==0?0:hsxfkyje_sh);
JSONObject m35 = new JSONObject();
m35.put("fieldName", "hsxfsysl_sh");
m35.put("fieldValue", hsxfsysl_sh==null||hsxfsysl_sh.compareTo(BigDecimal.ZERO)==0?0:hsxfsysl_sh);
JSONObject m36 = new JSONObject();
m36.put("fieldName", "cjgys_bj");
m36.put("fieldValue", cjgys_bj);
JSONObject m37 = new JSONObject();
m37.put("fieldName", "gysqyzz_bj");
m37.put("fieldValue", gysqyzz_bj);
JSONObject m38 = new JSONObject();
m38.put("fieldName", "shck_bj");
m38.put("fieldValue", shck_bj);
JSONObject m39 = new JSONObject();
m39.put("fieldName", "fktj_bj");
m39.put("fieldValue", fktj_bj);
JSONObject m40 = new JSONObject();
m40.put("fieldName", "jsfs_bj");
m40.put("fieldValue", jsfs_bj);
JSONObject m41 = new JSONObject();
m41.put("fieldName", "yhje_bj");
m41.put("fieldValue", yhje_bj==null||yhje_bj.compareTo(BigDecimal.ZERO)==0?0:yhje_bj);
JSONObject m42 = new JSONObject();
m42.put("fieldName", "cgsl_bj");
m42.put("fieldValue", cgsl_bj==null||cgsl_bj.compareTo(BigDecimal.ZERO)==0?0:cgsl_bj.toBigInteger().intValue());
JSONObject m43 = new JSONObject();
m43.put("fieldName", "yfje_bj");
m43.put("fieldValue", yfje_bj==null||yfje_bj.compareTo(BigDecimal.ZERO)==0?0:yfje_bj);
JSONObject m44 = new JSONObject();
m44.put("fieldName", "bz_bj");
m44.put("fieldValue", bz_bj);
JSONObject m45 = new JSONObject();
m45.put("fieldName", "hf_bj");
m45.put("fieldValue", hf_bj);
JSONObject m46 = new JSONObject();
m46.put("fieldName", "hshfsygz_bj");
m46.put("fieldValue", hshfsygz_bj);
JSONObject m47 = new JSONObject();
m47.put("fieldName", "hshfsyje_bj");
m47.put("fieldValue", hshfsyje_bj==null||hshfsyje_bj.compareTo(BigDecimal.ZERO)==0?0:hshfsyje_bj);
JSONObject m48 = new JSONObject();
m48.put("fieldName", "hshfzje_bj");
m48.put("fieldValue", hshfzje_bj==null||hshfzje_bj.compareTo(BigDecimal.ZERO)==0?0:hshfzje_bj);
JSONObject m49 = new JSONObject();
m49.put("fieldName", "hshfkyje_bj");
m49.put("fieldValue", hshfkyje_bj==null||hshfkyje_bj.compareTo(BigDecimal.ZERO)==0?0:hshfkyje_bj);
JSONObject m50 = new JSONObject();
m50.put("fieldName", "hshfsysl_bj");
m50.put("fieldValue", hshfsysl_bj==null||hshfsysl_bj.compareTo(BigDecimal.ZERO)==0?0:hshfsysl_bj);
JSONObject m51 = new JSONObject();
m51.put("fieldName", "xf_bj");
m51.put("fieldValue", xf_bj);
JSONObject m52 = new JSONObject();
m52.put("fieldName", "hsxfsygz_bj");
m52.put("fieldValue", hsxfsygz_bj);
JSONObject m53 = new JSONObject();
m53.put("fieldName", "hsxfsyje_bj");
m53.put("fieldValue", hsxfsyje_bj==null||hsxfsyje_bj.compareTo(BigDecimal.ZERO)==0?0:hsxfsyje_bj);
JSONObject m54 = new JSONObject();
m54.put("fieldName", "hsxfzje_bj");
m54.put("fieldValue", hsxfzje_bj==null||hsxfzje_bj.compareTo(BigDecimal.ZERO)==0?0:hsxfzje_bj);
JSONObject m55 = new JSONObject();
m55.put("fieldName", "hsxfkyje_bj");
m55.put("fieldValue", hsxfkyje_bj==null||hsxfkyje_bj.compareTo(BigDecimal.ZERO)==0?0:hsxfkyje_bj);
JSONObject m56 = new JSONObject();
m56.put("fieldName", "hsxfsysl_bj");
m56.put("fieldValue", hsxfsysl_bj==null||hsxfsysl_bj.compareTo(BigDecimal.ZERO)==0?0:hsxfsysl_bj);
JSONObject m57 = new JSONObject();
m57.put("fieldName", "cjgys_gz");
m57.put("fieldValue", cjgys_gz);
JSONObject m58 = new JSONObject();
m58.put("fieldName", "gysqyzz_gz");
m58.put("fieldValue", gysqyzz_gz);
JSONObject m59 = new JSONObject();
m59.put("fieldName", "shck_gz");
m59.put("fieldValue", shck_gz);
JSONObject m60 = new JSONObject();
m60.put("fieldName", "fktj_gz");
m60.put("fieldValue", fktj_gz);
JSONObject m61 = new JSONObject();
m61.put("fieldName", "jsfs_gz");
m61.put("fieldValue", jsfs_gz);
JSONObject m62 = new JSONObject();
m62.put("fieldName", "yhje_gz");
m62.put("fieldValue", yhje_gz==null||yhje_gz.compareTo(BigDecimal.ZERO)==0?0:yhje_gz);
JSONObject m63 = new JSONObject();
m63.put("fieldName", "cgsl_gz");
m63.put("fieldValue", cgsl_gz==null||cgsl_gz.compareTo(BigDecimal.ZERO)==0?0:cgsl_gz.toBigInteger().intValue());
JSONObject m64 = new JSONObject();
m64.put("fieldName", "yfje_gz");
m64.put("fieldValue", yfje_gz==null||yfje_gz.compareTo(BigDecimal.ZERO)==0?0:yfje_gz);
JSONObject m65 = new JSONObject();
m65.put("fieldName", "bz_gz");
m65.put("fieldValue", bz_gz);
JSONObject m66 = new JSONObject();
m66.put("fieldName", "hf_gz");
m66.put("fieldValue", hf_gz);
JSONObject m67 = new JSONObject();
m67.put("fieldName", "hshfsygz_gz");
m67.put("fieldValue", hshfsygz_gz);
JSONObject m68 = new JSONObject();
m68.put("fieldName", "hshfsyje_gz");
m68.put("fieldValue", hshfsyje_gz==null||hshfsyje_gz.compareTo(BigDecimal.ZERO)==0?0:hshfsyje_gz);
JSONObject m69 = new JSONObject();
m69.put("fieldName", "hshfzje_gz");
m69.put("fieldValue", hshfzje_gz==null||hshfzje_gz.compareTo(BigDecimal.ZERO)==0?0:hshfzje_gz);
JSONObject m70 = new JSONObject();
m70.put("fieldName", "hshfkyje_gz");
m70.put("fieldValue", hshfkyje_gz==null||hshfkyje_gz.compareTo(BigDecimal.ZERO)==0?0:hshfkyje_gz);
JSONObject m71 = new JSONObject();
m71.put("fieldName", "hshfsysl_gz");
m71.put("fieldValue", hshfsysl_gz==null||hshfsysl_gz.compareTo(BigDecimal.ZERO)==0?0:hshfsysl_gz);
JSONObject m72 = new JSONObject();
m72.put("fieldName", "xf_gz");
m72.put("fieldValue", xf_gz);
JSONObject m73 = new JSONObject();
m73.put("fieldName", "hsxfsygz_gz");
m73.put("fieldValue", hsxfsygz_gz);
JSONObject m74 = new JSONObject();
m74.put("fieldName", "hsxfsyje_gz");
m74.put("fieldValue", hsxfsyje_gz==null||hsxfsyje_gz.compareTo(BigDecimal.ZERO)==0?0:hsxfsyje_gz);
JSONObject m75 = new JSONObject();
m75.put("fieldName", "hsxfzje_gz");
m75.put("fieldValue", hsxfzje_gz==null||hsxfzje_gz.compareTo(BigDecimal.ZERO)==0?0:hsxfzje_gz);
JSONObject m76 = new JSONObject();
m76.put("fieldName", "hsxfkyje_gz");
m76.put("fieldValue", hsxfkyje_gz==null||hsxfkyje_gz.compareTo(BigDecimal.ZERO)==0?0:hsxfkyje_gz);
JSONObject m77 = new JSONObject();
m77.put("fieldName", "hsxfsysl_gz");
m77.put("fieldValue", hsxfsysl_gz==null||hsxfsysl_gz.compareTo(BigDecimal.ZERO)==0?0:hsxfsysl_gz);
JSONObject m78 = new JSONObject();
m78.put("fieldName", "sqzz");
m78.put("fieldValue", "8");
List<JSONObject> mlist = new ArrayList<>(Arrays.asList(
m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,m16,m17,m18,m19,m20,
m21,m22,m23,m24,m25,m26,m27,m28,m29,m30,m31,m32,m33,m34,m35,m36,m37,m38,m39,m40,
m41,m42,m43,m44,m45,m46,m47,m48,m49,m50,m51,m52,m53,m54,m55,m56,m57,m58,m59,m60,
m61,m62,m63,m64,m65,m66,m67,m68,m69,m70,m71,m72,m73,m74,m75,m76,m77,m78));
JSONArray mainArr = new JSONArray();
// 附件
List<JSONObject> fjList = new ArrayList<>();
List<Map<String, Object>> attachments = AttachmentServiceHelper.getAttachments("pm_purapplybill", bill.getPkValue(), "attachmentpanel");
for (Map<String, Object> attachment : attachments) {
String filePath = (String) attachment.get("url");
String fileName = (String) attachment.get("name");
byte[] bytes = HttpUtil.downloadBytes(filePath);
String str = "base64:" + cn.hutool.core.codec.Base64.encode(bytes);
JSONObject fj = new JSONObject();
fj.put("filePath", str);
fj.put("fileName", fileName);
fjList.add(fj);
}
if(fjList.size() > 0){
JSONObject fjObj = new JSONObject();
fjObj.put("fieldName", "fjsc");
fjObj.put("fieldValue", fjList);
mlist.add(fjObj);
}
mainArr.addAll(mlist);
String fw_wfid_xzcgdd = ConfigUtils.getThirdConfigByNumber("FW_WFID_JZCGSP");
FWRestfulUtils fwRestfulUtils = new FWRestfulUtils();
//如果单据上纯在泛微流程id重新提交调用泛微提交接口如果没有泛微流程id就调用新增接口
String resultStr = fwRestfulUtils.doBillAction(mainArr, detailRootArr, "集中采购审批单流程", fw_wfid_xzcgdd, lcbh, tqq9_fwrequestid, sqr);
if(StringUtils.isNotBlank(resultStr)){
JSONObject resultObj = JSONObject.parseObject(resultStr);
String code = resultObj.getString("code");
if("SUCCESS".equals(code)){
JSONObject data = resultObj.getJSONObject("data");
if(data != null){
String requestid = data.getString("requestid");
bill.set("tqq9_fwrequestid", requestid);
bill.set("tqq9_fwstate", "B");
SaveServiceHelper.save(new DynamicObject[]{bill});
}
}
}
}
}
}