WebAPI/Controllers/Êý¾Ýͬ²½/¶¤¶¤Í¬²½/DD_DataSynchronizationController.cs
@@ -75,7 +75,7 @@
        private string AppKey = "dingiokapm2dvjrhzl2g";                                                                             //已创建的企业内部应用的AppKey。
        private string AppSecret = "dPUD7tN3BGVYAC4lDzhpcBH7O4FWFDdjLJWa6cVRBQj5U7GJ4Gwr7Vohnv0oPBOr";                             //已创建的企业内部应用的AppSecret。
        private long AgentID = 3188176952;                                                                                          //应用的AgentId
        private string accessToken = "";                                                                                           //调用该接口的访问凭证。
        public string accessToken = "";                                                                                           //调用该接口的访问凭证。
        private string ProcessInstanceId = "";                                                                                     //审批实例ID。
        #endregion
@@ -276,11 +276,14 @@
            public string HNewModel;//   varchar(100)      --维修后新规格            addnew
            public Single HNewDesignLife;//   money         --新设计寿命
            public string HRemark;
            public string HPlanNo;
            public string HPlanInterID;
            public DateTime HRequestComDate;
            public double HRecentMainModule;
            public double HCumulativeModule;
            public double HProductionModule;
            public DateTime HRepairAccepDate;
            public string HMaintainLevID;
@@ -523,10 +526,10 @@
                //OriginatorId = "12",                                                                                          //根据流程发起人工号查询。
                //TaskId = "12",                                                                                                //任务ID。
                CreateFromTimeGMT = DateTime.Now.AddMonths(-10).ToString("yyyy-MM-dd"),                                          //创建时间起始值。
                CreateToTimeGMT = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),                                               //创建时间终止值。
                //ModifiedFromTimeGMT = DateTime.Now.AddDays(-14).ToString("yyyy-MM-dd"),                                          //修改时间起始值。
                //ModifiedToTimeGMT = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),                                               //修改时间终止值。
                //CreateFromTimeGMT = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd"),                                          //创建时间起始值。
                //CreateToTimeGMT = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"),                                               //创建时间终止值。
                ModifiedFromTimeGMT = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),                                          //修改时间起始值。
                ModifiedToTimeGMT = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),                                               //修改时间终止值。
                PageSize = pageSize,                                                  //分页大小。
                PageNumber = pageNumber,                                                 //分页页码
@@ -2081,6 +2084,30 @@
                                oItem.HDate = convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd HH:mm");
                            }
                            //模具保养级别
                            if (keys.Contains("selectField_m1ip9j31"))
                            {
                                string HDate_Temp = response.Body.Result[i].FormData["selectField_m1ip9j31"].ToString();
                                if (!HDate_Temp.Contains("三级"))
                                {
                                    ds = oCN.RunProcReturn("select  * from h_v_Gy_MaintainLev where ä¿å…»çº§åˆ«ä»£ç ='BY-SE-002'", "h_v_Gy_MaintainLev");
                                    if (ds.Tables[0].Rows.Count > 0)
                                    {
                                        HDate_Temp = ds.Tables[0].Rows[0]["HItemID"].ToString();
                                    }
                                }
                                else if (HDate_Temp.Contains("三级"))
                                {
                                    ds = oCN.RunProcReturn("select  * from h_v_Gy_MaintainLev where ä¿å…»çº§åˆ«ä»£ç ='BY-SE-003'", "h_v_Gy_MaintainLev");
                                    if (ds.Tables[0].Rows.Count > 0)
                                    {
                                        HDate_Temp = ds.Tables[0].Rows[0]["HItemID"].ToString();
                                    }
                                }
                                oItem.HMaintainLevID = HDate_Temp;
                            }
                            //修模开始时间
                            if (keys.Contains("dateField_lq4gf2ih"))
                            {
@@ -2141,7 +2168,7 @@
                            if (keys.Contains("selectField_lq3idkvg"))
                            {
                                string HDate_Temp = response.Body.Result[i].FormData["selectField_lq3idkvg"].ToString();
                                DataSet ds = oCN.RunProcReturn("select * from Gy_MouldFileMain with(nolock)  where HNumber='" + HDate_Temp + "'", "Gy_MouldFileMain");
                                DataSet ds = oCN.RunProcReturn("select * from Gy_MouldFileMain with(nolock)  where HMouldNo='" + HDate_Temp + "'", "Gy_MouldFileMain");
                                string HMouldID = "0";
                                if (ds.Tables[0].Rows.Count > 0)
                                {
@@ -2149,6 +2176,17 @@
                                }
                                oItem.HMouldID = long.Parse(HMouldID);
                                oItem.HRemark = HDate_Temp;
                                //查询保养计划
                                ds = oCN.RunProcReturn(@"select  a.HInterID,a.HBillNo from  Sc_MouldMaintainPlanBillMain a
                                    inner join Sc_MouldMaintainPlanBillSub b on a.HInterID = b.HInterID
                                    where a.HMouldID =" + oItem.HMouldID + " and a.HMaintainLevID = " + oItem.HMaintainLevID, "Sc_MouldMaintainPlanBillMain");
                                oItem.HPlanInterID = "";
                                if (ds.Tables[0].Rows.Count > 0) {
                                    oItem.HPlanInterID = ds.Tables[0].Rows[0]["HInterID"].ToString();
                                    oItem.HPlanNo = ds.Tables[0].Rows[0]["HInterID"].ToString();
                                }
                            }
@@ -2366,16 +2404,18 @@
                            string sql_main = "Insert Into Sc_MouldMaintainBillMain " +
                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate" +
                ",HYear,HPeriod,HRemark,HUpDateDate" +
                ",HPlanNo,HPlanInterID,HMouldID,HBeginDate" +
                ",HMouldID,HBeginDate" +
                ",HEndDate" +
                ",HInnerBillNo,HExplanation,HMouldMaintainRuleInterID,HMaintainLevID,HLastResult" +
                ",HRequestComDate,HRecentMainModule,HCumulativeModule,HProductionModule)" +
                ",HInnerBillNo,HExplanation,HMouldMaintainRuleInterID,HLastResult" +
                ",HRequestComDate,HRecentMainModule,HCumulativeModule,HProductionModule" +
                ",HPlanInterID,HPlanNo,HMaintainLevID)" +
                "values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + oItem.HBillNo + "','"+ oItem.HDate + "','" + oItem.HOriginator + "','" + oItem.HMakeDate + "'" +
                      ",'" + DateTime.Now.Year + "','" + DateTime.Now.Month + "','"+ oItem.HRemark + "','" + oItem.HUpdateDate + "'" +
                      ",'','0','" + oItem.HMouldID + "','" + oItem.HRepairBeginDate + "'" +
                      ",'" + oItem.HMouldID + "','" + oItem.HRepairBeginDate + "'" +
                      ",'" + oItem.HRepairEndDate + "'" +
                      ",'" + oItem.HInstanceID + "','',"+ HMouldMaintainRuleInterID + ",0,'OK'" +
                      ",'"+ oItem.HRequestComDate + "'," + oItem.HRecentMainModule + "," + oItem.HCumulativeModule + "," + oItem.HProductionModule + ")";
                      ",'" + oItem.HInstanceID + "','',"+ HMouldMaintainRuleInterID + ",'OK'" +
                      ",'"+ oItem.HRequestComDate + "'," + oItem.HRecentMainModule + "," + oItem.HCumulativeModule + "," + oItem.HProductionModule + "" +
                      "," + (oItem.HPlanInterID == "" ? "0" : oItem.HPlanInterID) + ",'" + oItem.HPlanNo + "'," + oItem.HMaintainLevID + ")";
                            LogService.Write(sql_main);
                            oCN.RunProc(sql_main);
                            int i = 1;
@@ -2522,6 +2562,72 @@
                                continue;
                            }
                            //if (oItem.HInstanceID != "9b6e108c-b7bf-45e4-910d-5629ac30d4aa") {
                            //    continue;
                            //}
                            //设备编码
                            if (keys.Contains("textField_lfg9hgys"))
                            {
                                string HDate_Temp = response.Body.Result[i].FormData["textField_lfg9hgys"].ToString();
                                DataSet ds = oCN.RunProcReturn("select * from Gy_EquipFileBillMain with(nolock)  where HEquipFileNo='" + HDate_Temp + "'", "Gy_EquipFileBillMain");
                                string HEquipID = "0";
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    HEquipID = ds.Tables[0].Rows[0]["HInterID"].ToString();
                                    oItem.HEquipID = long.Parse(HEquipID);
                                    oItem.HRemark2 = HDate_Temp;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            //维修部门
                            if (keys.Contains("selectField_kzgkw10a"))
                            {
                                string HDate_Temp = response.Body.Result[i].FormData["selectField_kzgkw10a"].ToString();
                                DataSet ds = oCN.RunProcReturn("select * from Gy_Department with(nolock)  where HName='" + HDate_Temp + "'", "Gy_Department");
                                string HDeptID = "0";
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    HDeptID = ds.Tables[0].Rows[0]["HItemID"].ToString();
                                    oItem.HDeptID = long.Parse(HDeptID);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            //维修人
                            if (keys.Contains("employeeField_lthwkdh2"))
                            {
                                string[] HDate_Temp = JsonConvert.DeserializeObject<string[]>(JsonConvert.SerializeObject(response.Body.Result[i].FormData["employeeField_lthwkdh2"]));
                                DataSet ds = oCN.RunProcReturn("select * from Gy_Employee with(nolock)  where HName='" + HDate_Temp[0] + "'", "Gy_Employee");
                                string HEmpID = "0";
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    HEmpID = ds.Tables[0].Rows[0]["HItemID"].ToString();
                                    oItem.HEmpID = long.Parse(HEmpID);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            //维修内容
                            if (keys.Contains("textField_l2r9bvwk"))
                            {
                                string HDate_Temp = response.Body.Result[i].FormData["textField_l2r9bvwk"].ToString();
                                oItem.HRepairContent = HDate_Temp;
                            }
                            //报修类别
                            if (keys.Contains("multiSelectField_lfg9hgyv"))
                            {
@@ -2564,60 +2670,11 @@
                                {
                                    HDate_Temp = "0";
                                }
                                LogService.Write("1:------"+HDate_Temp+ ",2:------" + int.Parse(new string(HDate_Temp.Where(char.IsDigit).ToArray())));
                                //LogService.Write("1:------"+HDate_Temp+ ",2:------" + int.Parse(new string(HDate_Temp.Where(char.IsDigit).ToArray())));
                                //a = HDate_Temp;
                                oItem.HTimes = int.Parse(new string(HDate_Temp.Where(char.IsDigit).ToArray()));
                                oItem.HPlanTimes = int.Parse(new string(HDate_Temp.Where(char.IsDigit).ToArray()));
                            }
                            //设备编码
                            if (keys.Contains("textField_lfg9hgys"))
                            {
                                string HDate_Temp = response.Body.Result[i].FormData["textField_lfg9hgys"].ToString();
                                DataSet ds = oCN.RunProcReturn("select * from Gy_EquipFileBillMain with(nolock)  where HEquipFileNo='" + HDate_Temp + "'", "Gy_EquipFileBillMain");
                                string HEquipID = "0";
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    HEquipID = ds.Tables[0].Rows[0]["HInterID"].ToString();
                                }
                                oItem.HEquipID = long.Parse(HEquipID);
                                oItem.HRemark2 = HDate_Temp;
                            }
                            //维修部门
                            if (keys.Contains("selectField_kzgkw10a"))
                            {
                                string HDate_Temp = response.Body.Result[i].FormData["selectField_kzgkw10a"].ToString();
                                DataSet ds = oCN.RunProcReturn("select * from Gy_Department with(nolock)  where HName='" + HDate_Temp + "'", "Gy_Department");
                                string HDeptID = "0";
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    HDeptID = ds.Tables[0].Rows[0]["HItemID"].ToString();
                                }
                                oItem.HDeptID = long.Parse(HDeptID);
                            }
                            //维修人
                            if (keys.Contains("employeeField_lthwkdh2"))
                            {
                                string[] HDate_Temp = JsonConvert.DeserializeObject<string[]>(JsonConvert.SerializeObject(response.Body.Result[i].FormData["employeeField_lthwkdh2"]));
                                DataSet ds = oCN.RunProcReturn("select * from Gy_Employee with(nolock)  where HName='" + HDate_Temp[0] + "'", "Gy_Employee");
                                string HEmpID = "0";
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    HEmpID = ds.Tables[0].Rows[0]["HItemID"].ToString();
                                }
                                oItem.HEmpID = long.Parse(HEmpID);
                            }
                            //维修内容
                            if (keys.Contains("textField_l2r9bvwk"))
                            {
                                string HDate_Temp = response.Body.Result[i].FormData["textField_l2r9bvwk"].ToString();
                                oItem.HRepairContent = HDate_Temp;
                            }
                            //子表 ç»´ä¿®è¦æ±‚ ç»´ä¿®å¤‡æ³¨(问题描述)
@@ -2673,7 +2730,7 @@
                        }
                        catch (Exception e)
                        {
                            //LogService.Write(a);
                            LogService.Write(e.Message);
                            a = "";
                            continue;
                        }