diff --git a/DigitalSchoolApi/Controllers/YKTTrabs.cs b/DigitalSchoolApi/Controllers/YKTTrabs.cs index 344067e..5af514a 100644 --- a/DigitalSchoolApi/Controllers/YKTTrabs.cs +++ b/DigitalSchoolApi/Controllers/YKTTrabs.cs @@ -813,7 +813,7 @@ namespace DigitalSchoolApi.Controllers conncore.Execute( "insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),121,'typecode','开票typecode:" + item.Key + "',getdate())"); } - InvoiceEBillByTypeTwo(conn,orderEntity, item.Key, item); + InvoiceEBillByTypeTwo(conn, orderEntity, item.Key, item); } catch (Exception ex) { @@ -1030,7 +1030,7 @@ namespace DigitalSchoolApi.Controllers } } - private static void InvoiceEBillByTypeTwo(IDbConnection conn,FinaChargeStuOrderEntity orderEntity, string billCode, IGrouping stuEnrollFeeOrderDetailList) + private static void InvoiceEBillByTypeTwo(IDbConnection conn, FinaChargeStuOrderEntity orderEntity, string billCode, IGrouping stuEnrollFeeOrderDetailList) { Encoding encoding = Encoding.UTF8; string StuName = conn.QuerySingle("select StuName from FinaChargeStudent where stuno='" + orderEntity.StuNo + "'").StuName; @@ -1465,37 +1465,7 @@ namespace DigitalSchoolApi.Controllers #endregion - using (IDbConnection db =new SqlConnection(_coresqlConnection)) - { - - #region 部门 - List departments = db.Query("select * from LR_Base_Department").ToList(); - int anumDept = 0; - int unumDept = 0; - foreach (var item in depts) - { - try - { - if(departments.Any(x=>x.F_DepartmentId==item.ID)) - { - var sql = $"update LR_Base_Department set F_FullName='{item.NAME_}',F_ParentId='{item.PID}',F_EnCode='{item.ID}',F_ShortName='{item.NAME_SHORT}',F_CreateDate='{DateTime.Now}' where F_DepartmentId='{item.ID}'"; - anumDept += db.Execute(sql); - } - else - { - var sql = $"insert into LR_Base_Department (F_DepartmentId,F_CompanyId,F_ParentId,F_EnCode,F_FullName,F_ShortName,F_SortCode,F_DeleteMark,F_EnabledMark,F_CreateDate,F_Order) values ('{item.ID}','207fa1a9-160c-4943-a89b-8fa4db0547ce','{item.PID}','{item.ID}','{item.NAME_}','{item.NAME_SHORT}',0,0,1,'{DateTime.Now}',0)"; - anumDept += db.Execute(sql); - } - } - catch (Exception ex) - { - db.Execute( - $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'更新部门数据','编号({item.ID}),姓名({item.NAME_})更新时出现异常:{ex.Message}',getdate())"); - } - } - - #endregion - } + var teachinfo = new List(); using (IDbConnection conncores = new SqlConnection(_sqlConnection)) { @@ -1532,7 +1502,7 @@ namespace DigitalSchoolApi.Controllers sb.Remove(sb.ToString().LastIndexOf(","), 1); } //修改条件 - sb.Append($" where MajorNo='{item.CODE_ }' and MajorName='{item.NAME_}'"); + sb.Append($" where MajorNo='{item.CODE_}' and MajorName='{item.NAME_}'"); unumMajor += conncores.Execute(sb.ToString()); } else @@ -1592,7 +1562,7 @@ namespace DigitalSchoolApi.Controllers sb.Remove(sb.ToString().LastIndexOf(","), 1); } //修改条件 - sb.Append($" where lessonno='{item.CODE_ }' and lessonName='{item.NAME_}'"); + sb.Append($" where lessonno='{item.CODE_}' and lessonName='{item.NAME_}'"); unumlesson += conncores.Execute(sb.ToString()); } else @@ -1619,18 +1589,20 @@ namespace DigitalSchoolApi.Controllers } #endregion - + #region 教师信息 - List teachinfo = conncores.Query("select * from empinfo").ToList(); + teachinfo = conncores.Query("select * from empinfo").ToList(); int anumTeach = 0; int unumTeach = 0; foreach (var item in jsxx) { try { - if (teachinfo.Exists(x => x.EmpNo == item.TEA_NO && x.EmpName == item.NAME_)) + if (teachinfo.Exists(x => x.EmpNo == item.TEA_NO)) { StringBuilder sb = new StringBuilder("update empinfo set "); + sb.Append($" EmpName='{item.NAME_}',"); + sb.Append($" UpdateTime='{DateTime.Now}', "); if (!string.IsNullOrEmpty(item.ZZJG_ID)) { sb.Append($" ZZJG_ID='{item.ZZJG_ID}',"); @@ -1678,12 +1650,12 @@ namespace DigitalSchoolApi.Controllers sb.Remove(sb.ToString().LastIndexOf(","), 1); } //修改条件 - sb.Append($" where empno='{item.TEA_NO }' and empName='{item.NAME_}'"); + sb.Append($" where empno='{item.TEA_NO}'"); unumTeach += conncores.Execute(sb.ToString()); } else { - int mysql = conncores.Execute($"insert into empinfo (empid,ZZJG_ID,F_DepartmentId,empNo,empName,Birthday,IdentityCardNo,mobile,DegreeNo,HighestRecord,CheckMark,F_CompanyId,BZLB_CODE,BZLX_CODE,IsInActiveStatus) values (newid(), '{item.ZZJG_ID}', '{item.DEPT_ID}', '{item.TEA_NO}', '{item.NAME_}', '{item.BIRTH_DATE}', '{item.IDNO}', '{item.PHONE}', '{item.EDU_ID}', '{item.DEGREE_ID}', '{item.IS_NORMAL}', '207fa1a9-160c-4943-a89b-8fa4db0547ce', '{item.BZLB_CODE}', '{item.BZLX_CODE}', '{item.TEA_STATUS_CODE}')"); + int mysql = conncores.Execute($"insert into empinfo (empid,ZZJG_ID,F_DepartmentId,empNo,empName,Birthday,IdentityCardNo,mobile,DegreeNo,HighestRecord,CheckMark,F_CompanyId,BZLB_CODE,BZLX_CODE,IsInActiveStatus,UpdateTime) values (newid(), '{item.ZZJG_ID}', '{item.DEPT_ID}', '{item.TEA_NO}', '{item.NAME_}', '{item.BIRTH_DATE}', '{item.IDNO}', '{item.PHONE}', '{item.EDU_ID}', '{item.DEGREE_ID}', '{item.IS_NORMAL}', '207fa1a9-160c-4943-a89b-8fa4db0547ce', '{item.BZLB_CODE}', '{item.BZLX_CODE}', '{item.TEA_STATUS_CODE}','{DateTime.Now}')"); anumTeach += mysql; } } @@ -1764,7 +1736,7 @@ namespace DigitalSchoolApi.Controllers sb.Remove(sb.ToString().LastIndexOf(","), 1); } //修改条件 - sb.Append($" where classno='{item.NO_ }' and className='{item.NAME_}'"); + sb.Append($" where classno='{item.NO_}' and className='{item.NAME_}'"); unumClass += conncores.Execute(sb.ToString()); } else @@ -1849,7 +1821,7 @@ namespace DigitalSchoolApi.Controllers sb.Remove(sb.ToString().LastIndexOf(","), 1); } //修改条件 - sb.Append($" where classroomno='{item.CODE_ }' and classroomName='{item.NAME_}'"); + sb.Append($" where classroomno='{item.CODE_}' and classroomName='{item.NAME_}'"); unumCroom += conncores.Execute(sb.ToString()); } else @@ -1881,6 +1853,47 @@ namespace DigitalSchoolApi.Controllers #endregion } + using (IDbConnection db = new SqlConnection(_coresqlConnection)) + { + + #region 部门 + List departments = db.Query("select * from LR_Base_Department").ToList(); + int anumDept = 0; + int unumDept = 0; + + foreach (var item in depts) + { + try + { + if (item.LEVEL_TYPE.ToLower() != "xx" && item.LEVEL_TYPE.ToLower() != "zy") + { + var manager = string.Empty; + if (!string.IsNullOrWhiteSpace(item.ADMIN_MANAGE_TEA_NO)) + { + manager = teachinfo.FirstOrDefault(x => x.EmpNo == item.ADMIN_MANAGE_TEA_NO)?.EmpId ?? ""; + } + if (departments.Any(x => x.F_DepartmentId == item.ID)) + { + var sql = $"update LR_Base_Department set F_FullName='{item.NAME_}',F_ParentId='{item.PID}',F_EnCode='{item.CODE_}',F_ShortName='{item.NAME_SHORT}',F_Manager='{manager}',F_Description='{item.LEVEL_TYPE}',F_ModifyDate='{DateTime.Now}' where F_DepartmentId='{item.ID}'"; + anumDept += db.Execute(sql); + } + else + { + var sql = $"insert into LR_Base_Department (F_DepartmentId,F_CompanyId,F_ParentId,F_EnCode,F_FullName,F_ShortName,F_Manager,F_Description,F_SortCode,F_DeleteMark,F_EnabledMark,F_CreateDate,F_Order) values ('{item.ID}','207fa1a9-160c-4943-a89b-8fa4db0547ce','{item.PID}','{item.CODE_}','{item.NAME_}','{item.NAME_SHORT}','{manager}','{item.LEVEL_TYPE}',0,0,1,'{DateTime.Now}',0)"; + anumDept += db.Execute(sql); + } + } + + } + catch (Exception ex) + { + db.Execute( + $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'更新部门数据','编号({item.ID}),姓名({item.NAME_})更新时出现异常:{ex.Message}',getdate())"); + } + } + + #endregion + } //获取oracle学生数据 //List xcStudentList = conn_oracle.Query(@"select ID,stu_no,name_, //(case when dept_id in ('01','02','03') then dept_id when dept_id='00' then '06' when dept_id='23' then '04' when dept_id='06' then '07' else '' end )as dept_id, @@ -1908,11 +1921,13 @@ namespace DigitalSchoolApi.Controllers { try { - if (stuInfoBasicList.Exists(x => x.StuNo == item.STU_NO && x.StuName == item.NAME_)) + if (stuInfoBasicList.Exists(x => x.StuNo == item.STU_NO)) { //学生存在,修改 #region 拼接SQL StringBuilder sb = new StringBuilder("update StuInfoBasic set "); + sb.Append($" StuName='{item.NAME_}',"); + sb.Append($" UpdateTime='{DateTime.Now}', "); if (!string.IsNullOrEmpty(item.DEPT_ID)) { sb.Append($" DeptNo='{item.DEPT_ID}',"); @@ -1947,7 +1962,7 @@ namespace DigitalSchoolApi.Controllers } if (!string.IsNullOrEmpty(item.SEX_CODE)) { - sb.Append(" GenderNo='"+(item.SEX_CODE=="1"?"1":"0")+"',"); + sb.Append(" GenderNo='" + (item.SEX_CODE == "1" ? "1" : "0") + "',"); } //民族 if (!string.IsNullOrEmpty(item.NATION_CODE)) @@ -1998,7 +2013,7 @@ namespace DigitalSchoolApi.Controllers { sb.Remove(sb.ToString().LastIndexOf(","), 1); } - sb.Append($" where StuNo='{item.STU_NO}' and StuName='{item.NAME_}'"); + sb.Append($" where StuNo='{item.STU_NO}'"); //System.IO.File.AppendAllText(@"c:\test.txt", sb.ToString() + "\r\n"); #endregion unum += conn.Execute(sb.ToString()); @@ -2056,8 +2071,8 @@ namespace DigitalSchoolApi.Controllers string mysql = "insert into StuInfoBasic("; StringBuilder fieleSb = new StringBuilder(); StringBuilder sb = new StringBuilder(); - fieleSb.Append("StuId,stuno,stuname,CheckMark,F_SchoolId,"); - sb.Append($" NEWID(),'{xsxx.STU_NO}','{xsxx.NAME_}','1','207fa1a9-160c-4943-a89b-8fa4db0547ce',"); + fieleSb.Append("StuId,stuno,stuname,CheckMark,F_SchoolId,UpdateTime,"); + sb.Append($" NEWID(),'{xsxx.STU_NO}','{xsxx.NAME_}','1','207fa1a9-160c-4943-a89b-8fa4db0547ce','{DateTime.Now}',"); if (!string.IsNullOrEmpty(xsxx.DEPT_ID)) { fieleSb.Append("DeptNo,"); @@ -2138,7 +2153,7 @@ namespace DigitalSchoolApi.Controllers sb.Append($" '{xsxx.ENROLL_GRADE.ToString().Substring(2)}',"); } - if (xsxx.IS_NORMAL!=null) + if (xsxx.IS_NORMAL != null) { fieleSb.Append("InSchoolStatus,"); sb.Append(" '" + (xsxx.IS_NORMAL) + "',"); @@ -2338,11 +2353,6 @@ namespace DigitalSchoolApi.Controllers { try { - using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) - { - conncore.Execute( - $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水1','开始执行',getdate())"); - } string Token = ""; #region 登陆获取token //获取配置文件 @@ -2362,57 +2372,83 @@ namespace DigitalSchoolApi.Controllers using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) { conncore.Execute( - $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水2','Token秘钥获取成功',getdate())"); + $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水','Token秘钥获取成功',getdate())"); } #endregion #region 插入数据 using (IDbConnection conn = new SqlConnection(_sqlConnection)) { + var tday = DateTime.Now.ToShortDateString(); + DateTime StartTime = DateTime.Today.AddHours(0); + DateTime EndTime = DateTime.Today.AddHours(1); + string JylsUrl = ConfigurationManager.AppSettings["JylsUrl"]; var Historylist = Convert.ToInt64(conn.ExecuteScalar("select isnull(Max(centralNo),0) from MealCardRunTab ")); - string data = "{ \"pageNo\":\"1\",\"PageSize\":\"1000\",\"Date\":\"" + DateTime.Now.ToShortDateString() + "\",\"StartTime\":\"00:00:00\",\"EndTime\":\"23:59:59\"}"; + string data = "{ \"pageNo\":\"1\",\"PageSize\":\"1000\",\"Date\":\"" + tday + "\",\"StartTime\":\"00:00:00\",\"EndTime\":\"23:59:59\",\"depcode\":\"7D\"}"; var responses = HttpMethods.sendHttpPost(JylsUrl, Token, data); var RequsetList = JsonConvert.DeserializeObject(responses); - if (RequsetList.pageTotal > 0) + + + using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) + { + conncore.Execute( + $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通数据()','本次一共" + RequsetList.total + "条数据',getdate())"); + } + + + for (int k = 0; k <= 23; k++) { - for (int i = 1; i <= RequsetList.pageTotal; i++) + using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) + { + conncore.Execute( + $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通数据','第" + k + "次循环',getdate())"); + } + if (k != 0) + { + StartTime = StartTime.AddHours(1); + EndTime = EndTime.AddHours(1); + } + data = "{ \"pageNo\":\"1\",\"PageSize\":\"1000\",\"Date\":\"" + tday + "\",\"StartTime\":\"" + StartTime + "\",\"EndTime\":\"" + EndTime + "\",\"depcode\":\"7D\"}"; + responses = HttpMethods.sendHttpPost(JylsUrl, Token, data); + RequsetList = JsonConvert.DeserializeObject(responses); + + if (RequsetList.pageTotal > 0) { - data = "{ \"pageNo\":\"" + i + " \",\"PageSize\":\"1000\",\"Date\":\"" + DateTime.Now.ToShortDateString() + "\",\"StartTime\":\"00:00:00\",\"EndTime\":\"23:59:59\"}"; - var responses1 = HttpMethods.sendHttpPost(JylsUrl, Token, data); - var RequsetList1 = JsonConvert.DeserializeObject(responses1); - var NowCen = RequsetList1.data.flowlist.Max(x => x.centralNo); - if (NowCen > Historylist) + int total = (int)Math.Ceiling((decimal)RequsetList.total / 1000); + using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) { - using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) - { - conncore.Execute( - $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水3','准备开始插入数据',getdate())"); - } - for (int j = 0; j < RequsetList1.data.flowlist.Count; j++) + conncore.Execute( + $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水1','一共" + RequsetList.total + "条数据',getdate())"); + } + + for (int i = 1; i <= total; i++) + { + data = "{ \"pageNo\":\"" + i + " \",\"PageSize\":\"1000\",\"Date\":\"" + tday + "\",\"StartTime\":\"" + StartTime + "\",\"EndTime\":\"" + EndTime + "\",\"depcode\":\"7D\"}"; + responses = HttpMethods.sendHttpPost(JylsUrl, Token, data); + RequsetList = JsonConvert.DeserializeObject(responses); + if (RequsetList.data.flowlist.Count > 0) { - var nowCen = Convert.ToInt32(conn.ExecuteScalar("select Count(*) from MealCardRunTab where centralNo='" + RequsetList1.data.flowlist[j].centralNo + "' ")); - if (nowCen <= 0) + var NowCen = RequsetList.data.flowlist.Max(x => x.centralNo); + if (NowCen > Historylist) { - conn.Execute( - "insert into MealCardRunTab(Id,accountNo,accountName,depName,personId,identiName,flowtype,flowamount,balance,cardNo,centralTm,centralNo,occurTime,node,bigGroup,smallGroup,seg,pos) " + - "values(newid(), '" + RequsetList1.data.flowlist[j].accountNo + "', '" + RequsetList1.data.flowlist[j].accountName + "', '" + RequsetList1.data.flowlist[j].depName + "','" + RequsetList1.data.flowlist[j].personId + "','" + RequsetList1.data.flowlist[j].identiName + "','" + RequsetList1.data.flowlist[j].flowType + "','" + RequsetList1.data.flowlist[j].flowAmount + - "','" + RequsetList1.data.flowlist[j].balance + "','" + RequsetList1.data.flowlist[j].cardNo + "','" + RequsetList1.data.flowlist[j].centralTm + "','" + RequsetList1.data.flowlist[j].centralNo + "','" + RequsetList1.data.flowlist[j].occurTime + "','" + RequsetList1.data.flowlist[j].node + "','" + RequsetList1.data.flowlist[j].bigGroup + "','" + RequsetList1.data.flowlist[j].group + "','" + RequsetList1.data.flowlist[j].seg + "','" + RequsetList1.data.flowlist[j].pos + "')"); - } - using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) - { - conncore.Execute( - $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水4','第" + j + "次插入数据完成',getdate())"); + for (int j = 0; j < RequsetList.data.flowlist.Count; j++) + { + var nowCen = Convert.ToInt32(conn.ExecuteScalar("select Count(*) from MealCardRunTab where centralNo='" + RequsetList.data.flowlist[j].centralNo + "' ")); + if (nowCen <= 0) + { + conn.Execute( + "insert into MealCardRunTab(Id,accountNo,accountName,depName,personId,identiName,flowtype,flowamount,balance,cardNo,centralTm,centralNo,occurTime,node,bigGroup,smallGroup,seg,pos) " + + "values(newid(), '" + RequsetList.data.flowlist[j].accountNo + "', '" + RequsetList.data.flowlist[j].accountName + "', '" + RequsetList.data.flowlist[j].depName + "','" + RequsetList.data.flowlist[j].personId + "','" + RequsetList.data.flowlist[j].identiName + "','" + RequsetList.data.flowlist[j].flowType + "','" + RequsetList.data.flowlist[j].flowAmount + + "','" + RequsetList.data.flowlist[j].balance + "','" + RequsetList.data.flowlist[j].cardNo + "','" + RequsetList.data.flowlist[j].centralTm + "','" + RequsetList.data.flowlist[j].centralNo + "','" + RequsetList.data.flowlist[j].occurTime + "','" + RequsetList.data.flowlist[j].node + "','" + RequsetList.data.flowlist[j].bigGroup + "','" + RequsetList.data.flowlist[j].group + "','" + RequsetList.data.flowlist[j].seg + "','" + RequsetList.data.flowlist[j].pos + "')"); + } + } } } } - using (IDbConnection conncore = new SqlConnection(_coresqlConnection)) - { - conncore.Execute( - $"insert into LR_Base_Log(F_LogId,F_CategoryId,F_SourceObjectId,F_SourceContentJson,F_OperateTime) values(newid(),55555,'一卡通交易流水5','插入数据',getdate())"); - } } } + } #endregion } diff --git a/DigitalSchoolApi/Web.config b/DigitalSchoolApi/Web.config index 33d69d6..0ca5377 100644 --- a/DigitalSchoolApi/Web.config +++ b/DigitalSchoolApi/Web.config @@ -21,7 +21,7 @@ - + @@ -53,18 +53,18 @@ - + - + - + - +