Browse Source

更新

master
赵新宇 4 weeks ago
parent
commit
0d0bfb2b76
  1. 284
      API/TaskManager.Entity/Data/SUPPLIER_EMPLOYEE_DT.cs
  2. 40
      API/TaskManager.Entity/Data/SUPPLIER_INFO_DT.cs
  3. 66
      API/TaskManager.Entity/Data/SUPPLIER_PRO_PROCESS_EQUIPMENT_DT.cs
  4. 208
      API/Wood.Service/Datas/SupplierEmployeeDtService.cs
  5. 180
      API/Wood.Service/Datas/SupplierInfoDtService.cs
  6. 164
      API/Wood.Service/Datas/SupplierProProcessEquipmentDtService.cs

284
API/TaskManager.Entity/Data/SUPPLIER_EMPLOYEE_DT.cs

@ -1,134 +1,162 @@
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TaskManager.Entity;
namespace TaskManager.Entity
public class SUPPLIER_EMPLOYEE_DT : BaseEntity_NoTask
{
/// <summary>
/// 人员资质信息
/// </summary>
public class SUPPLIER_EMPLOYEE_DT : BaseEntity_NoTask
{
/// <summary>
/// 供应商代码
/// </summary>
[ExporterHeader(DisplayName = "供应商代码")]
[ImporterHeader(Name = "供应商代码")]
public string SupplierCode { get; set; }
/// <summary>
/// 供应商名称
/// </summary>
[ExporterHeader(DisplayName = "供应商名称")]
[ImporterHeader(Name = "供应商名称")]
public string SupplierName { get; set; }
/// <summary>
/// 工厂代码
/// </summary>
[ExporterHeader(DisplayName = "工厂代码")]
[ImporterHeader(Name = "工厂代码")]
public string PlantId { get; set; }
/// <summary>
/// 工厂名称
/// </summary>
[ExporterHeader(DisplayName = "工厂名称")]
[ImporterHeader(Name = "工厂名称")]
public string PlantName { get; set; }
/// <summary>
/// 车间代码
/// </summary>
[ExporterHeader(DisplayName = "车间代码")]
[ImporterHeader(Name = "车间代码")]
public string WorkshopId { get; set; }
/// <summary>
/// 车间名称
/// </summary>
[ExporterHeader(DisplayName = "车间名称")]
[ImporterHeader(Name = "车间名称")]
public string WorkshopName { get; set; }
/// <summary>
/// 产线代码
/// </summary>
[ExporterHeader(DisplayName = "产线代码")]
[ImporterHeader(Name = "产线代码")]
public string ProductionLineId { get; set; }
/// <summary>
/// 产线名称
/// </summary>
[ExporterHeader(DisplayName = "产线名称")]
[ImporterHeader(Name = "产线名称")]
public string ProductionLineName { get; set; }
/// <summary>
/// 工位代码
/// </summary>
[ExporterHeader(DisplayName = "工位代码")]
[ImporterHeader(Name = "工位代码")]
public string StationId { get; set; }
/// <summary>
/// 工位名称
/// </summary>
[ExporterHeader(DisplayName = "工位名称")]
[ImporterHeader(Name = "工位名称")]
public string StationName { get; set; }
/// <summary>
/// 工位人员账号
/// </summary>
[ExporterHeader(DisplayName = "工位人员账号")]
[ImporterHeader(Name = "工位人员账号")]
public string OperatorId { get; set; }
/// <summary>
/// 工位人员姓名
/// </summary>
[ExporterHeader(DisplayName = "工位人员姓名")]
[ImporterHeader(Name = "工位人员姓名")]
public string OperatorName { get; set; }
/// <summary>
/// 是否有资质(Y,N)
/// </summary>
[ExporterHeader(DisplayName = "是否有资质(Y,N)")]
[ImporterHeader(Name = "是否有资质(Y,N)")]
[RegularExpression("^[YN]$", ErrorMessage = " Y N")]
public string HaveQuantity { get; set; }
/// <summary>
/// 供应商修改时间,格式(yyyy-MM-ddHH:mm:ss)
/// </summary>
[ExporterHeader(DisplayName = "供应商修改时间")]
[ImporterHeader(Name = "供应商修改时间", Format ="yyyy-MM-dd HH:mm:ss")]
public DateTime? DataUpdateTime { get; set; }
/// <summary>
/// 岗位代码
/// </summary>
[ExporterHeader(DisplayName = "岗位代码")]
[ImporterHeader(Name = "岗位代码")]
public string PositionId { get; set; }
/// <summary>
/// 岗位名称
/// </summary>
[ExporterHeader(DisplayName = "岗位名称")]
[ImporterHeader(Name = "岗位名称")]
public string PositionName { get; set; }
/// <summary>
/// 资质等级(Level_4,Level_3,Level_2,Level_1)
/// </summary>
[ExporterHeader(DisplayName = "资质等级")]
[ImporterHeader(Name = "资质等级")]
[RegularExpression("^(Level_4|Level_3|Level_2|Level_1)$", ErrorMessage = "资质等级 只能填写 Level_4,Level_3,Level_2, Level_1 其中之一")]
public string QualificationLevel { get; set; }
/// <summary>
/// 资质获取时间
/// </summary>
[ExporterHeader(DisplayName = "资质获取时间")]
[ImporterHeader(Name = "资质获取时间", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime? CheckInTime { get; set; }
/// <summary>
/// 资质失去时间
/// </summary>
[ExporterHeader(DisplayName = "资质失去时间")]
[ImporterHeader(Name = "资质失去时间", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime? CheckOutTime { get; set; }
}
}
/// 供应商代码
/// </summary>
[Required(ErrorMessage = "供应商代码为必填项")]
[ExporterHeader(DisplayName = "供应商代码")]
[ImporterHeader(Name = "供应商代码")]
public string SupplierCode { get; set; }
/// <summary>
/// 供应商名称
/// </summary>
[Required(ErrorMessage = "供应商名称为必填项")]
[ExporterHeader(DisplayName = "供应商名称")]
[ImporterHeader(Name = "供应商名称")]
public string SupplierName { get; set; }
/// <summary>
/// 工厂代码
/// </summary>
[Required(ErrorMessage = "工厂代码为必填项")]
[ExporterHeader(DisplayName = "工厂代码")]
[ImporterHeader(Name = "工厂代码")]
public string PlantId { get; set; }
/// <summary>
/// 工厂名称
/// </summary>
[Required(ErrorMessage = "工厂名称为必填项")]
[ExporterHeader(DisplayName = "工厂名称")]
[ImporterHeader(Name = "工厂名称")]
public string PlantName { get; set; }
/// <summary>
/// 车间代码
/// </summary>
[Required(ErrorMessage = "车间代码为必填项")]
[ExporterHeader(DisplayName = "车间代码")]
[ImporterHeader(Name = "车间代码")]
public string WorkshopId { get; set; }
/// <summary>
/// 车间名称
/// </summary>
[Required(ErrorMessage = "车间名称为必填项")]
[ExporterHeader(DisplayName = "车间名称")]
[ImporterHeader(Name = "车间名称")]
public string WorkshopName { get; set; }
/// <summary>
/// 产线代码
/// </summary>
[Required(ErrorMessage = "产线代码为必填项")]
[ExporterHeader(DisplayName = "产线代码")]
[ImporterHeader(Name = "产线代码")]
public string ProductionLineId { get; set; }
/// <summary>
/// 产线名称
/// </summary>
[Required(ErrorMessage = "产线名称为必填项")]
[ExporterHeader(DisplayName = "产线名称")]
[ImporterHeader(Name = "产线名称")]
public string ProductionLineName { get; set; }
/// <summary>
/// 工位代码
/// </summary>
[Required(ErrorMessage = "工位代码为必填项")]
[ExporterHeader(DisplayName = "工位代码")]
[ImporterHeader(Name = "工位代码")]
public string StationId { get; set; }
/// <summary>
/// 工位名称
/// </summary>
[Required(ErrorMessage = "工位名称为必填项")]
[ExporterHeader(DisplayName = "工位名称")]
[ImporterHeader(Name = "工位名称")]
public string StationName { get; set; }
/// <summary>
/// 工位人员账号
/// </summary>
[Required(ErrorMessage = "工位人员账号为必填项")]
[ExporterHeader(DisplayName = "工位人员账号")]
[ImporterHeader(Name = "工位人员账号")]
public string OperatorId { get; set; }
/// <summary>
/// 工位人员姓名
/// </summary>
[Required(ErrorMessage = "工位人员姓名为必填项")]
[ExporterHeader(DisplayName = "工位人员姓名")]
[ImporterHeader(Name = "工位人员姓名")]
public string OperatorName { get; set; }
/// <summary>
/// 是否有资质(Y,N)
/// </summary>
[Required(ErrorMessage = "是否有资质为必填项")]
[ExporterHeader(DisplayName = "是否有资质(Y,N)")]
[ImporterHeader(Name = "是否有资质(Y,N)")]
[RegularExpression("^[YN]$", ErrorMessage = " Y N")]
public string HaveQuantity { get; set; }
/// <summary>
/// 供应商修改时间,格式(yyyy-MM-ddHH:mm:ss)
/// </summary>
[Required(ErrorMessage = "供应商修改时间为必填项")]
[ExporterHeader(DisplayName = "供应商修改时间")]
[ImporterHeader(Name = "供应商修改时间", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime DataUpdateTime { get; set; }
/// <summary>
/// 岗位代码
/// </summary>
[Required(ErrorMessage = "岗位代码为必填项")]
[ExporterHeader(DisplayName = "岗位代码")]
[ImporterHeader(Name = "岗位代码")]
public string PositionId { get; set; }
/// <summary>
/// 岗位名称
/// </summary>
[Required(ErrorMessage = "岗位名称为必填项")]
[ExporterHeader(DisplayName = "岗位名称")]
[ImporterHeader(Name = "岗位名称")]
public string PositionName { get; set; }
/// <summary>
/// 资质等级(Level_4,Level_3,Level_2,Level_1)
/// </summary>
[Required(ErrorMessage = "资质等级为必填项")]
[ExporterHeader(DisplayName = "资质等级")]
[ImporterHeader(Name = "资质等级")]
[RegularExpression("^(Level_4|Level_3|Level_2|Level_1)$", ErrorMessage = "资质等级 只能填写 Level_4,Level_3,Level_2, Level_1 其中之一")]
public string QualificationLevel { get; set; }
/// <summary>
/// 资质获取时间
/// </summary>
[Required(ErrorMessage = "资质获取时间为必填项")]
[ExporterHeader(DisplayName = "资质获取时间")]
[ImporterHeader(Name = "资质获取时间", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime CheckInTime { get; set; }
/// <summary>
/// 资质失去时间
/// </summary>
[Required(ErrorMessage = "资质失去时间为必填项")]
[ExporterHeader(DisplayName = "资质失去时间")]
[ImporterHeader(Name = "资质失去时间", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime CheckOutTime { get; set; }
}

40
API/TaskManager.Entity/Data/SUPPLIER_INFO_DT.cs

@ -16,112 +16,146 @@ namespace TaskManager.Entity
/// <summary>
/// 供应商代码
/// </summary>
[Required(ErrorMessage = "供应商代码为必填项")]
[ExporterHeader(DisplayName = "供应商代码")]
[ImporterHeader(Name = "供应商代码")]
public string SupplierCode { get; set; }
/// <summary>
/// 供应商名称
/// </summary>
[Required(ErrorMessage = "供应商名称为必填项")]
[ExporterHeader(DisplayName = "供应商名称")]
[ImporterHeader(Name = "供应商名称")]
public string SupplierName { get; set; }
/// <summary>
/// 工厂代码
/// </summary>
[Required(ErrorMessage = "工厂代码为必填项")]
[ExporterHeader(DisplayName = "工厂代码")]
[ImporterHeader(Name = "工厂代码")]
public string PlantId { get; set; }
/// <summary>
/// 工厂名称
/// </summary>
[Required(ErrorMessage = "工厂名称为必填项")]
[ExporterHeader(DisplayName = "工厂名称")]
[ImporterHeader(Name = "工厂名称")]
public string PlantName { get; set; }
/// <summary>
/// 车间代码
/// </summary>
[Required(ErrorMessage = "车间代码为必填项")]
[ExporterHeader(DisplayName = "车间代码")]
[ImporterHeader(Name = "车间代码")]
public string WorkshopId { get; set; }
/// <summary>
/// 车间名称
/// </summary>
[Required(ErrorMessage = "车间名称为必填项")]
[ExporterHeader(DisplayName = "车间名称")]
[ImporterHeader(Name = "车间名称")]
public string WorkshopName { get; set; }
/// <summary>
/// 产线代码
/// </summary>
[Required(ErrorMessage = "产线代码为必填项")]
[ExporterHeader(DisplayName = "产线代码")]
[ImporterHeader(Name = "产线代码")]
public string ProductionLineId { get; set; }
/// <summary>
/// 产线名称
/// </summary>
[Required(ErrorMessage = "产线名称为必填项")]
[ExporterHeader(DisplayName = "产线名称")]
[ImporterHeader(Name = "产线名称")]
public string ProductionLineName { get; set; }
/// <summary>
/// 工位代码
/// </summary>
[Required(ErrorMessage = "工位代码为必填项")]
[ExporterHeader(DisplayName = "工位代码")]
[ImporterHeader(Name = "工位代码")]
public string StationId { get; set; }
/// <summary>
/// 工位名称
/// </summary>
[Required(ErrorMessage = "工位名称为必填项")]
[ExporterHeader(DisplayName = "工位名称")]
[ImporterHeader(Name = "工位名称")]
public string StationName { get; set; }
/// <summary>
/// 是否关键工位(Y/N)
/// </summary>
[Required(ErrorMessage = "是否关键工位为必填项")]
[ExporterHeader(DisplayName = "是否关键工位(Y/N)")]
[ImporterHeader(Name = "是否关键工位(Y/N)")]
[RegularExpression("^[YN]$", ErrorMessage = " Y N")]
public string KeyStation { get; set; }
/// <summary>
/// 供应商修改时间,格式(yyyy-MM-ddHH:mm:ss)
/// </summary>
[Required(ErrorMessage = "供应商修改时间为必填项")]
[ExporterHeader(DisplayName = "供应商修改时间")]
[ImporterHeader(Name = "供应商修改时间", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime? DataUpdateTime { get; set; }
public DateTime DataUpdateTime { get; set; }
/// <summary>
/// 产线顺序
/// </summary>
[Required(ErrorMessage = "产线顺序为必填项")]
[ExporterHeader(DisplayName = "产线顺序")]
[ImporterHeader(Name = "产线顺序")]
public decimal ProductionLineOrder { get; set; }
/// <summary>
/// 工位顺序
/// </summary>
[Required(ErrorMessage = "工位顺序为必填项")]
[ExporterHeader(DisplayName = "工位顺序")]
[ImporterHeader(Name = "工位顺序")]
public decimal StationOrder { get; set; }
/// <summary>
/// 供应商总成零件号
/// </summary>
[Required(ErrorMessage = "供应商总成零件号为必填项")]
[ExporterHeader(DisplayName = "供应商总成零件号")]
[ImporterHeader(Name = "供应商总成零件号")]
public string VendorProductNo { get; set; }
/// <summary>
/// 供应商总成零件名称
/// </summary>
[Required(ErrorMessage = "供应商总成零件名称为必填项")]
[ExporterHeader(DisplayName = "供应商总成零件名称")]
[ImporterHeader(Name = "供应商总成零件名称")]
public string VendorProductName { get; set; }
/// <summary>
/// 奇瑞零件号
/// </summary>
[Required(ErrorMessage = "奇瑞零件号为必填项")]
[ExporterHeader(DisplayName = "奇瑞零件号")]
[ImporterHeader(Name = "奇瑞零件号")]
public string CheryProductNo { get; set; }
/// <summary>
/// 奇瑞零件名称
/// </summary>
[Required(ErrorMessage = "奇瑞零件名称为必填项")]
[ExporterHeader(DisplayName = "奇瑞零件名称")]
[ImporterHeader(Name = "奇瑞零件名称")]
public string CheryProductName { get; set; }
}
}
}

66
API/TaskManager.Entity/Data/SUPPLIER_PRO_PROCESS_EQUIPMENT_DT.cs

@ -1,4 +1,5 @@
using Magicodes.ExporterAndImporter.Core;
using System.ComponentModel.DataAnnotations;
namespace TaskManager.Entity.Entitys
{
@ -10,184 +11,241 @@ namespace TaskManager.Entity.Entitys
/// <summary>
/// 供应商代码
/// </summary>
[Required(ErrorMessage = "供应商代码为必填项")]
[ExporterHeader(DisplayName = "供应商代码")]
[ImporterHeader(Name = "供应商代码")]
public string SupplierCode { get; set; }
/// <summary>
/// 供应商名称
/// </summary>
[Required(ErrorMessage = "供应商名称为必填项")]
[ExporterHeader(DisplayName = "供应商名称")]
[ImporterHeader(Name = "供应商名称")]
public string SupplierName { get; set; }
/// <summary>
/// 奇瑞零件号
/// </summary>
[Required(ErrorMessage = "奇瑞零件号为必填项")]
[ExporterHeader(DisplayName = "奇瑞零件号")]
[ImporterHeader(Name = "奇瑞零件号")]
public string CheryProductNo { get; set; }
/// <summary>
/// 奇瑞零件名称
/// </summary>
[Required(ErrorMessage = "奇瑞零件名称为必填项")]
[ExporterHeader(DisplayName = "奇瑞零件名称")]
[ImporterHeader(Name = "奇瑞零件名称")]
public string CheryProductName { get; set; }
/// <summary>
/// 供应商总成零件号
/// </summary>
[Required(ErrorMessage = "供应商总成零件号为必填项")]
[ExporterHeader(DisplayName = "供应商总成零件号")]
[ImporterHeader(Name = "供应商总成零件号")]
public string VendorProductNo { get; set; }
/// <summary>
/// 供应商总成零件名称
/// </summary>
[Required(ErrorMessage = "供应商总成零件名称为必填项")]
[ExporterHeader(DisplayName = "供应商总成零件名称")]
[ImporterHeader(Name = "供应商总成零件名称")]
public string VendorProductName { get; set; }
/// <summary>
/// 工艺装备类型分类(1模具;2检具;3夹具)
/// </summary>
[Required(ErrorMessage = "工艺装备类型分类为必填项")]
[ExporterHeader(DisplayName = "工艺装备类型分类")]
[ImporterHeader(Name = "工艺装备类型分类")]
public decimal DeviceType { get; set; }
/// <summary>
/// 工艺装备编码
/// </summary>
[Required(ErrorMessage = "工艺装备编码为必填项")]
[ExporterHeader(DisplayName = "工艺装备编码")]
[ImporterHeader(Name = "工艺装备编码")]
public string DeviceCode { get; set; }
/// <summary>
/// 工艺装备名称
/// </summary>
[Required(ErrorMessage = "工艺装备名称为必填项")]
[ExporterHeader(DisplayName = "工艺装备名称")]
[ImporterHeader(Name = "工艺装备名称")]
public string DeviceName { get; set; }
/// <summary>
/// 生产厂家
/// </summary>
[Required(ErrorMessage = "生产厂家为必填项")]
[ExporterHeader(DisplayName = "生产厂家")]
[ImporterHeader(Name = "生产厂家")]
public string Manufacturer { get; set; }
/// <summary>
/// 工艺装备型号
/// </summary>
[Required(ErrorMessage = "工艺装备型号为必填项")]
[ExporterHeader(DisplayName = "工艺装备型号")]
[ImporterHeader(Name = "工艺装备型号")]
public string ModelNumber { get; set; }
/// <summary>
/// 工艺装备序列号
/// </summary>
[Required(ErrorMessage = "工艺装备序列号为必填项")]
[ExporterHeader(DisplayName = "工艺装备序列号")]
[ImporterHeader(Name = "工艺装备序列号")]
public string SerialNumber { get; set; }
/// <summary>
/// 工艺装备制造日期,格式(yyyy-MM-dd)
/// </summary>
[Required(ErrorMessage = "工艺装备制造日期为必填项")]
[ExporterHeader(DisplayName = "工艺装备制造日期")]
[ImporterHeader(Name = "工艺装备制造日期", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime? ProductionDate { get; set; }
/// <summary>
/// 主要材质
/// </summary>
[Required(ErrorMessage = "主要材质为必填项")]
[ExporterHeader(DisplayName = "主要材质")]
[ImporterHeader(Name = "主要材质")]
public string Material { get; set; }
/// <summary>
/// 当前存放地点
/// </summary>
[Required(ErrorMessage = "当前存放地点为必填项")]
[ExporterHeader(DisplayName = "当前存放地点")]
[ImporterHeader(Name = "当前存放地点")]
public string CurrentLocation { get; set; }
/// <summary>
/// 工艺装备状态
/// </summary>
[Required(ErrorMessage = "工艺装备状态为必填项")]
[ExporterHeader(DisplayName = "工艺装备状态")]
[ImporterHeader(Name = "工艺装备状态")]
public string DeviceStatus { get; set; }
/// <summary>
/// 穴腔数量
/// </summary>
[Required(ErrorMessage = "穴腔数量为必填项")]
[ExporterHeader(DisplayName = "穴腔数量")]
[ImporterHeader(Name = "穴腔数量")]
public decimal CavityCount { get; set; }
/// <summary>
/// 模具尺寸规格
/// </summary>
[Required(ErrorMessage = "模具尺寸规格为必填项")]
[ExporterHeader(DisplayName = "模具尺寸规格")]
[ImporterHeader(Name = "模具尺寸规格")]
public string MoldSize { get; set; }
/// <summary>
/// 设计寿命单位
/// </summary>
[Required(ErrorMessage = "设计寿命单位为必填项")]
[ExporterHeader(DisplayName = "设计寿命单位")]
[ImporterHeader(Name = "设计寿命单位")]
public string DesignLifeUnits { get; set; }
/// <summary>
/// 设计寿命
/// </summary>
[Required(ErrorMessage = "设计寿命为必填项")]
[ExporterHeader(DisplayName = "设计寿命")]
[ImporterHeader(Name = "设计寿命")]
public string DesignLifeValue { get; set; }
/// <summary>
/// 当前剩余寿命,
/// 当前剩余寿命
/// </summary>
[Required(ErrorMessage = "当前剩余寿命为必填项")]
[ExporterHeader(DisplayName = "当前剩余寿命")]
[ImporterHeader(Name = "当前剩余寿命")]
public string CurrentUsageCount { get; set; }
/// <summary>
/// 模具大修次数
/// </summary>
[Required(ErrorMessage = "模具大修次数为必填项")]
[ExporterHeader(DisplayName = "模具大修次数")]
[ImporterHeader(Name = "模具大修次数")]
public decimal OverhaulCount { get; set; }
/// <summary>
/// 图纸编号描述
/// </summary>
[Required(ErrorMessage = "图纸编号描述为必填项")]
[ExporterHeader(DisplayName = "图纸编号描述")]
[ImporterHeader(Name = "图纸编号描述")]
public string CoolingChannelLayout { get; set; }
/// <summary>
/// 检测精度
/// </summary>
[Required(ErrorMessage = "检测精度为必填项")]
[ExporterHeader(DisplayName = "检测精度")]
[ImporterHeader(Name = "检测精度")]
public string DetectionAccuracy { get; set; }
/// <summary>
/// 最近校准日期,格式(yyyy-MM-ddHH:mm:ss)
/// </summary>
[Required(ErrorMessage = "最近校准日期为必填项")]
[ExporterHeader(DisplayName = "最近校准日期")]
[ImporterHeader(Name = "最近校准日期", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime? CalibrationDate { get; set; }
/// <summary>
/// 校准到期天数
/// </summary>
[Required(ErrorMessage = "校准到期天数为必填项")]
[ExporterHeader(DisplayName = "校准到期天数")]
[ImporterHeader(Name = "校准到期天数")]
public string CalibrationDueDays { get; set; }
/// <summary>
/// 允许误差范围
/// </summary>
[Required(ErrorMessage = "允许误差范围为必填项")]
[ExporterHeader(DisplayName = "允许误差范围")]
[ImporterHeader(Name = "允许误差范围")]
public string ToleranceRange { get; set; }
/// <summary>
/// 磨损阈值
/// </summary>
[Required(ErrorMessage = "磨损阈值为必填项")]
[ExporterHeader(DisplayName = "磨损阈值")]
[ImporterHeader(Name = "磨损阈值")]
public string WearThreshold { get; set; }
/// <summary>
/// 检测范围
/// </summary>
[Required(ErrorMessage = "检测范围为必填项")]
[ExporterHeader(DisplayName = "检测范围")]
[ImporterHeader(Name = "检测范围")]
public string DetectionRange { get; set; }
/// <summary>
/// 检测单位
/// </summary>
[Required(ErrorMessage = "检测单位为必填项")]
[ExporterHeader(DisplayName = "检测单位")]
[ImporterHeader(Name = "检测单位")]
public string UnitType { get; set; }
}
}
}

208
API/Wood.Service/Datas/SupplierEmployeeDtService.cs

@ -1,23 +1,25 @@
using Magicodes.ExporterAndImporter.Excel;
using Magicodes.ExporterAndImporter.Core.Models;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Configuration;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Omu.ValueInjecter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Transactions;
using TaskManager.Entity;
using TaskManager.EntityFramework.Repository;
using TaskManager.EntityFramework;
using TaskManager.EntityFramework.Repository;
using Wood.Service.Controllers;
using Magicodes.ExporterAndImporter.Core.Models;
using Wood.Util;
using static Dapper.SqlMapper;
using System.Transactions;
using Omu.ValueInjecter;
namespace Wood.Service.Datas
{
@ -81,13 +83,17 @@ namespace Wood.Service.Datas
}
using var transaction = _context.Database.BeginTransaction();
var tran = transaction.GetDbTransaction();
try
{
#region 数据库操作
//添加任务
TaskSub taskSubObj = _commonService.BuildTaskSub(entityLst.Count, _taskName);
await _taskSubRepository.AddAsync(taskSubObj);
await _context.TaskSub.AddAsync(taskSubObj);
//添加任务明细
List<SUPPLIER_EMPLOYEE> emps = new List<SUPPLIER_EMPLOYEE>();
foreach (var empDtObj in entityLst)
{
empDtObj.SupplierCode = VendCode;
@ -95,35 +101,49 @@ namespace Wood.Service.Datas
empObj.InjectFrom(empDtObj);
//SUPPLIER_EMPLOYEE empObj = EntityMapper<SUPPLIER_EMPLOYEE_DT, SUPPLIER_EMPLOYEE>.Trans(empDtObj);
empObj.TaskId = taskSubObj.TaskId;
await _supplierEmployeeRepository.AddAsync(empObj);
}
//await _supplierEmployeeRepository.AddAsync(empObj);
emps.Add(empObj);
foreach (var empDtObj in entityLst)
}
_context.BulkInsert(emps);
_context.BulkMerge(entityLst, options => {
options.ColumnPrimaryKeyExpression = itm =>
new
{
empDtObj.SupplierCode = VendCode;
//以“供应商代码+工厂代码+车间代码+产线代码+工位代码+操作人员账号”为唯一标识,做新增或者更新存储
var firstObj = _context.Set<SUPPLIER_EMPLOYEE_DT>().FirstOrDefault(
itm => itm.SupplierCode == empDtObj.SupplierCode
&& itm.PlantId == empDtObj.PlantId
&& itm.WorkshopId == empDtObj.WorkshopId
&& itm.ProductionLineId == empDtObj.ProductionLineId
&& itm.StationId == empDtObj.StationId
&& itm.OperatorId == empDtObj.OperatorId
);
if (firstObj == null)
{
var ret = await base.Create(empDtObj);
}
else
{
empDtObj.UId = firstObj.UId;
empDtObj.CreationTime = CommonHelper.CurrentTime;
var ret = await base.Update(empDtObj);
}
itm.SupplierCode,
itm.PlantId,
itm.WorkshopId,
itm.ProductionLineId,
itm.StationId
}; options.Transaction = tran;
}
);
//foreach (var empDtObj in entityLst)
//{
// empDtObj.SupplierCode = VendCode;
// //以“供应商代码+工厂代码+车间代码+产线代码+工位代码+操作人员账号”为唯一标识,做新增或者更新存储
// var firstObj = _context.Set<SUPPLIER_EMPLOYEE_DT>().FirstOrDefault(
// itm => itm.SupplierCode == empDtObj.SupplierCode
// && itm.PlantId == empDtObj.PlantId
// && itm.WorkshopId == empDtObj.WorkshopId
// && itm.ProductionLineId == empDtObj.ProductionLineId
// && itm.StationId == empDtObj.StationId
// && itm.OperatorId == empDtObj.OperatorId
// );
// if (firstObj == null)
// {
// var ret = await base.Create(empDtObj);
// }
// else
// {
// empDtObj.UId = firstObj.UId;
// empDtObj.CreationTime = CommonHelper.CurrentTime;
// var ret = await base.Update(empDtObj);
// }
//}
#endregion
transaction.Commit();
@ -139,33 +159,56 @@ namespace Wood.Service.Datas
public override async Task<ActionResult<SUPPLIER_EMPLOYEE_DT>> Create(SUPPLIER_EMPLOYEE_DT entity)
{
using var transaction = _context.Database.BeginTransaction();
var tran = transaction.GetDbTransaction();
try
{
#region 数据库操作
//添加任务
TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
await _taskSubRepository.AddAsync(taskSubObj);
await _context.TaskSub.AddAsync(taskSubObj);
//添加任务明细
SUPPLIER_EMPLOYEE empObj = EntityMapper<SUPPLIER_EMPLOYEE_DT, SUPPLIER_EMPLOYEE>.Trans(entity);
SUPPLIER_EMPLOYEE empObj = new SUPPLIER_EMPLOYEE();
empObj.InjectFrom(entity);
//EntityMapper<SUPPLIER_INFO_DT, SUPPLIER_INFO>.Trans(entity);
empObj.TaskId = taskSubObj.TaskId;
await _supplierEmployeeRepository.AddAsync(empObj);
var firstObj = _context.Set<SUPPLIER_EMPLOYEE_DT>().FirstOrDefault(
itm => itm.SupplierCode == entity.SupplierCode
&& itm.PlantId == entity.PlantId
&& itm.WorkshopId == entity.WorkshopId
&& itm.ProductionLineId == entity.ProductionLineId
&& itm.StationId == entity.StationId
&& itm.OperatorId == entity.OperatorId
);
if (firstObj == null)
{
var ret = await base.Create(entity);
}
else
{
throw new Exception("数据库已经存在,不能重复插入");
}
await _context.AddAsync(empObj);
await _context.BulkMergeAsync(new List<SUPPLIER_EMPLOYEE_DT> { entity }, options => { options.ColumnPrimaryKeyExpression = itm =>
new { itm.SupplierCode, itm.PlantId, itm.WorkshopId, itm.ProductionLineId, itm.StationId,itm.OperatorId }; options.Transaction = tran; }
);
_context.SaveChanges();
////添加任务明细
//SUPPLIER_EMPLOYEE empObj = EntityMapper<SUPPLIER_EMPLOYEE_DT, SUPPLIER_EMPLOYEE>.Trans(entity);
//empObj.TaskId = taskSubObj.TaskId;
//await _supplierEmployeeRepository.AddAsync(empObj);
//var firstObj = _context.Set<SUPPLIER_EMPLOYEE_DT>().FirstOrDefault(
// itm => itm.SupplierCode == entity.SupplierCode
// && itm.PlantId == entity.PlantId
// && itm.WorkshopId == entity.WorkshopId
// && itm.ProductionLineId == entity.ProductionLineId
// && itm.StationId == entity.StationId
// && itm.OperatorId == entity.OperatorId
// );
//if (firstObj == null)
//{
// var ret = await base.Create(entity);
//}
//else
//{
// throw new Exception("数据库已经存在,不能重复插入");
//}
#endregion
transaction.Commit();
@ -181,33 +224,58 @@ namespace Wood.Service.Datas
public override async Task<IActionResult> Update(SUPPLIER_EMPLOYEE_DT entity)
{
using var transaction = _context.Database.BeginTransaction();
var tran = transaction.GetDbTransaction();
try
{
#region 数据库操作
//添加任务
TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
await _taskSubRepository.AddAsync(taskSubObj);
await _context.TaskSub.AddAsync(taskSubObj);
//添加任务明细
SUPPLIER_EMPLOYEE empObj = EntityMapper<SUPPLIER_EMPLOYEE_DT, SUPPLIER_EMPLOYEE>.Trans(entity);
SUPPLIER_EMPLOYEE empObj = new SUPPLIER_EMPLOYEE();
empObj.InjectFrom(entity);
//EntityMapper<SUPPLIER_INFO_DT, SUPPLIER_INFO>.Trans(entity);
empObj.TaskId = taskSubObj.TaskId;
await _supplierEmployeeRepository.AddAsync(empObj);
var firstObj = _context.Set<SUPPLIER_EMPLOYEE_DT>().FirstOrDefault(
itm => itm.SupplierCode == entity.SupplierCode
&& itm.PlantId == entity.PlantId
&& itm.WorkshopId == entity.WorkshopId
&& itm.ProductionLineId == entity.ProductionLineId
&& itm.StationId == entity.StationId
&& itm.OperatorId == entity.OperatorId
);
if (firstObj == null)
{
throw new Exception("数据库不存在,不能更新");
}
else
{
var ret = await base.Update(entity);
await _context.AddAsync(empObj);
await _context.BulkMergeAsync(new List<SUPPLIER_EMPLOYEE_DT> { entity }, options => {
options.ColumnPrimaryKeyExpression = itm =>
new { itm.SupplierCode, itm.PlantId, itm.WorkshopId, itm.ProductionLineId, itm.StationId, itm.OperatorId }; options.Transaction = tran;
}
);
_context.SaveChanges();
//TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
//await _taskSubRepository.AddAsync(taskSubObj);
////添加任务明细
//SUPPLIER_EMPLOYEE empObj = EntityMapper<SUPPLIER_EMPLOYEE_DT, SUPPLIER_EMPLOYEE>.Trans(entity);
//empObj.TaskId = taskSubObj.TaskId;
//await _supplierEmployeeRepository.AddAsync(empObj);
//var firstObj = _context.Set<SUPPLIER_EMPLOYEE_DT>().FirstOrDefault(
// itm => itm.SupplierCode == entity.SupplierCode
// && itm.PlantId == entity.PlantId
// && itm.WorkshopId == entity.WorkshopId
// && itm.ProductionLineId == entity.ProductionLineId
// && itm.StationId == entity.StationId
// && itm.OperatorId == entity.OperatorId
// );
//if (firstObj == null)
//{
// throw new Exception("数据库不存在,不能更新");
//}
//else
//{
// var ret = await base.Update(entity);
//}
#endregion
transaction.Commit();

180
API/Wood.Service/Datas/SupplierInfoDtService.cs

@ -1,22 +1,25 @@
using Magicodes.ExporterAndImporter.Excel;
using Magicodes.ExporterAndImporter.Core.Models;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Configuration;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Database;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Omu.ValueInjecter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Transactions;
using TaskManager.Entity;
using TaskManager.EntityFramework.Repository;
using TaskManager.EntityFramework;
using TaskManager.EntityFramework.Repository;
using Wood.Service.Controllers;
using Magicodes.ExporterAndImporter.Core.Models;
using System.Transactions;
using Wood.Util;
using Omu.ValueInjecter;
namespace Wood.Service.Datas
{
@ -80,12 +83,16 @@ namespace Wood.Service.Datas
}
using var transaction = _context.Database.BeginTransaction();
var tran = transaction.GetDbTransaction();
try
{
#region 数据库操作
//添加任务
TaskSub taskSubObj = _commonService.BuildTaskSub(entityLst.Count, _taskName);
await _taskSubRepository.AddAsync(taskSubObj);
await _context.TaskSub.AddAsync(taskSubObj);
List< SUPPLIER_INFO> infos = new List< SUPPLIER_INFO>();
//添加任务明细
foreach (var empDtObj in entityLst)
{
@ -93,31 +100,45 @@ namespace Wood.Service.Datas
SUPPLIER_INFO empObj = new SUPPLIER_INFO();
empObj.InjectFrom(empDtObj);
empObj.TaskId = taskSubObj.TaskId;
await _supplierInfoRepository.AddAsync(empObj);
infos.Add(empObj);
//await _supplierInfoRepository.AddAsync(empObj);
}
foreach (var empDtObj in entityLst)
_context.BulkInsert(infos);
_context.BulkMerge(entityLst, options => {
options.ColumnPrimaryKeyExpression = itm =>
new
{
empDtObj.SupplierCode = VendCode;
//以“供应商代码+工厂代码+车间代码+产线代码+工位代码”为唯一标识,做新增或更新存储
var firstObj = _context.Set<SUPPLIER_INFO_DT>().FirstOrDefault(
itm => itm.SupplierCode == empDtObj.SupplierCode
&& itm.PlantId == empDtObj.PlantId
&& itm.WorkshopId == empDtObj.WorkshopId
&& itm.ProductionLineId == empDtObj.ProductionLineId
&& itm.StationId == empDtObj.StationId
);
if (firstObj == null)
{
var ret = await base.Create(empDtObj);
}
else
{
empDtObj.UId = firstObj.UId;
empDtObj.CreationTime = CommonHelper.CurrentTime;
var ret = await base.Update(empDtObj);
}
itm.SupplierCode,
itm.PlantId,
itm.WorkshopId,
itm.ProductionLineId,
itm.StationId
};options.Transaction = tran;
}
);
//foreach (var empDtObj in entityLst)
//{
// empDtObj.SupplierCode = VendCode;
// //以“供应商代码+工厂代码+车间代码+产线代码+工位代码”为唯一标识,做新增或更新存储
// var firstObj = _context.Set<SUPPLIER_INFO_DT>().FirstOrDefault(
// itm => itm.SupplierCode == empDtObj.SupplierCode
// && itm.PlantId == empDtObj.PlantId
// && itm.WorkshopId == empDtObj.WorkshopId
// && itm.ProductionLineId == empDtObj.ProductionLineId
// && itm.StationId == empDtObj.StationId
// );
// if (firstObj == null)
// {
// var ret = await base.Create(empDtObj);
// }
// else
// {
// empDtObj.UId = firstObj.UId;
// empDtObj.CreationTime = CommonHelper.CurrentTime;
// var ret = await base.Update(empDtObj);
// }
//}
#endregion
transaction.Commit();
@ -133,36 +154,51 @@ namespace Wood.Service.Datas
public override async Task<ActionResult<SUPPLIER_INFO_DT>> Create(SUPPLIER_INFO_DT entity)
{
using var transaction = _context.Database.BeginTransaction();
var tran = transaction.GetDbTransaction();
try
{
#region 数据库操作
//添加任务
//TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
//await _taskSubRepository.AddAsync(taskSubObj);
TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
await _context.TaskSub.AddAsync(taskSubObj);
await _taskSubRepository.AddAsync(taskSubObj);
//添加任务明细
SUPPLIER_INFO empObj = new SUPPLIER_INFO();
empObj.InjectFrom(entity);
//EntityMapper<SUPPLIER_INFO_DT, SUPPLIER_INFO>.Trans(entity);
empObj.TaskId = taskSubObj.TaskId;
await _supplierInfoRepository.AddAsync(empObj);
var firstObj = _context.Set<SUPPLIER_INFO_DT>().FirstOrDefault(
itm => itm.SupplierCode == entity.SupplierCode
&& itm.PlantId == entity.PlantId
&& itm.WorkshopId == entity.WorkshopId
&& itm.ProductionLineId == entity.ProductionLineId
&& itm.StationId == entity.StationId
);
if (firstObj == null)
{
var ret = await base.Create(entity);
}
else
{
throw new Exception("数据库已经存在,不能重复插入");
}
await _context.AddAsync(empObj);
await _context.BulkMergeAsync(new List<SUPPLIER_INFO_DT> { entity }, options => { options.ColumnPrimaryKeyExpression = itm => new { itm.SupplierCode, itm.PlantId, itm.WorkshopId, itm.ProductionLineId, itm.StationId }; options.Transaction = tran; }
);
_context.SaveChanges();
//var firstObj = _context.Set<SUPPLIER_INFO_DT>().FirstOrDefault(
// itm => itm.SupplierCode == entity.SupplierCode
// && itm.PlantId == entity.PlantId
// && itm.WorkshopId == entity.WorkshopId
// && itm.ProductionLineId == entity.ProductionLineId
// && itm.StationId == entity.StationId
// );
//if (firstObj == null)
//{
// var ret = await base.Create(entity);
//}
//else
//{
// throw new Exception("数据库已经存在,不能重复插入");
//}
#endregion
transaction.Commit();
@ -178,34 +214,50 @@ namespace Wood.Service.Datas
public override async Task<IActionResult> Update(SUPPLIER_INFO_DT entity)
{
using var transaction = _context.Database.BeginTransaction();
var tran = transaction.GetDbTransaction();
try
{
#region 数据库操作
//添加任务
//TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
//await _taskSubRepository.AddAsync(taskSubObj);
TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
await _taskSubRepository.AddAsync(taskSubObj);
await _context.TaskSub.AddAsync(taskSubObj);
//添加任务明细
//SUPPLIER_INFO empObj = EntityMapper<SUPPLIER_INFO_DT, SUPPLIER_INFO>.Trans(entity);
SUPPLIER_INFO empObj = new SUPPLIER_INFO();
empObj.InjectFrom(entity);
empObj.TaskId = taskSubObj.TaskId;
await _supplierInfoRepository.AddAsync(empObj);
var firstObj = _context.Set<SUPPLIER_INFO_DT>().FirstOrDefault(
itm => itm.SupplierCode == entity.SupplierCode
&& itm.PlantId == entity.PlantId
&& itm.WorkshopId == entity.WorkshopId
&& itm.ProductionLineId == entity.ProductionLineId
&& itm.StationId == entity.StationId
);
if (firstObj == null)
{
throw new Exception("数据库不存在,不能更新");
}
else
{
var ret = await base.Update(entity);
}
await _context.AddAsync(empObj);
await _context.BulkMergeAsync(new List<SUPPLIER_INFO_DT> { entity }, options => { options.ColumnPrimaryKeyExpression = itm => new { itm.SupplierCode, itm.PlantId, itm.WorkshopId, itm.ProductionLineId, itm.StationId }; options.Transaction = tran; });
_context.SaveChanges();
//var firstObj = _context.Set<SUPPLIER_INFO_DT>().FirstOrDefault(
// itm => itm.SupplierCode == entity.SupplierCode
// && itm.PlantId == entity.PlantId
// && itm.WorkshopId == entity.WorkshopId
// && itm.ProductionLineId == entity.ProductionLineId
// && itm.StationId == entity.StationId
// );
//if (firstObj == null)
//{
// throw new Exception("数据库不存在,不能更新");
//}
//else
//{
// var ret = await base.Update(entity);
//}
#endregion
transaction.Commit();

164
API/Wood.Service/Datas/SupplierProProcessEquipmentDtService.cs

@ -1,23 +1,25 @@
using Magicodes.ExporterAndImporter.Excel;
using Magicodes.ExporterAndImporter.Core.Models;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Configuration;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using Omu.ValueInjecter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Transactions;
using TaskManager.Entity;
using TaskManager.EntityFramework.Repository;
using TaskManager.Entity.Entitys;
using TaskManager.EntityFramework;
using TaskManager.EntityFramework.Repository;
using Wood.Service.Controllers;
using Magicodes.ExporterAndImporter.Core.Models;
using TaskManager.Entity.Entitys;
using System.Transactions;
using Wood.Util;
using Omu.ValueInjecter;
namespace Wood.Service.Datas
{
@ -81,6 +83,8 @@ namespace Wood.Service.Datas
}
using var transaction = _context.Database.BeginTransaction();
var tran = transaction.GetDbTransaction();
try
{
#region 数据库操作
@ -88,36 +92,44 @@ namespace Wood.Service.Datas
TaskSub taskSubObj = _commonService.BuildTaskSub(entityLst.Count, _taskName);
await _taskSubRepository.AddAsync(taskSubObj);
//添加任务明细
List<SUPPLIER_PRO_PROCESS_EQUIPMENT> eqs = new List<SUPPLIER_PRO_PROCESS_EQUIPMENT>();
foreach (var empDtObj in entityLst)
{
SUPPLIER_PRO_PROCESS_EQUIPMENT empObj = new SUPPLIER_PRO_PROCESS_EQUIPMENT();
empObj.InjectFrom(empDtObj);
empObj.TaskId = taskSubObj.TaskId;
empObj.SupplierCode = VendCode;
await _supplierProProcessEquipmentRepository.AddAsync(empObj);
}
eqs.Add(empObj);
foreach (var empDtObj in entityLst)
{
empDtObj.SupplierCode = VendCode;
//以供应商代码+奇瑞零件号+工艺编码+工艺版本为唯一数据,做新增或者更新存储
var firstObj = _context.Set<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT>().FirstOrDefault(
itm => itm.SupplierCode == empDtObj.SupplierCode
&& itm.CheryProductNo == empDtObj.CheryProductNo
&& itm.DeviceCode == empDtObj.DeviceCode
&& itm.DeviceType == empDtObj.DeviceType
);
if (firstObj == null)
{
var ret = await base.Create(empDtObj);
}
else
{
empDtObj.UId = firstObj.UId;
empDtObj.CreationTime = CommonHelper.CurrentTime;
var ret = await base.Update(empDtObj);
}
// await _supplierProProcessEquipmentRepository.AddAsync(empObj);
}
_context.BulkInsert(eqs);
_context.BulkMerge(eqs, options => { options.ColumnPrimaryKeyExpression = itm => new { itm.SupplierCode, itm.CheryProductNo, itm.DeviceCode, itm.DeviceType }; options.Transaction = tran; });
//foreach (var empDtObj in entityLst)
//{
// empDtObj.SupplierCode = VendCode;
// //以供应商代码+奇瑞零件号+工艺编码+工艺版本为唯一数据,做新增或者更新存储
// var firstObj = _context.Set<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT>().FirstOrDefault(
// itm => itm.SupplierCode == empDtObj.SupplierCode
// && itm.CheryProductNo == empDtObj.CheryProductNo
// && itm.DeviceCode == empDtObj.DeviceCode
// && itm.DeviceType == empDtObj.DeviceType
// );
// if (firstObj == null)
// {
// var ret = await base.Create(empDtObj);
// }
// else
// {
// empDtObj.UId = firstObj.UId;
// empDtObj.CreationTime = CommonHelper.CurrentTime;
// var ret = await base.Update(empDtObj);
// }
//}
#endregion
transaction.Commit();
@ -133,34 +145,48 @@ namespace Wood.Service.Datas
public override async Task<ActionResult<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT>> Create(SUPPLIER_PRO_PROCESS_EQUIPMENT_DT entity)
{
using var transaction = _context.Database.BeginTransaction();
var tran = transaction.GetDbTransaction();
try
{
#region 数据库操作
//添加任务
//TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
//await _taskSubRepository.AddAsync(taskSubObj);
TaskSub taskSubObj = _commonService.BuildTaskSub(1, _taskName);
await _taskSubRepository.AddAsync(taskSubObj);
await _context.TaskSub.AddAsync(taskSubObj);
//添加任务明细
SUPPLIER_PRO_PROCESS_EQUIPMENT empObj = new SUPPLIER_PRO_PROCESS_EQUIPMENT();
empObj.InjectFrom(entity);
empObj.SupplierCode = VendCode;
//EntityMapper<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT, SUPPLIER_PRO_PROCESS_EQUIPMENT>.Trans(entity);
empObj.TaskId = taskSubObj.TaskId;
await _supplierProProcessEquipmentRepository.AddAsync(empObj);
var firstObj = _context.Set<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT>().FirstOrDefault(
itm => itm.SupplierCode == entity.SupplierCode
&& itm.CheryProductNo == entity.CheryProductNo
&& itm.DeviceCode == entity.DeviceCode
&& itm.DeviceType == entity.DeviceType
);
if (firstObj == null)
{
var ret = await base.Create(entity);
}
else
{
throw new Exception("数据库已经存在,不能重复插入");
}
await _context.AddAsync(empObj);
//await _supplierProProcessEquipmentRepository.AddAsync(empObj);
await _context.BulkMergeAsync(new List<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT> { entity }, options => { options.ColumnPrimaryKeyExpression = itm =>
new { itm.SupplierCode, itm.CheryProductNo, itm.DeviceCode, itm.DeviceType}; options.Transaction = tran; }
);
_context.SaveChanges();
//var firstObj = _context.Set<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT>().FirstOrDefault(
// itm => itm.SupplierCode == entity.SupplierCode
// && itm.CheryProductNo == entity.CheryProductNo
// && itm.DeviceCode == entity.DeviceCode
// && itm.DeviceType == entity.DeviceType
// );
//if (firstObj == null)
//{
// var ret = await base.Create(entity);
//}
//else
//{
// throw new Exception("数据库已经存在,不能重复插入");
//}
#endregion
transaction.Commit();
@ -176,6 +202,7 @@ namespace Wood.Service.Datas
public override async Task<IActionResult> Update(SUPPLIER_PRO_PROCESS_EQUIPMENT_DT entity)
{
using var transaction = _context.Database.BeginTransaction();
var tran = transaction.GetDbTransaction();
try
{
#region 数据库操作
@ -187,24 +214,39 @@ namespace Wood.Service.Datas
empObj.InjectFrom(entity);
empObj.SupplierCode = VendCode;
empObj.TaskId = taskSubObj.TaskId;
await _context.AddAsync(empObj);
//await _supplierProProcessEquipmentRepository.AddAsync(empObj);
await _context.BulkMergeAsync(new List<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT> { entity }, options => {
options.ColumnPrimaryKeyExpression = itm =>
new { itm.SupplierCode, itm.CheryProductNo, itm.DeviceCode, itm.DeviceType }; options.Transaction = tran;
}
);
_context.SaveChanges();
//SUPPLIER_PRO_PROCESS_EQUIPMENT empObj = EntityMapper<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT, SUPPLIER_PRO_PROCESS_EQUIPMENT>.Trans(entity);
//empObj.TaskId = taskSubObj.TaskId;
await _supplierProProcessEquipmentRepository.AddAsync(empObj);
var firstObj = _context.Set<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT>().FirstOrDefault(
itm => itm.SupplierCode == entity.SupplierCode
&& itm.CheryProductNo == entity.CheryProductNo
&& itm.DeviceCode == entity.DeviceCode
&& itm.DeviceType == entity.DeviceType
);
if (firstObj == null)
{
throw new Exception("数据库不存在,不能更新");
}
else
{
var ret = await base.Update(entity);
}
//await _supplierProProcessEquipmentRepository.AddAsync(empObj);
//var firstObj = _context.Set<SUPPLIER_PRO_PROCESS_EQUIPMENT_DT>().FirstOrDefault(
// itm => itm.SupplierCode == entity.SupplierCode
// && itm.CheryProductNo == entity.CheryProductNo
// && itm.DeviceCode == entity.DeviceCode
// && itm.DeviceType == entity.DeviceType
// );
//if (firstObj == null)
//{
// throw new Exception("数据库不存在,不能更新");
//}
//else
//{
// var ret = await base.Update(entity);
//}
#endregion
transaction.Commit();

Loading…
Cancel
Save