Commit 104076d9 authored by solho's avatar solho

feat:結算細項與總表結算合併相關修改

parent 071ebf0f
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System.IO;
using System.Linq;
using System; using System;
using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
...@@ -141,9 +144,10 @@ namespace WebAPI.Controllers ...@@ -141,9 +144,10 @@ namespace WebAPI.Controllers
{ {
String sns = obj_input["SN"].ToString(); String sns = obj_input["SN"].ToString();
String sqlstr = @"select td.SN, tdp.SN as SN_tdp,td.points,AssignedTo_userid FROM esn_todos td String sqlstr = @"select td.SN, tdp.SN as SN_tdp,td.points,AssignedTo_userid,tdp.date_points_settlement,td.TaskDescription,td.CaseNo ,eel.* FROM esn_todos td
left join esn_todos_points tdp on tdp.sn=td.sn left join esn_todos_points tdp on tdp.sn=td.sn
WHERE td.sn in ("+ sns +")"; left join evw_Employee eel on eel.user_id=td.AssignedTo_userid
WHERE td.sn in (" + sns +")";
String value = obj_input["value"].ToString(); String value = obj_input["value"].ToString();
value = value == "" ? "null" : obj_input["value"].ToString(); value = value == "" ? "null" : obj_input["value"].ToString();
SqlCommand cmd = new SqlCommand("",Conn) SqlCommand cmd = new SqlCommand("",Conn)
...@@ -152,14 +156,61 @@ namespace WebAPI.Controllers ...@@ -152,14 +156,61 @@ namespace WebAPI.Controllers
}; };
cmd.Parameters.AddWithValue("@SN", obj_input["SN"].ToString()); cmd.Parameters.AddWithValue("@SN", obj_input["SN"].ToString());
DataTable dt = SqlToDt(cmd); DataTable dt = SqlToDt(cmd);
String point, AssignedTo_userID ; cmd.CommandText= @" select ets.* from esn_todos_Settle ets
left join evw_qResult_EmpDS eqe on ets.DSNum=eqe.Emp_DSNum";
DataTable dtSettle = SqlToDt(cmd);
List<Esn_todos_SettleModel> SettleMataData=new List<Esn_todos_SettleModel>();
foreach (DataRow drs in dtSettle.Rows)
{
Esn_todos_SettleModel etsm = new Esn_todos_SettleModel()
{
Settle_Date =Convert.ToDateTime( drs["Settle_Date"]),
Create_time = Convert.ToDateTime(drs["Create_time"]),
update_time = Convert.ToDateTime(drs["update_time"]),
Create_user_id = drs["Create_user_id"].ToString(),
DeptNum = drs["DeptNum"].ToString(),
DSNum = drs["DSNum"].ToString(),
ItemNum = drs["ItemNum"].ToString(),
update_user_id = drs["update_user_id"].ToString(),
isClosed =Convert.ToBoolean( drs["isClosed"])
};
SettleMataData.Add(etsm);
}
String point, AssignedTo_userID, Emp_DSNum, TaskDescription, CaseNo;
DateTime date_points_settlement;
DataRow dr; DataRow dr;
List<String> return_msgs = new List<string>(), return_msg_error = new List<string>(), return_sn = new List<string>();
sqlstr = "declare @TempTable TABLE(id INT) declare @FlowId int; "; sqlstr = "declare @TempTable TABLE(id INT) declare @FlowId int; ";
cmd.Parameters.Clear(); cmd.Parameters.Clear();
for (int i = 0;i< dt.Rows.Count;i++ ) for (int i = 0;i< dt.Rows.Count;i++ )
{ {
dr = dt.Rows[i]; dr = dt.Rows[i];
point = dr["points"].ToString(); point = dr["points"].ToString();
date_points_settlement = Convert.ToDateTime(dr["date_points_settlement"]);
Emp_DSNum = dr["Emp_DSNum"].ToString();
TaskDescription = dr["TaskDescription"].ToString();
CaseNo = dr["CaseNo"].ToString();
#region 關帳邏輯比對
Esn_todos_SettleModel etsm = SettleMataData.Where(a => ( a.Settle_Date.ToString("yyyyMM").Equals(date_points_settlement.ToString("yyyyMM"))
) && a.DSNum== Emp_DSNum && a.isClosed==true).FirstOrDefault(),
etsm2 = SettleMataData.Where(a => (a.Settle_Date.ToString("yyyyMM").Equals(Convert.ToDateTime(value).ToString("yyyyMM"))
) && a.DSNum == Emp_DSNum && a.isClosed == true).FirstOrDefault();
String etsmmsg = "sn:" + dr["SN_tdp"] + "<font color='blue'> 案件編號</font>:" + CaseNo + " <font color='blue'>子事項</font>:" + TaskDescription ;
if (etsm != null)
{
return_msg_error.Add(etsmmsg + date_points_settlement.ToString("yyyy年MM月 ").ToString() + " 已關帳,不可變更<br>");
continue;
}
else if (etsm2 != null)
{
return_msg_error.Add(etsmmsg + Convert.ToDateTime(value).ToString("yyyy年MM月 ").ToString() + " 已關帳,不可設定結算<br>");
continue;
}
#endregion
AssignedTo_userID = dr["AssignedTo_userID"].ToString(); AssignedTo_userID = dr["AssignedTo_userID"].ToString();
if (dr["SN_tdp"] == DBNull.Value) if (dr["SN_tdp"] == DBNull.Value)
{ {
...@@ -182,17 +233,45 @@ namespace WebAPI.Controllers ...@@ -182,17 +233,45 @@ namespace WebAPI.Controllers
insert into esn_todos_Flow_his(Flow_id,ConfirmTime,FromType_id,ToType_id,ConfirmUserId,ConfirmUserClass,ConfirmMethod,Description,Create_User_id,Create_time) insert into esn_todos_Flow_his(Flow_id,ConfirmTime,FromType_id,ToType_id,ConfirmUserId,ConfirmUserClass,ConfirmMethod,Description,Create_User_id,Create_time)
select id as Flow_id,GETDATE(),a.StepType_id,StepType_id,@gWadeID,'HR','SL','結算日期:' + @value,@gWadeID,GETDATE() from esn_todos_Flow a where a.id=@FlowId; select id as Flow_id,GETDATE(),a.StepType_id,StepType_id,@gWadeID,'HR','SL','結算日期:' + @value,@gWadeID,GETDATE() from esn_todos_Flow a where a.id=@FlowId;
", i); ", i);
return_sn.Add(dr["SN_tdp"].ToString());
} }
cmd.Parameters.AddWithValue("@value", value); cmd.Parameters.AddWithValue("@value", value);
cmd.Parameters.AddWithValue("@gWadeID", obj_input["gWadeID"].ToString()); cmd.Parameters.AddWithValue("@gWadeID", obj_input["gWadeID"].ToString());
cmd.CommandText = sqlstr; cmd.CommandText = sqlstr;
dt = SqlToDt(cmd);
response.Code = "1";
string JSONString = string.Empty; string JSONString = string.Empty;
JSONString = JsonConvert.SerializeObject(dt); if (return_msg_error.Count == 0)
response.Msg = "結算完畢"; {
return_msgs.Add("結算完畢");
dt = SqlToDt(cmd);
if (return_sn.Count > 0)
{
String fields = "convert(varchar(10),date_points_settlement,126) as date_points_settlement,date_points_settlement_pic_confirm ";
SqlCommand cmd2 = new SqlCommand("", Conn)
{
CommandText = "select SN, " + fields +
" from esn_todos_points a left join evw_Employee b on a.date_points_settlement_AssignTo=b.user_id where SN in (" +
String.Join(",", return_sn) + ")"
};
dt = SqlToDt(cmd2);
JSONString = JsonConvert.SerializeObject(dt);
}
response.Code = "1";
response.Msg = return_msgs;
response.ExtraInfo= JSONString;
}
else
{
response.Code = "0";
response.Msg = return_msg_error;
response.ExtraInfo = JSONString;
}
} }
} }
catch (Exception e) catch (Exception e)
......
using System;
using System.Collections.Generic;
namespace WebAPI.Models
{
/// <summary>
/// 處理事項子項相關
/// </summary>
public class Esn_todos_SettleModel
{
public DateTime Settle_Date { get; set; }
public String DSNum { get; set; }
public Boolean isClosed { get; set; }
public String DeptNum { get; set; }
public String ItemNum { get; set; }
public String update_user_id { get; set; }
public String Create_user_id { get; set; }
public DateTime? update_time { get; set; }
public DateTime? Create_time { get; set; }
}
}
\ No newline at end of file
...@@ -209,6 +209,7 @@ ...@@ -209,6 +209,7 @@
<Compile Include="Dal\DalFee.cs" /> <Compile Include="Dal\DalFee.cs" />
<Compile Include="Dal\DalCaseInfo.cs" /> <Compile Include="Dal\DalCaseInfo.cs" />
<Compile Include="Dal\DalProcInfo.cs" /> <Compile Include="Dal\DalProcInfo.cs" />
<Compile Include="Models\Esn_todos_SettleModel.cs" />
<Compile Include="Models\Esn_Todos_FlowModel.cs" /> <Compile Include="Models\Esn_Todos_FlowModel.cs" />
<Compile Include="Models\Esn_TodosModel.cs" /> <Compile Include="Models\Esn_TodosModel.cs" />
<Compile Include="Models\ParamModel.cs" /> <Compile Include="Models\ParamModel.cs" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment