yangle
2023-03-09 02aea9b1a44461c5f4f79d458670b2212e505a86
末道工序同步
2个文件已修改
4个文件已添加
762 ■■■■■ 已修改文件
WebAPI/Config/kdapi.config 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Controllers/ReportController.cs 257 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/HttpClient.cs 103 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/InvokeHelper.cs 264 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Utility/Util.cs 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/WebAPI.csproj 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebAPI/Config/kdapi.config
New file
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="DbId" value="6204a70eba35fc"></add>
        <add key="UserName" value="Administrator"></add>
        <add key="PassWord" value="qaz!@#123"></add>
        <add key="KDApiUrl" value="http://47.96.97.237/K3Cloud/"></add>
        <add key="DataBaseName" value="AIS20210811135644"></add>
    </appSettings>
</configuration>
WebAPI/Controllers/ReportController.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections;
@@ -115,5 +116,259 @@
        }
        //
        #region 末道工序汇报入库
        /// <summary>
        /// 末道工序汇报入库列表
        /// </summary>
        /// <param name="sWhere"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        [Route("Sc_ProcessMangement/Sc_ProcessReportList_Last")]
        [HttpGet]
        public object Sc_ProcessReportList_Last(string sWhere, string user)
        {
            try
            {
                string sql1 = "select * from h_v_Sc_ProcessReportList_Last where 1 = 1  and HLastProc='是'";
                string sql = sql1 + sWhere + "  order by hmainid desc";
                ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcessReportList_Last");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 斯莫尔 末道工序汇报列表  汇报 入库
        /// <summary>
        /// 生成 生产汇报单
        /// 同步金蝶云 工序汇报入库单 入库
        /// </summary>
        /// <param name="InterID"></param>
        /// <param name="user"></param>
        /// <param name="BillNo"></param>
        /// <param name="OrganizationID"></param>
        /// <returns></returns>
        [Route("Sc_ProcessMangement/SRM_SaveICMOReportBill")]
        [HttpGet]
        public object SRM_SaveICMOReportBill(string InterID, string user, string BillNo, string OrganizationID)
        {
            try
            {
                //获取生产汇报单最大InterID和单据号
                Int64 HInterID = DBUtility.ClsPub.CreateBillID("3711", ref DBUtility.ClsPub.sExeReturnInfo);
                string HBillNo = DBUtility.ClsPub.CreateBillCode("3711", ref DBUtility.ClsPub.sExeReturnInfo, true);
                HBillNo = "9010-" + HBillNo;
                //获取组织代码
                string OrganizationNUM = oCN.RunProcReturn("select HNumber from Xt_ORGANIZATIONS where HItemID=" + OrganizationID, "Xt_ORGANIZATIONS").Tables[0].Rows[0]["HNumber"].ToString();
                //根据工序汇报单主ID获取工序汇报入库单的数据
                DataSet ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList_LastProc where HInterID=" + InterID, "h_v_MES_StationOutBillList_LastProc");
                DataRow dr = ds.Tables[0].Rows[0];
                //保存
                oCN.BeginTran();
                DataSet DsTable = oCN.RunProcReturn($"select * from Sc_ICMOReportBillMain where HBillNo='{HBillNo}'", "Sc_ICMOReportBillMain");
                if (DsTable.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "已入库,请不要重复入库";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //生产汇报单主表
                oCN.RunProc("Insert Into Sc_ICMOReportBillMain   " +
            "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate,HBillStatus,HChecker,HCheckDate" +
            ",HYear,HPeriod,HRemark,HEmpID,HEmpNumber" +
            ",HGroupID,HDeptID,HDeptNumber" +
            ",HMainSourceBillNo,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillType" +
            ") " +
            " values('3711','3711'," + HInterID.ToString() + ",'" + HBillNo + "',getdate(),'" + user + "',getdate(),2,'" + user + "',getdate()" +
            ",DATENAME(YEAR,GETDATE()),"+DateTime.Now.Month+",'','" + dr["HEmpID"].ToString() + "','" + dr["操作员代码"].ToString() +
            "','" + dr["HGroupID"].ToString() + "',0,''" +
            ",'" + BillNo.ToString() + "'," + InterID.ToString() + ", 0,'3791'" +
            ") ");
                //生产汇报单子表
                oCN.RunProc("Insert into Sc_ICMOReportBillSub " +
                      " (HInterID,HEntryID,HMaterID,HMaterNumber" +
                      ",HQty,HUnitID,HUnitNumber,HTimes,HSourceID" +
                      ",HQtyMust,HWorkerID,HWorkerNumber,HBadCount,HWasterQty," +
                      "HCloseMan,HCloseType,HRemark," +
                      "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
                      ",HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo" +
                      ",HICMOInterID,HICMOBillNo,HBarCode" +
                      ") values("
                      + HInterID.ToString() + ",1," + dr["HMaterID"].ToString() + ",'" + dr["产品代码"].ToString() + "'" +
                      "," + dr["合格数量"].ToString() + ",0,'',0,0" +
                      "," + dr["接收数量"].ToString() + "," + dr["HEmpID"].ToString() + ",'" + dr["操作员代码"].ToString() + "'," + dr["不良数量"].ToString() + "," + dr["报废数量"].ToString() +
                      ",'',0,''" +
                      "," + InterID.ToString() + ",0,'" + BillNo.ToString() + "','3791',0,0" +
                      ",0,0,''" +
                      "," + dr["HICMOInterID"].ToString() + ",'" + dr["任务单"].ToString() + "',''" +
                      ") ");
                //同步金蝶
                //访问金蝶
                var loginRet = InvokeHelper.Login();
                var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
                if (isSuccess == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "操作失败,金蝶账号登录异常。" + loginRet;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //根据任务单查找到金蝶的生产订单
                DataSet ds1 = oCN.RunProcReturn("select * from  h_v_TOERP_StationOutBillList_LastProc_SMR where 单据号='" + dr["单据号"].ToString()+"'" , "h_v_TOERP_StationOutBillList_LastProc_SMR");
                if (ds1.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "操作失败,通过出站单查不到生产订单数据";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DataRow dr1 = ds1.Tables[0].Rows[0];
                JObject model = new JObject();
                model.Add("FBillType", new JObject() { ["Fnumber"] = "SCHBD01_SYS" }); //单据类型生产汇报“SCHBD02_SYS” 入库汇报SCHBD01_SYS
                model.Add("FPrdOrgId", new JObject() { ["Fnumber"] = dr1["FPrdOrgNUMBER"].ToString() }); //生产组织1
                model.Add("FDate", DateTime.Now.ToString("yyyy-MM-dd")); //单据日期1
                model.Add("FBillNo", HBillNo);
                model.Add("F_RCZU_LZKH", dr1["工序流转卡号"].ToString());
                JArray Fentity = new JArray();
                foreach (DataRow item in ds.Tables[0].Rows)
                {
                    JObject FentityModel = new JObject();
                    FentityModel.Add("FIsNew", false);//  源单类型
                    FentityModel.Add("FReportType", new JObject() { ["Fnumber"] = dr1["FREPORTTYPENUMBER"].ToString() });//生产汇报类型
                    FentityModel.Add("FSrcBillType", "PRD_MO");//  源单类型
                    FentityModel.Add("FProductType", "1");//  产品类型
                    FentityModel.Add("FSrcBillNo", item["任务单"].ToString());//  源单编号
                    FentityModel.Add("FSrcInterId", dr1["FMOID"].ToString());//  源单内码
                    FentityModel.Add("FSrcEntryId", dr1["FMOENTRYID"].ToString());//  源单分录内码、
                    FentityModel.Add("FSRCENTRYSEQ", dr1["FMOENTRYSEQ"].ToString());//  源单分录行号
                    FentityModel.Add("FUNITID", new JObject() { ["Fnumber"] = dr1["FUNITNUMBER"].ToString() });//单位
                    FentityModel.Add("FTimeUnitId", "1");//时间单位
                    FentityModel.Add("FWorkshipId", new JObject() { ["Fnumber"] = dr1["FWorkShopNUM"].ToString() }); //  生产车间
                    FentityModel.Add("FStandHourUnitId", "3600"); // 单位标准工时单位
                    FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = dr1["FMaterialNUM"].ToString() }); // 物料编码
                    FentityModel.Add("FMoEntrySeq", dr1["FMOENTRYSEQ"].ToString());//生产订单行号
                    FentityModel.Add("FMoId", dr1["HICMOInterID"].ToString());//生产订单内码
                    FentityModel.Add("FFinishQty", item["接收数量"].ToString());//完成数量1
                    FentityModel.Add("FQuaQty", item["合格数量"].ToString());//合格数量1FFailQty
                    FentityModel.Add("FFailQty", item["不良数量"].ToString());//不合格数量
                    FentityModel.Add("FStockInOrgId ", new JObject() { ["Fnumber"] = OrganizationNUM });// 入库组织
                    FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = dr1["FStockNUM"].ToString() }); // 仓库
                    FentityModel.Add("FMOBILLNO", dr1["FMOBILLNO"].ToString());//
                    FentityModel.Add("FMOENTRYID", dr1["FMOENTRYID"].ToString());//
                    FentityModel.Add("FOwnerTypeId", dr1["FOWNERTYPEID"].ToString()); //货主类型:FOwnerTypeId(必填项)
                    FentityModel.Add("FOwnerId", new JObject() { ["Fnumber"] = dr1["FOwnerNumber"].ToString() }); //货主:FOwnerId(必填项)
                    FentityModel.Add("FBomId", new JObject() { ["F    number"] = dr1["FBOMNUM"].ToString() }); //BOM版本:FBomId(必填项)
                    FentityModel.Add("FCostRate", dr1["FCostRate"].ToString());// 成本权重
                    FentityModel.Add("FISBACKFLUSH", dr1["FISBACKFLUSH"].ToString() == "1" ? true : false);// 倒冲领料
                    FentityModel.Add("FMOMAINENTRYID", dr1["FMOENTRYID"].ToString());//
                    FentityModel.Add("FLot", new JObject() { ["FNumber"] = dr1["FBATCHNO"].ToString() }); //批号
                    //FentityModel.Add("F_RCZU_LZKH", dr1["工序流转卡号"].ToString());//  工序流转卡
                    JArray Fentity2 = new JArray();
                    JObject FentityModel2 = new JObject();
                    FentityModel2.Add("FEntity_Link_FFlowId", "f6e6eec3-5267-4f02-8593-b633da508a72");
                    FentityModel2.Add("FEntity_Link_FFlowLineId", "PRD_MO2MORPT");
                    FentityModel2.Add("FEntity_Link_FRuleId", "3");
                    FentityModel2.Add("FEntity_Link_FSTableId", "0");
                    FentityModel2.Add("FEntity_Link_FSTableName", "T_PRD_MOENTRY");
                    FentityModel2.Add("FEntity_Link_FSBillId", dr1["FMOID"].ToString());
                    FentityModel2.Add("FEntity_Link_FSId", dr1["FMOENTRYID"].ToString());
                    FentityModel2.Add("FEntity_Link_FBaseQuaQtyOld", item["合格数量"].ToString());
                    FentityModel2.Add("FEntity_Link_FBaseQuaQty", item["合格数量"].ToString());
                    Fentity2.Add(FentityModel2);
                    FentityModel.Add("FEntity_Link", Fentity2);
                    Fentity.Add(FentityModel);
                }
                model.Add("FEntity", Fentity); //明细信息
                JObject jsonRoot = new JObject()
                {
                    ["Creator"] = "",
                    ["NeedUpDateFields"] = new JArray(),
                    ["NeedReturnFields"] = new JArray(),
                    ["IsDeleteEntry"] = "false",
                    ["SubSystemId"] = "",
                    ["IsVerifyBaseDataField"] = "false",
                    //["IsAutoSubmitAndAudit"] = true,//自动调用提交和审核功能
                    ["Model"] = model
                };
                string result = InvokeHelper.Save("PRD_MORPT", JsonConvert.SerializeObject(jsonRoot));//保存
                //判断保存是否成功
                if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                {
                    LogService.Write("工序汇报单入库错误jsonRoot:" + jsonRoot);
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = $"生产汇报入库单同步金蝶云失败!单号:{dr["单据号"].ToString()}" + result;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //提交审核
                string result1 = string.Empty;
                string result2 = string.Empty;
                var fID = JObject.Parse(result)["Result"]["Id"].ToString();
                var fBillNo = JObject.Parse(result)["Result"]["Number"].ToString();
                var json = new
                {
                    Ids = fID,
                };
                result1 = InvokeHelper.Submit("PRD_MORPT", JsonConvert.SerializeObject(json));//提交
                result2 = InvokeHelper.Audit("PRD_MORPT", JsonConvert.SerializeObject(json));//提交
                if (JObject.Parse(result1)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
                {
                    oCN.RollBack();
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = $"生产汇报单单号:{fBillNo},提交失败" + result;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.RunProc("update Sc_StationOutBillMain set HRelationQty=1 where  HBillNo='" + BillNo + "'");
                oCN.Commit();
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "保存成功!";
                objJsonResult.data = 1;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
    }
}
WebAPI/HttpClient.cs
New file
@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.Threading.Tasks;
namespace WebAPI
{
    public class HttpClient
    {
        /// <summary>
        /// Seivice URL
        /// </summary>
        public string Url { get; set; }
        /// <summary>
        /// 内容
        /// </summary>
        public string Content { get; set; }
        /// <summary>
        /// Cookie,保证登录后,所有访问持有一个Cookie;
        /// </summary>
        static CookieContainer Cookie = new CookieContainer();
        /// <summary>
        /// HTTP访问
        /// </summary>
        public string SyncRequest()
        {
            HttpWebRequest httpRequest = HttpWebRequest.Create(Url) as HttpWebRequest;
            httpRequest.Method = "POST";
            httpRequest.ContentType = "application/json";
            httpRequest.CookieContainer = Cookie;
            httpRequest.Timeout = 1000 * 60 * 10;//10min
            using (Stream reqStream = httpRequest.GetRequestStream())
            {
                JObject jObj = new JObject();
                jObj.Add("format", 1);
                jObj.Add("useragent", "ApiClient");
                jObj.Add("rid", Guid.NewGuid().ToString().GetHashCode().ToString());
                jObj.Add("parameters", Content);
                jObj.Add("timestamp", DateTime.Now);
                jObj.Add("v", "1.0");
                string sContent = jObj.ToString();
                var bytes = UnicodeEncoding.UTF8.GetBytes(sContent);
                reqStream.Write(bytes, 0, bytes.Length);
                reqStream.Flush();
            }
            using (var repStream = httpRequest.GetResponse().GetResponseStream())
            {
                using (var reader = new StreamReader(repStream))
                {
                    return ValidateResult(reader.ReadToEnd());
                }
            }
        }
        public async Task<string> AsyncRequest()
        {
            HttpWebRequest httpRequest = WebRequest.Create(Url) as HttpWebRequest;
            httpRequest.Method = "POST";
            httpRequest.ContentType = "application/json";
            httpRequest.CookieContainer = Cookie;
            httpRequest.Timeout = 1000 * 60 * 10;//10min
            using (Stream reqStream = await httpRequest.GetRequestStreamAsync())
            {
                JObject jObj = new JObject();
                jObj.Add("format", 1);
                jObj.Add("useragent", "ApiClient");
                jObj.Add("rid", Guid.NewGuid().ToString().GetHashCode().ToString());
                jObj.Add("parameters", Content);
                jObj.Add("timestamp", DateTime.Now);
                jObj.Add("v", "1.0");
                string content = jObj.ToString();
                var bytes = Encoding.UTF8.GetBytes(content);
                reqStream.Write(bytes, 0, bytes.Length);
                reqStream.Flush();
            }
            using (var repStream = (await httpRequest.GetResponseAsync()).GetResponseStream())
            {
                using (var reader = new StreamReader(repStream))
                {
                    return ValidateResult(await reader.ReadToEndAsync());
                }
            }
        }
        private static string ValidateResult(string responseText)
        {
            if (responseText.StartsWith("response_error:"))
            {
                responseText.TrimStart("response_error:".ToCharArray());
            }
            return responseText;
        }
    }
}
WebAPI/InvokeHelper.cs
New file
@@ -0,0 +1,264 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using WebAPI.Utility;
namespace WebAPI
{
    public static class InvokeHelper
    {
        private static string CloudUrl = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "KDApiUrl");//K/3 Cloud 业务站点地址
        /// <summary>
        /// 登陆
        /// </summary>
        public static string Login()
        {
            var dbId = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "DbId");
            var useName = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "UserName");
            var pwd = Util.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "/Config/kdapi.config", "PassWord");
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc");
            List<object> Parameters = new List<object>();
            Parameters.Add(dbId);//账套标示
            Parameters.Add(useName);//用户名
            Parameters.Add(pwd);//密码
            Parameters.Add(2052);//2052代表中文
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        public static async Task<string> LoginAsync()
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc");
            List<object> Parameters = new List<object>();
            Parameters.Add("622703e117d642");//账套标示
            Parameters.Add("Administrator");//用户名
            Parameters.Add("sa@123456");//密码
            Parameters.Add(2052);//2052代表中文
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return await httpClient.AsyncRequest();
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="formId"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string Save(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        public static string BatchSave(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.BatchSave.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        public static async Task<string> SaveAsync(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return await httpClient.AsyncRequest();
        }
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="formId"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string Submit(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="formId"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string Delete(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Delete.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        public static async Task<string> DeleteAsync(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Delete.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return await httpClient.AsyncRequest();
        }
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="formId"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string Audit(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="formId"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string View(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        //反审核
        public static string UnAudit(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.UnAudit.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        //下推
        public static string Push(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Push.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        public static string Query(string formId, string content)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExecuteBillQuery.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            //Parameters.Add(formId);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
        /// <summary>
        /// 自定义
        /// </summary>
        /// <param name="key">自定义方法标识</param>
        /// <param name="args">参数</param>
        /// <returns></returns>
        public static string AbstractWebApiBusinessService(string key, List<object> args)
        {
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, key, ".common.kdsvc");
            httpClient.Content = JsonConvert.SerializeObject(args);
            return httpClient.SyncRequest();
        }
        //生产订单 执行
        public static string ExcuteOperation(string formId, string opNumber, string content)
        {
            LogService.Write("生产订单 执行,opNumber: " + opNumber + ",content:" + content);
            HttpClient httpClient = new HttpClient();
            httpClient.Url = string.Concat(CloudUrl, "Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExcuteOperation.common.kdsvc");
            List<object> Parameters = new List<object>();
            //业务对象Id
            Parameters.Add(formId);
            //操作 开工"ToStart"
            Parameters.Add(opNumber);
            //Json字串
            Parameters.Add(content);
            httpClient.Content = JsonConvert.SerializeObject(Parameters);
            return httpClient.SyncRequest();
        }
    }
}
WebAPI/Utility/Util.cs
New file
@@ -0,0 +1,124 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace WebAPI.Utility
{
    public class Util
    {
        public static string GetObjectType(object obj)
        {
            var isType = false;
            isType = obj.GetType() == typeof(string);
            if (isType)
            {
                return "string";
            }
            isType = obj.GetType() == typeof(double);
            if (isType)
            {
                return "double";
            }
            isType = obj.GetType() == typeof(long);
            if (isType)
            {
                return "long";
            }
            isType = obj.GetType() == typeof(DateTime);
            if (isType)
            {
                return "date";
            }
            isType = obj.GetType() == typeof(int);
            if (isType)
            {
                return "int";
            }
            isType = obj.GetType() == typeof(decimal);
            if (isType)
            {
                return "decimal";
            }
            return "string";
        }
        public static JObject JsonVerify(string json)
        {
            if (string.IsNullOrEmpty(json))
            {
                throw new Exception("参数不能为空");
            }
            try
            {
                return JObject.Parse(json.ToString().Replace("\r", "").Replace("\n", "").Replace("\t", ""));
            }
            catch (Exception)
            {
                throw;
            }
        }
        //public static T DeepCopy<T>(T obj)
        //{
        //    object retval;
        //    using (MemoryStream ms = new MemoryStream())
        //    {
        //        XmlSerializer xml = new XmlSerializer(typeof(T));
        //        xml.Serialize(ms, obj);
        //        ms.Seek(0, SeekOrigin.Begin);
        //        retval = xml.Deserialize(ms);
        //        ms.Close();
        //    }
        //    return (T)retval;
        //}
        public static String GetConfigKey(String configPath, String key)
        {
            Configuration ConfigurationInstance = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap()
            {
                ExeConfigFilename = configPath
            }, ConfigurationUserLevel.None);
            if (ConfigurationInstance.AppSettings.Settings[key] != null)
                return ConfigurationInstance.AppSettings.Settings[key].Value;
            else
                return string.Empty;
        }
        public static bool SetConfigKey(String configPath, String key, String vls)
        {
            try
            {
                Configuration ConfigurationInstance = ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap()
                {
                    ExeConfigFilename = configPath
                }, ConfigurationUserLevel.None);
                if (ConfigurationInstance.AppSettings.Settings[key] != null)
                    ConfigurationInstance.AppSettings.Settings[key].Value = vls;
                else
                    ConfigurationInstance.AppSettings.Settings.Add(key, vls);
                ConfigurationInstance.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection("appSettings");
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
WebAPI/WebAPI.csproj
@@ -248,6 +248,7 @@
    <Content Include="Scripts\bootstrap.js" />
    <Content Include="Scripts\bootstrap.min.js" />
    <Fakes Include="Fakes\Newtonsoft.Json.fakes" />
    <Content Include="Config\kdapi.config" />
    <None Include="Properties\PublishProfiles\API.pubxml" />
    <None Include="Properties\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
@@ -356,6 +357,8 @@
    <Compile Include="Controllers\Sc_PackUnionBillController.cs" />
    <Compile Include="Controllers\SellOutBackController.cs" />
    <Compile Include="Controllers\SellOutController.cs" />
    <Compile Include="HttpClient.cs" />
    <Compile Include="InvokeHelper.cs" />
    <Compile Include="ListModels.cs" />
    <Compile Include="Models\ClsCg_POInStockBill.cs" />
    <Compile Include="Models\GroupOrderBill.cs" />
@@ -373,6 +376,7 @@
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
      <DependentUpon>Settings.settings</DependentUpon>
    </Compile>
    <Compile Include="Utility\Util.cs" />
    <Compile Include="Web References\WebS\Reference.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>