【泛微推送工具类】其他入库单,其他出库单提交推送泛微
This commit is contained in:
parent
eb069ce139
commit
68cf88bb85
|
|
@ -0,0 +1,53 @@
|
|||
package tqq9.lc123.cloud.app.plugin.operate.im;
|
||||
|
||||
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.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import tqq9.lc123.cloud.app.plugin.trd.FWImpl;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.FWOrgMappingUtils;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.FWRestfulUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class OtherInSubmitToFwOp 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, "im_otherinbill");
|
||||
String resultStr = FWImpl.pushFwOtherIn(bill);
|
||||
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);
|
||||
SaveServiceHelper.save(new DynamicObject[]{bill});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package tqq9.lc123.cloud.app.plugin.operate.im;
|
||||
|
||||
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.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import tqq9.lc123.cloud.app.plugin.trd.FWImpl;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.ConfigUtils;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.FWOrgMappingUtils;
|
||||
import tqq9.lc123.cloud.app.plugin.utils.FWRestfulUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class OtherOutSubmitToFwOp 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, "im_otheroutbill");
|
||||
String resultStr = FWImpl.pushFwOtherOut(bill);
|
||||
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);
|
||||
SaveServiceHelper.save(new DynamicObject[]{bill});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ public class PurOrderSubmitOp extends AbstractOperationServicePlugIn {
|
|||
for (Object successPkId : successPkIds) {
|
||||
DynamicObject pm_purorderbill = BusinessDataServiceHelper.loadSingle(successPkId, "pm_purorderbill");
|
||||
//组装数据,调用泛微接口
|
||||
String resultStr = FWImpl.sendFW(pm_purorderbill);
|
||||
String resultStr = FWImpl.pushFwPurorder(pm_purorderbill);
|
||||
if(StringUtils.isNotBlank(resultStr)){
|
||||
JSONObject resultObj = JSONObject.parseObject(resultStr);
|
||||
String code = resultObj.getString("code");
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import tqq9.lc123.cloud.app.plugin.utils.FWRestfulUtils;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
|
@ -69,7 +70,7 @@ public class FWImpl {
|
|||
* @param pm_purorderbill
|
||||
* @return
|
||||
*/
|
||||
public static String sendFW(DynamicObject pm_purorderbill){
|
||||
public static String pushFwPurorder(DynamicObject pm_purorderbill){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String billno = pm_purorderbill.getString("billno");//lcbh
|
||||
String tqq9_fwrequestid = pm_purorderbill.getString("tqq9_fwrequestid");//泛微流程ID
|
||||
|
|
@ -499,7 +500,733 @@ public class FWImpl {
|
|||
String fw_wfid_xzcgdd = ConfigUtils.getThirdConfigByNumber("FW_WFID_XZCGDD");
|
||||
FWRestfulUtils fwRestfulUtils = new FWRestfulUtils();
|
||||
//如果单据上纯在泛微流程id,重新提交调用泛微提交接口,如果没有泛微流程id,就调用新增接口
|
||||
String resultStr = fwRestfulUtils.doBillAction(mainArr, detailRootArr, "新增采购单", fw_wfid_xzcgdd, billno, tqq9_fwrequestid);
|
||||
String resultStr = fwRestfulUtils.doBillAction(mainArr, detailRootArr, "采购单流程", fw_wfid_xzcgdd, billno, tqq9_fwrequestid);
|
||||
return resultStr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 其他入库单推送泛微
|
||||
* @param bill
|
||||
* @return
|
||||
*/
|
||||
public static String pushFwOtherIn(DynamicObject bill) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String billno = bill.getString("billno");
|
||||
String tqq9_fwrequestid = bill.getString("tqq9_fwrequestid");//泛微流程ID
|
||||
DynamicObject creator = bill.getDynamicObject("creator");
|
||||
creator = BusinessDataServiceHelper.loadSingle(creator.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
String sqr = creator.getString("tqq9_fwuserid");
|
||||
String bm = null;
|
||||
DynamicObject tqq9_dept = bill.getDynamicObject("tqq9_dept");
|
||||
if(tqq9_dept != null){
|
||||
String number = tqq9_dept.getString("number");
|
||||
bm = FWOrgMappingUtils.getFwOrgNumberByKdOrgNumber(number);
|
||||
}
|
||||
Date biztime = bill.getDate("biztime");
|
||||
String sqrq = sdf.format(biztime);
|
||||
DynamicObject org = bill.getDynamicObject("org");
|
||||
String orgNumber = org.getString("number");
|
||||
String ywgz = FWOrgMappingUtils.getFwOrgNumberByKdOrgNumber(orgNumber);
|
||||
int crk = 1;
|
||||
DynamicObject biztype = bill.getDynamicObject("biztype");
|
||||
String biztypeNumber = biztype.getString("number");
|
||||
int ywlxrk = 1;
|
||||
String ywlxxsm = "其他入库";
|
||||
if("350".equals(biztypeNumber)){
|
||||
ywlxrk = 0;
|
||||
ywlxxsm = "盘盈入库";
|
||||
}else if("354".equals(biztypeNumber)){
|
||||
ywlxrk = 1;
|
||||
ywlxxsm = "其他入库";
|
||||
}else if("605".equals(biztypeNumber)){
|
||||
ywlxrk = 2;
|
||||
ywlxxsm = "调拨入库";
|
||||
}else if("606".equals(biztypeNumber)){
|
||||
ywlxrk = 3;
|
||||
ywlxxsm = "赠品入库";
|
||||
}else if("607".equals(biztypeNumber)){
|
||||
ywlxrk = 4;
|
||||
ywlxxsm = "礼品入库";
|
||||
}else if("608".equals(biztypeNumber)){
|
||||
ywlxrk = 5;
|
||||
ywlxxsm = "展会领用入库";
|
||||
}else if("609".equals(biztypeNumber)){
|
||||
ywlxrk = 6;
|
||||
ywlxxsm = "拍照领用入库";
|
||||
}else if("610".equals(biztypeNumber)){
|
||||
ywlxrk = 7;
|
||||
ywlxxsm = "换货入库";
|
||||
}else if("611".equals(biztypeNumber)){
|
||||
ywlxrk = 8;
|
||||
ywlxxsm = "错货入库";
|
||||
}
|
||||
String drzz = ywgz;
|
||||
String jsr = null;
|
||||
DynamicObject tqq9_jsr = bill.getDynamicObject("tqq9_jsr");
|
||||
if(tqq9_jsr != null){
|
||||
tqq9_jsr = BusinessDataServiceHelper.loadSingle(tqq9_jsr.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
jsr = tqq9_jsr.getString("tqq9_fwuserid");
|
||||
}
|
||||
String kgy = null;
|
||||
DynamicObject tqq9_operator = bill.getDynamicObject("tqq9_operator");
|
||||
if(tqq9_operator != null){
|
||||
tqq9_operator = BusinessDataServiceHelper.loadSingle(tqq9_operator.getPkValue(), "bd_operator");
|
||||
DynamicObject user = tqq9_operator.getDynamicObject("operatorid");
|
||||
if(user != null){
|
||||
user = BusinessDataServiceHelper.loadSingle(user.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
kgy = user.getString("tqq9_fwuserid");
|
||||
}
|
||||
}
|
||||
String sqyybz = bill.getString("comment");
|
||||
BigDecimal hzje = bill.getBigDecimal("tqq9_hzje");
|
||||
String shdh = bill.getString("tqq9_returnapply");
|
||||
String dyxsddh = bill.getString("tqq9_dyxsddh");
|
||||
String dpdh = bill.getString("tqq9_dpdh");
|
||||
String szkf = null;
|
||||
DynamicObject tqq9_sskf = bill.getDynamicObject("tqq9_sskf");
|
||||
if(tqq9_sskf != null){
|
||||
tqq9_sskf = BusinessDataServiceHelper.loadSingle(tqq9_sskf.getPkValue(), "bd_operator");
|
||||
DynamicObject user = tqq9_sskf.getDynamicObject("operatorid");
|
||||
if(user != null){
|
||||
user = BusinessDataServiceHelper.loadSingle(user.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
szkf = user.getString("tqq9_fwuserid");
|
||||
}
|
||||
}
|
||||
String szxs = null;
|
||||
DynamicObject tqq9_ssxs = bill.getDynamicObject("tqq9_ssxs");
|
||||
if(tqq9_ssxs != null){
|
||||
tqq9_ssxs = BusinessDataServiceHelper.loadSingle(tqq9_ssxs.getPkValue(), "bd_operator");
|
||||
DynamicObject user = tqq9_ssxs.getDynamicObject("operatorid");
|
||||
if(user != null){
|
||||
user = BusinessDataServiceHelper.loadSingle(user.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
szxs = user.getString("tqq9_fwuserid");
|
||||
}
|
||||
}
|
||||
String shsq = bill.getString("tqq9_shsq");
|
||||
String wtyy = bill.getString("tqq9_wtyy");
|
||||
String khfptt = bill.getString("tqq9_khfptt");
|
||||
DynamicObject tqq9_sscg = bill.getDynamicObject("tqq9_sscg");
|
||||
String szcg = null;
|
||||
if(tqq9_sscg != null){
|
||||
tqq9_sscg = BusinessDataServiceHelper.loadSingle(tqq9_sscg.getPkValue(), "bd_operator");
|
||||
DynamicObject user = tqq9_sscg.getDynamicObject("operatorid");
|
||||
if(user != null){
|
||||
user = BusinessDataServiceHelper.loadSingle(user.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
szcg = user.getString("tqq9_fwuserid");
|
||||
}
|
||||
}
|
||||
|
||||
String rkck = null;
|
||||
|
||||
JSONObject detail1 = new JSONObject();
|
||||
JSONArray recordsArr1 = new JSONArray();
|
||||
DynamicObjectCollection billentries = bill.getDynamicObjectCollection("billentry");
|
||||
for (DynamicObject billentry : billentries) {
|
||||
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");
|
||||
String ggxh = masterid.getString("modelnum");
|
||||
DynamicObject tqq9_brand = masterid.getDynamicObject("tqq9_brand");
|
||||
String pp = null;
|
||||
if(tqq9_brand != null){
|
||||
pp = tqq9_brand.getString("name");
|
||||
}
|
||||
String jldw = null;
|
||||
DynamicObject unit = billentry.getDynamicObject("unit");
|
||||
if(unit != null){
|
||||
jldw = unit.getString("name");
|
||||
}
|
||||
BigDecimal sl = billentry.getBigDecimal("qty");
|
||||
BigDecimal bhsdj = billentry.getBigDecimal("qty");
|
||||
BigDecimal je = billentry.getBigDecimal("amount");
|
||||
int sfzp = 1;
|
||||
boolean ispresent = billentry.getBoolean("ispresent");
|
||||
if(ispresent){
|
||||
sfzp = 0;
|
||||
}
|
||||
|
||||
JSONObject e1 = new JSONObject();
|
||||
e1.put("fieldName", "wlbm");
|
||||
e1.put("fieldValue", wlbm);
|
||||
JSONObject e12 = new JSONObject();
|
||||
e12.put("fieldName", "wlmc");
|
||||
e12.put("fieldValue", wlmc);
|
||||
JSONObject e2 = new JSONObject();
|
||||
e2.put("fieldName", "pp");
|
||||
e2.put("fieldValue", pp);
|
||||
JSONObject e3 = new JSONObject();
|
||||
e3.put("fieldName", "ggxh");
|
||||
e3.put("fieldValue", ggxh);
|
||||
JSONObject e4 = new JSONObject();
|
||||
e4.put("fieldName", "jldw");
|
||||
e4.put("fieldValue", jldw);
|
||||
JSONObject e5 = new JSONObject();
|
||||
e5.put("fieldName", "sl");
|
||||
e5.put("fieldValue", sl);
|
||||
JSONObject e6 = new JSONObject();
|
||||
e6.put("fieldName", "bhsdj");
|
||||
e6.put("fieldValue", bhsdj);
|
||||
JSONObject e7 = new JSONObject();
|
||||
e7.put("fieldName", "je");
|
||||
e7.put("fieldValue", je);
|
||||
JSONObject e15 = new JSONObject();
|
||||
e15.put("fieldName", "sfzp");
|
||||
e15.put("fieldValue", sfzp);
|
||||
|
||||
List<JSONObject> elist = Arrays.asList(e1,e12,e2,e3,e4,e5,e6,e7,//e8,e9,e10,e11,e13,e14
|
||||
e15);
|
||||
JSONArray recordsArr = new JSONArray();
|
||||
for (JSONObject obj : elist) {
|
||||
recordsArr.add(obj);
|
||||
}
|
||||
|
||||
JSONObject recordObj = new JSONObject();
|
||||
recordObj.put("recordOrder", 0);
|
||||
recordObj.put("workflowRequestTableFields", recordsArr);
|
||||
recordsArr1.add(recordObj);
|
||||
|
||||
//入库仓库
|
||||
DynamicObject warehouse = billentry.getDynamicObject("warehouse");
|
||||
if(warehouse != null){
|
||||
rkck = warehouse.getString("number");
|
||||
}
|
||||
}
|
||||
detail1.put("tableDBName", "formtable_main_110_dt2");
|
||||
detail1.put("workflowRequestTableRecords", recordsArr1);
|
||||
JSONArray detailRootArr = new JSONArray();
|
||||
detailRootArr.add(detail1);
|
||||
|
||||
//单头赋值
|
||||
JSONObject m1 = new JSONObject();
|
||||
m1.put("fieldName", "KDBillType");
|
||||
m1.put("fieldValue", "im_otherinbill");
|
||||
JSONObject m2 = new JSONObject();
|
||||
m2.put("fieldName", "lcbh");
|
||||
m2.put("fieldValue", billno);
|
||||
JSONObject m3 = new JSONObject();
|
||||
m3.put("fieldName", "sqr");
|
||||
m3.put("fieldValue", sqr);
|
||||
JSONObject m4 = new JSONObject();
|
||||
m4.put("fieldName", "bm");
|
||||
m4.put("fieldValue", bm);
|
||||
JSONObject m5 = new JSONObject();
|
||||
m5.put("fieldName", "sqrq");
|
||||
m5.put("fieldValue", sqrq);
|
||||
JSONObject m6 = new JSONObject();
|
||||
m6.put("fieldName", "ywgz");
|
||||
m6.put("fieldValue", ywgz);
|
||||
JSONObject m7 = new JSONObject();
|
||||
m7.put("fieldName", "crk");
|
||||
m7.put("fieldValue", crk);
|
||||
JSONObject m8 = new JSONObject();
|
||||
m8.put("fieldName", "ywlxxsm");
|
||||
m8.put("fieldValue", ywlxxsm);
|
||||
JSONObject m9 = new JSONObject();
|
||||
m9.put("fieldName", "ywlxrk");
|
||||
m9.put("fieldValue", ywlxrk);
|
||||
JSONObject m13 = new JSONObject();
|
||||
m13.put("fieldName", "drzz");
|
||||
m13.put("fieldValue", drzz);
|
||||
JSONObject m14 = new JSONObject();
|
||||
m14.put("fieldName", "jsr");
|
||||
m14.put("fieldValue", jsr);
|
||||
JSONObject m15 = new JSONObject();
|
||||
m15.put("fieldName", "kgy");
|
||||
m15.put("fieldValue", kgy);
|
||||
JSONObject m16 = new JSONObject();
|
||||
m16.put("fieldName", "sqyybz");
|
||||
m16.put("fieldValue", sqyybz);
|
||||
JSONObject m17 = new JSONObject();
|
||||
m17.put("fieldName", "hzje");
|
||||
m17.put("fieldValue", hzje);
|
||||
JSONObject m18 = new JSONObject();
|
||||
m18.put("fieldName", "shdh");
|
||||
m18.put("fieldValue", shdh);
|
||||
JSONObject m19 = new JSONObject();
|
||||
m19.put("fieldName", "dyxsddh");
|
||||
m19.put("fieldValue", dyxsddh);
|
||||
JSONObject m20 = new JSONObject();
|
||||
m20.put("fieldName", "dpdh");
|
||||
m20.put("fieldValue", dpdh);
|
||||
JSONObject m21 = new JSONObject();
|
||||
m21.put("fieldName", "szkf");
|
||||
m21.put("fieldValue", szkf);
|
||||
JSONObject m22 = new JSONObject();
|
||||
m22.put("fieldName", "szxs");
|
||||
m22.put("fieldValue", szxs);
|
||||
JSONObject m23 = new JSONObject();
|
||||
m23.put("fieldName", "shsq");
|
||||
m23.put("fieldValue", shsq);
|
||||
JSONObject m24 = new JSONObject();
|
||||
m24.put("fieldName", "wtyy");
|
||||
m24.put("fieldValue", wtyy);
|
||||
JSONObject m25 = new JSONObject();
|
||||
m25.put("fieldName", "khfptt");
|
||||
m25.put("fieldValue", khfptt);
|
||||
JSONObject m26 = new JSONObject();
|
||||
m26.put("fieldName", "rkck");
|
||||
m26.put("fieldValue", rkck);
|
||||
JSONObject m27 = new JSONObject();
|
||||
m27.put("fieldName", "szcg");
|
||||
m27.put("fieldValue", szcg);
|
||||
|
||||
List<JSONObject> mlist = new ArrayList<>(Arrays.asList(m1,m2,m3,m4,m5,m6,m7,m8,m9,m13,m14,m15,m16,m17,m18,m19,m20,m21,
|
||||
m22,m23,m24,m25,m26,m27));
|
||||
if (ywlxrk == 2){
|
||||
int dblx = 0;
|
||||
String tqq9_dblx = bill.getString("tqq9_dblx");
|
||||
if("A".equals(tqq9_dblx)){
|
||||
dblx = 0;
|
||||
}else{
|
||||
dblx = 1;
|
||||
}
|
||||
JSONObject m10 = new JSONObject();
|
||||
m10.put("fieldName", "dblx");
|
||||
m10.put("fieldValue", dblx);
|
||||
int dbfl = 0;
|
||||
String tqq9_dbrk = bill.getString("tqq9_dbrk");
|
||||
if("A".equals(tqq9_dbrk)){
|
||||
dbfl = 0;
|
||||
}else if("B".equals(tqq9_dbrk)){
|
||||
dbfl = 1;
|
||||
}else if("C".equals(tqq9_dbrk)){
|
||||
dbfl = 2;
|
||||
}else if("F".equals(tqq9_dbrk)){
|
||||
dbfl = 4;
|
||||
}else if("G".equals(tqq9_dbrk)){
|
||||
dbfl = 5;
|
||||
}else if("QT".equals(tqq9_dbrk)){
|
||||
dbfl = 6;
|
||||
}
|
||||
JSONObject m11 = new JSONObject();
|
||||
m11.put("fieldName", "dbfl");
|
||||
m11.put("fieldValue", dbfl);
|
||||
mlist.add(m10);
|
||||
mlist.add(m11);
|
||||
}
|
||||
JSONArray mainArr = new JSONArray();
|
||||
for (JSONObject obj : mlist) {
|
||||
mainArr.add(obj);
|
||||
}
|
||||
String fw_wfid_xzcgdd = ConfigUtils.getThirdConfigByNumber("FW_WFID_XZCRKD");
|
||||
FWRestfulUtils fwRestfulUtils = new FWRestfulUtils();
|
||||
//如果单据上纯在泛微流程id,重新提交调用泛微提交接口,如果没有泛微流程id,就调用新增接口
|
||||
String resultStr = fwRestfulUtils.doBillAction(mainArr, detailRootArr, "入库单流程", fw_wfid_xzcgdd, billno, tqq9_fwrequestid);
|
||||
return resultStr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 其他出库单推送泛微
|
||||
* @param bill
|
||||
* @return
|
||||
*/
|
||||
public static String pushFwOtherOut(DynamicObject bill) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String billno = bill.getString("billno");
|
||||
String tqq9_fwrequestid = bill.getString("tqq9_fwrequestid");//泛微流程ID
|
||||
DynamicObject creator = bill.getDynamicObject("creator");
|
||||
creator = BusinessDataServiceHelper.loadSingle(creator.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
String sqr = creator.getString("tqq9_fwuserid");
|
||||
String bm = null;
|
||||
DynamicObject tqq9_dept = bill.getDynamicObject("tqq9_dept");
|
||||
if(tqq9_dept != null){
|
||||
String number = tqq9_dept.getString("number");
|
||||
bm = FWOrgMappingUtils.getFwOrgNumberByKdOrgNumber(number);
|
||||
}
|
||||
Date biztime = bill.getDate("biztime");
|
||||
String sqrq = sdf.format(biztime);
|
||||
DynamicObject org = bill.getDynamicObject("org");
|
||||
String orgNumber = org.getString("number");
|
||||
String ywgz = FWOrgMappingUtils.getFwOrgNumberByKdOrgNumber(orgNumber);
|
||||
int crk = 0;
|
||||
DynamicObject biztype = bill.getDynamicObject("biztype");
|
||||
String biztypeNumber = biztype.getString("number");
|
||||
int ywlxck = 1;
|
||||
String ywlxxsm = "其他入库";
|
||||
if("351".equals(biztypeNumber)){
|
||||
ywlxck = 0;
|
||||
ywlxxsm = "盘亏入库";
|
||||
}else if("355".equals(biztypeNumber)){
|
||||
ywlxck = 1;
|
||||
ywlxxsm = "其他出库";
|
||||
}else if("612".equals(biztypeNumber)){
|
||||
ywlxck = 2;
|
||||
ywlxxsm = "调拨出库";
|
||||
}else if("613".equals(biztypeNumber)){
|
||||
ywlxck = 3;
|
||||
ywlxxsm = "礼品领用";
|
||||
}else if("614".equals(biztypeNumber)){
|
||||
ywlxck = 4;
|
||||
ywlxxsm = "展会领用";
|
||||
}else if("615".equals(biztypeNumber)){
|
||||
ywlxck = 5;
|
||||
ywlxxsm = "拍照领用";
|
||||
}else if("616".equals(biztypeNumber)){
|
||||
ywlxck = 6;
|
||||
ywlxxsm = "样品领用";
|
||||
}else if("617".equals(biztypeNumber)){
|
||||
ywlxck = 7;
|
||||
ywlxxsm = "报损出库";
|
||||
}
|
||||
String dczz = ywgz;
|
||||
String drzz = ywgz;
|
||||
DynamicObject tqq9_drck2 = bill.getDynamicObject("tqq9_drck2");
|
||||
if(tqq9_drck2 != null){
|
||||
String number = tqq9_drck2.getString("number");
|
||||
drzz = FWOrgMappingUtils.getFwOrgNumberByKdOrgNumber(number);
|
||||
}
|
||||
String jsr = null;
|
||||
DynamicObject tqq9_jsr = bill.getDynamicObject("tqq9_jsr");
|
||||
if(tqq9_jsr != null){
|
||||
tqq9_jsr = BusinessDataServiceHelper.loadSingle(tqq9_jsr.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
jsr = tqq9_jsr.getString("tqq9_fwuserid");
|
||||
}
|
||||
String kgy = null;
|
||||
DynamicObject operator = bill.getDynamicObject("operator");
|
||||
if(operator != null){
|
||||
operator = BusinessDataServiceHelper.loadSingle(operator.getPkValue(), "bd_operator");
|
||||
DynamicObject user = operator.getDynamicObject("operatorid");
|
||||
if(user != null){
|
||||
user = BusinessDataServiceHelper.loadSingle(user.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
kgy = user.getString("tqq9_fwuserid");
|
||||
}
|
||||
}
|
||||
String sqyybz = bill.getString("comment");
|
||||
BigDecimal hzje = bill.getBigDecimal("tqq9_hzje");
|
||||
String shdh = null;
|
||||
DynamicObject tqq9_returnapply = bill.getDynamicObject("tqq9_returnapply");
|
||||
if(tqq9_returnapply != null){
|
||||
shdh = tqq9_returnapply.getString("billno");
|
||||
}
|
||||
String dyxsddh = null;
|
||||
DynamicObject tqq9_saleorderbill = bill.getDynamicObject("tqq9_saleorderbill");
|
||||
if(tqq9_saleorderbill != null){
|
||||
dyxsddh = tqq9_saleorderbill.getString("billno");
|
||||
}
|
||||
String dpdh = bill.getString("tqq9_dpdh");
|
||||
String szkf = null;
|
||||
DynamicObject tqq9_sskf = bill.getDynamicObject("tqq9_sskf");
|
||||
if(tqq9_sskf != null){
|
||||
tqq9_sskf = BusinessDataServiceHelper.loadSingle(tqq9_sskf.getPkValue(), "bd_operator");
|
||||
DynamicObject user = tqq9_sskf.getDynamicObject("operatorid");
|
||||
if(user != null){
|
||||
user = BusinessDataServiceHelper.loadSingle(user.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
szkf = user.getString("tqq9_fwuserid");
|
||||
}
|
||||
}
|
||||
String szxs = null;
|
||||
DynamicObject tqq9_ssxs = bill.getDynamicObject("tqq9_ssxs");
|
||||
if(tqq9_ssxs != null){
|
||||
tqq9_ssxs = BusinessDataServiceHelper.loadSingle(tqq9_ssxs.getPkValue(), "bd_operator");
|
||||
DynamicObject user = tqq9_ssxs.getDynamicObject("operatorid");
|
||||
if(user != null){
|
||||
user = BusinessDataServiceHelper.loadSingle(user.getPkValue(), "bos_user", "tqq9_fwuserid,id,number");
|
||||
szxs = user.getString("tqq9_fwuserid");
|
||||
}
|
||||
}
|
||||
String shsq = bill.getString("tqq9_shsq");
|
||||
String wtyy = bill.getString("tqq9_wtyy");
|
||||
DynamicObject tqq9_kufptt = bill.getDynamicObject("tqq9_kufptt");
|
||||
String khfptt = null;
|
||||
if(tqq9_kufptt != null){
|
||||
khfptt = tqq9_kufptt.getString("number");
|
||||
}
|
||||
String ckck = null;
|
||||
|
||||
JSONObject detail1 = new JSONObject();
|
||||
JSONArray recordsArr1 = new JSONArray();
|
||||
DynamicObjectCollection billentries = bill.getDynamicObjectCollection("billentry");
|
||||
for (DynamicObject billentry : billentries) {
|
||||
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");
|
||||
String ggxh = masterid.getString("modelnum");
|
||||
DynamicObject tqq9_brand = masterid.getDynamicObject("tqq9_brand");
|
||||
String pp = null;
|
||||
if(tqq9_brand != null){
|
||||
pp = tqq9_brand.getString("name");
|
||||
}
|
||||
String jldw = null;
|
||||
DynamicObject unit = billentry.getDynamicObject("unit");
|
||||
if(unit != null){
|
||||
jldw = unit.getString("name");
|
||||
}
|
||||
BigDecimal sl = billentry.getBigDecimal("qty");
|
||||
BigDecimal bhsdj = billentry.getBigDecimal("qty");
|
||||
BigDecimal je = billentry.getBigDecimal("amount");
|
||||
Date producedate = billentry.getDate("producedate");
|
||||
String scrq = sdf.format(producedate);
|
||||
Date expirydate = billentry.getDate("expirydate");
|
||||
String yxjzsj = sdf.format(expirydate);
|
||||
String drph = null;
|
||||
DynamicObject lot = billentry.getDynamicObject("lot");
|
||||
if(lot != null){
|
||||
drph = lot.getString("number");
|
||||
}
|
||||
String zczh = null;
|
||||
DynamicObject tqq9_zczh = billentry.getDynamicObject("tqq9_zczh");
|
||||
if(tqq9_zczh != null){
|
||||
zczh = tqq9_zczh.getString("number");
|
||||
}
|
||||
String xkzh = billentry.getString("tqq9_licenseno");
|
||||
|
||||
JSONObject e1 = new JSONObject();
|
||||
e1.put("fieldName", "wlbm");
|
||||
e1.put("fieldValue", wlbm);
|
||||
JSONObject e12 = new JSONObject();
|
||||
e12.put("fieldName", "wlmc");
|
||||
e12.put("fieldValue", wlmc);
|
||||
JSONObject e2 = new JSONObject();
|
||||
e2.put("fieldName", "pp");
|
||||
e2.put("fieldValue", pp);
|
||||
JSONObject e3 = new JSONObject();
|
||||
e3.put("fieldName", "ggxh");
|
||||
e3.put("fieldValue", ggxh);
|
||||
JSONObject e4 = new JSONObject();
|
||||
e4.put("fieldName", "jldw");
|
||||
e4.put("fieldValue", jldw);
|
||||
JSONObject e5 = new JSONObject();
|
||||
e5.put("fieldName", "sl");
|
||||
e5.put("fieldValue", sl);
|
||||
JSONObject e6 = new JSONObject();
|
||||
e6.put("fieldName", "bhsdj");
|
||||
e6.put("fieldValue", bhsdj);
|
||||
JSONObject e7 = new JSONObject();
|
||||
e7.put("fieldName", "je");
|
||||
e7.put("fieldValue", je);
|
||||
JSONObject e8 = new JSONObject();
|
||||
e8.put("fieldName", "scrq");
|
||||
e8.put("fieldValue", scrq);
|
||||
JSONObject e9 = new JSONObject();
|
||||
e9.put("fieldName", "yxjzsj");
|
||||
e9.put("fieldValue", yxjzsj);
|
||||
JSONObject e10 = new JSONObject();
|
||||
e10.put("fieldName", "ckph");
|
||||
e10.put("fieldValue", drph);
|
||||
JSONObject e11 = new JSONObject();
|
||||
e11.put("fieldName", "drph");
|
||||
e11.put("fieldValue", drph);
|
||||
JSONObject e13 = new JSONObject();
|
||||
e13.put("fieldName", "zczh");
|
||||
e13.put("fieldValue", zczh);
|
||||
JSONObject e14 = new JSONObject();
|
||||
e14.put("fieldName", "xkzh");
|
||||
e14.put("fieldValue", xkzh);
|
||||
|
||||
List<JSONObject> elist = Arrays.asList(e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14);
|
||||
JSONArray recordsArr = new JSONArray();
|
||||
for (JSONObject obj : elist) {
|
||||
recordsArr.add(obj);
|
||||
}
|
||||
|
||||
JSONObject recordObj = new JSONObject();
|
||||
recordObj.put("recordOrder", 0);
|
||||
recordObj.put("workflowRequestTableFields", recordsArr);
|
||||
recordsArr1.add(recordObj);
|
||||
|
||||
//出库仓库
|
||||
DynamicObject warehouse = billentry.getDynamicObject("warehouse");
|
||||
if(warehouse != null){
|
||||
ckck = warehouse.getString("number");
|
||||
}
|
||||
}
|
||||
detail1.put("tableDBName", "formtable_main_110_dt1");
|
||||
detail1.put("workflowRequestTableRecords", recordsArr1);
|
||||
JSONArray detailRootArr = new JSONArray();
|
||||
detailRootArr.add(detail1);
|
||||
|
||||
//单头赋值
|
||||
JSONObject m1 = new JSONObject();
|
||||
m1.put("fieldName", "KDBillType");
|
||||
m1.put("fieldValue", "im_otheroutbill");
|
||||
JSONObject m2 = new JSONObject();
|
||||
m2.put("fieldName", "lcbh");
|
||||
m2.put("fieldValue", billno);
|
||||
JSONObject m3 = new JSONObject();
|
||||
m3.put("fieldName", "sqr");
|
||||
m3.put("fieldValue", sqr);
|
||||
JSONObject m4 = new JSONObject();
|
||||
m4.put("fieldName", "bm");
|
||||
m4.put("fieldValue", bm);
|
||||
JSONObject m5 = new JSONObject();
|
||||
m5.put("fieldName", "sqrq");
|
||||
m5.put("fieldValue", sqrq);
|
||||
JSONObject m6 = new JSONObject();
|
||||
m6.put("fieldName", "ywgz");
|
||||
m6.put("fieldValue", ywgz);
|
||||
JSONObject m7 = new JSONObject();
|
||||
m7.put("fieldName", "crk");
|
||||
m7.put("fieldValue", crk);
|
||||
JSONObject m8 = new JSONObject();
|
||||
m8.put("fieldName", "ywlxxsm");
|
||||
m8.put("fieldValue", ywlxxsm);
|
||||
JSONObject m9 = new JSONObject();
|
||||
m9.put("fieldName", "ywlxck");
|
||||
m9.put("fieldValue", ywlxck);
|
||||
JSONObject m12 = new JSONObject();
|
||||
m12.put("fieldName", "dczz");
|
||||
m12.put("fieldValue", dczz);
|
||||
JSONObject m13 = new JSONObject();
|
||||
m13.put("fieldName", "drzz");
|
||||
m13.put("fieldValue", drzz);
|
||||
JSONObject m14 = new JSONObject();
|
||||
m14.put("fieldName", "jsr");
|
||||
m14.put("fieldValue", jsr);
|
||||
JSONObject m15 = new JSONObject();
|
||||
m15.put("fieldName", "kgy");
|
||||
m15.put("fieldValue", kgy);
|
||||
JSONObject m16 = new JSONObject();
|
||||
m16.put("fieldName", "sqyybz");
|
||||
m16.put("fieldValue", sqyybz);
|
||||
JSONObject m17 = new JSONObject();
|
||||
m17.put("fieldName", "hzje");
|
||||
m17.put("fieldValue", hzje);
|
||||
JSONObject m18 = new JSONObject();
|
||||
m18.put("fieldName", "shdh");
|
||||
m18.put("fieldValue", shdh);
|
||||
JSONObject m19 = new JSONObject();
|
||||
m19.put("fieldName", "dyxsddh");
|
||||
m19.put("fieldValue", dyxsddh);
|
||||
JSONObject m20 = new JSONObject();
|
||||
m20.put("fieldName", "dpdh");
|
||||
m20.put("fieldValue", dpdh);
|
||||
JSONObject m21 = new JSONObject();
|
||||
m21.put("fieldName", "szkf");
|
||||
m21.put("fieldValue", szkf);
|
||||
JSONObject m22 = new JSONObject();
|
||||
m22.put("fieldName", "szxs");
|
||||
m22.put("fieldValue", szxs);
|
||||
JSONObject m23 = new JSONObject();
|
||||
m23.put("fieldName", "shsq");
|
||||
m23.put("fieldValue", shsq);
|
||||
JSONObject m24 = new JSONObject();
|
||||
m24.put("fieldName", "wtyy");
|
||||
m24.put("fieldValue", wtyy);
|
||||
JSONObject m25 = new JSONObject();
|
||||
m25.put("fieldName", "khfptt");
|
||||
m25.put("fieldValue", khfptt);
|
||||
JSONObject m26 = new JSONObject();
|
||||
m26.put("fieldName", "ckck");
|
||||
m26.put("fieldValue", ckck);
|
||||
|
||||
List<JSONObject> mlist = new ArrayList<>(Arrays.asList(m1,m2,m3,m4,
|
||||
m5,m6,m7,m8,m9,m12,m13,m14,m15,m16,m17,m18,m19,m20,m21,m22,m23,m24,m25,m26));
|
||||
if (ywlxck == 2){
|
||||
int dblx = 0;
|
||||
String tqq9_dblx = bill.getString("tqq9_dblxqtckd");
|
||||
if("A".equals(tqq9_dblx)){
|
||||
dblx = 0;
|
||||
}else{
|
||||
dblx = 1;
|
||||
}
|
||||
int dbfl = 0;
|
||||
String tqq9_dbck = bill.getString("tqq9_dbck");
|
||||
if("A".equals(tqq9_dbck)){
|
||||
dbfl = 0;
|
||||
}else if("B".equals(tqq9_dbck)){
|
||||
dbfl = 1;
|
||||
}else if("C".equals(tqq9_dbck)){
|
||||
dbfl = 2;
|
||||
}else if("F".equals(tqq9_dbck)){
|
||||
dbfl = 4;
|
||||
}else if("G".equals(tqq9_dbck)){
|
||||
dbfl = 5;
|
||||
}else if("QT".equals(tqq9_dbck)){
|
||||
dbfl = 6;
|
||||
}
|
||||
int shlx = 0;
|
||||
String tqq9_shlx = bill.getString("tqq9_shlx");
|
||||
if("A".equals(tqq9_shlx)){
|
||||
shlx = 0;
|
||||
}else if("B".equals(tqq9_shlx)){
|
||||
shlx = 1;
|
||||
}else if("C".equals(tqq9_shlx)){
|
||||
shlx = 3;
|
||||
}else if("D".equals(tqq9_shlx)){
|
||||
shlx = 4;
|
||||
}else if("E".equals(tqq9_shlx)){
|
||||
shlx = 5;
|
||||
}
|
||||
JSONObject m10 = new JSONObject();
|
||||
m10.put("fieldName", "dblx");
|
||||
m10.put("fieldValue", dblx);
|
||||
JSONObject m11 = new JSONObject();
|
||||
m11.put("fieldName", "dbfl");
|
||||
m11.put("fieldValue", dbfl);
|
||||
JSONObject m29 = new JSONObject();
|
||||
m29.put("fieldName", "shlx");
|
||||
m29.put("fieldValue", shlx);
|
||||
|
||||
mlist.add(m10);
|
||||
mlist.add(m11);
|
||||
mlist.add(m29);
|
||||
}else if(ywlxck == 0){
|
||||
//盘亏出库
|
||||
int pkyy = 0;
|
||||
String tqq9_pkyy = bill.getString("tqq9_pkyy");
|
||||
if("A".equals(tqq9_pkyy)){
|
||||
pkyy = 0;
|
||||
}else if("B".equals(tqq9_pkyy)){
|
||||
pkyy = 1;
|
||||
}else if("C".equals(tqq9_pkyy)){
|
||||
pkyy = 2;
|
||||
}
|
||||
String pkzrr = null;
|
||||
DynamicObject tqq9_zrr = bill.getDynamicObject("tqq9_zrr");
|
||||
if(tqq9_zrr != null){
|
||||
tqq9_zrr = BusinessDataServiceHelper.loadSingle(tqq9_zrr.getPkValue(), "bos_user","id,tqq9_fwuserid");
|
||||
pkzrr = tqq9_zrr.getString("tqq9_fwuserid");
|
||||
}
|
||||
JSONObject m27 = new JSONObject();
|
||||
m27.put("fieldName", "pkyy");
|
||||
m27.put("fieldValue", pkyy);
|
||||
JSONObject m28 = new JSONObject();
|
||||
m28.put("fieldName", "pkzrr");
|
||||
m28.put("fieldValue", pkzrr);
|
||||
mlist.add(m27);
|
||||
mlist.add(m28);
|
||||
}else if(ywlxck == 7){
|
||||
//报损出库
|
||||
int bsckfl = 8;
|
||||
String tqq9_bsck = bill.getString("tqq9_bsck");
|
||||
if("A".equals(tqq9_bsck)){
|
||||
bsckfl = 0;
|
||||
}else if("B".equals(tqq9_bsck)){
|
||||
bsckfl = 1;
|
||||
}else if("C".equals(tqq9_bsck)){
|
||||
bsckfl = 2;
|
||||
}else if("D".equals(tqq9_bsck)){
|
||||
bsckfl = 3;
|
||||
}else if("E".equals(tqq9_bsck)){
|
||||
bsckfl = 4;
|
||||
}else if("F".equals(tqq9_bsck)){
|
||||
bsckfl = 5;
|
||||
}else if("G".equals(tqq9_bsck)){
|
||||
bsckfl = 6;
|
||||
}else if("H".equals(tqq9_bsck)){
|
||||
bsckfl = 7;
|
||||
}else if("QT".equals(tqq9_bsck)){
|
||||
bsckfl = 8;
|
||||
}
|
||||
JSONObject m29 = new JSONObject();
|
||||
m29.put("fieldName", "bsckfl");
|
||||
m29.put("fieldValue", bsckfl);
|
||||
mlist.add(m29);
|
||||
}
|
||||
JSONArray mainArr = new JSONArray();
|
||||
for (JSONObject obj : mlist) {
|
||||
mainArr.add(obj);
|
||||
}
|
||||
String fw_wfid_xzcgdd = ConfigUtils.getThirdConfigByNumber("FW_WFID_XZCRKD");
|
||||
FWRestfulUtils fwRestfulUtils = new FWRestfulUtils();
|
||||
//如果单据上纯在泛微流程id,重新提交调用泛微提交接口,如果没有泛微流程id,就调用新增接口
|
||||
String resultStr = fwRestfulUtils.doBillAction(mainArr, detailRootArr, "出库单流程", fw_wfid_xzcgdd, billno, tqq9_fwrequestid);
|
||||
return resultStr;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue