@ -13,6 +13,7 @@ using MySql.Data.MySqlClient;
using CommonFunc.Tools ;
using XGL.Models.Model ;
using XGL.Models ;
using XGL.Models.Model.OrderPrepare ;
namespace XGL.Dats.DBServiceFinishProd
{
@ -663,11 +664,11 @@ where 1=1 and
/// <param name="deviceCode"></param>
/// <param name="date"></param>
/// <returns></returns>
public DataTable GetUnitPriceData ( string deviceCode )
public DataTable GetUnitPriceData ( string deviceCode , string sheredata )
{
string sql = $ @ "select [workorder_code], [workorder_code_sap], [product_name], SUBSTRING([product_code], 8, LEN(product_code)) as product_code, [user_name], [nick_name], [childprocess_code], [childprocess_name] ,[create_by], [create_time], [line_code] ,[attr1]
from mes_unitprice_report
where line_code = ' { deviceCode } ' and CONVERT ( VARCHAR ( 10 ) , Create_time , 120 ) = CONVERT ( VARCHAR ( 10 ) , GETDATE ( ) , 120 ) ORDER BY childprocess_code , create_time ";
where line_code = ' { deviceCode } ' AND create_time BETWEEN ' { sheredata } 00 : 00 : 00 ' AND ' { sheredata } 23 : 59 : 59 ' ORDER BY childprocess_code , create_time ";
DataSet dtset = Utils . netClientDBHelper . getDataSet ( sql ) ;
if ( dtset ! = null & & dtset . Tables . Count > 0 & & dtset . Tables [ 0 ] . Rows . Count > 0 )
@ -680,8 +681,10 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C
public string GetUsernumbereData ( string deviceCode )
{
string sql = $@"SELECT SUM(quantity_feedback) as total_quantity FROM mes_report_work WHERE workorder_code='{deviceCode}'" ;
string sql = $ @ "SELECT COALESCE(CAST(SUM(quantity_feedback) / SUM(use_man) AS INT), 0) as total_quantity
FROM mes_report_work
WHERE parent_order = ' { deviceCode } ' and del_flag = '0' ;
";
DataSet dtset = Utils . netClientDBHelper . getDataSet ( sql ) ;
if ( dtset ! = null & & dtset . Tables . Count > 0 & & dtset . Tables [ 0 ] . Rows . Count > 0 )
{
@ -717,7 +720,7 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C
/// </summary>
/// <param name="item"></param>
/// <exception cref="NotImplementedException"></exception>
public string GetCreateUnitPriceInfo ( sys_user item , string workorderCode , string sapWorkorderCode , string productCode , string productName , string childProcessCode , string childProcessName , string deviceCode , string number )
public string GetCreateUnitPriceInfo ( sys_user item , string workorderCode , string sapWorkorderCode , string productCode , string productName , string childProcessCode , string childProcessName , string deviceCode , string number ,string credata )
{
string sql = $ @ "INSERT INTO [dbo].[mes_unitprice_report] (
[id] , [ workorder_code ] , [ workorder_code_sap ] , [ product_name ] , [ product_code ] ,
@ -729,7 +732,7 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C
(
' { Common . GetUUID ( ) } ' , ' { workorderCode } ',' { sapWorkorderCode } ' , ' { productName } ' , ' { productCode } ' ,
N ' { item . user_name } ' , N ' { item . nick_name } ' , N ' { childProcessCode } ' , N ' { childProcessName } ',' { number } ' ,
NULL , NULL , ' { LoginUser . UserName } ' , getdate ( ) , NULL ,
NULL , NULL , ' { LoginUser . UserName } ' , ' { credata } 00 : 00 : 00 ' , NULL ,
NULL , NULL , ' { deviceCode } ' ) ; ";
return sql ;
@ -748,9 +751,9 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C
return null ;
}
public List < sys_user > GetOnWorkUserList ( string deviceCode )
public List < sys_user > GetOnWorkUserList ( string deviceCode ,string shereDate )
{
string sql = $" SELECT user_id as user_name,user_name as nick_name,sex,age FROM [dbo].[mes_attendance_records] where start_addr = '{deviceCode}' and CONVERT(VARCHAR(10), create_time , 120) = CONVERT(VARCHAR(10), GETDATE() , 120) order by create_time desc ;";
string sql = $" WITH RankedRecords AS (\r\n SELECT \r\n user_id as user_name,\r\n user_name as nick_name,\r\n sex,\r\n age,\r\n create_time,\r\n ROW_NUMBER() OVER (PARTITION BY user_name ORDER BY create_time DESC) as rn\r\n FROM [dbo].[mes_attendance_records]\r\n WHERE start_addr = '{deviceCode}' \r\n AND create_time BETWEEN '{shereDate} 00:00:00' AND '{shereDate} 23:59:59'\r\n)\r\nSELECT \r\n user_name,\r\n nick_name,\r\n sex,\r\n age,\r\n create_time\r\nFROM RankedRecords\r\nWHERE rn = 1\r\nORDER BY create_time DESC ;";
DataTable dt = Utils . netClientDBHelper . getDataSet ( sql ) . Tables [ 0 ] ;
@ -991,9 +994,9 @@ where detail.parent_work_order = '{processid}'"; //where CONVERT(VARCHAR(10), w
/// 更新湿料计划同步状态、工单状态
/// </summary>
/// <returns></returns>
public bool UpdateSycnFlag ( string workOrderID , string deviceCode )
public bool UpdateSycnFlag ( string workOrderID , string deviceCode ,string user )
{
string sql1 = $@"update pro_order_workorder set status = 'w2',workorder_name = '{deviceCode}', update_by = '{LoginUser.UserName}', update_time = GETDATE() where workorder_code = '{workOrderID}' ";
string sql1 = $@"update pro_order_workorder set status = 'w2',workorder_name = '{deviceCode}', update_by = '{LoginUser.UserName}', attr3='{user}', update_time = GETDATE() where workorder_code = '{workOrderID}' ";
return Utils . netClientDBHelper . executeUpdate ( sql1 ) > 0 ? true : false ;
@ -3498,39 +3501,8 @@ left join basedata_plcsetting f on a.PlcId5=f.Id
return null ;
}
public void InsertCheckTaskDetail ( string value , string where )
public int InsertCheckTaskDetail ( string value , string where )
{
//StringBuilder strSql = new StringBuilder();
//strSql.Append("UPDATE qc_check_task_detail ");
//strSql.Append("SET actual_value =");
//if (value == null)
//StringBuilder strSql = new StringBuilder();
//strSql.Append("UPDATE qc_check_task_detail ");
//strSql.Append("SET actual_value =");
//if (value==null)
//{
// strSql.Append("NULL");
//}
//else
//{
// strSql.Append($"'{value}'");
//}
//strSql.Append(" WHERE record_id =");
//strSql.Append($"'{where}'");
//Utils.netClientDBHelper.executeUpdate(strSql.ToString());
//strSql.Append(" WHERE record_id =");
//strSql.Append($"'{where}'");
//int rowsAffected = Utils.netClientDBHelper.executeUpdate(strSql.ToString());
StringBuilder strSql = new StringBuilder ( ) ;
strSql . Append ( "UPDATE qc_check_task_detail " ) ;
strSql . Append ( "SET actual_value =" ) ;
@ -3545,8 +3517,8 @@ left join basedata_plcsetting f on a.PlcId5=f.Id
strSql . Append ( " WHERE record_id =" ) ;
strSql . Append ( $"'{where}'" ) ;
Utils . netClientDBHelper . executeUpdate ( strSql . ToString ( ) ) ;
int result = Utils . netClientDBHelper . executeUpdate ( strSql . ToString ( ) ) ;
return result ;
}
// /// <summary>