1963 lines
105 KiB
C#
1963 lines
105 KiB
C#
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data.SqlClient;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Net.Mail;
|
||
using PLMTEST;
|
||
using MisDataSaveDate.MOM;
|
||
using Newtonsoft.Json.Linq;
|
||
using System.Web.Http;
|
||
using DataLinkMesWork;
|
||
using System.Configuration;
|
||
using ExternalDataSync;
|
||
using NPOI.SS.Formula.Functions;
|
||
using static System.Windows.Forms.AxHost;
|
||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||
using System.Net.NetworkInformation;
|
||
using NPOI.XSSF.Streaming.Values;
|
||
using MesServerWork;
|
||
using static MisDataSaveDate.Helper.ApiLogHelper;
|
||
|
||
namespace MisDataSaveDate
|
||
{
|
||
public class AnalysisMomMsg
|
||
{
|
||
/// <summary>
|
||
/// UUID生成
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public static string UuidUtil()
|
||
{
|
||
string result = Guid.NewGuid().ToString();
|
||
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 员工信息保存
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string MES_To_AMS_AlarmClosed(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new MsgResHeader<string>();
|
||
result.code = 200;
|
||
result.message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.code = 500;
|
||
result.message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("员工信息保存res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
AlarmClosed alarmclosed = JsonConvert.DeserializeObject<AlarmClosed>(str);
|
||
if (string.IsNullOrWhiteSpace(alarmclosed.alarmTaskId))
|
||
{
|
||
throw new Exception("参数taskID值不正确!");
|
||
}
|
||
if (alarmclosed.HandleInfos == null || alarmclosed.HandleInfos.Count <= 0)
|
||
{
|
||
throw new Exception("参数handleInfo值不正确!");
|
||
}
|
||
List<MisDataSaveDate.MOM.AlarmHandleInfo> alarmHandleInfos = alarmclosed.HandleInfos;
|
||
foreach (var alrmitem in alarmHandleInfos)
|
||
{
|
||
var param = new SqlParameter[] {
|
||
new SqlParameter("@报警任务ID",alarmclosed.alarmTaskId),
|
||
new SqlParameter("@处理人ID",alrmitem.UserId),
|
||
new SqlParameter("@处理人编号",alrmitem.UserCode),
|
||
new SqlParameter("@处理人名称",alrmitem.UserName),
|
||
new SqlParameter("@处理开始时间",alrmitem.StartTime),
|
||
new SqlParameter("@处理完成时间",alrmitem.EndTime)
|
||
};
|
||
//DataAccess.ExecuteStoredProcedure("报警工位记录表_处理",ref param);
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("报警工位记录表_处理", ref param, out errorMessage);
|
||
}
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.code = 500;
|
||
result.message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 员工信息保存
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string MES_To_AMS_Employee(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new ApiResponse();
|
||
result.Code = 200;
|
||
result.Message = "";
|
||
result.Data = new List<Response_Data>();
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("员工信息保存res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
EmployeeInfoSave employeeScheme = JsonConvert.DeserializeObject<EmployeeInfoSave>(str);
|
||
if (employeeScheme?.Data == null || employeeScheme.Data.Count == 0)
|
||
{
|
||
throw new Exception("数据列表为空!");
|
||
}
|
||
|
||
foreach (var employee in employeeScheme.Data)
|
||
{
|
||
var responseData = new Response_Data();
|
||
try
|
||
{
|
||
if (string.IsNullOrWhiteSpace(employee.PersonId))
|
||
{
|
||
throw new Exception("参数personID值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(employee.PersonCode))
|
||
{
|
||
throw new Exception("参数personCode值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(employee.PersonName))
|
||
{
|
||
throw new Exception("参数personName值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(employee.OrgId))
|
||
{
|
||
throw new Exception("参数orgID值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(employee.PhoneNumber))
|
||
{
|
||
throw new Exception("参数phoneNumber值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(employee.CreateTime))
|
||
{
|
||
throw new Exception("参数createTime值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(employee.LastModifyTime))
|
||
{
|
||
throw new Exception("参数lastModifyTime值不正确!");
|
||
}
|
||
|
||
var param = new SqlParameter[] {
|
||
new SqlParameter("@人员ID", employee.PersonId),
|
||
new SqlParameter("@人员编号", employee.PersonCode),
|
||
new SqlParameter("@人员名称", employee.PersonName),
|
||
new SqlParameter("@所属组织", employee.OrgId),
|
||
new SqlParameter("@手机号", employee.PhoneNumber),
|
||
new SqlParameter("@创建时间", employee.CreateTime),
|
||
new SqlParameter("@最后修改时间", employee.LastModifyTime)
|
||
};
|
||
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_人员名单_新增或更新", ref param, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
responseData.Code = 200;
|
||
responseData.Message = "";
|
||
responseData.DataId = employee.PersonId;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
responseData.Code = 500;
|
||
responseData.Message = ex.Message;
|
||
responseData.DataId = employee.PersonId;
|
||
}
|
||
result.Data.Add(responseData);
|
||
}
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("员工信息保存res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 组织信息保存
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string MES_To_AMS_OrgInfo(string url, [FromBody] JObject jobj)
|
||
{
|
||
|
||
var result = new ApiResponse();
|
||
result.Code = 200;
|
||
result.Message = "";
|
||
result.Data = null;
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("生产组织信息保存res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
OrganizationData OrgScheme = JsonConvert.DeserializeObject<OrganizationData>(str);
|
||
List<MisDataSaveDate.MOM.Organization> OrgInfoList = OrgScheme.Data;
|
||
if (OrgScheme.Data == null || OrgScheme.Data.Count <= 0)
|
||
{
|
||
throw new Exception("参数Data值不正确!");
|
||
}
|
||
List<Response_Data> resDataList = new List<Response_Data>();
|
||
foreach (var orgitem in OrgInfoList)
|
||
{
|
||
if (string.IsNullOrEmpty(orgitem.OrgID))
|
||
{
|
||
errorMessage = "参数orgID值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(orgitem.OrgCode))
|
||
{
|
||
errorMessage = "参数orgCode值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(orgitem.OrgName))
|
||
{
|
||
errorMessage = "参数orgName值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(orgitem.Classification))
|
||
{
|
||
errorMessage = "参数classification值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(orgitem.LevelNo))
|
||
{
|
||
errorMessage = "参数level值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(orgitem.Detail))
|
||
{
|
||
errorMessage = "参数detail值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(orgitem.CreateTime))
|
||
{
|
||
errorMessage = "参数createTime值不正确!";
|
||
}
|
||
else
|
||
{
|
||
var param = new SqlParameter[]
|
||
{
|
||
new SqlParameter("@OrgID",orgitem.OrgID),
|
||
new SqlParameter("@OrgCode",orgitem.OrgCode),
|
||
new SqlParameter("@OrgName",orgitem.OrgName),
|
||
new SqlParameter("@Classification",orgitem.Classification),
|
||
new SqlParameter("@LevelNo",orgitem.LevelNo),
|
||
new SqlParameter("@Detail",orgitem.Detail),
|
||
new SqlParameter("@CreateTime",orgitem.CreateTime),
|
||
new SqlParameter("@LastModifyTime",VHandle(orgitem.LastModifyTime))
|
||
};
|
||
//DataAccess.ExecuteStoredProcedure("MOM_生产组织_新增或更新", ref param);
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产组织_新增或更新", ref param, out errorMessage);
|
||
}
|
||
Response_Data resData = new Response_Data();
|
||
resData.Message = errorMessage;
|
||
resData.Code = errorMessage == "" ? 200 : 500;
|
||
resData.DataId = "";
|
||
resDataList.Add(resData);
|
||
}
|
||
result.Data = resDataList;
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("生产组织信息保存res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 工作中心保存
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string MES_To_AMS_WorkCenterSave(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new ApiResponse();
|
||
result.Code = 200;
|
||
result.Message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("工作中心信息保存res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
WorkCenterData Scheme = JsonConvert.DeserializeObject<WorkCenterData>(str);
|
||
List<MisDataSaveDate.MOM.WorkCenter> workCenterList = Scheme.Data;
|
||
if (Scheme.Data == null || Scheme.Data.Count <= 0)
|
||
{
|
||
throw new Exception("参数Data值不正确!");
|
||
}
|
||
List<Response_Data> resDataList = new List<Response_Data>();
|
||
foreach (var dataitem in workCenterList)
|
||
{
|
||
if (string.IsNullOrEmpty(dataitem.WorkCenterID))
|
||
{
|
||
errorMessage = "参数workCenterID值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.WorkCenterCode))
|
||
{
|
||
errorMessage = "参数workCenterCode值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.WorkCenterName))
|
||
{
|
||
errorMessage = "参数workCenterName值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.OrgID))
|
||
{
|
||
errorMessage = "参数orgID值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.Classification))
|
||
{
|
||
errorMessage = "参数classification值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.LevelNo))
|
||
{
|
||
errorMessage = "参数level值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.Detail))
|
||
{
|
||
errorMessage = "参数detail值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.CreateTime))
|
||
{
|
||
errorMessage = "参数createTime值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.LastModifyTime))
|
||
{
|
||
errorMessage = "参数lastModifyTime值不正确!";
|
||
}
|
||
else
|
||
{
|
||
var param = new SqlParameter[]
|
||
{
|
||
new SqlParameter("@workCenterID",dataitem.WorkCenterID),
|
||
new SqlParameter("@workCenterCode",dataitem.WorkCenterCode),
|
||
new SqlParameter("@workCenterName",dataitem.WorkCenterName),
|
||
new SqlParameter("@orgID",dataitem.OrgID),
|
||
new SqlParameter("@classification",dataitem.Classification),
|
||
new SqlParameter("@LevelNo",dataitem.LevelNo),
|
||
new SqlParameter("@Detail",dataitem.Detail),
|
||
new SqlParameter("@CreateTime",dataitem.CreateTime),
|
||
new SqlParameter("@LastModifyTime",dataitem.LastModifyTime)
|
||
};
|
||
//DataAccess.ExecuteStoredProcedure("MOM_工作中心_新增或更新", ref param);
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_工作中心_新增或更新", ref param, out errorMessage);
|
||
}
|
||
Response_Data resData = new Response_Data();
|
||
resData.Message = errorMessage;
|
||
resData.Code = errorMessage == "" ? 200 : 500;
|
||
resData.DataId = "";
|
||
resDataList.Add(resData);
|
||
}
|
||
result.Data = resDataList;
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("工作中心信息保存res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 物料信息保存
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string MES_To_AMS_MaterialSave(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new ApiResponse();
|
||
result.Code = 200;
|
||
result.Message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("物料信息保存res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
MaterialInfoSave Scheme = JsonConvert.DeserializeObject<MaterialInfoSave>(str);
|
||
List<MisDataSaveDate.MOM.Material> materialList = Scheme.Data;
|
||
if (Scheme.Data == null || Scheme.Data.Count <= 0)
|
||
{
|
||
throw new Exception("参数Data值不正确!");
|
||
}
|
||
List<Response_Data> resDataList = new List<Response_Data>();
|
||
foreach (var dataitem in materialList)
|
||
{
|
||
if (string.IsNullOrEmpty(dataitem.MaterialID))
|
||
{
|
||
errorMessage = "参数materialID值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.MaterialCode))
|
||
{
|
||
errorMessage = "参数materialCode值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.MaterialName))
|
||
{
|
||
errorMessage = "参数materialName值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.CreateTime))
|
||
{
|
||
errorMessage = "参数createTime值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.LastModifyTime))
|
||
{
|
||
errorMessage = "参数lastModifyTime值不正确!";
|
||
}
|
||
else
|
||
{
|
||
var param = new SqlParameter[]
|
||
{
|
||
new SqlParameter("@materialID",dataitem.MaterialID),
|
||
new SqlParameter("@materialCode",dataitem.MaterialCode),
|
||
new SqlParameter("@materialName",dataitem.MaterialName),
|
||
new SqlParameter("@unitOfMeasure",VHandle(dataitem.UnitOfMeasure)),
|
||
new SqlParameter("@materialCategory",VHandle(dataitem.MaterialCategory)),
|
||
new SqlParameter("@materialSpec",VHandle(dataitem.MaterialSpec)),
|
||
new SqlParameter("@materialModel",VHandle(dataitem.MaterialModel)),
|
||
new SqlParameter("@materialDescription",VHandle(dataitem.MaterialDescription)),
|
||
new SqlParameter("@CreateTime",dataitem.CreateTime),
|
||
new SqlParameter("@LastModifyTime",dataitem.LastModifyTime)
|
||
};
|
||
//DataAccess.ExecuteStoredProcedure("MOM_物料信息_新增或更新", ref param);
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_物料信息_新增或更新", ref param, out errorMessage);
|
||
}
|
||
Response_Data resData = new Response_Data();
|
||
resData.Message = errorMessage;
|
||
resData.Code = errorMessage == "" ? 200 : 500;
|
||
resData.DataId = dataitem.MaterialID;
|
||
resDataList.Add(resData);
|
||
}
|
||
result.Data = resDataList;
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("物料信息保存res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 计量单位信息保存
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string MES_To_AMS_UnitInfoSave(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new ApiResponse();
|
||
result.Code = 200;
|
||
result.Message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("计量单位信息保存res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
UnitData Scheme = JsonConvert.DeserializeObject<UnitData>(str);
|
||
List<MisDataSaveDate.MOM.Unit> materialList = Scheme.Data;
|
||
if (Scheme.Data == null || Scheme.Data.Count <= 0)
|
||
{
|
||
throw new Exception("参数Data值不正确!");
|
||
}
|
||
List<Response_Data> resDataList = new List<Response_Data>();
|
||
foreach (var dataitem in materialList)
|
||
{
|
||
if (string.IsNullOrEmpty(dataitem.UnitID))
|
||
{
|
||
errorMessage = "参数unitID值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.UnitCode))
|
||
{
|
||
errorMessage = "参数unitCode值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.UnitName))
|
||
{
|
||
errorMessage = "参数unitName值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.CreateTime))
|
||
{
|
||
errorMessage = "参数createTime值不正确!";
|
||
}
|
||
else if (string.IsNullOrEmpty(dataitem.LastModifyTime))
|
||
{
|
||
errorMessage = "参数lastModifyTime值不正确!";
|
||
}
|
||
else
|
||
{
|
||
var param = new SqlParameter[]
|
||
{
|
||
new SqlParameter("@unitID",dataitem.UnitID),
|
||
new SqlParameter("@unitCode",dataitem.UnitCode),
|
||
new SqlParameter("@unitName",dataitem.UnitName),
|
||
new SqlParameter("@CreateTime",dataitem.CreateTime),
|
||
new SqlParameter("@LastModifyTime",dataitem.LastModifyTime)
|
||
};
|
||
//DataAccess.ExecuteStoredProcedure("MOM_计量单位_新增或更新", ref param);
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_计量单位_新增或更新", ref param, out errorMessage);
|
||
}
|
||
Response_Data resData = new Response_Data();
|
||
resData.Message = errorMessage;
|
||
resData.Code = errorMessage == "" ? 200 : 500;
|
||
resData.DataId = "";
|
||
resDataList.Add(resData);
|
||
}
|
||
result.Data = resDataList;
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("计量单位信息保存res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 员工排班信息
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string MES_To_AMS_ShiftScheduleSave(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new MsgResHeader<string>();
|
||
result.code = 200;
|
||
result.message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.code = 500;
|
||
result.message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("员工排班信息保存res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
ShiftSchedule Scheme = JsonConvert.DeserializeObject<ShiftSchedule>(str);
|
||
if (string.IsNullOrWhiteSpace(Scheme.EmployeeID))
|
||
{
|
||
throw new Exception("参数EmployeeID值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(Scheme.EmployeeCode))
|
||
{
|
||
throw new Exception("参数EmployeeCode值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(Scheme.EmployeeName))
|
||
{
|
||
throw new Exception("参数EmployeeName值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(Scheme.StartDate))
|
||
{
|
||
throw new Exception("参数StartDate值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(Scheme.EndDate))
|
||
{
|
||
throw new Exception("参数EndDate值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(Scheme.ProductionOrg))
|
||
{
|
||
throw new Exception("参数prodOrg值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(Scheme.ProductionCenter))
|
||
{
|
||
throw new Exception("参数prodCenter值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(Scheme.WorkProcess))
|
||
{
|
||
throw new Exception("参数workProc值不正确!");
|
||
}
|
||
var param = new SqlParameter[]
|
||
{
|
||
new SqlParameter("@empID",Scheme.EmployeeID),
|
||
new SqlParameter("@empCode",Scheme.EmployeeCode),
|
||
new SqlParameter("@empName",Scheme.EmployeeName),
|
||
new SqlParameter("@startDate",Scheme.StartDate),
|
||
new SqlParameter("@endDate",Scheme.EndDate),
|
||
new SqlParameter("@prodOrg",Scheme.ProductionOrg),
|
||
new SqlParameter("@prodCenter",Scheme.ProductionCenter),
|
||
new SqlParameter("@workProc",Scheme.WorkProcess)
|
||
};
|
||
//DataAccess.ExecuteStoredProcedure("MOM_员工排班信息_新增或更新",ref param);
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_员工排班信息_新增或更新", ref param, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.code = 500;
|
||
result.message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("员工排班信息保存res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// AGV与产线AMS交互接口
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string AGV_To_AMS_Interaction(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new MsgResHeader<string>();
|
||
result.code = 200;
|
||
result.message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.code = 500;
|
||
result.message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
AGV_InterAction interAction = JsonConvert.DeserializeObject<AGV_InterAction>(str);
|
||
|
||
if (string.IsNullOrWhiteSpace(interAction.LocationCode))
|
||
{
|
||
throw new Exception("参数LocationCode值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(interAction.TaskCode))
|
||
{
|
||
throw new Exception("参数TaskCode值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(interAction.DeliveryType))
|
||
{
|
||
throw new Exception("参数deliveryType值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(interAction.ReqCMD))
|
||
{
|
||
throw new Exception("参数ReqCMD值不正确!");
|
||
}
|
||
|
||
switch (interAction.LocationCode)
|
||
{
|
||
case "AGV_To_AMS_RequestEnter":
|
||
//向PLC发送请求进入信号
|
||
//MIS_BASE.WritePLC();
|
||
break;
|
||
case "AGV_To_AMS_PlaceCompleted":
|
||
//向PLC发送器具放置完毕信号
|
||
|
||
break;
|
||
case "AGV_To_AMS_ExitGrating":
|
||
//向PLC发送
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.code = 500;
|
||
result.message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 工艺信息接口
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string ProcessInfo(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new MsgResHeader<string>();
|
||
result.code = 200;
|
||
result.message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.code = 500;
|
||
result.message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
ProcessScheme processScheme = JsonConvert.DeserializeObject<ProcessScheme>(str);
|
||
|
||
if (string.IsNullOrWhiteSpace(processScheme.id))
|
||
{
|
||
throw new Exception("参数id值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processScheme.code))
|
||
{
|
||
throw new Exception("参数code值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processScheme.orderNo))
|
||
{
|
||
throw new Exception("参数orderNo值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processScheme.productId))
|
||
{
|
||
throw new Exception("参数productId值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processScheme.productCode))
|
||
{
|
||
throw new Exception("参数productCode值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processScheme.productName))
|
||
{
|
||
throw new Exception("参数productName值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processScheme.createdTime))
|
||
{
|
||
throw new Exception("参数createdTime值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processScheme.lastModifiedTime))
|
||
{
|
||
throw new Exception("参数lastModifiedTime值不正确!");
|
||
}
|
||
//if (processScheme.processInfo == null || processScheme.processInfo.Count <= 0)
|
||
//{
|
||
// throw new Exception("参数processInfo值不正确!");
|
||
//}
|
||
if (processScheme.routingInfo == null || processScheme.routingInfo.Count <= 0)
|
||
{
|
||
throw new Exception("参数routingInfo值不正确!");
|
||
}
|
||
var param = new SqlParameter[] {
|
||
new SqlParameter("@id",processScheme.id),
|
||
new SqlParameter("@code",processScheme.code),
|
||
new SqlParameter("@name",VHandle(processScheme.name)),
|
||
new SqlParameter("@orderNo",processScheme.orderNo),
|
||
new SqlParameter("@productId",processScheme.productId),
|
||
new SqlParameter("@productCode",processScheme.productCode),
|
||
new SqlParameter("@productName",processScheme.productName),
|
||
new SqlParameter("@productSpec",VHandle(processScheme.productSpec)),
|
||
new SqlParameter("@model",VHandle(processScheme.model)),
|
||
new SqlParameter("@createdTime",processScheme.createdTime),
|
||
new SqlParameter("@lastModifiedTime",processScheme.lastModifiedTime),
|
||
|
||
};
|
||
//DataAccess.ExecuteStoredProcedure("MOM_工艺信息_新增", ref param);
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_工艺信息_新增", ref param, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
List<MisDataSaveDate.MOM.ProcessInfo> processInfoList = processScheme.processInfo;
|
||
|
||
for (int i = 0; i < processInfoList.Count; i++)
|
||
{
|
||
MisDataSaveDate.MOM.ProcessInfo processInfo = processInfoList[i];
|
||
if (string.IsNullOrWhiteSpace(processInfo.processInfoid))
|
||
{
|
||
throw new Exception("参数processInfoid值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processInfo.sequenceNo))
|
||
{
|
||
throw new Exception("参数sequenceNo值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processInfo.processId))
|
||
{
|
||
throw new Exception("参数processId值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processInfo.processCode))
|
||
{
|
||
throw new Exception("参数processCode值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(processInfo.processName))
|
||
{
|
||
throw new Exception("参数processName值不正确!");
|
||
}
|
||
// 文件文档路径非必填,允许为空
|
||
var param2 = new SqlParameter[] {
|
||
new SqlParameter("@ProcessSchemeId",processScheme.id),
|
||
new SqlParameter("@processInfoid",processInfo.processInfoid),
|
||
new SqlParameter("@sequenceNo",processInfo.sequenceNo),
|
||
new SqlParameter("@processId",processInfo.processId),
|
||
new SqlParameter("@processCode",processInfo.processCode),
|
||
new SqlParameter("@processName",processInfo.processName),
|
||
new SqlParameter("@docInfo", VHandle(processInfo.docInfo)),
|
||
new SqlParameter("@filename", VHandle(processInfo.filename))
|
||
};
|
||
//DataAccess.ExecuteStoredProcedure("MOM_工艺信息_工序信息_新增", ref param2);
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_工艺信息_工序信息_新增", ref param2, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
}
|
||
|
||
List<MisDataSaveDate.MOM.RoutingInfo> routingInfoList = processScheme.routingInfo;
|
||
|
||
for (int i = 0; i < routingInfoList.Count; i++)
|
||
{
|
||
MisDataSaveDate.MOM.RoutingInfo routingInfo = routingInfoList[i];
|
||
if (string.IsNullOrWhiteSpace(routingInfo.routingid))
|
||
{
|
||
throw new Exception("参数routingid值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(routingInfo.routingcode))
|
||
{
|
||
throw new Exception("参数routingcode值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(routingInfo.processId))
|
||
{
|
||
throw new Exception("参数processId值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(routingInfo.processCode))
|
||
{
|
||
throw new Exception("参数processCode值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(routingInfo.processName))
|
||
{
|
||
throw new Exception("参数processName值不正确!");
|
||
}
|
||
var param3 = new SqlParameter[] {
|
||
new SqlParameter("@ProcessSchemeId",processScheme.id),
|
||
new SqlParameter("@routingid",routingInfo.routingid),
|
||
new SqlParameter("@routingcode",routingInfo.routingcode),
|
||
new SqlParameter("@processId",routingInfo.processId),
|
||
new SqlParameter("@processCode",routingInfo.processCode),
|
||
new SqlParameter("@processName",routingInfo.processName)
|
||
};
|
||
//DataAccess.ExecuteStoredProcedure("MOM_工艺信息_工艺路线_新增", ref param3);
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_工艺信息_工艺路线_新增", ref param3, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
}
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.code = 500;
|
||
result.message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 计划下发
|
||
/// </summary>
|
||
/// <param name="str"></param>
|
||
/// <returns></returns>
|
||
public static string DispatchOrder(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new MsgResHeader<string>();
|
||
result.code = 200;
|
||
result.message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.code = 500;
|
||
result.message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("生产任务接口res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
DispatchOrder dispatchOrder = JsonConvert.DeserializeObject<DispatchOrder>(str);
|
||
|
||
if (!ValidateProperty(dispatchOrder.orderID, "orderID", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(dispatchOrder.orderNo, "orderNo", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(dispatchOrder.materialId, "materialId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(dispatchOrder.materialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(dispatchOrder.materialName, "materialName", out errorMessage)) throw new Exception(errorMessage);
|
||
//if (!ValidateProperty(dispatchOrder.planStartTime, "planStartTime", out errorMessage)) throw new Exception(errorMessage);
|
||
|
||
var qty = dispatchOrder.qty == null ? 1 : Convert.ToInt32(double.Parse(dispatchOrder.qty));
|
||
var planStartDate = string.IsNullOrEmpty(dispatchOrder.planStartTime) ? DateTime.Now.ToString("yyyy-MM-dd") : DateTime.Parse(dispatchOrder.planStartTime).ToString("yyyy-MM-dd");
|
||
|
||
var param = new SqlParameter[] {
|
||
new SqlParameter("@orderID",dispatchOrder.orderID),
|
||
new SqlParameter("@orderNo",dispatchOrder.orderNo),
|
||
new SqlParameter("@materialId",dispatchOrder.materialId),
|
||
new SqlParameter("@materialCode",dispatchOrder.materialCode),
|
||
new SqlParameter("@materialName",dispatchOrder.materialName),
|
||
new SqlParameter("@materialSpec",VHandle(dispatchOrder.materialSpec)),
|
||
new SqlParameter("@materialModel",VHandle(dispatchOrder.materialModel )),
|
||
new SqlParameter("@projectCode",VHandle(dispatchOrder.projectCode)),
|
||
new SqlParameter("@projectName",VHandle(dispatchOrder.projectName)),
|
||
new SqlParameter("@routingId",VHandle(dispatchOrder.routingId)),
|
||
new SqlParameter("@qty",qty),
|
||
new SqlParameter("@planStartTime",planStartDate),
|
||
};
|
||
//新增生产任务、执行计划(根据计划数量拆分流水号及各工序Moby)
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_新增", ref param, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
List<DispatchTask> processInfoList = dispatchOrder.dispatchTask;
|
||
|
||
for (int i = 0; i < processInfoList.Count; i++)
|
||
{
|
||
DispatchTask processInfo = processInfoList[i];
|
||
if (!ValidateProperty(processInfo.taskId, "taskId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.taskNo, "taskNo", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.workOrderProcessId, "workOrderProcessId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.workOrderNo, "workOrderNo", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.workCenterId, "workCenterId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.workCenterCode, "workCenterCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.workCenterName, "workCenterName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.processId, "processId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.processCode, "processCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.processName, "processName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.materialId, "materialId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.materialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.materialName, "materialName", out errorMessage)) throw new Exception(errorMessage);
|
||
//if (!ValidateProperty(processInfo.materialModel, "materialModel", out errorMessage))throw new Exception(errorMessage);
|
||
//if (!ValidateProperty(processInfo.planStartTime, "planStartTime", out errorMessage))throw new Exception(errorMessage);
|
||
//if (!ValidateProperty(processInfo.planEndTime, "planEndTime", out errorMessage))throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.dispatchQty, "dispatchQty", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.taskStatus, "taskStatus", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.createdAt, "createdAt", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.modifiedAt, "modifiedAt", out errorMessage)) throw new Exception(errorMessage);
|
||
|
||
var param2 = new SqlParameter[] {
|
||
new SqlParameter("@orderID", dispatchOrder.orderID),
|
||
new SqlParameter("@orderNo", dispatchOrder.orderNo),
|
||
new SqlParameter("@taskId", processInfo.taskId),
|
||
new SqlParameter("@taskNo", processInfo.taskNo),
|
||
new SqlParameter("@workOrderProcessId", processInfo.workOrderProcessId),
|
||
new SqlParameter("@workOrderNo", processInfo.workOrderNo),
|
||
new SqlParameter("@workCenterId", processInfo.workCenterId),
|
||
new SqlParameter("@workCenterCode", processInfo.workCenterCode),
|
||
new SqlParameter("@workCenterName", processInfo.workCenterName),
|
||
new SqlParameter("@processId", processInfo.processId),
|
||
new SqlParameter("@processCode", processInfo.processCode),
|
||
new SqlParameter("@processName", processInfo.processName),
|
||
new SqlParameter("@materialId", processInfo.materialId),
|
||
new SqlParameter("@materialCode", processInfo.materialCode),
|
||
new SqlParameter("@materialName", processInfo.materialName),
|
||
new SqlParameter("@materialModel", VHandle(processInfo.materialModel)),
|
||
new SqlParameter("@planStartTime", VHandle(processInfo.planStartTime)),
|
||
new SqlParameter("@planEndTime", VHandle(processInfo.planEndTime)),
|
||
new SqlParameter("@dispatchQty",Convert.ToInt32(double.Parse(processInfo.dispatchQty))),
|
||
new SqlParameter("@taskStatus", processInfo.taskStatus),
|
||
new SqlParameter("@createdAt", processInfo.createdAt),
|
||
new SqlParameter("@modifiedAt", processInfo.modifiedAt),
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_派工任务_新增", ref param2, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
List<DeliveryInfo> deliveryInfoList = processInfo.deliveryInfo;
|
||
|
||
for (int j = 0; j < deliveryInfoList.Count; j++)
|
||
{
|
||
DeliveryInfo deliveryInfo = deliveryInfoList[j];
|
||
if (!ValidateProperty(deliveryInfo.deliveryInfoid, "deliveryInfoid", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.momid, "momid", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.preparationNo, "preparationNo", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.materialId, "materialId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.materialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.materialName, "materialName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.processId, "processId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.processCode, "processCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.processName, "processName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.workCenterId, "workCenterId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.workCenterCode, "workCenterCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.workCenterName, "workCenterName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.requiredQty, "requiredQty", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.planTime, "planTime", out errorMessage)) throw new Exception(errorMessage);
|
||
|
||
var param3 = new SqlParameter[] {
|
||
new SqlParameter("@orderID", dispatchOrder.orderID),
|
||
new SqlParameter("@orderNo", dispatchOrder.orderNo),
|
||
new SqlParameter("@taskId", processInfo.taskId),
|
||
new SqlParameter("@taskNo", processInfo.taskNo),
|
||
new SqlParameter("@deliveryInfoid", deliveryInfo.deliveryInfoid),
|
||
new SqlParameter("@momid", deliveryInfo.momid),
|
||
new SqlParameter("@preparationNo", deliveryInfo.preparationNo),
|
||
new SqlParameter("@materialId", deliveryInfo.materialId),
|
||
new SqlParameter("@materialCode", deliveryInfo.materialCode),
|
||
new SqlParameter("@materialName", deliveryInfo.materialName),
|
||
new SqlParameter("@materialSpec", VHandle(deliveryInfo.materialSpec)),
|
||
new SqlParameter("@materialModel", VHandle(deliveryInfo.materialModel)),
|
||
new SqlParameter("@materialDesc", VHandle(deliveryInfo.materialDesc)),
|
||
new SqlParameter("@processId", deliveryInfo.processId),
|
||
new SqlParameter("@processCode", deliveryInfo.processCode),
|
||
new SqlParameter("@processName", deliveryInfo.processName),
|
||
new SqlParameter("@workCenterId", deliveryInfo.workCenterId),
|
||
new SqlParameter("@workCenterCode", deliveryInfo.workCenterCode),
|
||
new SqlParameter("@workCenterName", deliveryInfo.workCenterName),
|
||
new SqlParameter("@requiredQty", Convert.ToInt32(double.Parse(deliveryInfo.requiredQty))),
|
||
new SqlParameter("@planTime", deliveryInfo.planTime),
|
||
new SqlParameter("@batchNo", VHandle(deliveryInfo.batchNo)),
|
||
new SqlParameter("@serialNo", VHandle(deliveryInfo.serialNo)),
|
||
new SqlParameter("@deliveryPosId", VHandle(deliveryInfo.deliveryPosId)),
|
||
new SqlParameter("@deliveryPosCode", VHandle(deliveryInfo.deliveryPosCode)),
|
||
new SqlParameter("@deliveryPosName", VHandle(deliveryInfo.deliveryPosName)),
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_派工任务_配送信息_新增", ref param3, out errorMessage);
|
||
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
}
|
||
}
|
||
//将订单数据转移到MES
|
||
var param4 = new SqlParameter[] {
|
||
new SqlParameter("@orderID", dispatchOrder.orderID),
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产任务_平移到MES", ref param4, out errorMessage);
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.code = 500;
|
||
result.message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("生产任务接口res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 生产工单接口
|
||
/// </summary>
|
||
/// <param name="url"></param>
|
||
/// <param name="jobj"></param>
|
||
/// <returns></returns>
|
||
public static string ProductionOrder(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new MsgResHeader<string>();
|
||
result.code = 200;
|
||
result.message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.code = 500;
|
||
result.message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("生产工单接口res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
ProductionOrder productionOrder = JsonConvert.DeserializeObject<ProductionOrder>(str);
|
||
|
||
if (!ValidateProperty(productionOrder.OrderID, "orderID", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(productionOrder.OrderNo, "orderNo", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(productionOrder.MaterialId, "materialId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(productionOrder.MaterialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(productionOrder.MaterialName, "materialName", out errorMessage)) throw new Exception(errorMessage);
|
||
|
||
var param = new SqlParameter[] {
|
||
new SqlParameter("@OrderID",productionOrder.OrderID),
|
||
new SqlParameter("@OrderNo",productionOrder.OrderNo),
|
||
new SqlParameter("@MaterialId",productionOrder.MaterialId),
|
||
new SqlParameter("@MaterialCode",productionOrder.MaterialCode),
|
||
new SqlParameter("@MaterialName",productionOrder.MaterialName),
|
||
new SqlParameter("@MaterialSpec",VHandle( productionOrder.MaterialSpec)),
|
||
new SqlParameter("@MaterialModel",VHandle(productionOrder.MaterialModel)),
|
||
new SqlParameter("@OrderType",VHandle(productionOrder.OrderType)),
|
||
new SqlParameter("@Clr",VHandle(productionOrder.Clr)),
|
||
new SqlParameter("@PlanProdDate",VHandle(productionOrder.PlanProdDate)),
|
||
new SqlParameter("@PlanProdQty",VHandle(productionOrder.PlanProdQty)),
|
||
new SqlParameter("@PlanOutputDate",VHandle(productionOrder.PlanOutputDate)),
|
||
new SqlParameter("@PlanOutputQty",VHandle(productionOrder.PlanOutputQty)),
|
||
new SqlParameter("@ProjectNo",VHandle(productionOrder.ProjectNo)),
|
||
new SqlParameter("@ProjectName",VHandle(productionOrder.ProjectName)),
|
||
new SqlParameter("@PlanId",VHandle(productionOrder.PlanId))
|
||
};
|
||
//新增生产任务、执行计划(根据计划数量拆分流水号及各工序Moby)
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产工单_新增", ref param, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
List<ProcessPlan> processInfoList = productionOrder.ProcessPlans;
|
||
|
||
for (int i = 0; i < processInfoList.Count; i++)
|
||
{
|
||
ProcessPlan processInfo = processInfoList[i];
|
||
|
||
if (!ValidateProperty(processInfo.RoutingId, "rountingid", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.ProcessPlanId, "processplanid", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.ProcessPlanNo, "processplanNo", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.WorkOrderProcessId, "workOrderProcessId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.WorkOrderNo, "workOrderNo", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.WorkCenterId, "workCenterId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.WorkCenterCode, "workCenterCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.WorkCenterName, "workCenterName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.ProcessId, "processId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.ProcessCode, "processCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.ProcessName, "processName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.MaterialId, "materialId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.MaterialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(processInfo.MaterialName, "materialName", out errorMessage)) throw new Exception(errorMessage);
|
||
|
||
var param2 = new SqlParameter[] {
|
||
new SqlParameter("@OrderID", productionOrder.OrderID),
|
||
new SqlParameter("@ProcessPlanId", processInfo.ProcessPlanId),
|
||
new SqlParameter("@RoutingId", processInfo.RoutingId),
|
||
new SqlParameter("@ProcessPlanNo", processInfo.ProcessPlanNo),
|
||
new SqlParameter("@WorkOrderProcessId", processInfo.WorkOrderProcessId),
|
||
new SqlParameter("@WorkOrderNo", processInfo.WorkOrderNo),
|
||
new SqlParameter("@WorkCenterId", processInfo.WorkCenterId),
|
||
new SqlParameter("@WorkCenterCode", processInfo.WorkCenterCode),
|
||
new SqlParameter("@WorkCenterName", processInfo.WorkCenterName),
|
||
new SqlParameter("@ProcessId", processInfo.ProcessId),
|
||
new SqlParameter("@ProcessCode", processInfo.ProcessCode),
|
||
new SqlParameter("@ProcessName", processInfo.ProcessName),
|
||
new SqlParameter("@MaterialId", processInfo.MaterialId),
|
||
new SqlParameter("@MaterialCode", processInfo.MaterialCode),
|
||
new SqlParameter("@MaterialName", processInfo.MaterialName),
|
||
new SqlParameter("@MaterialModel",VHandle(processInfo.MaterialModel)),
|
||
new SqlParameter("@PlanStartTime", VHandle(processInfo.PlanStartTime)),
|
||
new SqlParameter("@PlanEndTime", VHandle(processInfo.PlanEndTime)),
|
||
new SqlParameter("@Qty", processInfo.Qty),
|
||
new SqlParameter("@OutQty", processInfo.OutQty),
|
||
new SqlParameter("@Status", VHandle(processInfo.Status)),
|
||
new SqlParameter("@CreatedAt", VHandle(processInfo.CreatedAt)),
|
||
new SqlParameter("@ModifiedAt", VHandle(processInfo.ModifiedAt))
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产工单_工单工序_新增", ref param2, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
List<DeliveryMaterialInfo> deliveryInfoList = processInfo.DeliveryInfo;
|
||
|
||
for (int j = 0; j < deliveryInfoList.Count; j++)
|
||
{
|
||
DeliveryMaterialInfo deliveryInfo = deliveryInfoList[j];
|
||
if (!ValidateProperty(deliveryInfo.DeliveryInfoId, "deliveryInfoid", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.PreparationNo, "preparationNo", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.MaterialId, "materialId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.MaterialCode, "materialCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.MaterialName, "materialName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.ProcessId, "processId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.ProcessCode, "processCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.ProcessName, "processName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.WorkCenterId, "workCenterId", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.WorkCenterCode, "workCenterCode", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.WorkCenterName, "workCenterName", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.RequiredQty, "requiredQty", out errorMessage)) throw new Exception(errorMessage);
|
||
if (!ValidateProperty(deliveryInfo.PlanTime, "planTime", out errorMessage)) throw new Exception(errorMessage);
|
||
|
||
var param3 = new SqlParameter[] {
|
||
new SqlParameter("@OrderId", productionOrder.OrderID),
|
||
new SqlParameter("@ProcessPlanId", processInfo.ProcessPlanId),
|
||
new SqlParameter("@DeliveryInfoId", deliveryInfo.DeliveryInfoId),
|
||
new SqlParameter("@PreparationNo", deliveryInfo.PreparationNo),
|
||
new SqlParameter("@MaterialId", deliveryInfo.MaterialId),
|
||
new SqlParameter("@MaterialCode", deliveryInfo.MaterialCode),
|
||
new SqlParameter("@MaterialName", deliveryInfo.MaterialName),
|
||
new SqlParameter("@MaterialSpec",VHandle(deliveryInfo.MaterialSpec)),
|
||
new SqlParameter("@MaterialModel", VHandle(deliveryInfo.MaterialModel)),
|
||
new SqlParameter("@MaterialDesc", VHandle(deliveryInfo.MaterialDesc)),
|
||
new SqlParameter("@ProcessId", deliveryInfo.ProcessId),
|
||
new SqlParameter("@ProcessCode", deliveryInfo.ProcessCode),
|
||
new SqlParameter("@ProcessName", deliveryInfo.ProcessName),
|
||
new SqlParameter("@WorkCenterId", deliveryInfo.WorkCenterId),
|
||
new SqlParameter("@WorkCenterCode", deliveryInfo.WorkCenterCode),
|
||
new SqlParameter("@WorkCenterName", deliveryInfo.WorkCenterName),
|
||
new SqlParameter("@RequiredQty", deliveryInfo.RequiredQty),
|
||
new SqlParameter("@PlanTime", deliveryInfo.PlanTime)
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产工单_工单工序_工单备料_新增", ref param3, out errorMessage);
|
||
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
}
|
||
}
|
||
//将订单数据转移到MES
|
||
//var param4 = new SqlParameter[] {
|
||
// new SqlParameter("@orderID", productionOrder.orderID),
|
||
// };
|
||
//DataAccess.ExecuteStoredProcedure("MOM_生产任务_平移到MES", ConnectionString, ref param4, out errorMessage);
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.code = 500;
|
||
result.message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("工艺信息接口res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 缓存位置查询
|
||
/// </summary>
|
||
/// <param name="url"></param>
|
||
/// <param name="jobj"></param>
|
||
/// <returns></returns>
|
||
public static string AGV_To_AMS_LineSideStock(string url, [FromBody] JObject jobj)
|
||
{
|
||
|
||
var result = new Res_LineSideStock();
|
||
result.Code = 200;
|
||
result.Message = "";
|
||
result.Data = null;
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("缓存位置查询res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
LineSideStock LSSScheme = JsonConvert.DeserializeObject<LineSideStock>(str);
|
||
if (string.IsNullOrEmpty(LSSScheme.RequestId))
|
||
{
|
||
throw new Exception("参数requestId值不正确!");
|
||
}
|
||
if (string.IsNullOrEmpty(LSSScheme.Process))
|
||
{
|
||
throw new Exception("参数process值不正确!");
|
||
}
|
||
var param = new SqlParameter[]
|
||
{
|
||
new SqlParameter("@Process",LSSScheme.Process)
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_缓存位置_查询", ref param, out DataTable dt_lss, out errorMessage);
|
||
////////////////////List<LSSData> lssData = new List<LSSData>();
|
||
////////////////////foreach (DataRow dr in dt_lss.Rows)
|
||
////////////////////{
|
||
//////////////////// LSSData lssData = new LSSData();
|
||
//////////////////// lssData.ProcessNo = LSSScheme.Process;
|
||
//////////////////// lssData.LocationNo = dr["工位号"].ToString();
|
||
|
||
////////////////////}
|
||
////////////////////lssData.ProcessNo = LSSScheme.Process;
|
||
////////////////////lssData.LocationNo = errorMessage;
|
||
////////////////////lssData.
|
||
////////////////////result.Data = responseDatas;
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("缓存位置查询res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 点检计划
|
||
/// </summary>
|
||
/// <param name="url"></param>
|
||
/// <param name="jobj"></param>
|
||
/// <returns></returns>
|
||
public static string InspectionPlan(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new ApiResponse();
|
||
result.Code = 200;
|
||
result.Message = "";
|
||
result.Data = new List<Response_Data>();
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("点检计划res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
InspectionPlan Scheme = JsonConvert.DeserializeObject<InspectionPlan>(str);
|
||
|
||
if (string.IsNullOrWhiteSpace(Scheme.Id))
|
||
{
|
||
throw new Exception("参数id值不正确!");
|
||
}
|
||
else if (string.IsNullOrWhiteSpace(Scheme.Code))
|
||
{
|
||
throw new Exception("参数code值不正确!");
|
||
}
|
||
else if (string.IsNullOrWhiteSpace(Scheme.Name))
|
||
{
|
||
throw new Exception("参数name值不正确!");
|
||
}
|
||
|
||
var param = new SqlParameter[] {
|
||
new SqlParameter("@点检计划ID",Scheme.Id),
|
||
new SqlParameter("@点检编号",Scheme.Code),
|
||
new SqlParameter("@点检名称",Scheme.Name),
|
||
new SqlParameter("@编制单位编码",VHandle(Scheme.CompileUnitCode)),
|
||
new SqlParameter("@编制单位名称",VHandle(Scheme.CompileUnitName)),
|
||
new SqlParameter("@点检类别编号",VHandle(Scheme.CheckTypeCode)),
|
||
new SqlParameter("@点检类别名称",VHandle(Scheme.CheckTypeName)),
|
||
new SqlParameter("@是否周期计划",VHandle(Scheme.IsCyclePlan)),
|
||
new SqlParameter("@点检周期",VHandle(Scheme.CheckCycle)),
|
||
new SqlParameter("@周期单位",VHandle(Scheme.CycleUnit)),
|
||
new SqlParameter("@下次点检时间",VHandle(Scheme.NextCheckTime)),
|
||
new SqlParameter("@计划状态",VHandle(Scheme.PlanStatus)),
|
||
new SqlParameter("@巡检",VHandle(Scheme.WhetherInspect)),
|
||
new SqlParameter("@任务有效期",VHandle(Scheme.TaskValidityPeriod)),
|
||
new SqlParameter("@有效期单位",VHandle(Scheme.ValidityUnit)),
|
||
new SqlParameter("@提前生成",VHandle(Scheme.DaysAhead)),
|
||
new SqlParameter("@提前单位",VHandle(Scheme.AheadUnit))
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_点检计划_新增", ref param, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
List<MisDataSaveDate.MOM.CheckObject> checkObjectList = Scheme.CheckObjects;
|
||
|
||
for (int i = 0; i < checkObjectList.Count; i++)
|
||
{
|
||
MisDataSaveDate.MOM.CheckObject checkObject = checkObjectList[i];
|
||
if (string.IsNullOrWhiteSpace(checkObject.CheckObjectId))
|
||
{
|
||
throw new Exception("参数checkobjectsid值不正确!");
|
||
}
|
||
|
||
var param2 = new SqlParameter[] {
|
||
new SqlParameter("@点检计划ID",Scheme.Id),
|
||
new SqlParameter("@点检对象ID",checkObject.CheckObjectId),
|
||
new SqlParameter("@资产编号",VHandle(checkObject.AssetCode)),
|
||
new SqlParameter("@资产名称",VHandle(checkObject.AssetName)),
|
||
new SqlParameter("@资产位置",VHandle(checkObject.PositionCode)),
|
||
new SqlParameter("@资产位置名称",VHandle(checkObject.PositionName)),
|
||
new SqlParameter("@计划点检人编号",VHandle(checkObject.PlanCheckerCode)),
|
||
new SqlParameter("@计划点检人名称",VHandle(checkObject.PlanCheckerName))
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_点检计划_点检对象_新增", ref param2, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
List<MisDataSaveDate.MOM.CheckDetail> checkDetailList = checkObject.Details;
|
||
|
||
for (int j = 0; j < checkDetailList.Count; j++)
|
||
{
|
||
MisDataSaveDate.MOM.CheckDetail checkDetail = checkDetailList[j];
|
||
if (string.IsNullOrWhiteSpace(checkDetail.DetailId))
|
||
{
|
||
throw new Exception("参数detailid值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(checkDetail.CheckItem))
|
||
{
|
||
throw new Exception("参数checkitem值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(checkDetail.CheckContent))
|
||
{
|
||
throw new Exception("参数checkcontent值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(checkDetail.CheckMethodName))
|
||
{
|
||
throw new Exception("参数checkmethodname值不正确!");
|
||
}
|
||
|
||
var param3 = new SqlParameter[] {
|
||
new SqlParameter("@点检计划ID",Scheme.Id),
|
||
new SqlParameter("@点检对象ID",checkObject.CheckObjectId),
|
||
new SqlParameter("@详细信息ID",checkDetail.DetailId),
|
||
new SqlParameter("@点检部位",VHandle(checkDetail.CheckPart)),
|
||
new SqlParameter("@点检项目",checkDetail.CheckItem),
|
||
new SqlParameter("@点检内容",checkDetail.CheckContent),
|
||
new SqlParameter("@点检方法编号",VHandle(checkDetail.CheckMethodCode)),
|
||
new SqlParameter("@点检方法名称",checkDetail.CheckMethodName),
|
||
new SqlParameter("@标准要求",VHandle(checkDetail.StandardClaim)),
|
||
new SqlParameter("@结果类型",VHandle(checkDetail.ResultType)),
|
||
new SqlParameter("@结果选项ID",VHandle(checkDetail.ResultOptionsIds)),
|
||
new SqlParameter("@结果选项",VHandle(checkDetail.ResultOptions)),
|
||
new SqlParameter("@异常对策编号",VHandle(checkDetail.AbnormalMeasuresCode)),
|
||
new SqlParameter("@异常对策名称",VHandle(checkDetail.AbnormalMeasuresName)),
|
||
new SqlParameter("@点检状态编号",VHandle(checkDetail.CheckStatusEnumCode)),
|
||
new SqlParameter("@点检状态名称",VHandle(checkDetail.CheckStatusEnumName)),
|
||
new SqlParameter("@必须拍照",VHandle(checkDetail.IsPhotographed)),
|
||
new SqlParameter("@计划点检人编号",VHandle(checkDetail.PlanCheckerCode)),
|
||
new SqlParameter("@计划点检人名称",VHandle(checkDetail.PlanCheckerName)),
|
||
new SqlParameter("@最后点检时间",VHandle(checkDetail.LastCheckTime))
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_点检计划_点检对象_详细信息_新增", ref param3, out errorMessage);
|
||
if (errorMessage != "")
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
// 仅在 data 中返回一条顶层ID结果
|
||
var headerRes = new Response_Data();
|
||
headerRes.Code = string.IsNullOrEmpty(errorMessage) ? 200 : 500;
|
||
headerRes.Message = errorMessage;
|
||
headerRes.DataId = Scheme.Id;
|
||
result.Data.Add(headerRes);
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("点检计划res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 检验模板信息接收接口
|
||
/// </summary>
|
||
/// <param name="url"></param>
|
||
/// <param name="jobj"></param>
|
||
/// <returns></returns>
|
||
public static string QTItemTemplateInfo(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new ApiResponse();
|
||
result.Code = 200;
|
||
result.Message = "";
|
||
result.Data = new List<Response_Data>();
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("检验模板信息res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
QTTemplateInfo Scheme = JsonConvert.DeserializeObject<QTTemplateInfo>(str);
|
||
|
||
if (string.IsNullOrWhiteSpace(Scheme.Id))
|
||
{
|
||
throw new Exception("参数id值不正确!");
|
||
}
|
||
else if (string.IsNullOrWhiteSpace(Scheme.Code))
|
||
{
|
||
throw new Exception("参数code值不正确!");
|
||
}
|
||
else if (string.IsNullOrWhiteSpace(Scheme.Name))
|
||
{
|
||
throw new Exception("参数name值不正确!");
|
||
}
|
||
else if (string.IsNullOrWhiteSpace(Scheme.State))
|
||
{
|
||
throw new Exception("参数name值不正确!");
|
||
}
|
||
else if (Scheme.Type == null)
|
||
{
|
||
throw new Exception("参数type值不正确!");
|
||
}
|
||
|
||
var param = new SqlParameter[] {
|
||
new SqlParameter("@Id",Scheme.Id),
|
||
new SqlParameter("@Code",Scheme.Code),
|
||
new SqlParameter("@Name",Scheme.Name),
|
||
new SqlParameter("@Note",VHandle(Scheme.Note)),
|
||
new SqlParameter("@ClassIdentifier1",VHandle(Scheme.ClassIdentifier1)),
|
||
new SqlParameter("@ClassIdentifier2",VHandle(Scheme.ClassIdentifier2)),
|
||
new SqlParameter("@ClassIdentifier3",VHandle(Scheme.ClassIdentifier3)),
|
||
new SqlParameter("@ClassIdentifier4",VHandle(Scheme.ClassIdentifier4)),
|
||
new SqlParameter("@ClassIdentifier5",VHandle(Scheme.ClassIdentifier5)),
|
||
new SqlParameter("@ClassIdentifier6",VHandle(Scheme.ClassIdentifier6)),
|
||
new SqlParameter("@ClassIdentifier7",VHandle(Scheme.ClassIdentifier7)),
|
||
new SqlParameter("@ClassIdentifier8",VHandle(Scheme.ClassIdentifier8)),
|
||
new SqlParameter("@FileData",VHandle(Scheme.FileData)),
|
||
new SqlParameter("@State",Scheme.State),
|
||
new SqlParameter("@CreateUserId",VHandle(Scheme.CreateUserId)),
|
||
new SqlParameter("@CreateUser",VHandle(Scheme.CreateUser)),
|
||
new SqlParameter("@CreateTime",VHandle(Scheme.CreateTime)),
|
||
new SqlParameter("@LastModifiedUserId",VHandle(Scheme.LastModifiedUserId)),
|
||
new SqlParameter("@LastModifiedUser",VHandle(Scheme.LastModifiedUser)),
|
||
new SqlParameter("@LastModifiedTime",VHandle(Scheme.LastModifiedTime)),
|
||
new SqlParameter("@ProductionWorkCenterId",VHandle(Scheme.ProductionWorkCenter.ProductionWorkCenter)),
|
||
new SqlParameter("@ProductionWorkCenterCode",VHandle(Scheme.ProductionWorkCenter.ProductionWorkCenterPpsczxZxbh)),
|
||
new SqlParameter("@ProductionWorkCenterName",VHandle(Scheme.ProductionWorkCenter.ProductionWorkCenterNameChs)),
|
||
new SqlParameter("@MaterialId",VHandle(Scheme.Material.MaterialId)),
|
||
new SqlParameter("@MaterialCode",VHandle(Scheme.Material.MaterialIdCode)),
|
||
new SqlParameter("@MaterialName",VHandle(Scheme.Material.MaterialIdNameChs)),
|
||
new SqlParameter("@TypeId",VHandle(Scheme.Type.TypeID)),
|
||
new SqlParameter("@TypeCode",VHandle(Scheme.Type.TypeCode)),
|
||
new SqlParameter("@TypeName",VHandle(Scheme.Type.TypeName)),
|
||
new SqlParameter("@ProcedureId",VHandle(Scheme.Process.ProcedureId)),
|
||
new SqlParameter("@ProcedureCode",VHandle(Scheme.Process.ProcedureIdPpbzgxGxbh)),
|
||
new SqlParameter("@ProcedureName",VHandle(Scheme.Process.ProcedureIdNameChs)),
|
||
new SqlParameter("@MaterialTypeId",VHandle(Scheme.MaterialType.MaterialTypeValue)),
|
||
new SqlParameter("@MaterialTypeCode",VHandle(Scheme.MaterialType.MaterialTypeCode)),
|
||
new SqlParameter("@MaterialTypeName",VHandle(Scheme.MaterialType.MaterialTypeNameChs)),
|
||
new SqlParameter("@QualityOrgId",VHandle(Scheme.QualityOrg.QualityOrgValue)),
|
||
new SqlParameter("@QualityOrgCode",VHandle(Scheme.QualityOrg.QualityOrgPpzzzlZzbh)),
|
||
new SqlParameter("@QualityOrgName",VHandle(Scheme.QualityOrg.QualityOrgNameChs)),
|
||
new SqlParameter("@ProductionOrgId",VHandle(Scheme.ProductionOrg.ProductionOrgValue)),
|
||
new SqlParameter("@ProductionOrgCode",VHandle(Scheme.ProductionOrg.ProductionOrgPpzzscZzbh)),
|
||
new SqlParameter("@ProductionOrgName",VHandle(Scheme.ProductionOrg.ProductionOrgNameChs))
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验模板_新增", ref param, out errorMessage);
|
||
|
||
List<MisDataSaveDate.MOM.RecordTemplateItem> checkItemList = Scheme.RecordTemplateItems;
|
||
for (int i = 0; i < checkItemList.Count; i++)
|
||
{
|
||
MisDataSaveDate.MOM.RecordTemplateItem checkItem = checkItemList[i];
|
||
if (string.IsNullOrWhiteSpace(checkItem.Id))
|
||
{
|
||
throw new Exception("参数recordtemplateitems.id值不正确!");
|
||
}
|
||
var param2 = new SqlParameter[] {
|
||
new SqlParameter("@Id",checkItem.Id),
|
||
new SqlParameter("@TemplateId",Scheme.Id),
|
||
new SqlParameter("@LineNum",VHandle(checkItem.LineNum)),
|
||
new SqlParameter("@InspectionItemName",VHandle(checkItem.InspectionItemName)),
|
||
new SqlParameter("@InspectionItemsType",VHandle(checkItem.InspectionItemsType)),
|
||
new SqlParameter("@RequirementDesc",VHandle(checkItem.RequirementDesc)),
|
||
new SqlParameter("@DefaultValue",VHandle(checkItem.DefaultValue)),
|
||
new SqlParameter("@Note",VHandle(checkItem.Note)),
|
||
new SqlParameter("@UploadAttachments",VHandle(checkItem.UploadAttachments)),
|
||
new SqlParameter("@InspectKey",VHandle(checkItem.InspectKey)),
|
||
new SqlParameter("@MutualInspect",VHandle(checkItem.MutualInspect)),
|
||
new SqlParameter("@SpecialInspect",VHandle(checkItem.SpecialInspect)),
|
||
new SqlParameter("@SelfInspect",VHandle(checkItem.SelfInspect)),
|
||
new SqlParameter("@FirstInspect",VHandle(checkItem.FirstInspect)),
|
||
new SqlParameter("@Importance",VHandle(checkItem.Importance)),
|
||
new SqlParameter("@RequiredText",VHandle(checkItem.RequiredText)),
|
||
new SqlParameter("@AutoAdject",VHandle(checkItem.AutoAdject)),
|
||
new SqlParameter("@InspectionItemId",VHandle(checkItem.InspectionItem.inspectionItemId)),
|
||
new SqlParameter("@InspectionItemCode",VHandle(checkItem.InspectionItem.InspectionItemIdCode)),
|
||
new SqlParameter("@InspectionItemNameChs",VHandle(checkItem.InspectionItem.InspectionItemIdNameChs)),
|
||
new SqlParameter("@DefaultResultValueId",VHandle(checkItem.DefaultResult.defaultResultValue)),
|
||
new SqlParameter("@DefaultResultValueCode",VHandle(checkItem.DefaultResult.DefaultResultValueCode)),
|
||
new SqlParameter("@DefaultResultValueName",VHandle(checkItem.DefaultResult.DefaultResultValueName)),
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验模板_检验项目_新增", ref param2, out errorMessage);
|
||
|
||
List<MisDataSaveDate.MOM.XmInspectFile> xmInspectFileList = Scheme.XmInspectFile;
|
||
for (int j = 0; j < xmInspectFileList.Count; j++)
|
||
{
|
||
MisDataSaveDate.MOM.XmInspectFile xmInspectFile = xmInspectFileList[j];
|
||
if (string.IsNullOrWhiteSpace(xmInspectFile.Id))
|
||
{
|
||
throw new Exception("参数xm_inspectfile.id值不正确!");
|
||
}
|
||
var param3 = new SqlParameter[] {
|
||
new SqlParameter("@Id",xmInspectFile.Id),
|
||
new SqlParameter("@TemplateId",Scheme.Id),
|
||
new SqlParameter("@FileId",VHandle(xmInspectFile.FileId)),
|
||
new SqlParameter("@FileName",VHandle(xmInspectFile.FileName)),
|
||
new SqlParameter("@FileExt",VHandle(xmInspectFile.FileExt)),
|
||
new SqlParameter("@FileSize",VHandle(xmInspectFile.FileSize)),
|
||
new SqlParameter("@FileUser",VHandle(xmInspectFile.FileUser)),
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验模板_附件表_新增", ref param3, out errorMessage);
|
||
}
|
||
|
||
}
|
||
// 仅在 data 中返回一条顶层ID结果
|
||
var headerRes = new Response_Data();
|
||
headerRes.Code = string.IsNullOrEmpty(errorMessage) ? 200 : 500;
|
||
headerRes.Message = errorMessage;
|
||
headerRes.DataId = Scheme.Id;
|
||
result.Data.Add(headerRes);
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("检验模板信息res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
/// 删除派工订单接口
|
||
/// </summary>
|
||
/// <param name="url"></param>
|
||
/// <param name="jobj"></param>
|
||
/// <returns></returns>
|
||
public static string DeleteDispatchOrder(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new MsgResHeader<object>();
|
||
result.code = 200;
|
||
result.message = "";
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.code = 500;
|
||
result.message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("删除派工订单res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析参数
|
||
var reqData = JsonConvert.DeserializeObject<dynamic>(str);
|
||
|
||
string orderID = reqData.orderID?.ToString() ?? "";
|
||
string orderNo = reqData.orderNo?.ToString() ?? "";
|
||
|
||
// 参数验证
|
||
if (string.IsNullOrWhiteSpace(orderID))
|
||
{
|
||
throw new Exception("参数orderID值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(orderNo))
|
||
{
|
||
throw new Exception("参数orderNo值不正确!");
|
||
}
|
||
|
||
// 检查data数组是否存在
|
||
if (reqData.data == null)
|
||
{
|
||
throw new Exception("参数data值不正确!");
|
||
}
|
||
|
||
// 验证data数组中的参数
|
||
var dataArray = reqData.data;
|
||
foreach (var dataItem in dataArray)
|
||
{
|
||
string taskid = dataItem.taskid?.ToString() ?? "";
|
||
string moid = dataItem.moid?.ToString() ?? "";
|
||
|
||
if (string.IsNullOrWhiteSpace(taskid))
|
||
{
|
||
throw new Exception("参数taskid值不正确!");
|
||
}
|
||
if (string.IsNullOrWhiteSpace(moid))
|
||
{
|
||
throw new Exception("参数moid值不正确!");
|
||
}
|
||
}
|
||
|
||
// 调用存储过程删除订单(只调用一次)
|
||
var param = new SqlParameter[] {
|
||
new SqlParameter("@派工单ID", orderID),
|
||
new SqlParameter("@派工单号", orderNo)
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_生产工单_删除", ref param, out errorMessage);
|
||
|
||
if (!string.IsNullOrEmpty(errorMessage))
|
||
{
|
||
throw new Exception(errorMessage);
|
||
}
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.code = 500;
|
||
result.message = err.Message;
|
||
}
|
||
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("删除派工订单res:", retString);
|
||
return retString;
|
||
}
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="url"></param>
|
||
/// <param name="jobj"></param>
|
||
/// <returns></returns>
|
||
public static string QTStandardInfo(string url, [FromBody] JObject jobj)
|
||
{
|
||
var result = new ApiResponse();
|
||
result.Code = 200;
|
||
result.Message = "";
|
||
result.Data = new List<Response_Data>();
|
||
string errorMessage = "";
|
||
|
||
if (jobj == null)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = "参数格式不正确!";
|
||
string retString1 = JsonConvert.SerializeObject(result);
|
||
MyLog4Net.MyLogHelper.Info("检验模板信息res:", retString1);
|
||
return retString1;
|
||
}
|
||
string str = jobj.ToString();
|
||
//存储日志
|
||
SaveLog_Interface_Request(url, 2, str, out int AID);
|
||
try
|
||
{
|
||
// 解析订单内容,存储数据库,根据实际业务来写
|
||
QTStandardInfo Scheme = JsonConvert.DeserializeObject<QTStandardInfo>(str);
|
||
|
||
if (string.IsNullOrWhiteSpace(Scheme.Id))
|
||
{
|
||
throw new Exception("参数id值不正确!");
|
||
}
|
||
var param = new SqlParameter[] {
|
||
new SqlParameter("@id",VHandle(Scheme.Id)),
|
||
new SqlParameter("@code",VHandle(Scheme.Code)),
|
||
new SqlParameter("@name_chs",VHandle(Scheme.NameChs.ToString())),
|
||
new SqlParameter("@createdate",VHandle(Scheme.CreateDate.ToString())),
|
||
new SqlParameter("@lastmodifiedtime",VHandle(Scheme.LastModifiedTime.ToString())),
|
||
new SqlParameter("@note",VHandle(Scheme.Note)),
|
||
new SqlParameter("@standardstate",VHandle(Scheme.StandardState)),
|
||
new SqlParameter("@materialid",VHandle(Scheme.Material.MaterialId)),
|
||
new SqlParameter("@materialid_code",VHandle(Scheme.Material.MaterialIdCode)),
|
||
new SqlParameter("@materialid_name_chs",VHandle(Scheme.Material.MaterialIdNameChs)),
|
||
new SqlParameter("@procedureid",VHandle(Scheme.Procedure.ProcedureId)),
|
||
new SqlParameter("@procedureid_name_chs",VHandle(Scheme.Procedure.ProcedureName)),
|
||
new SqlParameter("@procedureid_ppbzgx_gxbh",VHandle(Scheme.Procedure.ProcedureCode)),
|
||
new SqlParameter("@standardsortid",VHandle(Scheme.StandardSort.StandardSortId)),
|
||
new SqlParameter("@standardsortid_code",VHandle(Scheme.StandardSort.StandardSortCode)),
|
||
new SqlParameter("@standardsortid_name_chs",VHandle(Scheme.StandardSort.StandardSortName)),
|
||
new SqlParameter("@standardsortid_sortpath",VHandle(Scheme.StandardSort.StandardSortPath)),
|
||
new SqlParameter("@standardtypeid",VHandle(Scheme.StandardType.StandardTypeId)),
|
||
new SqlParameter("@standardtypeid_code",VHandle(Scheme.StandardType.StandardTypeCode)),
|
||
new SqlParameter("@standardtypeid_iseffective",VHandle(Scheme.StandardType.IsEffective)),
|
||
new SqlParameter("@standardtypeid_issystem",VHandle(Scheme.StandardType.IsSystem)),
|
||
new SqlParameter("@standardtypeid_name_chs",VHandle(Scheme.StandardType.StandardTypeName)),
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验标准_新增", ref param, out errorMessage);
|
||
|
||
List<MisDataSaveDate.MOM.StandardItemSource> standardItemList = Scheme.StandardItemList;
|
||
for (int i = 0; i < standardItemList.Count; i++)
|
||
{
|
||
MisDataSaveDate.MOM.StandardItemSource standardItem = standardItemList[i];
|
||
if (string.IsNullOrWhiteSpace(standardItem.itemId))
|
||
{
|
||
throw new Exception("参数meqmstandarditemsource.id值不正确!");
|
||
}
|
||
var param2 = new SqlParameter[] {
|
||
new SqlParameter("@id",VHandle(standardItem.itemId)),
|
||
new SqlParameter("@standard_id",VHandle(Scheme.Id)),
|
||
new SqlParameter("@standard_code",VHandle(Scheme.Code)),
|
||
new SqlParameter("@standard_name_chs",VHandle(Scheme.NameChs)),
|
||
new SqlParameter("@createtime",VHandle(standardItem.CreateTime.ToString())),
|
||
new SqlParameter("@inspecclassification",VHandle(standardItem.InspectionClassification)),
|
||
new SqlParameter("@inspecclassificationname",VHandle(standardItem.InspectionClassificationName)),
|
||
new SqlParameter("@note",VHandle(standardItem.Note)),
|
||
new SqlParameter("@targetauxdescribe",VHandle(standardItem.TargetAuxDescribe)),
|
||
new SqlParameter("@targetdescribe",VHandle(standardItem.TargetDescribe)),
|
||
new SqlParameter("@targetno",VHandle(standardItem.TargetNo)),
|
||
new SqlParameter("@targetgroup_id",VHandle(standardItem.TargetGroup.TargetGroupId)),
|
||
new SqlParameter("@targetgroup_code",VHandle(standardItem.TargetGroup.TargetGroupCode)),
|
||
new SqlParameter("@targetgroup_name_chs",VHandle(standardItem.TargetGroup.TargetGroupName)),
|
||
new SqlParameter("@target_id",VHandle(standardItem.Target.TargetId)),
|
||
new SqlParameter("@target_code",VHandle(standardItem.Target.TargetCode)),
|
||
new SqlParameter("@target_name_chs",VHandle(standardItem.Target.TargetName)),
|
||
new SqlParameter("@target_note",VHandle(standardItem.Target.TargetNote)),
|
||
new SqlParameter("@target_targetgroupid",VHandle(standardItem.Target.TargetGroupId)),
|
||
new SqlParameter("@target_targettype",VHandle(standardItem.Target.TargetType)),
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验标准_标准项目_新增", ref param2, out errorMessage);
|
||
}
|
||
List<MisDataSaveDate.MOM.StandardValueInfo> standardValueList = Scheme.StandardValueList;
|
||
for (int j = 0; j < standardValueList.Count; j++)
|
||
{
|
||
MisDataSaveDate.MOM.StandardValueInfo standardValue = standardValueList[j];
|
||
if (string.IsNullOrWhiteSpace(standardValue.Id))
|
||
{
|
||
throw new Exception("参数meqmstandardvaluesource.id值不正确!");
|
||
}
|
||
var param3 = new SqlParameter[] {
|
||
new SqlParameter("@id",VHandle(standardValue.Id)),
|
||
new SqlParameter("@standard_id",VHandle(Scheme.Id)),
|
||
new SqlParameter("@itemid",VHandle(standardValue.StandardItemId)),
|
||
new SqlParameter("@inspectionresultsname",VHandle(standardValue.InspectionResultsName)),
|
||
new SqlParameter("@itemvaluetype",VHandle(standardValue.ItemValueType)),
|
||
new SqlParameter("@lowercharacter",VHandle(standardValue.LowerCharacter)),
|
||
new SqlParameter("@lowerdiffvalue",VHandle(standardValue.LowerDiffValue.ToString())),
|
||
new SqlParameter("@lowervalue",VHandle(standardValue.LowerValue.ToString())),
|
||
new SqlParameter("@note",VHandle(standardValue.Note)),
|
||
new SqlParameter("@standardstrvalue",VHandle(standardValue.StandardStrValue)),
|
||
new SqlParameter("@standardvalue",VHandle(standardValue.StandardValue.ToString())),
|
||
new SqlParameter("@uppercharacter",VHandle(standardValue.UpperCharacter)),
|
||
new SqlParameter("@upperdiffvalue",VHandle(standardValue.UpperDiffValue.ToString())),
|
||
new SqlParameter("@uppervalue",VHandle(standardValue.UpperValue.ToString())),
|
||
new SqlParameter("@valueno",VHandle(standardValue.ValueNo)),
|
||
new SqlParameter("@inspectionresults",VHandle(standardValue.InspectionResults.InspectionResults)),
|
||
new SqlParameter("@inspectionresults_code",VHandle(standardValue.InspectionResults.InspectionResultsCode)),
|
||
new SqlParameter("@inspectionresults_enable",VHandle(standardValue.InspectionResults.InspectionResultsEnable)),
|
||
new SqlParameter("@inspectionresults_name",VHandle(standardValue.InspectionResults.InspectionResultsName)),
|
||
new SqlParameter("@targetvalueid_id",VHandle(standardValue.TargetValue.TargetValueId)),
|
||
new SqlParameter("@targetvalueid_code",VHandle(standardValue.TargetValue.TargetValueCode)),
|
||
new SqlParameter("@targetvalueid_name",VHandle(standardValue.TargetValue.TargetValueName)),
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验标准_标准值表_新增", ref param3, out errorMessage);
|
||
}
|
||
|
||
var param4 = new SqlParameter[] {
|
||
new SqlParameter("@检验标准ID",Scheme.Id),
|
||
};
|
||
DataLinkMesWork2.DataAccess2.ExecuteStoredProcedure("MOM_检验标准_综合表_新增", ref param4, out errorMessage);
|
||
// 仅在 data 中返回一条顶层ID结果
|
||
var headerRes = new Response_Data();
|
||
headerRes.Code = string.IsNullOrEmpty(errorMessage) ? 200 : 500;
|
||
headerRes.Message = errorMessage;
|
||
headerRes.DataId = Scheme.Id;
|
||
result.Data.Add(headerRes);
|
||
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
result.Code = 500;
|
||
result.Message = err.Message;
|
||
}
|
||
string retString = JsonConvert.SerializeObject(result);
|
||
SaveLog_Interface_Response(retString, AID);
|
||
MyLog4Net.MyLogHelper.Info("检验模板信息res:", retString);
|
||
return retString;
|
||
}
|
||
|
||
|
||
}
|
||
}
|