|
@@ -10120,11 +10120,146 @@ namespace OASystem.API.Controllers
|
|
|
_sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
|
|
|
//var groupClinetData1
|
|
|
|
|
|
+ string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
|
|
|
+ var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
|
|
|
|
|
|
|
|
|
+ int updateCount = 0;
|
|
|
+
|
|
|
+ if (oldOAClientList.Count > 0 )
|
|
|
+ {
|
|
|
+
|
|
|
+ _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
|
|
|
+
|
|
|
+ _sqlSugar.BeginTran();
|
|
|
+
|
|
|
+ var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
|
|
|
+ var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
|
|
|
+
|
|
|
+ foreach (var item in oldOAClientList)
|
|
|
+ {
|
|
|
+
|
|
|
+ int comId = 0;
|
|
|
+
|
|
|
+ string format = "yyyy-MM-dd HH:mm:ss";
|
|
|
+
|
|
|
+ string data11 = "1990-01-01 00:00";
|
|
|
+ var data1 = IsValidDate(item.OPdate, format);
|
|
|
+ if (data1) data11 = item.OPdate;
|
|
|
+
|
|
|
+
|
|
|
+ //客户公司验证
|
|
|
+ if (!string.IsNullOrEmpty(item.Company))
|
|
|
+ {
|
|
|
+ var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (clientComInfo == null) // add
|
|
|
+ {
|
|
|
+ var addInfo = new Crm_CustomerCompany()
|
|
|
+ {
|
|
|
+ CompanyAbbreviation = "",
|
|
|
+ CompanyFullName = item.Company,
|
|
|
+ Address = "",
|
|
|
+ PostCodes = "",
|
|
|
+ LastedOpUserId = item.OPer,
|
|
|
+ LastedOpDt = Convert.ToDateTime(data11),
|
|
|
+ CreateUserId = item.OPer,
|
|
|
+ CreateTime = Convert.ToDateTime(data11),
|
|
|
+ IsDel = 0
|
|
|
+ };
|
|
|
+
|
|
|
+ var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
|
|
|
+ if (comId1 > 0) comId = comId1;
|
|
|
+ }
|
|
|
+ else comId = clientComInfo.Id;
|
|
|
+ }
|
|
|
+
|
|
|
+ //客户人员验证
|
|
|
+ int clientId = 0;
|
|
|
+ string name = item.LastName + item.Name;
|
|
|
+ if (!string.IsNullOrEmpty(name))
|
|
|
+ {
|
|
|
+ var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
|
|
|
+ if (clientInfo == null)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ string format1 = "yyyy-MM-dd";
|
|
|
+
|
|
|
+ string data111 = "1990-01-01";
|
|
|
+
|
|
|
+ var data11_1 = IsValidDate(item.Birthday, format1);
|
|
|
+ if (data11_1) data111 = item.OPdate;
|
|
|
+
|
|
|
+ var addInfo1 = new Crm_DeleClient()
|
|
|
+ {
|
|
|
+ CrmCompanyId = comId,
|
|
|
+ DiId = -1,
|
|
|
+ LastName = item.LastName,
|
|
|
+ FirstName = item.Name,
|
|
|
+ OldName = "",
|
|
|
+ Pinyin = item.Pinyin,
|
|
|
+ Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
|
|
|
+ Marriage = 0,
|
|
|
+ Phone = item.Phone,
|
|
|
+ Job = item.Job,
|
|
|
+ BirthDay = Convert.ToDateTime(data111).ToString("yyyy-MM-dd"),
|
|
|
+
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
|
|
|
+ if (clientId1 > 0) clientId = clientId1;
|
|
|
+ }
|
|
|
+ else clientId = clientInfo.Id;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (clientId < 1)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ int airType= 0;
|
|
|
+
|
|
|
+ if (item.AirType == "超经舱") airType = 459;
|
|
|
+ else if (item.AirType == "公务舱") airType = 458;
|
|
|
+ else if (item.AirType == "经济舱") airType = 460;
|
|
|
+ else if (item.AirType == "其他") airType = 565;
|
|
|
+ else if (item.AirType == "头等舱") airType = 457;
|
|
|
+
|
|
|
+ var _TourClientListEntity = new Grp_TourClientList()
|
|
|
+ {
|
|
|
+ DiId = item.Diid,
|
|
|
+ ClientId = clientId,
|
|
|
+ CreateUserId = item.OPer,
|
|
|
+ CreateTime = Convert.ToDateTime(data11),
|
|
|
+ Remark = item.Remark,
|
|
|
+ IsDel = item.Isdel,
|
|
|
+ ShippingSpaceTypeId = airType,
|
|
|
+ ShippingSpaceSpecialNeeds = item.AirRemark,
|
|
|
+ HotelSpecialNeeds = item.RoomType
|
|
|
+ };
|
|
|
+
|
|
|
+ var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
|
|
|
+
|
|
|
+ if (_TourClientList > 0)
|
|
|
+ {
|
|
|
+ updateCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(JsonView(true, $"更新条数:{updateCount}条"));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
|
|
|
return Ok(JsonView(false, ex.Message));
|
|
|
}
|
|
@@ -10133,7 +10268,12 @@ namespace OASystem.API.Controllers
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ private bool IsValidDate(string dateString, string format)
|
|
|
+ {
|
|
|
+ DateTime dateValue;
|
|
|
+ bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
|
|
|
+ return valid;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/// <summary>
|