|
|
@@ -0,0 +1,320 @@
|
|
|
+/*******************************************************************************
|
|
|
+ * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
|
|
|
+ * 类的信息:
|
|
|
+ * 1.程序名称:PDAModuleLogicWorkShop3.cs
|
|
|
+ * 2.功能描述:PDA相关处理(三车间专用)。
|
|
|
+ * 编辑履历:
|
|
|
+ * 作者 日期 版本 修改内容
|
|
|
+ * 徐伟 2019/11/05 1.00 新建
|
|
|
+ *******************************************************************************/
|
|
|
+
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Data;
|
|
|
+using System.Drawing;
|
|
|
+using System.Drawing.Imaging;
|
|
|
+using System.IO;
|
|
|
+using System.Text;
|
|
|
+
|
|
|
+using Dongke.IBOSS.PRD.Basics.BaseResources;
|
|
|
+using Dongke.IBOSS.PRD.Basics.DataAccess;
|
|
|
+using Dongke.IBOSS.PRD.Basics.Library;
|
|
|
+using Dongke.IBOSS.PRD.Service.DataModels;
|
|
|
+using Dongke.IBOSS.PRD.WCF.DataModels;
|
|
|
+using Dongke.IBOSS.PRD.WCF.DataModels.HRModule;
|
|
|
+using Dongke.IBOSS.PRD.WCF.DataModels.PCModule;
|
|
|
+using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
|
|
|
+using Oracle.ManagedDataAccess.Client;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
+using Dongke.IBOSS.PRD.Service.CMNModuleService;
|
|
|
+using System.Collections;
|
|
|
+
|
|
|
+namespace Dongke.IBOSS.PRD.Service.PDAModuleLogic
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 三车间专用接口
|
|
|
+ /// </summary>
|
|
|
+ public partial class PDAModuleLogic
|
|
|
+ {
|
|
|
+ #region feiyue add 2022-07-20 装板接口
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 生产工号装具操作权限
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="groutingLineNo"></param>
|
|
|
+ /// <param name="sUser"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static ServiceResultEntity CheckEntruckUser(string functionCode,string currentUserCode, SUserInfo sUser)
|
|
|
+ {
|
|
|
+ ServiceResultEntity sre = new ServiceResultEntity();
|
|
|
+ sre.Data = new DataSet();
|
|
|
+ sre.Status = Constant.ServiceResultStatus.Success;
|
|
|
+ IDBTransaction conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
|
|
|
+ string sqlStr = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ conn.Connect();
|
|
|
+ if (sre.Status == Constant.ServiceResultStatus.Success)
|
|
|
+ {
|
|
|
+ sqlStr = $@"
|
|
|
+ SELECT
|
|
|
+ TMUR.FunctionCode
|
|
|
+ FROM
|
|
|
+ TP_MST_UserRight TMUR
|
|
|
+ INNER JOIN TP_MST_USER U ON U.USERID = TMUR.USERID
|
|
|
+ WHERE
|
|
|
+ TMUR.FunctionCode = '{functionCode}'
|
|
|
+ AND u.USERCODE = '{currentUserCode}'
|
|
|
+ AND u.accountID = {sUser.AccountID}
|
|
|
+ ";
|
|
|
+ DataTable dt = conn.GetSqlResultToDt(sqlStr);
|
|
|
+ if (dt.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.NoFunRight;
|
|
|
+ sre.Message = "工号"+ currentUserCode + "无该操作权限!";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.Success;
|
|
|
+ sre.Message = "操作成功!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ throw ex;
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ conn.Disconnect();
|
|
|
+ }
|
|
|
+ //返回数据
|
|
|
+ return sre;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取装具的使用状态
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="entruckingCode"></param>
|
|
|
+ /// <param name="sUser"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static ServiceResultEntity GetTruckStatus(string entruckingCode, SUserInfo sUser)
|
|
|
+ {
|
|
|
+ ServiceResultEntity sre = new ServiceResultEntity();
|
|
|
+ sre.Data = new DataSet();
|
|
|
+ sre.Status = Constant.ServiceResultStatus.Success;
|
|
|
+ IDBTransaction conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
|
|
|
+ string sqlStr = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ conn.Connect();
|
|
|
+ if (sre.Status == Constant.ServiceResultStatus.Success)
|
|
|
+ {
|
|
|
+ sqlStr = $@"
|
|
|
+ SELECT
|
|
|
+ TPE.STATUS
|
|
|
+ FROM TP_PM_ENTRUCKING TPE
|
|
|
+ WHERE TPE.VALUEFLAG = '1'
|
|
|
+ AND TPE.ENTRUCKINGCODE = '{entruckingCode}'
|
|
|
+ ";
|
|
|
+ DataTable dt = conn.GetSqlResultToDt(sqlStr);
|
|
|
+ sre.Data.Tables.Add(dt);
|
|
|
+ if (dt.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.NoSearchResults;
|
|
|
+ sre.Message = "无效装具条码!";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.Success;
|
|
|
+ sre.Message = "操作成功!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ throw ex;
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ conn.Disconnect();
|
|
|
+ }
|
|
|
+ //返回数据
|
|
|
+ return sre;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 验证产品条码有效性,及产品与装具的绑定状态
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="barCode"></param>
|
|
|
+ /// <param name="sUser"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static ServiceResultEntity CheckTruckBarCode(string barCode, SUserInfo sUser)
|
|
|
+ {
|
|
|
+ ServiceResultEntity sre = new ServiceResultEntity();
|
|
|
+ sre.Data = new DataSet();
|
|
|
+ sre.Status = Constant.ServiceResultStatus.Success;
|
|
|
+ IDBTransaction conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
|
|
|
+ string sqlStr = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ conn.Connect();
|
|
|
+ if (sre.Status == Constant.ServiceResultStatus.Success)
|
|
|
+ {
|
|
|
+ sqlStr = $@"select 1 from TP_PM_GroutingDailyDetail where barcode='{barCode}' and valueflag=1";
|
|
|
+ DataTable dt = conn.GetSqlResultToDt(sqlStr);
|
|
|
+ if (dt.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.NoSearchResults;
|
|
|
+ sre.Message = "无效条码!";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //产品与装具的绑定状态
|
|
|
+ sqlStr = $@"
|
|
|
+ SELECT
|
|
|
+ TPE.EntruckingCode
|
|
|
+ FROM TP_PM_ENTRUCKING TPE
|
|
|
+ INNER JOIN TP_PM_EntruckingDetail TPED
|
|
|
+ ON TPE.EntruckingCode = TPED.EntruckingCode
|
|
|
+ AND TPE.Batch = TPED.Batch
|
|
|
+ WHERE TPE.Status = 1
|
|
|
+ AND TPED.BARCODE = '{barCode}'";
|
|
|
+ dt = conn.GetSqlResultToDt(sqlStr);
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.Other;
|
|
|
+ sre.Message = "产品" + barCode + "已在装具" + dt.Rows[0]["EntruckingCode"] + "上"; ;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.Success;
|
|
|
+ sre.Message = "操作成功!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ throw ex;
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ conn.Disconnect();
|
|
|
+ }
|
|
|
+ //返回数据
|
|
|
+ return sre;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 绑定装具
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="barcodes"></param>
|
|
|
+ /// <param name="entruckingCode"></param>
|
|
|
+ /// <param name="currentUserCode"></param>
|
|
|
+ /// <param name="sUser"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static ServiceResultEntity AddTruckBarCode(string[] barcodes, string entruckingCode, string currentUserCode, SUserInfo sUser)
|
|
|
+ {
|
|
|
+ ServiceResultEntity sre = new ServiceResultEntity();
|
|
|
+ sre.Data = new DataSet();
|
|
|
+ sre.Status = Constant.ServiceResultStatus.Success;
|
|
|
+ IDBTransaction conn = ClsDbFactory.CreateDBTransaction(DataBaseType.ORACLE, DataManager.ConnectionString);
|
|
|
+ string sqlStr = "";
|
|
|
+ int execute = 0;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ conn.Connect();
|
|
|
+ if (sre.Status == Constant.ServiceResultStatus.Success)
|
|
|
+ {
|
|
|
+ //获取最大批次
|
|
|
+ sqlStr = $@"SELECT
|
|
|
+ TPE.BATCH,TPE.STATUS
|
|
|
+ FROM TP_PM_ENTRUCKING TPE
|
|
|
+ WHERE TPE.VALUEFLAG = '1'
|
|
|
+ AND TPE.ENTRUCKINGCODE = '{entruckingCode}'";
|
|
|
+ DataTable dt = conn.GetSqlResultToDt(sqlStr);
|
|
|
+ if (dt.Rows.Count == 0)
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.NoSearchResults;
|
|
|
+ sre.Message = "无效装具条码!";
|
|
|
+ }
|
|
|
+ else if (dt.Rows[0]["STATUS"].ToString().Equals("0"))
|
|
|
+ {
|
|
|
+ int batch = Convert.ToInt32(dt.Rows[0]["BATCH"]) + 1;
|
|
|
+ for (int i = 0; i < barcodes.Length; i++)
|
|
|
+ {
|
|
|
+ //获取产品条码当前工序
|
|
|
+ sqlStr = $@"
|
|
|
+ select PROCEDUREID from TP_PM_INPRODUCTION where barcode = '{barcodes[i]}'
|
|
|
+ ";
|
|
|
+ string procedureid = conn.GetSqlResultToStr(sqlStr);
|
|
|
+
|
|
|
+ //插入装具明细
|
|
|
+ sqlStr = $@"
|
|
|
+ INSERT INTO TP_PM_EntruckingDetail (
|
|
|
+ ENTRUCKINGCODE,
|
|
|
+ BARCODE,
|
|
|
+ BATCH,
|
|
|
+ DOFUNCTION,
|
|
|
+ PROCEDUREID,
|
|
|
+ REMARKS,
|
|
|
+ ACCOUNTID,
|
|
|
+ USERID,
|
|
|
+ USERCODE,
|
|
|
+ VALUEFLAG,
|
|
|
+ CREATEUSERID,
|
|
|
+ UPDATEUSERID )
|
|
|
+ SELECT
|
|
|
+ '{entruckingCode}',
|
|
|
+ '{barcodes[i]}',
|
|
|
+ '{batch}',
|
|
|
+ 1,
|
|
|
+ {procedureid},
|
|
|
+ '',
|
|
|
+ '{sUser.AccountID}',
|
|
|
+ USERID,
|
|
|
+ '{currentUserCode}',
|
|
|
+ 1,
|
|
|
+ '{sUser.UserID}',
|
|
|
+ '{sUser.UserID}'
|
|
|
+ FROM TP_MST_USER WHERE USERCODE = '{currentUserCode}'
|
|
|
+ ";
|
|
|
+ }
|
|
|
+
|
|
|
+ execute = conn.ExecuteNonQuery(sqlStr);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.NoSearchResults;
|
|
|
+ sre.Message = "装具不可用!";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (execute > 0)
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.Success;
|
|
|
+ sre.Message = "操作完成!";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sre.Status = Constant.ServiceResultStatus.NoModifyData;
|
|
|
+ sre.Message = "操作失败,没有更新任何数据!";
|
|
|
+ }
|
|
|
+ conn.Commit();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ conn.Rollback();
|
|
|
+ throw ex;
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ conn.Disconnect();
|
|
|
+ }
|
|
|
+ //返回数据
|
|
|
+ return sre;
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+}
|