11
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1,58 @@
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BLL.APIService
|
||||
{
|
||||
|
||||
public class SyncContractorService
|
||||
{
|
||||
private const string GETAPIUrl = "https://reportserver.basf-ypc.net.cn:3033/api/query";
|
||||
public static void GetSyncContractor()
|
||||
{
|
||||
//string file = System.Web.HttpContext.Current.Server.MapPath("~/ContractorData.txt");
|
||||
//string result = System.IO.File.ReadAllText(file);
|
||||
|
||||
string username = "EpermitContractor_EFC";
|
||||
string password = "nM3#yU5$pO8%aZ6";
|
||||
string result = BLL.Common.HttpHelper.HttpGetRequest(GETAPIUrl, username, password);
|
||||
//BLL.ErrLogInfo.WriteLog($"请求API Result={result}");
|
||||
|
||||
var data = JsonHelper.DeserializeJsonToObject<List<ContractorInfo>>(result);
|
||||
List<Model.EMC_Contractor> conList = new List<Model.EMC_Contractor>();
|
||||
foreach (var item in data)
|
||||
{
|
||||
var conModel = new Model.EMC_Contractor();
|
||||
conModel.ContractorId = SQLHelper.GetNewID(typeof(Model.EMC_Contractor));
|
||||
conModel.ContractorCN = item.accepter_basf_dep;
|
||||
conModel.WorkDate = item.WorkDate;
|
||||
conModel.SyncTime = DateTime.Now;
|
||||
conList.Add(conModel);
|
||||
}
|
||||
AddSyncContractor(conList);
|
||||
}
|
||||
|
||||
private static void AddSyncContractor(List<Model.EMC_Contractor> cons)
|
||||
{
|
||||
string sql = "delete from EMC_Contractor";
|
||||
SQLHelper.ExecutSql(sql);
|
||||
|
||||
Funs.DB.EMC_Contractor.InsertAllOnSubmit(cons);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#region 内部类
|
||||
[Serializable]
|
||||
internal class ContractorInfo
|
||||
{
|
||||
public string accepter_basf_dep { get; set; }
|
||||
public string WorkDate { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,731 @@
|
||||
using Model;
|
||||
using NPOI.POIFS.Properties;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BLL.APIService
|
||||
{
|
||||
public class SyncSESService
|
||||
{
|
||||
private const string GETAPIUrl = "https://reportserver.basf-ypc.net.cn:3033/api/query";
|
||||
public static void GetSyncContractor()
|
||||
{
|
||||
//string file = System.Web.HttpContext.Current.Server.MapPath("~/ContractorData.txt");
|
||||
//string result = System.IO.File.ReadAllText(file);
|
||||
|
||||
string username = "EpermitContractor_EFC";
|
||||
string password = "nM3#yU5$pO8%aZ6";
|
||||
//string postData = $"Username={username}&Password={password}";
|
||||
string result = BLL.Common.HttpHelper.HttpGetRequest(GETAPIUrl, username, password);
|
||||
//BLL.ErrLogInfo.WriteLog($"请求API Result={result}");
|
||||
|
||||
var data = JsonHelper.DeserializeJsonToObject<List<SES>>(result);
|
||||
ConcurrentBag<FC_SESReport> fcSesList = new ConcurrentBag<FC_SESReport>();
|
||||
string errorInfos = string.Empty;
|
||||
string message=string.Empty;
|
||||
string fo=string.Empty;
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
string errorInfo = string.Empty;
|
||||
string sesNo = string.Empty;
|
||||
FC_SESReport fcSesModel = new FC_SESReport();
|
||||
if (!string.IsNullOrEmpty(item.sesNo))
|
||||
{
|
||||
fcSesModel.SES_No = item.sesNo;
|
||||
sesNo = item.sesNo;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += " [SES No.] cannot be empty!";
|
||||
}
|
||||
|
||||
fcSesModel.Short_Descrption = item.shortDescrption;
|
||||
|
||||
if (item.startDate != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
message = TimeValidation(item.startDate);
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
fcSesModel.Start_Date = TimeValue(item.startDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += "[Start Date]" + message;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += " [Start Date]" + message;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.endDate != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
message = TimeValidation(item.endDate);
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
fcSesModel.End_Date = TimeValue(item.endDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += "[End Date]" + message;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += " [End Date]" + message;
|
||||
}
|
||||
}
|
||||
|
||||
fcSesModel.Created_by = item.createdBy;
|
||||
|
||||
if (item.createdOn != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
message = TimeValidation(item.createdOn);
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
fcSesModel.Created_on = TimeValue(item.createdOn);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += "[Created on]" + message;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += " [Created on]" + message;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.tecoDate != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
message = TimeValidation(item.tecoDate);
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
fcSesModel.TECO_Date = TimeValue(item.tecoDate);
|
||||
fcSesModel.TECO_Format = TimeValue(item.tecoDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += "[TECO Date]" + message;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += " [TECO Date]" + message;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.requisitioner))
|
||||
{
|
||||
string requisitioner = item.requisitioner;
|
||||
string[] reman = requisitioner.Split('/');
|
||||
if (reman.Count() == 2)
|
||||
{
|
||||
fcSesModel.Requisitioner = reman[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
fcSesModel.Requisitioner = requisitioner;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fcSesModel.Requisitioner = "";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.fo))
|
||||
{
|
||||
fcSesModel.FO = item.fo;
|
||||
fo = fcSesModel.FO;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += "[FO] cannot be empty!";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.item))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsWholeNumber(item.item))
|
||||
{
|
||||
fcSesModel.Item = int.Parse(item.item);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += " [Item]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += "[Item]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
|
||||
fcSesModel.Vendor_Name = item.vendorName;
|
||||
|
||||
if (item.ssrBudget!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsNumber(item.ssrBudget))
|
||||
{
|
||||
fcSesModel.SSR_budget = DecibelConversion(item.ssrBudget.Value.ToString().Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += "[SSR budget]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += "[SSR budget]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fcSesModel.SSR_budget = 0;
|
||||
}
|
||||
|
||||
fcSesModel.Currency = item.currency;
|
||||
|
||||
if (item.contractorQuotation!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsNumber(item.contractorQuotation))
|
||||
{
|
||||
fcSesModel.Contractor_quotation = DecibelConversion(item.contractorQuotation.Value.ToString().Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += " [Contractor quotation]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += " [Contractor quotation]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fcSesModel.Contractor_quotation = 0;
|
||||
}
|
||||
|
||||
if (item.ssrActualCost!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsNumber(item.ssrActualCost))
|
||||
{
|
||||
fcSesModel.SSR_Actual_cost = DecibelConversion(item.ssrActualCost.Value.ToString().Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += "[SSR Actual cost]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += "[SSR Actual cost]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fcSesModel.SSR_Actual_cost = 0;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.taxRate))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsNumber(item.taxRate.Replace("%", "")))
|
||||
{
|
||||
fcSesModel.Tax_rate = DecibelConversion(item.taxRate.Replace("%", "").Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += "[Tax rate]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += "[Tax rate]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
|
||||
if (item.deduction!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsNumber(item.deduction))
|
||||
{
|
||||
fcSesModel.Deviation = DecibelConversion(item.deduction.Value.ToString().Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfos += "[Deviation]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfos += "[Deviation]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
|
||||
//if (item.deductionPercentage!=null)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// if (IsNumber(item.deductionPercentage))
|
||||
// {
|
||||
// fcSesModel.Deviation_Percentage = DecibelConversion(item.deductionPercentage.ToString().Trim());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// errorInfos += (i + 2) + "line[Deviation Percentage]Must be in numeric format</br>";
|
||||
// }
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// errorInfos += (i + 2) + "line[Deviation Percentage]Must be in numeric format</br>";
|
||||
// }
|
||||
//}
|
||||
|
||||
fcSesModel.Long_text = item.longText;
|
||||
if (!string.IsNullOrEmpty(item.workOrder))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsWholeNumber(item.workOrder))
|
||||
{
|
||||
fcSesModel.Work_Order = int.Parse(item.workOrder.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfos += "[Work Order]Must be in pure number format!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfos += "[Work Order]Must be in pure number format!";
|
||||
}
|
||||
}
|
||||
fcSesModel.Function_location = item.functionLocation;
|
||||
fcSesModel.Main_work_center = item.mainWorkCenter;
|
||||
|
||||
if (!string.IsNullOrEmpty(item.workCenter))
|
||||
{
|
||||
fcSesModel.Work_Center = item.workCenter.ToString();
|
||||
|
||||
if (fcSesModel.Work_Center.Contains("CTM/L"))
|
||||
{
|
||||
fcSesModel.Dep = "CTM";
|
||||
fcSesModel.Section = "CTM/P";
|
||||
}
|
||||
else if (fcSesModel.Work_Center.Length > 5 && (fcSesModel.Work_Center.ToString() == "CTA/LV" || fcSesModel.Work_Center.ToString() == "CTA/LW"))
|
||||
{
|
||||
fcSesModel.Dep = "CTA";
|
||||
fcSesModel.Section = "CTA/L";
|
||||
}
|
||||
else if (fcSesModel.Work_Center.Length > 5 && fcSesModel.Work_Center.Substring(0, 5) == "CTA/L" && (fcSesModel.Work_Center.ToString() != "CTA/LV" || fcSesModel.Work_Center.ToString() != "CTA/LW"))
|
||||
{
|
||||
fcSesModel.Section = "CTA/P";
|
||||
}
|
||||
else if (fcSesModel.Work_Center.Length >= 5)
|
||||
{
|
||||
fcSesModel.Dep = fcSesModel.Work_Center.Substring(0, 3);
|
||||
fcSesModel.Section = fcSesModel.Work_Center.Substring(0, 5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.wbs))
|
||||
{
|
||||
fcSesModel.Section = "PS";
|
||||
}
|
||||
}
|
||||
|
||||
fcSesModel.Cost_center = item.costCenter;
|
||||
fcSesModel.WBS = item.wbs;
|
||||
fcSesModel.Network = item.network;
|
||||
|
||||
if (item.claimSheetsReceive!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
message = TimeValidation(item.claimSheetsReceive);
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
fcSesModel.Claim_sheets_receive = TimeValue(item.claimSheetsReceive);
|
||||
fcSesModel.CS_REC_Format = TimeValue(item.claimSheetsReceive);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfos += "[Claim sheets receive]" + message + "!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfos += "[Claim sheets receive]" + message + "!";
|
||||
}
|
||||
}
|
||||
|
||||
if (item.engineerConfirmedO!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
message = TimeValidation(item.engineerConfirmedO);
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
fcSesModel.Engineer_confirmed_o = TimeValue(item.engineerConfirmedO);
|
||||
fcSesModel.ENG_CONF_Format = TimeValue(item.engineerConfirmedO);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfos += "[Engineer confirmed o]" + message + "!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfos += "[Engineer confirmed o]" + message + "!";
|
||||
}
|
||||
}
|
||||
|
||||
if (item.sesConfirmedOn!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
message = TimeValidation(item.sesConfirmedOn);
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
fcSesModel.SES_Confirmed_on = TimeValue(item.sesConfirmedOn);
|
||||
fcSesModel.SES_CONF_Format = TimeValue(item.sesConfirmedOn);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfos += "[SES Confirmed on]" + message + "!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfos += "[SES Confirmed on]" + message + "!";
|
||||
}
|
||||
}
|
||||
// 以下没有
|
||||
// Contractor_duration
|
||||
// BoQ_confirmation_dur
|
||||
// Settlement duration
|
||||
// Invoiced on
|
||||
//Invoice duration
|
||||
// Payment made on
|
||||
//Payment duration
|
||||
|
||||
fcSesModel.Accepted = item.Accepted;
|
||||
fcSesModel.Deleted = item.deleted;
|
||||
fcSesModel.Blocked = item.blocked;
|
||||
fcSesModel.Changed_by = item.changedDy;
|
||||
fcSesModel.DateIn= DateTime.Now;
|
||||
|
||||
// 以下和诚实度和及时性有关
|
||||
fcSesModel.CPT_No = item.cptNo;
|
||||
if (!string.IsNullOrEmpty(item.con))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsNumber(item.con))
|
||||
{
|
||||
fcSesModel.Con_Days = DecibelConversion(item.con.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += " [con]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += " [con]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
|
||||
if (item.submiteDate != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
message = TimeValidation(item.submiteDate);
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
fcSesModel.Submit_Date = TimeValue(item.submiteDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfos += "[submiteDate]" + message + "!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfos += "[submiteDate]" + message + "!";
|
||||
}
|
||||
}
|
||||
if (item.contractorQuotation!=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsNumber(item.contractorQuotation))
|
||||
{
|
||||
fcSesModel.Quotation = DecibelConversion(item.contractorQuotation.Value.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
errorInfo += " [contractorQuotation]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
errorInfo += " [contractorQuotation]Must be in numeric format!";
|
||||
}
|
||||
}
|
||||
|
||||
if (item.ssrActualCost != null && item.contractorQuotation != null)
|
||||
{
|
||||
decimal punishment = 0;
|
||||
var pun = from x in Funs.DB.EMC_Punishment where x.SES_No == item.sesNo select x;
|
||||
if (pun.Count() > 0)
|
||||
{
|
||||
punishment = pun.Sum(x => x.Company != null ? x.Company.Value : 0) + pun.Sum(x => x.Individual != null ? x.Individual.Value : 0);
|
||||
}
|
||||
|
||||
decimal tax_Value = decimal.Parse((item.ssrActualCost.Value * (1 + fcSesModel.Tax_rate)).Value.ToString("0.00"));
|
||||
fcSesModel.Deduction = decimal.Parse((item.contractorQuotation.Value - tax_Value - punishment).ToString("0.00"));
|
||||
}
|
||||
|
||||
|
||||
if (errorInfo != string.Empty)
|
||||
{
|
||||
errorInfos += errorInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
fcSesList.Add(fcSesModel);
|
||||
}
|
||||
}
|
||||
AddSyncSES(fcSesList);
|
||||
}
|
||||
|
||||
private static void AddSyncSES(ConcurrentBag<FC_SESReport> sesList)
|
||||
{
|
||||
SQLHelper.ExecutSql("truncate table FC_SESReport");
|
||||
var result = SqlBulkHelper.BulkInsert(SqlBulkHelper.GetCon(), "FC_SESReport", sesList.ToList());
|
||||
|
||||
}
|
||||
|
||||
#region 格式验证
|
||||
/// <summary>
|
||||
/// 时间格式验证
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
/// <returns></returns>
|
||||
private static string TimeValidation(object time)
|
||||
{
|
||||
string message = string.Empty;
|
||||
try
|
||||
{
|
||||
if (time.ToString().Contains("."))
|
||||
{
|
||||
DateTime.ParseExact(time.ToString(), "dd.MM.yyyy", CultureInfo.InvariantCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
Convert.ToDateTime(time);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = "Please enter a valid time format!";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带小数的数字验证
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsNumber(object input)
|
||||
{
|
||||
string pattern = "^-?\\d+$|^(-?\\d+)(\\.\\d+)?$";
|
||||
Regex regex = new Regex(pattern);
|
||||
string value = input != null ? DecibelConversion(input.ToString()).ToString() : "";
|
||||
return regex.IsMatch(value.Trim());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 整数
|
||||
/// </summary>
|
||||
/// <param name="strNumber"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsWholeNumber(object input)
|
||||
{
|
||||
Regex g = new Regex(@"^[-]?[0-9]\d*$");
|
||||
string value = input != null ? input.ToString() : "";
|
||||
return g.IsMatch(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 千分位转换
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal DecibelConversion(string input)
|
||||
{
|
||||
var inputValue = string.Empty;
|
||||
if (input.Contains(',') && input.Contains('.'))
|
||||
{
|
||||
var inputstr = input.Replace(".", "").Split(',');
|
||||
if (inputstr.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < inputstr.Length; i++)
|
||||
{
|
||||
inputValue += i < (inputstr.Length - 1) ? inputstr[i] : "." + inputstr[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (input.Contains(','))
|
||||
{
|
||||
inputValue = input.Replace(",", ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
inputValue = input;
|
||||
}
|
||||
inputValue = inputValue.Length > 18 ? inputValue.Substring(0, 17) : inputValue;
|
||||
return decimal.Parse(inputValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间格式转换
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static DateTime TimeValue(object value)
|
||||
{
|
||||
string dateValue = string.Empty;
|
||||
if (value != null)
|
||||
{
|
||||
if (value.ToString().Contains("."))
|
||||
{
|
||||
dateValue = DateTime.ParseExact(value.ToString(), "dd.MM.yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");
|
||||
}
|
||||
else
|
||||
{
|
||||
dateValue = DateTime.Parse(value.ToString()).ToString("yyyy-MM-dd");
|
||||
}
|
||||
}
|
||||
return DateTime.Parse(dateValue);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
#region 内部类
|
||||
[Serializable]
|
||||
internal class SES
|
||||
{
|
||||
public string Accepted { get; set; }
|
||||
public string blocked { get; set; }
|
||||
public DateTime? startDate { get; set; }
|
||||
public DateTime? endDate { get; set; }
|
||||
public string createdBy { get; set; }
|
||||
public DateTime? tecoDate { get; set; }
|
||||
public string sesNo { get; set; }
|
||||
public string deleted { get; set; }
|
||||
public string workOrder { get; set; }
|
||||
public string OpSopNo { get; set; }
|
||||
public string prItem { get; set; }
|
||||
public string prNumber { get; set; }
|
||||
public string shortDescrption { get; set; }
|
||||
public string fo { get; set; }
|
||||
public string item { get; set; }
|
||||
public string vendorName { get; set; }
|
||||
public decimal? ssrBudget { get; set; }
|
||||
public decimal? contractorQuotation { get; set; }
|
||||
public decimal? ssrActualCost { get; set; }
|
||||
public decimal? ssrActualCostNetAmount { get; set; }
|
||||
public string wbs { get; set; }
|
||||
public DateTime? createdOn { get; set; }
|
||||
public DateTime? claimSheetsReceive { get; set; }
|
||||
public decimal? sesConfirmedOn { get; set; }
|
||||
public string requisitioner { get; set; }
|
||||
public string currency { get; set; }
|
||||
public string reducedByQuantity { get; set; }
|
||||
public string userField { get; set; }
|
||||
public string taxRate { get; set; }
|
||||
|
||||
public string changedDy { get; set; }
|
||||
public string longText { get; set; }
|
||||
public string functionLocation { get; set; }
|
||||
public string mainWorkCenter { get; set; }
|
||||
public string workCenter { get; set; }
|
||||
public string costCenter { get; set; }
|
||||
public string network { get; set; }
|
||||
public decimal? deduction { get; set; }
|
||||
public string deductionPercentage { get; set; }
|
||||
public string con { get; set; }
|
||||
public DateTime? submiteDate { get; set; }
|
||||
public DateTime? updateTime { get; set; }
|
||||
public string cptNo { get; set; }
|
||||
public string revision { get; set; }
|
||||
public string tarItem { get; set; }
|
||||
public string budgetBy { get; set; }
|
||||
public string sesStatus { get; set; }
|
||||
public string sesConfirm { get; set; }
|
||||
public string visaResetCount { get; set; }
|
||||
public string visaExceptionCount { get; set; }
|
||||
public string settleExceptionCount { get; set; }
|
||||
public string settleResetCount { get; set; }
|
||||
public string finishDate { get; set; }
|
||||
public string finishDateConfirm { get; set; }
|
||||
public string finishDateVerify { get; set; }
|
||||
public string isPack { get; set; }
|
||||
public string checkMoney { get; set; }
|
||||
|
||||
public decimal? amountDeclared { get; set; }
|
||||
public decimal? priceFirstValue { get; set; }
|
||||
public decimal? approvedValue { get; set; }
|
||||
public decimal? entrustValue { get; set; }
|
||||
public decimal? overdueDeductions { get; set; }
|
||||
public decimal? safetyAssDeduc { get; set; }
|
||||
|
||||
public string settleApprovedType { get; set; }
|
||||
public string externalNo { get; set; }
|
||||
public decimal? cptEndTime { get; set; }
|
||||
public string engineerConfirmedO { get; set; }
|
||||
public string settleClaimSheetsReceive { get; set; }
|
||||
public string section { get; set; }
|
||||
public string deviation { get; set; }
|
||||
public string deviationPercentage { get; set; }
|
||||
public string LastPayment { get; set; }
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace BLL.APIService
|
||||
public class SyncUserInfoService
|
||||
{
|
||||
private const string GETTOKENAPI = "https://ppsintf.basf-ypc.net.cn/ppsinterface/token/getToken";
|
||||
private const string GETHRINfOAPI = "https://ppsintf.basf-ypc.net.cn/ppsinterface/interfaceInfo/getHrInfo";
|
||||
private const string GETHRINfOAPI = "https://ppsintf.basf-ypc.net.cn/ppsinterface/interfaceInfo/getHrInfo?start=1&nums=3000";
|
||||
public static string GetUserToken()
|
||||
{
|
||||
string username = "itinforadm";
|
||||
@@ -44,7 +44,7 @@ namespace BLL.APIService
|
||||
List<Model.SyncDataUserLogs> logList = new List<Model.SyncDataUserLogs>();
|
||||
if (data.code == "200")
|
||||
{
|
||||
ErrLogInfo.WriteLog($"userinfo={data.data}");
|
||||
//ErrLogInfo.WriteLog($"userinfo={data.data}");
|
||||
var userInfo = data.data;
|
||||
string batchNo = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
DateTime syncTime = DateTime.Now;
|
||||
@@ -211,7 +211,6 @@ namespace BLL.APIService
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
resultId = UpdateUserInfo(item, departId);
|
||||
log.UserId = resultId;
|
||||
log.DataType = 1; //同步用户类型数据
|
||||
@@ -457,9 +456,8 @@ namespace BLL.APIService
|
||||
/// <returns></returns>
|
||||
private static Dictionary<string,string> GetUserInfoByAccount()
|
||||
{
|
||||
return BLL.Funs.DB.Sys_User.Where(t=>t.IsPost==true).Select(t => new { t.UserId, t.Account }).ToList()
|
||||
return BLL.Funs.DB.Sys_User.Select(t => new { t.UserId, t.Account }).ToList()
|
||||
.ToDictionary(t => t.Account.ToLower(), t => t.UserId);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新BU
|
||||
|
||||
@@ -165,6 +165,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="APIService\APIFCLService.cs" />
|
||||
<Compile Include="APIService\SyncContractor.cs" />
|
||||
<Compile Include="APIService\SyncSESService.cs" />
|
||||
<Compile Include="APIService\SyncUserInfoService.cs" />
|
||||
<Compile Include="BaseInfo\ContractorService.cs" />
|
||||
<Compile Include="BaseInfo\CurrencyService.cs" />
|
||||
|
||||
@@ -18,6 +18,25 @@ namespace BLL
|
||||
return Funs.DB.Base_Contractor.FirstOrDefault(e => e.ContractorId == contractorId);
|
||||
}
|
||||
|
||||
// 返回承包商中英文名称
|
||||
public static string GetContractorNameById(string contractorId)
|
||||
{
|
||||
string contractorName=string.Empty;
|
||||
var con= Funs.DB.Base_Contractor.FirstOrDefault(e => e.ContractorId == contractorId);
|
||||
if (con != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(con.Contractor))
|
||||
{
|
||||
contractorName = con.Contractor;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(con.ContractorCN))
|
||||
{
|
||||
contractorName += con.ContractorCN;
|
||||
}
|
||||
}
|
||||
return contractorName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取承包商列表
|
||||
/// </summary>
|
||||
|
||||
@@ -266,6 +266,11 @@ namespace BLL
|
||||
public const string BtnConTab13Modify = "承包商Modify";
|
||||
public const string BtnConTab13Delete = "承包商Delete";
|
||||
public const string BtnConTab13View = "承包商View";
|
||||
|
||||
public const string BtnConTab17Add = "确认函Add";
|
||||
public const string BtnConTab17Modify = "确认函Modify";
|
||||
public const string BtnConTab17Delete = "确认函Delete";
|
||||
public const string BtnConTab17View = "确认函View";
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -536,6 +541,8 @@ namespace BLL
|
||||
public const string ContractorEvaluationMenuId = "7E2A5BAA-1F3C-4930-9E76-0FBABBA40B20";
|
||||
|
||||
public const string EvaluationReportMenuId = "DD0202E2-0EBD-41A3-AA81-33684B8DE014";
|
||||
|
||||
public const string SafePerformanceReportMenuId = "4BA63D21-8745-4FD5-8472-4AD586F072CB";
|
||||
#endregion
|
||||
|
||||
#region 承包商质量事件调查
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using Microsoft.SqlServer.Dts.Runtime;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -32,7 +34,25 @@ namespace BLL.Common
|
||||
}
|
||||
return strGetResponse;
|
||||
}
|
||||
public static string HttpGetRequest(string url, string basicUsername, string basicPassword)
|
||||
{
|
||||
string strGetResponse = string.Empty;
|
||||
try
|
||||
{
|
||||
var getRequest = CreateHttpRequest(url, "GET", "");
|
||||
// 添加 Basic 认证头
|
||||
string credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{basicUsername}:{basicPassword}"));
|
||||
getRequest.Headers["Authorization"] = $"Basic {credentials}";
|
||||
|
||||
var getResponse = getRequest.GetResponse() as HttpWebResponse;
|
||||
strGetResponse = GetHttpResponse(getResponse, "GET");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
strGetResponse = ex.Message;
|
||||
}
|
||||
return strGetResponse;
|
||||
}
|
||||
/// <summary>
|
||||
/// Http Post Request
|
||||
/// </summary>
|
||||
@@ -41,14 +61,14 @@ namespace BLL.Common
|
||||
/// <returns></returns>
|
||||
public static string HttpPostRequest(string url, string postJsonData,string token)
|
||||
{
|
||||
BLL.ErrLogInfo.WriteLog("token=" + token);
|
||||
//BLL.ErrLogInfo.WriteLog("token=" + token);
|
||||
string strPostReponse = string.Empty;
|
||||
try
|
||||
{
|
||||
var postRequest = CreateHttpRequest(url, "POST",token, postJsonData);
|
||||
var postResponse = postRequest.GetResponse() as HttpWebResponse;
|
||||
strPostReponse = GetHttpResponse(postResponse, "POST");
|
||||
BLL.ErrLogInfo.WriteLog("result=" + strPostReponse);
|
||||
//BLL.ErrLogInfo.WriteLog("result=" + strPostReponse);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -92,6 +112,40 @@ namespace BLL.Common
|
||||
}
|
||||
}
|
||||
|
||||
public static string PostJsonByHttps(string url,string basicUsername,string basicPassword, string jsonParams )
|
||||
{
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
|
||||
HttpWebRequest request = null;
|
||||
CookieContainer cookie = new CookieContainer();
|
||||
//HTTPSQ请求
|
||||
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
|
||||
request = WebRequest.Create(url) as HttpWebRequest;
|
||||
request.CookieContainer = cookie;
|
||||
request.ProtocolVersion = HttpVersion.Version11;
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/x-www-form-urlencoded";
|
||||
request.KeepAlive = true;
|
||||
byte[] byteData = Encoding.UTF8.GetBytes(jsonParams);
|
||||
int length = byteData.Length;
|
||||
request.ContentLength = length;
|
||||
|
||||
// 添加 Basic 认证头
|
||||
string credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{basicUsername}:{basicPassword}"));
|
||||
request.Headers["Authorization"] = $"Basic {credentials}";
|
||||
|
||||
using (Stream stream = request.GetRequestStream())
|
||||
{
|
||||
stream.Write(byteData, 0, byteData.Length);
|
||||
}
|
||||
|
||||
var response = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
using (StreamReader st = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")))
|
||||
{
|
||||
return st.ReadToEnd().ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private static HttpWebRequest CreateHttpRequest(string url, string requestType, string token, params object[] strJson)
|
||||
{
|
||||
HttpWebRequest request = null;
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
/// <returns></returns>
|
||||
public static ListItem[] getConFileTypeDropList()
|
||||
{
|
||||
ListItem[] lis = new ListItem[13];
|
||||
ListItem[] lis = new ListItem[14];
|
||||
lis[0] = new ListItem("合同续签", "1");
|
||||
lis[1] = new ListItem("费用增补", "2");
|
||||
lis[2] = new ListItem("份额变更", "3");
|
||||
@@ -97,6 +97,7 @@
|
||||
lis[10] = new ListItem("合同终止", "11");
|
||||
lis[11] = new ListItem("组织架构", "12");
|
||||
lis[12] = new ListItem("框架承包商评估表", "13");
|
||||
lis[13] = new ListItem("确认函", "17");
|
||||
return lis;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user