예제 #1
0
        /// <summary> 15.配件入库单入库
        /// </summary>
        /// <param name="rationSendCode">DSN配送单号,入库状态</param>
        /// <returns>-1为失败,0为成功</returns>
        public static bool UpLoadPartPutStore(string rationSendCode)
        {
            //如果没有接入码或者sap代码,则不调用接口
            if (string.IsNullOrEmpty(GlobalStaticObj_YT.ClientID) ||
                string.IsNullOrEmpty(GlobalStaticObj_YT.SAPCode))
            {
                return true;
            }
            Utility.Log.Log.writeLineToLog("【配件入库单入库】" + rationSendCode, "接口");
            //string[] param = rationSendCode.Split(',');
            ////rationSendCode = "30457907";
            ////stateCode = "";
            //if (param.Length != 2)
            //{
            //    return false;
            //}
            //rationSendCode = param[0];
            string stateCode = "";//入库状态
            string requestType = string.IsNullOrEmpty(rationSendCode) ? "CREATE" : "UPDATE";

            ServicePointManager.ServerCertificateValidationCallback = WebServUtil.ValidateServerCertificate;

            SUPartPutStore.clientInfo clientInfo = new SUPartPutStore.clientInfo();
            clientInfo.clientID = GlobalStaticObj_YT.ClientID;
            clientInfo.serviceID = "partPutStore";
            SUPartPutStore.partPutStoreService serv = new SUPartPutStore.partPutStoreService();
            rationSendCode = Secret.Encrypt3DES_UTF8(rationSendCode, GlobalStaticObj_YT.KeySecurity_YT);
            if (!string.IsNullOrEmpty(stateCode))
            {
                stateCode = Secret.Encrypt3DES_UTF8(stateCode, GlobalStaticObj_YT.KeySecurity_YT);//加密字段
            }
            string stationCode = Secret.Encrypt3DES_UTF8(GlobalStaticObj_YT.SAPCode, GlobalStaticObj_YT.KeySecurity_YT);
            string dateStr = Secret.Encrypt3DES_UTF8(GlobalStaticObj_Server.Instance.CurrentDateTime.ToString("yyyy-MM-dd HH:mm:ss"), GlobalStaticObj_YT.KeySecurity_YT);
            requestType = Secret.Encrypt3DES_UTF8(requestType, GlobalStaticObj_YT.KeySecurity_YT);
            clientInfo = WebServUtil.EncModel<SUPartPutStore.clientInfo>(clientInfo);
            //SUPartPutStore.Result result = serv.partPutStore(stationCode, dateStr, requestType, rationSendCode, stateCode, clientInfo);
            SUPartPutStore.Result result = serv.partPutStore(stateCode, dateStr, requestType, rationSendCode, clientInfo);
            string state = Secret.Decrypt3DES_UTF8(result.state, GlobalStaticObj_YT.KeySecurity_YT);
            if (state == "F")
            {
                string errMsg = Secret.Decrypt3DES_UTF8(result.errorMsg, GlobalStaticObj_YT.KeySecurity_YT);
                Utility.Log.Log.writeLineToLog("【配件入库单入库】" + errMsg, "接口");
                return false;
            }
            result = WebServUtil.DesModel(result);
            SUPartPutStore.Detail[] details = WebServUtil.DesList(result.Details);
            //记录返回数据
            Utility.Log.Log.writeLineToLog("【配件入库单入库】返回\r\n" + Newtonsoft.Json.JsonConvert.SerializeObject(result), "接口");
            if (string.IsNullOrEmpty(result.dsn_adjustable_parts))
            {
                return false;
            }
            //解密返回数据
            string ration_send_code = result.ration_send_code;//配送单号
            string dsn_adjustable_parts = result.dsn_adjustable_parts;//配件需求单号
            #region 自动生成采购开单
            List<SysSQLString> listSql = new List<SysSQLString>();
            string billingID = Guid.NewGuid().ToString();//采购开单ID
            string nowDate = Common.LocalDateTimeToUtcLong(DateTime.Now).ToString();//当前时间
            //采购开单住主表
            SysSQLString billingSql = new SysSQLString();
            billingSql.cmdType = CommandType.Text;
            billingSql.Param = new Dictionary<string, string>();
            CodingRule cr = new CodingRule(DataSources.EnumProjectType.PurchaseOpenOrder);
            string orderNum = cr.AddNewNo();
            //更新最新采购开单编号
            SysSQLString sqlCode = new SysSQLString();
            sqlCode.cmdType = CommandType.Text;
            sqlCode.Param = new Dictionary<string, string>();
            sqlCode.Param.Add("bill_code_rule_id", cr.ruleID);
            sqlCode.Param.Add("last_bill_no", orderNum);
            sqlCode.sqlString = "update sys_bill_code_rule set last_bill_no=@last_bill_no where bill_code_rule_id=@bill_code_rule_id";
            listSql.Add(sqlCode);

            billingSql.Param.Add("order_num", orderNum);
            billingSql.Param.Add("order_date", Common.LocalDateTimeToUtcLong(DateTime.Now).ToString());
            billingSql.Param.Add("crm_bill_id", dsn_adjustable_parts);
            billingSql.Param.Add("purchase_billing_id", billingID);
            billingSql.Param.Add("ration_send_code", ration_send_code);//配送单号
            billingSql.Param.Add("order_status", ((int)DataSources.EnumAuditStatus.SUBMIT).ToString());
            billingSql.Param.Add("order_status_name", DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT));
            billingSql.Param.Add("remark", string.Format("由单号为【{0}】的宇通配送单字段生成,收到货后请审核", ration_send_code));
            billingSql.Param.Add("payment_date", Common.LocalDateTimeToUtcLong(GlobalStaticObj_Server.Instance.CurrentDateTime.AddMonths(-1)).ToString());//付款日期为当前日期后一个月
            billingSql.sqlString = string.Format(@"insert into tb_parts_purchase_billing(purchase_billing_id,order_num,order_date,order_status,order_status_name,
order_type,order_type_name,sup_id,sup_code,sup_name,receipt_type,receipt_type_name,receipt_no,
contacts,contacts_tel,fax,trans_way,trans_way_name,payment_date,payment_limit,this_payment,sup_arrears,
balance_unit,balance_way,balance_way_name,whythe_discount,balance_account,balance_account_name,
delivery_man,check_number,delivery_address,balance_money,org_id,org_name,handle,handle_name,operators,
operator_name,create_by,create_name,create_time,enable_flag,is_lock,is_occupy,ration_send_code,remark)
select @purchase_billing_id,@order_num,@order_date,@order_status,@order_status_name,'1','采购收货',
'00000000000000000000000000000000' sup_id,'GYS-20140101-00000' sup_code,'宇通客车' sup_name,null receipt_type,null receipt_type_name,null receipt_no,
consignee contacts,consignee_tel contacts_tel,null fax,req_delivery trans_way,req_delivery_name trans_way_name,
@payment_date payment_date,null payment_limit,null this_payment,null sup_arrears,'宇通客车' balance_unit,null balance_way,
null balance_way_name,null whythe_discount,null balance_account,null balance_account_name,null delivery_man,
null check_number,delivery_address,0 balance_money,org_id,org_name,handle,handle_name,operators,
operator_name,create_by,create_name,{0},enable_flag,0 is_lock,0 is_occupy,@ration_send_code,@remark
 from tb_parts_purchase_order_2
 where crm_bill_id=@crm_bill_id", nowDate);
            listSql.Add(billingSql);
            //采购开单明细
            foreach (SUPartPutStore.Detail detail in details)
            {
                int num = (int)Convert.ToSingle(detail.send_count);
                SysSQLString detailSql = new SysSQLString();
                detailSql.cmdType = CommandType.Text;
                detailSql.Param = new Dictionary<string, string>();
                detailSql.Param.Add("crm_bill_id", dsn_adjustable_parts);
                detailSql.Param.Add("purchase_billing_id", billingID);
                detailSql.Param.Add("id", Guid.NewGuid().ToString());
                detailSql.Param.Add("parts_code", detail.car_parts_code);
                detailSql.Param.Add("num", num.ToString());
                detailSql.Param.Add("unit", detail.unit);
                detailSql.sqlString = string.Format(@"insert into tb_parts_purchase_billing_p(id,purchase_billing_id,num,wh_id,wh_code,wh_name,parts_code,
parts_name,parts_type_id,parts_type_name,parts_brand,parts_brand_name,unit_id,unit_name,parts_barcode,car_factory_code,drawing_num,model,business_counts,original_price,discount,business_price,
tax_rate,tax,payment,valorem_together,is_gift,relation_order,return_bus_count,storage_count,remark,
assisted_count,create_by,create_time,create_name,arrival_date,make_date)
select @id,@purchase_billing_id,num,'' wh_id,'' wh_code,'' wh_name,parts_code,parts_name,parts_type_id,parts_type_name,parts_brand,parts_brand_name,
unit_id,@unit unit_name,parts_barcode,car_factory_code,drawing_num,model,@num business_counts,price original_price,100 discount,price business_price,
null tax_rate,null tax,@num*price payment,@num*price+0 valorem_together,'0' is_gift,
b.order_num relation_order,null retum_bus_count,null storage_count,null remark,0 assisted_count,
a.create_by,{0},a.create_name,0 arrival_date,0 make_date
from tb_parts_purchase_order_p_2 a 
inner join tb_parts_purchase_order_2 b on a.purchase_order_yt_id=b.purchase_order_yt_id
where b.crm_bill_id=@crm_bill_id and a.car_factory_code=@parts_code", nowDate);
                listSql.Add(detailSql);
            }
            //采购开单总金额
            SysSQLString sqlAllmoney = new SysSQLString();
            sqlAllmoney.cmdType = CommandType.Text;
            sqlAllmoney.Param = new Dictionary<string, string>();
            sqlAllmoney.Param.Add("purchase_billing_id", billingID);
            sqlAllmoney.sqlString = @"update a set allmoney=b.valorem_together from tb_parts_purchase_billing
a inner join 
(select purchase_billing_id,sum(valorem_together) valorem_together from tb_parts_purchase_billing_p group by purchase_billing_id)
b  on a.purchase_billing_id=b.purchase_billing_id
where a.purchase_billing_id=@purchase_billing_id";
            listSql.Add(sqlAllmoney);
            #endregion
            #region 配送单
            string distribution_id = Guid.NewGuid().ToString();//配送单ID

            SysSQLString sqlDistribution = new SysSQLString();
            sqlDistribution.cmdType = CommandType.Text;
            sqlDistribution.Param = new Dictionary<string, string>();
            sqlDistribution.Param.Add("distribution_id", distribution_id);
            sqlDistribution.Param.Add("ration_send_code", result.ration_send_code);
            sqlDistribution.Param.Add("dsn_adjustable_parts", result.dsn_adjustable_parts);
            sqlDistribution.Param.Add("distribution_status", "1");
            sqlDistribution.sqlString = @"insert into tb_distribution (distribution_id,ration_send_code,dsn_adjustable_parts,distribution_status)
                                        values (@distribution_id,@ration_send_code,@dsn_adjustable_parts,@distribution_status)";
            listSql.Add(sqlDistribution);
            foreach (SUPartPutStore.Detail detail in details)
            {
                SysSQLString sqlDetail = new SysSQLString();
                sqlDetail.cmdType = CommandType.Text;
                sqlDetail.Param = new Dictionary<string, string>();
                sqlDetail.Param.Add("distribution_parts_id", Guid.NewGuid().ToString());
                sqlDetail.Param.Add("distribution_id", distribution_id);
                sqlDetail.Param.Add("car_parts_code", detail.car_parts_code);
                sqlDetail.Param.Add("unit", detail.unit);
                sqlDetail.Param.Add("send_count", detail.send_count);
                sqlDetail.sqlString = @"insert into tb_distribution_parts (distribution_parts_id,distribution_id,car_parts_code,unit,send_count)
                                    values (@distribution_parts_id,@distribution_id,@car_parts_code,@unit,@send_count)";
                listSql.Add(sqlDetail);
            }
            #endregion
            if (DBHelper.BatchExeSQLStrMultiByTransNoLogNoBackup("生成采购单", GlobalStaticObj_Server.Instance.MainAccCode, listSql))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
예제 #2
0
        /// <summary> 维修结算单查询
        /// </summary>
        /// <returns>返回标识:1:成功 0:无数数据 -1:失败</returns>
        public static bool QuerySettleAccounts(string settlementNo)
        {
            //如果没有接入码或者sap代码,则不调用接口
            if (string.IsNullOrEmpty(GlobalStaticObj_YT.ClientID) ||
                string.IsNullOrEmpty(GlobalStaticObj_YT.SAPCode))
            {
                return true;
            }
            Utility.Log.Log.writeLineToLog("【维修结算单查询】" + settlementNo, "接口");
            //settlementNo = "80030601";
            ServicePointManager.ServerCertificateValidationCallback = WebServUtil.ValidateServerCertificate;
            QueryServiceSettleAccounts.clientInfo clientInfo = new QueryServiceSettleAccounts.clientInfo();
            clientInfo.clientID = GlobalStaticObj_YT.ClientID;
            clientInfo.serviceID = "serviceSettleAccountsQuery";
            QueryServiceSettleAccounts.serviceSettleAccountsQueryService serv = new QueryServiceSettleAccounts.serviceSettleAccountsQueryService();
            string stationCode = Secret.Encrypt3DES_UTF8(GlobalStaticObj_YT.SAPCode, GlobalStaticObj_YT.KeySecurity_YT);
            string dateStr = Secret.Encrypt3DES_UTF8(GlobalStaticObj_Server.Instance.CurrentDateTime.ToString("yyyy-MM-dd HH:mm:ss"), GlobalStaticObj_YT.KeySecurity_YT);
            string requestType = Secret.Encrypt3DES_UTF8("QUERY", GlobalStaticObj_YT.KeySecurity_YT);
            settlementNo = Secret.Encrypt3DES_UTF8(settlementNo, GlobalStaticObj_YT.KeySecurity_YT);
            clientInfo = WebServUtil.EncModel<QueryServiceSettleAccounts.clientInfo>(clientInfo);
            QueryServiceSettleAccounts.Result result = serv.serviceSettleAccountsQuery(stationCode, dateStr, requestType, settlementNo, clientInfo);
            string state = Secret.Decrypt3DES_UTF8(result.state, GlobalStaticObj_YT.KeySecurity_YT);
            if (state == "F")
            {
                string errMsg = Secret.Decrypt3DES_UTF8(result.errorMsg, GlobalStaticObj_YT.KeySecurity_YT);
                Utility.Log.Log.writeLineToLog("【维修结算单查询】" + errMsg, "接口");
                return false;
            }
            QueryServiceSettleAccounts.ResultServiceDetail[] servArr = result.ServiceDetails;
            QueryServiceSettleAccounts.ResultOldPartDetail[] oldPartArr = result.OldPartDetails;
            QueryServiceSettleAccounts.ResultOtherFeeDetail[] otherFeeArr = result.OtherFeeDetails;
            result = WebServUtil.DesModel<QueryServiceSettleAccounts.Result>(result);

            servArr = WebServUtil.DesList<QueryServiceSettleAccounts.ResultServiceDetail>(servArr);
            oldPartArr = WebServUtil.DesList<QueryServiceSettleAccounts.ResultOldPartDetail>(oldPartArr);
            otherFeeArr = WebServUtil.DesList<QueryServiceSettleAccounts.ResultOtherFeeDetail>(otherFeeArr);
            //记录返回数据
            Utility.Log.Log.writeLineToLog("【维修结算单查询】返回数据\r\n" + Newtonsoft.Json.JsonConvert.SerializeObject(result), "接口");
            if (string.IsNullOrEmpty(result.settlement_no))
            {
                return false;
            }
            string nowTicks = Common.LocalDateTimeToUtcLong(GlobalStaticObj_Server.Instance.CurrentDateTime).ToString();
            List<SysSQLString> list = new List<SysSQLString>();
            SysSQLString sysSQLString = new SysSQLString();
            sysSQLString.cmdType = CommandType.Text;
            sysSQLString.Param = new Dictionary<string, string>();
            StringBuilder strSql = new StringBuilder();

            #region 三包结算单
            string st_id = DBHelper.GetSingleValue("获取三包结算单id", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_maintain_three_guaranty_settlement", "st_id", "settlement_no='" + result.settlement_no + "'", "");
            if (!string.IsNullOrEmpty(st_id))
            {
                #region 更新语句
                strSql.Append("update tb_maintain_three_guaranty_settlement set ");
                strSql.Append("cust_id='00000000000000000000000000000000',");//宇通客户
                strSql.Append(" service_station_code= @service_station_code , ");
                strSql.Append(" service_station_name= @service_station_name , ");
                strSql.Append(" bill_sum_cost= @bill_sum_cost , ");
                strSql.Append(" sum_cost= @sum_cost , ");
                strSql.Append(" oldpart_sum_cost= @oldpart_sum_cost , ");
                strSql.Append(" other_sum_cost= @other_sum_cost , ");
                strSql.Append(" settlement_date= @settlement_date , ");
                strSql.Append("settlement_cycle_start=@settlement_cycle_start,");
                strSql.Append("settlement_cycle_end=@settlement_cycle_end,");
                strSql.Append(" info_status= @info_status , ");
                strSql.Append(" update_time= @update_time , ");
                strSql.Append(" enable_flag= @enable_flag , ");
                strSql.Append(" update_by= @update_by , ");
                strSql.Append(" update_name= @update_name  ");
                strSql.Append(" where settlement_no=@settlement_no  ");
                #endregion
            }
            else
            {
                #region 插入语句
                strSql.Append("insert into tb_maintain_three_guaranty_settlement(");
                strSql.Append("st_id,cust_id,settlement_no,station_settlement_no,service_station_code,service_station_name,bill_sum_cost,sum_cost,oldpart_sum_cost,other_sum_cost,settlement_date,settlement_cycle_start,settlement_cycle_end,info_status,create_time,update_time,enable_flag,create_by,update_by,create_name,update_name");
                strSql.Append(") values (");
                strSql.Append("@st_id,'00000000000000000000000000000000',@settlement_no,@station_settlement_no,@service_station_code,@service_station_name,@bill_sum_cost,@sum_cost,@oldpart_sum_cost,@other_sum_cost,@settlement_date,@settlement_cycle_start,@settlement_cycle_end,@info_status,@create_time,@update_time,@enable_flag,@create_by,@update_by,@create_name,@update_name) ");
                #endregion
                st_id = Guid.NewGuid().ToString();
                sysSQLString.Param.Add("st_id", st_id);
                sysSQLString.Param.Add("create_by", GlobalStaticObj_Server.Instance.UserID);
                sysSQLString.Param.Add("create_name", GlobalStaticObj_Server.Instance.UserName);
                sysSQLString.Param.Add("create_time", nowTicks);
                CodingRule cr = new CodingRule(DataSources.EnumProjectType.ThreeGuarantyServiceSettlement);
                string station_settlement_no = cr.AddNewNo();//结算单号
                sysSQLString.Param.Add("station_settlement_no", station_settlement_no);
                #region 更新编码
                SysSQLString sqlRule = new SysSQLString();
                sqlRule.cmdType = CommandType.Text;
                sqlRule.Param = new Dictionary<string, string>();
                sqlRule.Param.Add("bill_code_rule_id", cr.ruleID);
                sqlRule.Param.Add("last_bill_no", station_settlement_no);
                sqlRule.sqlString = "update sys_bill_code_rule set last_bill_no=@last_bill_no where bill_code_rule_id=@bill_code_rule_id";
                list.Add(sqlRule);
                #endregion
            }
            #region  参数项 9
            sysSQLString.Param.Add("settlement_no", result.settlement_no);
            sysSQLString.Param.Add("service_station_code", result.service_station_code);
            sysSQLString.Param.Add("service_station_name", result.service_station_name);
            sysSQLString.Param.Add("bill_sum_cost", result.bill_sum_cost);
            sysSQLString.Param.Add("sum_cost", result.sum_cost);
            sysSQLString.Param.Add("oldpart_sum_cost", result.oldpart_sum_cost);
            sysSQLString.Param.Add("other_sum_cost", result.other_sum_cost);
            sysSQLString.Param.Add("settlement_date", result.settlement_date);
            sysSQLString.Param.Add("info_status", "D1FEDED3-23ED-EBB1-40EA-B613AD2F505A");//单据状态为“未确认”
            //结算周期
            if (result.settlement_cycle.Trim().Length > 0)
            {
                string[] sp = new string[] { "--" };
                string[] cycles = result.settlement_cycle.Trim().Split(sp, StringSplitOptions.None);
                if (cycles.Length == 2)
                {

                    sysSQLString.Param.Add("settlement_cycle_start", Common.LocalDateTimeToUtcLong(DateTime.Parse(cycles[0])).ToString());
                    sysSQLString.Param.Add("settlement_cycle_end", Common.LocalDateTimeToUtcLong(DateTime.Parse(cycles[1])).ToString());
                }
                else
                {
                    sysSQLString.Param.Add("settlement_cycle_start", null);
                    sysSQLString.Param.Add("settlement_cycle_end", null);
                }
            }
            sysSQLString.Param.Add("update_time", nowTicks);
            sysSQLString.Param.Add("enable_flag", ((int)DataSources.EnumEnableFlag.USING).ToString());
            sysSQLString.Param.Add("update_by", GlobalStaticObj_Server.Instance.UserID);
            sysSQLString.Param.Add("update_name", GlobalStaticObj_Server.Instance.UserName);
            #endregion
            sysSQLString.sqlString = strSql.ToString();
            list.Add(sysSQLString);
            #endregion

            #region 维修服务单
            foreach (QueryServiceSettleAccounts.ResultServiceDetail item in servArr)
            {
                sysSQLString = new SysSQLString();
                sysSQLString.cmdType = CommandType.Text;
                sysSQLString.Param = new Dictionary<string, string>();
                strSql = new StringBuilder();
                bool isOldExist = DBHelper.IsExist("判断维修服务单是否存在", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_maintain_three_guaranty_settlement_ser", "service_no='" + item.service_no + "'");
                if (isOldExist)
                {
                    #region 更新语句
                    strSql.Append("update tb_maintain_three_guaranty_settlement_ser set ");
                    strSql.Append(" submit_time= @submit_time , ");
                    strSql.Append(" st_id= @st_id , ");
                    strSql.Append(" depot_no= @depot_no , ");
                    strSql.Append(" receipt_type= @receipt_type , ");
                    strSql.Append(" repairer_name= @repairer_name , ");
                    strSql.Append(" approval_date= @approval_date , ");//审批通过日期
                    strSql.Append(" other_item_sum_money= @other_item_sum_money , ");
                    strSql.Append(" man_hour_sum_money= @man_hour_sum_money , ");
                    strSql.Append(" fitting_sum_money= @fitting_sum_money , ");
                    strSql.Append(" travel_cost= @travel_cost , ");
                    strSql.Append(" service_sum_cost= @service_sum_cost , ");
                    strSql.Append(" enable_flag= @enable_flag ");
                    strSql.Append(" where service_no=@service_no  ");
                    #endregion
                }
                else
                {
                    #region 插入语句

                    strSql.Append("insert into tb_maintain_three_guaranty_settlement_ser(");
                    strSql.Append("ser_id,service_no,st_id,submit_time,depot_no,receipt_type,repairer_name,approval_date,other_item_sum_money,man_hour_sum_money,fitting_sum_money,travel_cost,service_sum_cost,enable_flag");
                    strSql.Append(") values (");
                    strSql.Append("@ser_id,@service_no,@st_id,@submit_time,@depot_no,@receipt_type,@repairer_name,@approval_date,@other_item_sum_money,@man_hour_sum_money,@fitting_sum_money,@travel_cost,@service_sum_cost,@enable_flag) ");
                    #endregion
                    sysSQLString.Param.Add("ser_id", Guid.NewGuid().ToString());
                }
                #region 参数项 11
                sysSQLString.Param.Add("service_no", item.service_no);
                sysSQLString.Param.Add("st_id", st_id);
                string submit_time = "";
                //提交日期为空处理
                if (!String.IsNullOrEmpty(item.submit_time))
                {
                    submit_time = Common.LocalDateTimeToUtcLong(Convert.ToDateTime(item.submit_time)).ToString();
                }
                sysSQLString.Param.Add("submit_time", submit_time);
                sysSQLString.Param.Add("depot_no", item.depot_no);
                sysSQLString.Param.Add("receipt_type", item.receipt_type);
                sysSQLString.Param.Add("repairer_name", item.repairer_name);
                string approval_date = "";
                //审批通过时间为空处理
                if (!String.IsNullOrEmpty(item.approval_date))
                {
                    approval_date = Common.LocalDateTimeToUtcLong(Convert.ToDateTime(item.approval_date)).ToString();
                }
                sysSQLString.Param.Add("approval_date", approval_date);
                sysSQLString.Param.Add("other_item_sum_money", item.other_item_sum_money);
                sysSQLString.Param.Add("man_hour_sum_money", item.man_hour_sum_money);
                sysSQLString.Param.Add("fitting_sum_money", item.fitting_sum_money);
                sysSQLString.Param.Add("travel_cost", item.travel_cost);
                sysSQLString.Param.Add("service_sum_cost", item.service_sum_cost);

                sysSQLString.Param.Add("enable_flag", ((int)DataSources.EnumEnableFlag.USING).ToString());
                #endregion
                sysSQLString.sqlString = strSql.ToString();
                list.Add(sysSQLString);
            }
            #endregion

            #region 旧件结算单
            foreach (QueryServiceSettleAccounts.ResultOldPartDetail item in oldPartArr)
            {
                sysSQLString = new SysSQLString();
                sysSQLString.cmdType = CommandType.Text;
                sysSQLString.Param = new Dictionary<string, string>();
                strSql = new StringBuilder();
                bool isOldExist = DBHelper.IsExist("判断旧件结算单是否存在", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_maintain_three_guaranty_settlement_old", "recycle_no='" + item.recycle_no + "'");
                if (isOldExist)
                {
                    #region 更新语句
                    strSql.Append("update tb_maintain_three_guaranty_settlement_old set ");
                    strSql.Append(" service_station_code= @service_station_code , ");
                    strSql.Append(" service_station_name= @service_station_name , ");
                    strSql.Append(" sum_cost= @sum_cost , ");
                    strSql.Append(" st_id= @st_id , ");
                    strSql.Append(" enable_flag= @enable_flag ");
                    strSql.Append(" where recycle_no=@recycle_no  ");
                    #endregion
                }
                else
                {
                    #region 插入语句
                    strSql.Append("insert into tb_maintain_three_guaranty_settlement_old(");
                    strSql.Append("old_id,recycle_no,service_station_code,service_station_name,sum_cost,st_id,enable_flag");
                    strSql.Append(") values (");
                    strSql.Append("@old_id,@recycle_no,@service_station_code,@service_station_name,@sum_cost,@st_id,@enable_flag) ");
                    #endregion
                    sysSQLString.Param.Add("old_id", Guid.NewGuid().ToString());
                }
                #region 参数项 4
                sysSQLString.Param.Add("recycle_no", item.recycle_no);
                sysSQLString.Param.Add("service_station_code", item.service_station_code);
                sysSQLString.Param.Add("service_station_name", item.service_station_name);
                sysSQLString.Param.Add("sum_cost", item.sum_cost);
                sysSQLString.Param.Add("st_id", st_id);
                sysSQLString.Param.Add("enable_flag", ((int)DataSources.EnumEnableFlag.USING).ToString());
                #endregion
                sysSQLString.sqlString = strSql.ToString();
                list.Add(sysSQLString);
            }
            #endregion

            #region 其他费用结算单
            foreach (QueryServiceSettleAccounts.ResultOtherFeeDetail item in otherFeeArr)
            {
                sysSQLString = new SysSQLString();
                sysSQLString.cmdType = CommandType.Text;
                sysSQLString.Param = new Dictionary<string, string>();
                strSql = new StringBuilder();
                bool isOldExist = DBHelper.IsExist("判断其他费用结算单是否存在", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_maintain_three_guaranty_settlement_oth", "other_cost_no='" + item.other_cost_no + "'");
                if (isOldExist)
                {
                    #region 更新语句
                    strSql.Append("update tb_maintain_three_guaranty_settlement_oth set ");
                    strSql.Append(" cost_name= @cost_name , ");
                    strSql.Append(" cost_type= @cost_type , ");
                    strSql.Append(" tally_time= @tally_time , ");
                    strSql.Append(" cost_explain= @cost_explain , ");
                    strSql.Append(" sum_cost= @sum_cost , ");
                    strSql.Append(" st_id= @st_id , ");
                    strSql.Append(" enable_flag= @enable_flag  ");
                    strSql.Append(" where other_cost_no=@other_cost_no  ");
                    #endregion
                }
                else
                {
                    #region 插入语句
                    strSql.Append("insert into tb_maintain_three_guaranty_settlement_oth(");
                    strSql.Append("cost_id,other_cost_no,cost_name,cost_type,tally_time,cost_explain,sum_cost,st_id,enable_flag");
                    strSql.Append(") values (");
                    strSql.Append("@cost_id,@other_cost_no,@cost_name,@cost_type,@tally_time,@cost_explain,@sum_cost,@st_id,@enable_flag) ");
                    #endregion
                    sysSQLString.Param.Add("cost_id", Guid.NewGuid().ToString());
                }
                #region 参数项 6
                sysSQLString.Param.Add("other_cost_no", item.other_cost_no);
                sysSQLString.Param.Add("cost_name", item.cost_name);
                sysSQLString.Param.Add("cost_type", item.cost_type);
                string tally_time = "";
                //提交日期为空处理
                if (!String.IsNullOrEmpty(item.tally_time))
                {
                    tally_time = Common.LocalDateTimeToUtcLong(Convert.ToDateTime(item.tally_time)).ToString();
                }
                sysSQLString.Param.Add("tally_time", tally_time);
                sysSQLString.Param.Add("cost_explain", item.cost_explain);
                sysSQLString.Param.Add("sum_cost", item.sum_cost);
                sysSQLString.Param.Add("st_id", st_id);
                sysSQLString.Param.Add("enable_flag", ((int)DataSources.EnumEnableFlag.USING).ToString());
                #endregion
                sysSQLString.sqlString = strSql.ToString();
                list.Add(sysSQLString);
            }
            #endregion

            bool flag = DBHelper.BatchExeSQLStringMultiByTrans("宇通:同步三包服务单信息", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, list);
            if (!flag)
            {
                return false;
            }
            return true;
        }
        /// <summary>
        /// 非批量保存配件信息
        /// </summary>
        /// <param name="partArr">配件信息</param>
        /// <param name="updateCount">更新条数</param>
        /// <returns></returns>
        private static bool SavePartNotBatch(QueryPart.part[] partArr, ref int updateCount)
        {
            long nowTicks = Common.LocalDateTimeToUtcLong(GlobalStaticObj_Server.Instance.CurrentDateTime);
            int partIndex = 0;//列表索引
            int partCount = 10000;//每批执行条数
            int partSum = partArr.Count() / partCount + 1;//执行批数
            //partSum = 0;
            bool flag = true;//执行结果
            DateTime startDate = DateTime.Now;
            YuTongDic dic = new YuTongDic();
            //配件
            DataTable dtParts = DBHelper.GetTable("配件信息", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts", "car_parts_code,parts_id",
                string.Format("data_source='{0}'", (int)DataSources.EnumDataSources.YUTONG), null, null);
            Dictionary<string, string> dicParts = new Dictionary<string, string>();
            foreach (DataRow dr in dtParts.Rows)
            {
                dicParts.Add(dr["car_parts_code"].ToString(), dr["parts_id"].ToString());
            }
            //配件替代信息
            DataTable dtReplace = DBHelper.GetTable("配件替代信息", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts_replace", "parts_id,repl_id", null, null, null);
            //Dictionary<string, string> dicReplace = new Dictionary<string, string>();
            List<string> listReplace = new List<string>();
            foreach (DataRow dr in dtReplace.Rows)
            {
                //dicReplace.Add(dr["repl_id"].ToString(), dr["parts_id"].ToString());
                listReplace.Add(string.Format("{0},{1}", dr["repl_id"], dr["parts_id"]));
            }
            CodingRule comm = new CodingRule(DataSources.EnumProjectType.Parts);
            string partCode = string.Empty;//配件编码
            #region 生成表列
            //配件表
            List<DataRow> listTbParts = new List<DataRow>();
            DataTable dtTbParts = new DataTable();
            dtTbParts.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("ser_parts_code", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("car_parts_code", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("parts_name", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("sales_unit_code", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("data_source", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("default_unit", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("sales_unit_name", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("model", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("retail", typeof(decimal)));
            dtTbParts.Columns.Add(new DataColumn("price3a_back", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("price2a_back", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("status", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            dtTbParts.Columns.Add("parts_type", typeof(string));
            dtTbParts.Columns.Add(new DataColumn("base_unit_code", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("base_unit_name", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("sales_unit_quantity", typeof(int)));
            dtTbParts.Columns.Add(new DataColumn("base_unit_quantity", typeof(int)));
            dtTbParts.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbParts.Columns.Add(new DataColumn("create_time", typeof(long)));
            //配件价格信息
            DataTable dtTbPartsPrice = new DataTable();
            List<DataRow> listTbPrice = new List<DataRow>();
            dtTbPartsPrice.Columns.Add(new DataColumn("pp_id", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbPartsPrice.Columns.Add("is_stock", typeof(string));
            dtTbPartsPrice.Columns.Add("is_purchase", typeof(string));
            dtTbPartsPrice.Columns.Add("is_sale", typeof(string));
            dtTbPartsPrice.Columns.Add(new DataColumn("unit", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("ref_out_price", typeof(decimal)));
            dtTbPartsPrice.Columns.Add(new DataColumn("out_price_two", typeof(decimal)));
            dtTbPartsPrice.Columns.Add(new DataColumn("out_price_three", typeof(decimal)));
            dtTbPartsPrice.Columns.Add("sort_index", typeof(string));
            dtTbPartsPrice.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbPartsPrice.Columns.Add(new DataColumn("create_time", typeof(long)));
            //替换配件表
            DataTable dtTbReplace = new DataTable();
            List<DataRow> listTbReplace = new List<DataRow>();
            dtTbReplace.Columns.Add(new DataColumn("replace_id", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_id", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_parts_code", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_parts_status", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("repl_remark", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("change", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbReplace.Columns.Add(new DataColumn("create_time", typeof(long)));
            //单位设置
            DataTable dtTbPartsSetup = new DataTable();
            List<DataRow> listTbSetup = new List<DataRow>();
            dtTbPartsSetup.Columns.Add(new DataColumn("set_id", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("parts_id", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("stock_unit", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("purchase_unit", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("sale_unit", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("stock_purchase", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("purchase_sale", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("create_by", typeof(string)));
            dtTbPartsSetup.Columns.Add(new DataColumn("create_time", typeof(long)));
            dtTbPartsSetup.Columns.Add(new DataColumn("enable_flag", typeof(string)));
            #endregion
            for (int i = 0; i < partSum; i++)
            {
                List<SysSQLString> list = new List<SysSQLString>();
                dtTbParts.Rows.Clear();
                dtTbReplace.Rows.Clear();
                listTbParts.Clear();
                listTbReplace.Clear();
                listTbPrice.Clear();
                listTbSetup.Clear();
                for (int y = partIndex; y < partCount; y++)
                {
                    int index = i * partCount + y;
                    if (index >= partArr.Count())
                    {
                        break;
                    }
                    #region 配件信息
                    QueryPart.part item = partArr[index];

                    string price3a = WebServUtil.GetEncField(item.price3a);//加密
                    string price2a = WebServUtil.GetEncField(item.price2a);//加密
                    string partType = dic.GetLocalDicID("part_type", item.part_type);//配件类型
                    string partsID = null;
                    bool isAdd = false;//是否新增
                    if (dicParts.ContainsKey(item.car_parts_code))
                    {
                        partsID = dicParts[item.car_parts_code];
                    }
                    if (!string.IsNullOrEmpty(partsID))
                    {
                        #region 更新语句
                        SysSQLString sysSQLString = new SysSQLString();
                        sysSQLString.cmdType = CommandType.Text;
                        sysSQLString.Param = new Dictionary<string, string>();
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append(" update tb_parts set ");
                        strSql.AppendFormat(" parts_name = '{0}' , ", item.parts_name);
                        strSql.AppendFormat(" sales_unit_code = '{0}' , ", item.unit_code);
                        strSql.AppendFormat(" sales_unit_name = '{0}' , ", item.unit_name);
                        strSql.AppendFormat(" model = '{0}' , ", item.model);
                        strSql.AppendFormat(" status = '{0}' , ", item.status == "0" ? "1" : "0");
                        strSql.AppendFormat(" retail = '{0}' , ", item.retail);
                        strSql.AppendFormat(" price3a = {0} , ", price3a);
                        strSql.AppendFormat(" price2a = {0} , ", price2a);
                        strSql.AppendFormat(" parts_type='{0}',", partType);
                        strSql.AppendFormat(" base_unit_code = '{0}' , ", item.basic_unit_code);
                        strSql.AppendFormat(" base_unit_name = '{0}' , ", item.basic_unit_name);
                        if (!string.IsNullOrEmpty(item.unit_name_quantity))
                        {
                            strSql.AppendFormat(" sales_unit_quantity = {0} , ", item.unit_name_quantity);
                        }
                        if (!string.IsNullOrEmpty(item.basic_unit_quantity))
                        {
                            strSql.AppendFormat(" base_unit_quantity = {0} , ", item.basic_unit_quantity);
                        }
                        strSql.AppendFormat(" enable_flag = '{0}' ,", (int)DataSources.EnumEnableFlag.USING);
                        strSql.AppendFormat(" data_source = '{0}' ,", (int)DataSources.EnumDataSources.YUTONG);
                        strSql.AppendFormat(" update_time = {0} ,", nowTicks);
                        strSql.AppendFormat(" update_by = '{0}' ", GlobalStaticObj_Server.Instance.UserID);
                        strSql.AppendFormat(" where car_parts_code='{0}';  ", item.car_parts_code);
                        sysSQLString.sqlString = strSql.ToString();
                        list.Add(sysSQLString);
                        #endregion
                    }
                    else
                    {
                        isAdd = true;
                        #region 插入语句
                        partsID = Guid.NewGuid().ToString();
                        //strSql.Append(" insert into tb_parts(");
                        //strSql.Append("parts_id,car_parts_code,parts_name,sales_unit_code,data_source,sales_unit_name,model,retail,price3a,price2a,status,enable_flag,base_unit_code,base_unit_name,sales_unit_quantity,base_unit_quantity,create_by,create_time");
                        //strSql.Append(") values (");
                        //strSql.AppendFormat("'{0}',", partsID);
                        //strSql.AppendFormat("'{0}',", item.car_parts_code);
                        //strSql.AppendFormat("'{0}',", item.parts_name);
                        //strSql.AppendFormat("'{0}',", item.unit_code);
                        //strSql.AppendFormat("'{0}',", (int)DataSources.EnumDataSources.YUTONG);
                        //strSql.AppendFormat("'{0}',", item.unit_name);
                        //strSql.AppendFormat("'{0}',", item.model);
                        //strSql.AppendFormat("'{0}',", item.retail);
                        //strSql.AppendFormat("{0},", price3a);
                        //strSql.AppendFormat("{0},", price2a);
                        //strSql.AppendFormat("'{0}',", item.status);
                        //strSql.AppendFormat("'{0}',", (int)DataSources.EnumEnableFlag.USING);
                        //strSql.AppendFormat("'{0}',", item.basic_unit_code);
                        //strSql.AppendFormat("'{0}',", item.basic_unit_name);
                        //strSql.AppendFormat("'{0}',", item.unit_name_quantity);
                        //strSql.AppendFormat("'{0}',", item.basic_unit_quantity);
                        //strSql.AppendFormat("'{0}',", GlobalStaticObj_Server.Instance.ClientID);
                        //strSql.AppendFormat("{0})", nowTicks);
                        //DataRow dr = dtParts.NewRow();
                        //dr["parts_id"] = partsID;
                        //dr["car_parts_code"] = item.car_parts_code;
                        //dtParts.Rows.Add(dr);
                        dicParts.Add(item.car_parts_code, partsID);
                        partCode = comm.AddNewNo();
                        DataRow drParts = dtTbParts.NewRow();
                        drParts["parts_id"] = partsID;
                        drParts["ser_parts_code"] = partCode;
                        drParts["car_parts_code"] = item.car_parts_code;
                        drParts["parts_name"] = item.parts_name;
                        drParts["sales_unit_code"] = item.unit_code;
                        drParts["data_source"] = ((int)DataSources.EnumDataSources.YUTONG).ToString();
                        drParts["default_unit"] = item.unit_name;
                        drParts["sales_unit_name"] = item.unit_name;
                        drParts["model"] = item.model;
                        if (!string.IsNullOrEmpty(item.retail))
                        {
                            drParts["retail"] = Convert.ToDecimal(item.retail);
                        }
                        drParts["price3a_back"] = item.price3a;
                        drParts["price2a_back"] = item.price2a;
                        drParts["parts_type"] = partType;
                        drParts["status"] = item.status == "0" ? "1" : "0";
                        drParts["enable_flag"] = ((int)DataSources.EnumEnableFlag.USING).ToString();
                        drParts["base_unit_code"] = item.basic_unit_code;
                        drParts["base_unit_name"] = item.basic_unit_name;
                        if (!string.IsNullOrEmpty(item.unit_name_quantity))
                        {
                            drParts["sales_unit_quantity"] = (int)Convert.ToDecimal(item.unit_name_quantity);
                        }
                        if (!string.IsNullOrEmpty(item.basic_unit_quantity))
                        {
                            drParts["base_unit_quantity"] = (int)Convert.ToDecimal(item.basic_unit_quantity);
                        }
                        drParts["create_by"] = GlobalStaticObj_Server.Instance.UserID;
                        drParts["create_time"] = nowTicks;
                        listTbParts.Add(drParts);
                        //dtTbParts.Rows.Add(drParts);

                        #endregion
                    }

                    #endregion

                    #region 替代配件
                    foreach (QueryPart.replaceDetail itemReplace in item.partReplace)
                    {
                        if (!dicParts.ContainsKey(item.car_parts_code) || dicParts.ContainsKey(itemReplace.repl_parts_code)
                            || string.IsNullOrEmpty(itemReplace.repl_parts_code))
                        {
                            continue;
                        }
                        string partid = dicParts[item.car_parts_code];
                        string replacepartid = dicParts[itemReplace.repl_parts_code];
                        if (listReplace.Contains(string.Format("{0},{1}", replacepartid, partid)))
                        {
                            #region 更新语句
                            SysSQLString sysSQLString0 = new SysSQLString();
                            sysSQLString0.cmdType = CommandType.Text;
                            sysSQLString0.Param = new Dictionary<string, string>();
                            StringBuilder strSql0 = new StringBuilder();
                            strSql0.Append(" update tb_parts_replace set ");
                            strSql0.AppendFormat(" repl_parts_code = '{0}' , ", itemReplace.repl_parts_code);
                            strSql0.AppendFormat(" repl_parts_status = '{0}' , ", itemReplace.repl_parts_status);
                            strSql0.AppendFormat(" repl_remark = '{0}' , ", itemReplace.repl_remark);
                            strSql0.AppendFormat(" change = '{0}' ", itemReplace.change);
                            strSql0.AppendFormat(" update_time = {0} ", nowTicks);
                            strSql0.AppendFormat(" update_by = '{0}' ", GlobalStaticObj_Server.Instance.UserID);
                            strSql0.AppendFormat(" where parts_id='{0}' and repl_id='{1}'", partid, replacepartid);
                            list.Add(sysSQLString0);
                            #endregion
                        }
                        else
                        {
                            #region 插入语句
                            replacepartid = Guid.NewGuid().ToString();
                            //strSql0.Append(" insert into tb_parts_replace(");
                            //strSql0.Append("replace_id,parts_id,repl_id,repl_parts_code,repl_parts_status,repl_remark,change,create_by,create_time");
                            //strSql0.Append(") values (");
                            //strSql0.AppendFormat("'{0}',", replacepartid);
                            //strSql0.AppendFormat("'{0}',", partid);
                            //strSql0.AppendFormat("'{0}',", Guid.NewGuid());
                            //strSql0.AppendFormat("'{0}',", itemReplace.repl_parts_code);
                            //strSql0.AppendFormat("'{0}',", itemReplace.repl_parts_status);
                            //strSql0.AppendFormat("'{0}',", itemReplace.repl_remark);
                            //strSql0.AppendFormat("'{0}',", itemReplace.change);
                            //strSql0.AppendFormat("'{0}',", GlobalStaticObj_Server.Instance.ClientID);
                            //strSql0.AppendFormat("{0})", nowTicks);
                            //DataRow dr = dtReplace.NewRow();
                            //dr["parts_id"] = partid;
                            //dr["repl_id"] = replacepartid;
                            //dtReplace.Rows.Add(dr);
                            listReplace.Add(string.Format("{0},{1}", replacepartid, partid));

                            DataRow drReplace = dtTbReplace.NewRow();
                            drReplace["replace_id"] = replacepartid;
                            drReplace["parts_id"] = partid;
                            drReplace["repl_id"] = Guid.NewGuid().ToString();
                            drReplace["repl_parts_code"] = itemReplace.repl_parts_code;
                            drReplace["repl_parts_status"] = itemReplace.repl_parts_status;
                            drReplace["repl_remark"] = itemReplace.repl_remark;
                            drReplace["change"] = itemReplace.change;
                            drReplace["create_by"] = GlobalStaticObj_Server.Instance.UserID;
                            drReplace["create_time"] = nowTicks;
                            //dtTbReplace.Rows.Add(drReplace);
                            listTbReplace.Add(drReplace);
                            #endregion
                        }
                    }
                    #endregion

                    #region 配件价格信息
                    if (!isAdd)
                    {
                        DataRow drPrice = dtTbPartsPrice.NewRow();
                        drPrice["pp_id"] = Guid.NewGuid().ToString();
                        drPrice["parts_id"] = partsID;
                        drPrice["unit"] = item.unit_name;
                        drPrice["is_stock"] = "0";
                        drPrice["is_purchase"] = "0";
                        drPrice["is_sale"] = "1";
                        if (!string.IsNullOrEmpty(item.retail))
                        {
                            drPrice["ref_out_price"] = Convert.ToDecimal(item.retail);//参考售价
                        }
                        if (!string.IsNullOrEmpty(item.price2a))
                        {
                            drPrice["out_price_two"] = Convert.ToDecimal(item.price2a);
                        }
                        if (!string.IsNullOrEmpty(item.price3a))
                        {
                            drPrice["out_price_three"] = Convert.ToDecimal(item.price3a);
                        }
                        drPrice["sort_index"] = "0";
                        drPrice["enable_flag"] = ((int)DataSources.EnumEnableFlag.USING).ToString();
                        drPrice["create_by"] = GlobalStaticObj_Server.Instance.UserID;
                        drPrice["create_time"] = nowTicks;
                        listTbPrice.Add(drPrice);
                    }
                    #endregion
                    partArr[index] = null;//释放项
                }

                //flag = DBHelper.BatchExeSQLStringMultiByTrans("宇通:同步配件", list);
                //flag = DBHelper.BatchExeSQLStringMultiByTrans("tb_parts", listTbParts);

                flag = DBHelper.SqlBulkByTransNoLogNoBackUp("同步配件", GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts", listTbParts);
                if (!flag)
                {
                    break;
                }
                #region 更新配件编码
                List<SysSQLString> listUpCode = new List<SysSQLString>();
                SysSQLString sqlCode = new SysSQLString();
                sqlCode.cmdType = CommandType.Text;
                sqlCode.Param = new Dictionary<string, string>();
                sqlCode.Param.Add("bill_code_rule_id", comm.ruleID);
                sqlCode.Param.Add("last_bill_no", partCode);
                sqlCode.sqlString = "update sys_bill_code_rule set last_bill_no=@last_bill_no where bill_code_rule_id=@bill_code_rule_id";
                listUpCode.Add(sqlCode);
                flag = DBHelper.BatchExeSQLStrMultiByTransNoLogNoBackup("", GlobalStaticObj_Server.Instance.MainAccCode, listUpCode);
                if (!flag)
                {
                    break;
                }
                #endregion
                //flag = DBHelper.BatchExeSQLStringMultiByTrans("tb_parts_replace", listTbReplace);
                flag = DBHelper.SqlBulkByTransNoLogNoBackUp("同步替换配件", GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts_replace", listTbReplace);
                if (!flag)
                {
                    break;
                }
                flag = DBHelper.SqlBulkByTransNoLogNoBackUp("同步价格信息", GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts_price", listTbPrice);
                if (!flag)
                {
                    break;
                }
                flag = DBHelper.SqlBulkByTransNoLogNoBackUp("同步单位设置", GlobalStaticObj_Server.Instance.MainAccCode, "tb_parts_setup", listTbSetup);
                if (list.Count > 0)
                {
                    flag = DBHelper.BatchExeSQLStrMultiByTransNoLogNoBackup("更新配件信息", GlobalStaticObj_Server.Instance.MainAccCode, list);
                    if (!flag)
                    {
                        break;
                    }
                }

            }
            #region 加密价格
            List<SysSQLString> listUp = new List<SysSQLString>();
            SysSQLString sqlPrice = new SysSQLString();
            sqlPrice.cmdType = CommandType.Text;
            string price3aEnc = WebServUtil.GetEncFieldByField("price3a_back");
            string price2aEnc = WebServUtil.GetEncFieldByField("price2a_back");
            sqlPrice.sqlString = string.Format("update tb_parts set price3a={0},price2a={1},price2a_back=null,price3a_back=null where price3a_back is not null or price2a_back is not null",
                price2aEnc, price2aEnc);
            sqlPrice.Param = new Dictionary<string, string>();
            listUp.Add(sqlPrice);
            DBHelper.BatchExeSQLStrMultiByTransNoLogNoBackup("", GlobalStaticObj_Server.Instance.MainAccCode, listUp);
            #endregion

            SysConfig sysConfig = new SysConfig();
            sysConfig.UpdateLastTime("PartLastTime");
            updateCount += partArr.Count();
            dtParts = null;
            dtReplace = null;
            dtTbParts = null;
            dtTbPartsPrice = null;
            dtTbPartsSetup = null;
            dtTbReplace = null;
            dic = null;
            DateTime endDate = DateTime.Now;
            TimeSpan span = endDate - startDate;

            return flag;
        }