You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
194 lines
7.0 KiB
C#
194 lines
7.0 KiB
C#
using SlnMesnac.Model.domain;
|
|
using SlnMesnac.Repository.service;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace SlnMesnac.Business.business
|
|
{
|
|
public class DatabaseHandleBusniess
|
|
{
|
|
private ProdPlanInfoService _prodPlanInfoService;
|
|
private ProdPlanExecuteUserService _prodPlanExecuteUserService;
|
|
private ProdOrderInfoService _prodOrderInfoService;
|
|
private IRecordStaffRealTimeService _recordStaffRealTimeService;
|
|
private List<ProdPLanInfo> prodPlanInfos;
|
|
|
|
public DatabaseHandleBusniess(ProdPlanInfoService prodPlanInfoService, ProdOrderInfoService prodOrderInfoService, ProdPlanExecuteUserService prodPlanExecuteUserService,IRecordStaffRealTimeService recordStaffRealTimeService)
|
|
{
|
|
_prodPlanInfoService = prodPlanInfoService;
|
|
_prodOrderInfoService = prodOrderInfoService;
|
|
prodPlanInfos = _prodPlanInfoService.GetRecordStaffAttendances();
|
|
_prodPlanExecuteUserService = prodPlanExecuteUserService;
|
|
_recordStaffRealTimeService = recordStaffRealTimeService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据订单编号查询订单信息
|
|
/// </summary>
|
|
/// <param name="orderCode"></param>
|
|
/// <returns></returns>
|
|
public ProdOrderInfo GetProdOrderInfoByOrderCode(string orderCode)
|
|
{
|
|
return _prodOrderInfoService.GetProdOrderInfoByOrderCode(orderCode);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加新的工单信息
|
|
/// </summary>
|
|
/// <param name="orderCode"></param>
|
|
/// <param name="stationCode"></param>
|
|
public void AddNewPlanInfo(string? orderCode,string? stationCode,string? deviceCode,string? processCode,string? importFlag)
|
|
{
|
|
var orderInfo = GetProdOrderInfoByOrderCode(orderCode);
|
|
string randomString = GenerateRandomString(14);
|
|
_prodPlanInfoService.Insert(new ProdPLanInfo()
|
|
{
|
|
PlanCode = orderCode + randomString,
|
|
OrderCode = orderCode,
|
|
MaterialCode = orderInfo.MaterialCode,
|
|
MaterialName = orderInfo.MaterialName,
|
|
StationCode = stationCode,
|
|
DeviceCode = deviceCode,
|
|
PlanAmount = orderInfo.OrderAmount,
|
|
CompleteAmount = orderInfo.CompleteAmount,
|
|
PlanStatus = "4",
|
|
ProcessCode = processCode,
|
|
ImportFlag = importFlag
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成随机字符串
|
|
/// </summary>
|
|
/// <param name="length"></param>
|
|
/// <returns></returns>
|
|
private string GenerateRandomString(int length)
|
|
{
|
|
const string chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
Random random = new Random();
|
|
StringBuilder result = new StringBuilder();
|
|
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
result.Append(chars[random.Next(chars.Length)]);
|
|
}
|
|
|
|
return result.ToString();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新订单状态
|
|
/// </summary>
|
|
/// <param name="orderCode"></param>
|
|
/// <param name="stationCode"></param>
|
|
/// <param name="deviceCode"></param>
|
|
/// <param name="processCode"></param>
|
|
/// <param name="v"></param>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
public void UpdatePlanStatus(string orderCode, string stationCode, string deviceCode, string processCode, string status)
|
|
{
|
|
_prodPlanInfoService.UpdatePlanStatus(orderCode, stationCode, deviceCode, processCode, status);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 插入工单执行人员信息
|
|
/// </summary>
|
|
public void InsertPlanExecuteUser(ProdPLanInfo prodPlanInfo,ProdPlanDetail prodPlanDetail,List<RecordStaffRealTime> realTimes)
|
|
{
|
|
foreach (var item in realTimes)
|
|
{
|
|
ProdPlanExecuteUser prodPlanExecuteUser = new ProdPlanExecuteUser()
|
|
{
|
|
PlanCode = prodPlanInfo.PlanCode,
|
|
OrderCode = prodPlanInfo.OrderCode,
|
|
ProcessCode = prodPlanInfo.ProcessCode,
|
|
StationCode = prodPlanInfo.StationCode,
|
|
StaffId = item.StaffId,
|
|
CompleteAmount = prodPlanDetail.CompleteAmount,
|
|
PlanBeginDate = prodPlanInfo.BeginTime,
|
|
PlanEndDate = prodPlanInfo.EndTime,
|
|
CreatedBy = prodPlanInfo.CreatedBy,
|
|
CreatedTime = prodPlanInfo.CreatedTime,
|
|
UpdatedBy = prodPlanInfo.UpdatedBy,
|
|
UpdatedTime = prodPlanInfo.UpdatedTime,
|
|
BatchNumber = prodPlanDetail.BatchNumber
|
|
};
|
|
_prodPlanExecuteUserService.Insert(prodPlanExecuteUser);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询所有工单执行人员信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<RecordStaffRealTime> GetRecordStaffRealTimes()
|
|
{
|
|
var list = _recordStaffRealTimeService.Query();
|
|
return list;
|
|
}
|
|
|
|
///// <summary>
|
|
///// 查询所有计划工位
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public List<string> GetProductLineCodes()
|
|
//{
|
|
|
|
// List<string> productLineCodes = new List<string>();
|
|
// foreach (var prodPlanInfo in prodPlanInfos)
|
|
// {
|
|
// productLineCodes.Add(prodPlanInfo.StationCode);
|
|
// }
|
|
// return productLineCodes;
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 查询所有工单编号
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public List<string> GetPlanCodes()
|
|
//{
|
|
|
|
// List<string> planCodes = new List<string>();
|
|
// foreach (var prodPlanInfo in prodPlanInfos)
|
|
// {
|
|
// planCodes.Add(prodPlanInfo.PlanCode);
|
|
// }
|
|
// return planCodes;
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 查询所有订单编号
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public List<string> GetOrderCodes()
|
|
//{
|
|
|
|
// List<string> orderCodes = new List<string>();
|
|
// foreach (var prodPlanInfo in prodPlanInfos)
|
|
// {
|
|
// orderCodes.Add(prodPlanInfo.OrderCode);
|
|
// }
|
|
// return orderCodes;
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 查询所有物料名称
|
|
///// </summary>
|
|
///// <returns></returns>
|
|
//public List<string> GetMaterialNames()
|
|
//{
|
|
|
|
// List<string> materialNames = new List<string>();
|
|
// foreach (var prodPlanInfo in prodPlanInfos)
|
|
// {
|
|
// materialNames.Add(prodPlanInfo.MaterialName);
|
|
// }
|
|
// return materialNames;
|
|
//}
|
|
}
|
|
}
|