You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
4.1 KiB

3 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using FactorySystemCommon;
using FactorySystemModel.EnumModel;
using FactorySystemModel.RequestModel;
using FactorySystemModel.ResponseModel;
using FactorySystemModel.SqlSugarModel;
using Newtonsoft.Json;
using SqlSugar;
namespace FactorySystemBll
{
public class HalfMaterialTaskBll
{
/// <summary>
/// 获取任务列表
/// </summary>
public List<object> GetList(TaskQuery tq, out int totalNumber)
{
totalNumber = 0;
var db = AppSettingsHelper.GetSqlSugar();
3 years ago
return db.Queryable<TFS_HalfMaterialTask, TFS_HalfMaterialFTeamwork, TBasicCode, TUser>((a, b, c, d) => new JoinQueryInfos(JoinType.Inner, a.FTeamID == b.FID,
JoinType.Inner, c.FType == 46 && a.FType == int.Parse(c.FValue), JoinType.Left, a.FEditUser == d.FID))
3 years ago
// 事项状态
.WhereIF(tq.FState > 0 && tq.FState != 99, (a, b) => a.FState == tq.FState)
// 事项状态
.WhereIF(tq.FState == 99, (a, b) => a.FState <= 1)
3 years ago
.WhereIF(tq.FTestCode != null,(a,b)=>b.FNewTestCode.Contains(tq.FTestCode))
3 years ago
// 销售号
.WhereIF(tq.FSaleCode != null, (a, b) => b.FSaleCode.Contains(tq.FSaleCode))
// 当前流程
.WhereIF(tq.FType > 0, (a, b) => a.FType == tq.FType)
// 发起时间1
.WhereIF(tq.FDateRange != null && tq.FDateRange[0] != "", (a, b) => a.FAddDate >= DateTime.Parse(tq.FDateRange[0]))
.WhereIF(tq.FDateRange != null && tq.FDateRange[1] != "", (a, b) => a.FAddDate <= DateTime.Parse(tq.FDateRange[1]))
// 责任人
.WhereIF(tq.FUserID != null, a => (',' + a.FUserID + ',').Contains(',' + tq.FUserID + ','))
// 协同
.WhereIF(tq.FTeamID > 0, a => a.FTeamID == tq.FTeamID).OrderBy((a, b, c) => a.FID, OrderByType.Desc)
2 years ago
.Select<object>("a.*,b.FNewTestCode,b.FVersionCode,a.FType as 'FormulaType',b.FSaleCode,b.FFormulaTestCode as FTestCode,b.FMdmCode,b.FFormulaName,b.FMaterialHalfIDs,cast(substring(c.FRemark,4,2)as int)as FViewType,d.FName AS 'FUserName1',(case when b.FBomJson IS NULL then 0 when cast(b.FBomJson as nvarchar) = '' then 0 else 1 end) as FHasBomJson")
3 years ago
.ToPageList(tq.FPageIndex, tq.FPageSize, ref totalNumber);
}
3 years ago
public int CloseHalfMaterialTask(int teamId, int userId, int type)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
2 years ago
List<TFS_HalfMaterialTask> taskList = db.Queryable<TFS_HalfMaterialTask>().Where(s => s.FType == type && s.FTeamID == teamId).ToList();
3 years ago
int result = 0;
if (taskList != null && taskList.Count > 0)
{
TFS_HalfMaterialTask fmt = taskList[0];
fmt.FCanEdit = 2;
fmt.FState = 2;
fmt.FEditUser = userId;
fmt.FEditDate = DateTime.Now;
result = db.Updateable(fmt).IgnoreColumns(true).WhereColumns("FID").ExecuteCommand();
}
2 years ago
return result;
}
/// <summary>
/// 关闭任务当是可以编辑
/// </summary>
/// <param name="teamId"></param>
/// <param name="userId"></param>
/// <param name="type"></param>
/// <returns></returns>
public int CloseHalfMaterialTask2(int teamId, int userId, int type)
{
SqlSugarClient db = AppSettingsHelper.GetSqlSugar();
List<TFS_HalfMaterialTask> taskList = db.Queryable<TFS_HalfMaterialTask>().Where(s => s.FType == type && s.FTeamID == teamId && s.FState == 1).ToList();
int result = 0;
3 years ago
2 years ago
if (taskList != null && taskList.Count > 0)
{
TFS_HalfMaterialTask fmt = taskList[0];
fmt.FState = 2;
fmt.FEditUser = userId;
fmt.FEditDate = DateTime.Now;
result = db.Updateable(fmt).IgnoreColumns(true).WhereColumns("FID").ExecuteCommand();
}
3 years ago
return result;
}
3 years ago
}
}