123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using UFSoft.UBF.PL.Engine.Cache;
- using UFSoft.UBF.Util.DataAccess;
- using UFSoft.UBF.Util.Log;
- namespace UFIDA.U9.Cust.KuSi.zhangky.BPSVPlug
- {
- internal class UpdateBarCodeNew
- {
- public static void Update(long id, string entityType, string barcode, long binid, string binCode, string binName, long whid, string whCode, string whName)
- {
- string strTmp;
- ILogger logger = LoggerManager.GetLogger("BPSVPlug_UpdateBarCodeNew------");
- if (string.IsNullOrEmpty(barcode))
- {
- strTmp = "UseDocLine.EntityID=@ID and UseDocLine.EntityType=@EntityType order by CreatedOn desc";
- }
- else
- {
- strTmp = "UseDocLine.EntityID=@ID and UseDocLine.EntityType=@EntityType and BarCode='" + barcode + "' order by CreatedOn desc";
- }
- if (entityType.Contains("TransferFormL") || entityType.Contains("TransferFormSL") || entityType.Contains("TransInSubLine") || entityType.Contains("MiscRcvTransBin"))
- {
- strTmp = strTmp.Replace("UseDocLine", "CreateEntity");
- }
- logger.Error(string.Format("-------1开始找条码使用档 {0},{1}", id.ToString(),entityType));
- UFIDA.U9.BC.BaseData.BarCodeUsed.EntityList tmp = UFIDA.U9.BC.BaseData.BarCodeUsed.Finder.FindAll(strTmp
- , new UFSoft.UBF.PL.OqlParam[]
- {
- new UFSoft.UBF.PL.OqlParam(id),
- new UFSoft.UBF.PL.OqlParam(entityType)
- });
- if (tmp != null && tmp.Count > 0)
- {
- logger.Error(string.Format("-------2找到条码使用档 {0},{1}", id.ToString(), entityType));
- List<UFIDA.U9.BC.BaseData.BarCodeUsed> list = Distinct(tmp);
- logger.Error(string.Format("-------3去重 {0},{1}", id.ToString(), entityType));
- foreach (var barCodeUsed in list)
- {
- StringBuilder sql = new StringBuilder();
- sql.Append(string.Format
- ("if not exists(select 1 from BC_BarCodeUsed_Trl with (nolock) where id={0} and SysMLFlag='zh-CN') begin insert into BC_BarCodeUsed_Trl(ID, SysMLFlag) values({1}, 'zh-CN') end if not exists(select 1 from BC_BarCode_Trl with (nolock) where id={2} and SysMLFlag='zh-CN') begin insert into BC_BarCode_Trl(ID,SysMLFlag) values({3},'zh-CN') end ", barCodeUsed.ID, barCodeUsed.ID, barCodeUsed.BarCodeMaster.ID, barCodeUsed.BarCodeMaster.ID));
- DataAccessor.RunSQL(DataAccessor.GetConn(), sql.ToString(), null);
- barCodeUsed.SetValue("Cust4Binid", binid);
- barCodeUsed.SetValue("Cust4Bincode", binCode);
- barCodeUsed.SetValue("Cust4Binname", binName);
- barCodeUsed.BarCodeMaster.SetValue("Cust4Binid", binid);
- barCodeUsed.BarCodeMaster.SetValue("Cust4Bincode", binCode);
- barCodeUsed.BarCodeMaster.SetValue("Cust4Binname", binName);
- if (whid != 0)
- {
- barCodeUsed.SetValue("Cust4Whid", whid);
- barCodeUsed.SetValue("Cust4Whcode", whCode);
- barCodeUsed.SetValue("Cust4Whname", whName);
- barCodeUsed.BarCodeMaster.SetValue("Cust4Whid", whid);
- barCodeUsed.BarCodeMaster.SetValue("Cust4Whcode", whCode);
- barCodeUsed.BarCodeMaster.SetValue("Cust4Whname", whName);
- }
- logger.Error(string.Format("-------4更新库位 {0},{1},{2},{3}", barCodeUsed.ID, barCodeUsed.BarCode, binCode, whCode));
- }
- }
- }
- private static List<UFIDA.U9.BC.BaseData.BarCodeUsed> Distinct(UFIDA.U9.BC.BaseData.BarCodeUsed.EntityList list)
- {
- Dictionary<string, UFIDA.U9.BC.BaseData.BarCodeUsed> dic = new Dictionary<string, UFIDA.U9.BC.BaseData.BarCodeUsed>();
- foreach (var barCodeUsed in list)
- {
- if (!dic.ContainsKey(barCodeUsed.BarCode))
- {
- dic.Add(barCodeUsed.BarCode, barCodeUsed);
- }
- }
- return new List<UFIDA.U9.BC.BaseData.BarCodeUsed>(dic.Values);
- }
- }
- }
|