计件薪酬和人员刷卡改动

master
zhaoaomin 2 years ago
parent 9fe5e82fb3
commit e9bdecf486

@ -13,7 +13,6 @@ using MySql.Data.MySqlClient;
using CommonFunc.Tools; using CommonFunc.Tools;
using XGL.Models.Model; using XGL.Models.Model;
using XGL.Models; using XGL.Models;
using System.Threading;
namespace XGL.Dats.DBServiceFinishProd namespace XGL.Dats.DBServiceFinishProd
{ {
@ -87,9 +86,14 @@ namespace XGL.Dats.DBServiceFinishProd
return Items; return Items;
} }
/// <summary>
/// 刷卡功能变更为取pe_snr的值
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
public DataTable GetUserInfoFromCloudServer(string userID) public DataTable GetUserInfoFromCloudServer(string userID)
{ {
string sql = $@"SELECT user_name,nick_name,sex FROM [dbo].[sys_user] where del_flag = '0' and user_name = '{userID}'"; string sql = $@"SELECT user_name,nick_name,sex FROM [dbo].[sys_user] where del_flag = '0' and (user_name = '{userID}' or pe_snr = '{userID}')";
DataSet dtset = Utils.cloudDBHelper.getDataSet(sql); DataSet dtset = Utils.cloudDBHelper.getDataSet(sql);
if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0)
{ {
@ -138,6 +142,7 @@ namespace XGL.Dats.DBServiceFinishProd
public DataTable GetExistAttendanceRecord(string v) public DataTable GetExistAttendanceRecord(string v)
{ {
//不会存在一个人俩个班次工作的情况
string sql = $@" select id, user_id, user_name, attendance_status, sex, age, string sql = $@" select id, user_id, user_name, attendance_status, sex, age,
id_number, start_time, start_addr, end_time, end_addr, attendance_time, id_number, start_time, start_addr, end_time, end_addr, attendance_time,
attendance_date, work_hours, create_time attendance_date, work_hours, create_time
@ -689,6 +694,21 @@ where line_code = '{deviceCode}' and CONVERT(VARCHAR(10), Create_time , 120) = C
} }
return null; return null;
} }
public List<sys_user> GetOnWorkUserList(string deviceCode)
{
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) ;";
DataTable dt = Utils.netClientDBHelper.getDataSet(sql).Tables[0];
var lst = Utils.ToDataList<sys_user>(dt);
if (lst.Count > 0)
{
return lst;
}
return null;//lst.Count > 0 ? true : false;
}
public string GetUpdateUnitPriceSql(string workOrderCode) public string GetUpdateUnitPriceSql(string workOrderCode)
{ {
string updateOrderSql = $@"update pro_order_workorder set salary_flag = '1', update_by = '{LoginUser.UserName}',update_time = GETDATE() where workorder_code = '{workOrderCode}' "; string updateOrderSql = $@"update pro_order_workorder set salary_flag = '1', update_by = '{LoginUser.UserName}',update_time = GETDATE() where workorder_code = '{workOrderCode}' ";
@ -3416,6 +3436,36 @@ left join basedata_plcsetting f on a.PlcId5=f.Id
public void InsertCheckTaskDetail(string value,string where) public void 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(); StringBuilder strSql = new StringBuilder();
strSql.Append("UPDATE qc_check_task_detail "); strSql.Append("UPDATE qc_check_task_detail ");
strSql.Append("SET actual_value ="); strSql.Append("SET actual_value =");
@ -3431,6 +3481,7 @@ left join basedata_plcsetting f on a.PlcId5=f.Id
strSql.Append(" WHERE record_id ="); strSql.Append(" WHERE record_id =");
strSql.Append($"'{where}'"); strSql.Append($"'{where}'");
Utils.netClientDBHelper.executeUpdate(strSql.ToString()); Utils.netClientDBHelper.executeUpdate(strSql.ToString());
} }
// /// <summary> // /// <summary>

@ -12,7 +12,7 @@
<!--设备编码--> <!--设备编码-->
<add key="DeviceCode" value="XL01" /> <add key="DeviceCode" value="XL01" />
<!--上位机类型 0:工单准备1成型机\shoupei2烘房,3:人员登录,4:称重系统--> <!--上位机类型 0:工单准备1成型机\shoupei2烘房,3:人员登录,4:称重系统-->
<add key="ClientMode" value="4" /> <add key="ClientMode" value="1" />
<add key="SerialPort" value="COM5" /> <add key="SerialPort" value="COM5" />
<add key="weigh" value="COM12" /> <add key="weigh" value="COM12" />

@ -16,9 +16,9 @@
<Setter Property="TextBlock.TextAlignment" Value="Center" /> <Setter Property="TextBlock.TextAlignment" Value="Center" />
<Setter Property="TextBlock.FontSize" Value="22" /> <Setter Property="TextBlock.FontSize" Value="22" />
</Style> </Style>
<!--<convert:MyValueConverter x:Key="MyConverter"/> <convert:MyValueConverter x:Key="MyConverter"/>
<convert:OrderInOutConverter x:Key="TaskCodeConverter"/> <convert:OrderInOutConverter x:Key="TaskCodeConverter"/>
<convert:BtnBackGroundColorConverter x:Key="ButtonContentToBackgroundColorConverter"/>--> <convert:BtnBackGroundColorConverter x:Key="ButtonContentToBackgroundColorConverter"/>
<SolidColorBrush x:Key="EvenRowBackground" Color="#E0E0E0"/> <SolidColorBrush x:Key="EvenRowBackground" Color="#E0E0E0"/>
<SolidColorBrush x:Key="OddRowBackground" Color="#FFFFFF"/> <SolidColorBrush x:Key="OddRowBackground" Color="#FFFFFF"/>
<Style x:Key="DataGridRowStyle" TargetType="DataGridRow"> <Style x:Key="DataGridRowStyle" TargetType="DataGridRow">

@ -457,7 +457,7 @@ Background="#F2F3F5"
Click="btnRefresh_Click" Content="刷新"></Button> Click="btnRefresh_Click" Content="刷新"></Button>
</StackPanel> </StackPanel>
<StackPanel <!--<StackPanel
Background="#F2F3F5" Background="#F2F3F5"
Grid.Row="0" Grid.Row="0"
Grid.Column="9" Grid.Column="9"
@ -471,7 +471,7 @@ Background="#F2F3F5"
FontSize="20" FontSize="20"
Foreground="White" Foreground="White"
Content="称重"></Button> Content="称重"></Button>
</StackPanel> </StackPanel>-->
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>

@ -82,9 +82,10 @@ namespace XGLFinishPro.Views
CustomMessageBox.Show("找不到该账户,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); CustomMessageBox.Show("找不到该账户,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return; return;
} }
string userCode = dtUserInfo.Rows[0]["user_name"].ToString();
string userName = dtUserInfo.Rows[0]["nick_name"].ToString(); string userName = dtUserInfo.Rows[0]["nick_name"].ToString();
string sex = dtUserInfo.Rows[0]["sex"].ToString(); string sex = dtUserInfo.Rows[0]["sex"].ToString();
bool isSucc = finishProdDBService.InsertAttendanceRecord(userID, userName, sex,deviceCode); bool isSucc = finishProdDBService.InsertAttendanceRecord(userCode, userName, sex,deviceCode);
if (isSucc) if (isSucc)
{ {
CustomMessageBox.Show("打卡成功,祝您工作愉快!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); CustomMessageBox.Show("打卡成功,祝您工作愉快!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
@ -113,12 +114,19 @@ namespace XGLFinishPro.Views
try try
{ {
string userID = txtOffWorkUserID.Text; string userID = txtOffWorkUserID.Text;
DataTable dtUserInfo = finishProdDBService.GetUserInfoFromCloudServer(userID);
if (dtUserInfo == null || dtUserInfo.Rows.Count <= 0)
{
CustomMessageBox.Show("找不到该账户,请重试!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
string userCode = dtUserInfo.Rows[0]["user_name"].ToString();
DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode); DataTable dt = finishProdDBService.GetExistAttendanceRecord(deviceCode);
if (dt!=null && dt.Select("user_id = '" + userID + "'").Length > 0) if (dt!=null && dt.Select("user_id = '" + userCode + "'").Length > 0)
{ {
if (dt.Select("user_id = '" + userID + "' and start_addr = '" + deviceCode + "'").Length > 0) if (dt.Select("user_id = '" + userCode + "' and start_addr = '" + deviceCode + "'").Length > 0)
{ {
bool isSucc = finishProdDBService.UpdateAttendanceRecord(userID, deviceCode); bool isSucc = finishProdDBService.UpdateAttendanceRecord(userCode, deviceCode);
if (isSucc) if (isSucc)
{ {
CustomMessageBox.Show("打卡成功,再见!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); CustomMessageBox.Show("打卡成功,再见!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
@ -127,7 +135,7 @@ namespace XGLFinishPro.Views
} }
else else
{ {
string start_addr = dt.Select("user_id = '" + userID + "'")[0]["start_addr"].ToString(); string start_addr = dt.Select("user_id = '" + userCode + "'")[0]["start_addr"].ToString();
CustomMessageBox.Show("打卡失败,您的打卡地址在" + start_addr + "", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning); CustomMessageBox.Show("打卡失败,您的打卡地址在" + start_addr + "", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return; return;
} }

@ -29,6 +29,7 @@ namespace XGLFinishPro.Views
{ {
FinishProdDBService prodDBService = new FinishProdDBService(); FinishProdDBService prodDBService = new FinishProdDBService();
string _deviceCode = "", _productCode= "",_workOrderCode="",_sapWorkOrderCode="",_productName="", _childprocessCode="", _childprocessName = ""; string _deviceCode = "", _productCode= "",_workOrderCode="",_sapWorkOrderCode="",_productName="", _childprocessCode="", _childprocessName = "";
string _LineCode = "";
public PieceSalaryCalWin() public PieceSalaryCalWin()
{ {
InitializeComponent(); InitializeComponent();
@ -37,6 +38,7 @@ namespace XGLFinishPro.Views
public PieceSalaryCalWin(string productCode,string productName,string deviceCode,string workOrderCode,string sapWorkOrderCode) public PieceSalaryCalWin(string productCode,string productName,string deviceCode,string workOrderCode,string sapWorkOrderCode)
{ {
InitializeComponent(); InitializeComponent();
_LineCode = deviceCode;
_deviceCode = deviceCode; _deviceCode = deviceCode;
_productCode = productCode; _productCode = productCode;
_productName = productName; _productName = productName;
@ -99,8 +101,9 @@ namespace XGLFinishPro.Views
this.dgUserInfo.ItemsSource = null; this.dgUserInfo.ItemsSource = null;
checkedRowsCache.Clear(); checkedRowsCache.Clear();
Utils.userList.ForEach(t => t.IsChecked = false); //Utils.userList.ForEach(t => t.IsChecked = false);
dataSource = Utils.userList; OnWorkUserList.ForEach(t => t.IsChecked = false);
dataSource = OnWorkUserList;// Utils.userList;
this.dgUserInfo.ItemsSource = dataSource; this.dgUserInfo.ItemsSource = dataSource;
} }
@ -149,6 +152,8 @@ namespace XGLFinishPro.Views
} }
//从上下班的名单中找
List<sys_user> OnWorkUserList = new List<sys_user>();
//作为选中行的缓存 //作为选中行的缓存
List<sys_user> checkedRowsCache = new List<sys_user>(); List<sys_user> checkedRowsCache = new List<sys_user>();
@ -163,9 +168,20 @@ namespace XGLFinishPro.Views
} }
_deviceCode = ds.Tables[0].Rows[0][0].ToString(); _deviceCode = ds.Tables[0].Rows[0][0].ToString();
this.lstSelectedStep.ItemsSource = GetStepData(); this.lstSelectedStep.ItemsSource = GetStepData();
GetUserData();
GetData(); GetData();
} }
private void GetUserData()
{
OnWorkUserList = prodDBService.GetOnWorkUserList(_LineCode);
if (OnWorkUserList == null || OnWorkUserList.Count <= 0)
{
CustomMessageBox.Show("没有找到上班的人员信息!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
return;
}
}
private void GetData() private void GetData()
{ {
DataTable dt = prodDBService.GetUnitPriceData(_deviceCode); DataTable dt = prodDBService.GetUnitPriceData(_deviceCode);
@ -233,11 +249,11 @@ namespace XGLFinishPro.Views
string queryP = this.txtP.Text.Trim(); string queryP = this.txtP.Text.Trim();
if (string.IsNullOrEmpty(queryP)) if (string.IsNullOrEmpty(queryP))
{ {
this.dgUserInfo.ItemsSource = Utils.userList; this.dgUserInfo.ItemsSource = OnWorkUserList;//Utils.userList;
return; return;
} }
this.dgUserInfo.ItemsSource = null; this.dgUserInfo.ItemsSource = null;
var queryList = Utils.userList.Where(t => t.nick_name.Contains(queryP) || t.user_name.Contains(queryP)); var queryList = OnWorkUserList.Where(t => t.nick_name.Contains(queryP) || t.user_name.Contains(queryP));//Utils.userList.Where(t => t.nick_name.Contains(queryP) || t.user_name.Contains(queryP));
this.dgUserInfo.ItemsSource = queryList; this.dgUserInfo.ItemsSource = queryList;
} }
@ -251,7 +267,7 @@ namespace XGLFinishPro.Views
{ {
try try
{ {
if (CustomMessageBox.Show("确定要生成该工序的数据吗?", CustomMessageBoxButton.YesNo, CustomMessageBoxIcon.Question) == CustomMessageBoxResult.No) if (CustomMessageBox.Show("确定要生成该工序的数据吗?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Question) == CustomMessageBoxResult.Cancel)
return; return;
if (checkedRowsCache.Count == 0) if (checkedRowsCache.Count == 0)
{ {

Loading…
Cancel
Save