using MES.Common;
using MES.Common.Entities;
using MES.Common.Exceptions;
using MES.Module.Services;
using System;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using Infragistics.Win.UltraWinGrid;
namespace MES.Module.Views.Carrier
{
public partial class CleanCarrierView : ChildForm
{
FactoryService facService = new FactoryService();
LotService lotService = new LotService();
DurableService durService = new DurableService();
bool islistbysql = false;
public CleanCarrierView()
{
InitializeComponent();
}
#region HoldCarrierView_Load
private void HoldCarrierView_Load(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
SetInitialGrid();
GetReaseonCodeList();
this.grdCarrierList.Grid.DisplayLayout.Bands[0].Columns["REASONCODE"].Nullable = Infragistics.Win.UltraWinGrid.Nullable.EmptyString;
//SetcmbMaterialLocationType();
}
catch (IDMMessageException idmEx)
{
UILogger.This.Trace(idmEx);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, idmEx.MessageKey, idmEx.LabelKey, idmEx.MessageBody);
}
catch (Exception err)
{
UILogger.This.Trace(err);
}
finally
{
UILogger.This.Log(UILogger.Query, true, "[ " + this.Name + " : Load End ]", null);
this.Cursor = Cursors.Default;
}
}
#endregion
#region SetInitialGrid
private void SetInitialGrid()
{
try
{
#region grdConsumableList Heads
GridHeaders head = new GridHeaders();
head.AddGridColumn("CHECKBOX", "Sel", 45, Infragistics.Win.HAlign.Center, false, Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox);
head.AddGridColumn("DURABLESPECNAME", "CarrierSpec", 120, Infragistics.Win.HAlign.Center);
head.AddGridColumn("DURABLENAME", "CarrierName", 90, Infragistics.Win.HAlign.Center, true);
head.AddGridColumn("DURABLESTATE", "DurableState", 100, Infragistics.Win.HAlign.Center);
head.AddGridColumn("DURABLECLEANSTATE", "DurableCleanState", 100, Infragistics.Win.HAlign.Center);
head.AddGridColumn("LOTNAME", "LotName", 100, Infragistics.Win.HAlign.Center);
head.AddGridColumn("DURABLEHOLDSTATE", "DurableHoldState", 100, Infragistics.Win.HAlign.Center);
head.AddGridColumn("MACHINENAME", "MachineName", 80, Infragistics.Win.HAlign.Center);
head.AddGridColumn("PORTNAME", "PortName", 80, Infragistics.Win.HAlign.Center);
head.AddGridColumn("CAPACITY", "Capacity", 90, Infragistics.Win.HAlign.Right);
head.AddGridColumn("CLEANENDTIMEKEY", "CleanEndTimeKey", 150, Infragistics.Win.HAlign.Center);
//head.AddGridColumn("TIMEUSEDLIMIT", "TimeUsedLimit", 120, Infragistics.Win.HAlign.Right);
//head.AddGridColumn("TIMEUSED", "TimeUsed", 90, Infragistics.Win.HAlign.Right);
head.AddGridColumn("DURATIONUSEDLIMIT", "DurationUsedLimit", 120, Infragistics.Win.HAlign.Right);
head.AddGridColumn("DURATIONUSED", "DurationUsed", 110, Infragistics.Win.HAlign.Right);
head.AddGridColumn("DURABLETYPE", "CarrierType", 90, Infragistics.Win.HAlign.Left);
//head.AddGridColumn("MATERIALLOCATIONNAME", "MaterialLocationName", 170, Infragistics.Win.HAlign.Left);
head.AddGridColumn("LOTQUANTITY", "LotQuantity", 100, Infragistics.Win.HAlign.Right);
head.AddGridColumn("CREATEUSER", "CreateUser", 100, Infragistics.Win.HAlign.Left);
head.AddGridColumn("CREATETIME", "CreateTime", 160, Infragistics.Win.HAlign.Left);
this.grdCarrierList.SetColumns(head);
#endregion
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
//checkbox change
#region rbtn_CheckedChanged
private void rbtnTray_CheckedChanged(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
cmbCarrierSpec.Text = string.Empty;
txtCarrierName.Text = string.Empty;
dURABLEBindingSource.Clear();
this.grdCarrierList.DataSource = dURABLEBindingSource;
SetInitialGrid();
this.Cursor = Cursors.Default;
}
#endregion
//cbm act
#region cmbCarrierSpec_BeforeDropDown
private void cmbCarrierSpec_BeforeDropDown(object sender, System.ComponentModel.CancelEventArgs e)
{
if (string.IsNullOrEmpty(ConnectionInfo.FactoryName))
{
return;
}
try
{
txtCarrierName.Text = string.Empty;
this.LoadCarrierSpec(ConnectionInfo.FactoryName);
}
catch (IDMMessageException idmex)
{
UILogger.This.Trace(idmex);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, idmex.MessageKey, idmex.LabelKey, idmex.MessageBody);
}
catch (System.Exception ex)
{
UILogger.This.Trace(ex);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, "COMM10011", this.Text, ex);
}
}
#endregion
//cmb data
#region LoadCarrierSpec
private void LoadCarrierSpec(string factoryName)
{
try
{
DURABLE objDurable = new DURABLE();
Collection<DURABLE> colSpec = new Collection<DURABLE>();
objDurable.FACTORYNAME = ConnectionInfo.FactoryName;
if(rbtnTray.Checked || rbtnTrayGroup.Checked)
{
//objDurable.DURABLETYPE = rbtnTray.Text;
objDurable.DURABLETYPE = "TurnOverTray";
}
else
{
objDurable.DURABLETYPE = rbtnCarrier.Text;
}
colSpec = durService.GetDurableSpecList25(objDurable);
cmbCarrierSpec.DataSource = colSpec;
cmbCarrierSpec.HiddenAllColunms();
cmbCarrierSpec.ShowColumn("DURABLESPECNAME", 0, cmbCarrierSpec.Width, true);
cmbCarrierSpec.ShowColumn("DESCRIPTION", 1, cmbCarrierSpec.Width, false);
}
catch (System.Exception ex)
{
throw ex;
}
}
#endregion
#region GetReaseonCodeList
private void GetReaseonCodeList()
{
try
{
// ReasonCode
REASONCODE objReasonCode = new REASONCODE();
objReasonCode.FACTORYNAME = ConnectionInfo.FactoryName;
//objReasonCode.FACTORYNAME = "MODULE";
//objReasonCode.REASONCODETYPE = "Hold";
Collection<REASONCODE> colReason = facService.GetReasonCodeListV3(objReasonCode);
colReason.Insert(0, new REASONCODE() { REASONCODENAME = string.Empty, DESCRIPTION = string.Empty });
this.dakHoldCode.DataSource = colReason;
this.grdCarrierList.Grid.DisplayLayout.Bands[0].Columns["REASONCODE"].ValueList = this.dakHoldCode;
this.grdCarrierList.Grid.DisplayLayout.Bands[0].Columns["REASONCODE"].CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.Edit;
this.grdCarrierList.Grid.DisplayLayout.Bands[0].Columns["REASONCODE"].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.OnRowActivate;
this.dakHoldCode.HiddenAllColunms();
this.dakHoldCode.ShowColumn("REASONCODENAME", 0, dakHoldCode.Width, true);
this.dakHoldCode.ShowColumn("DESCRIPTION", 1, dakHoldCode.Width, false);
}
catch (IDMMessageException idmEx)
{
UILogger.This.Trace(idmEx);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, idmEx.MessageKey, idmEx.LabelKey, idmEx.MessageBody);
}
catch (Exception ex)
{
UILogger.This.Trace(ex);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, "COMM10011", this.Text, ex);
}
finally
{
UILogger.This.Log(UILogger.Query, true, "[ " + this.Name + " : Load End ]", null);
}
}
#endregion
#region btnView_Click
private void btnView_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(this.cmbCarrierSpec.Text))
{
ExceptionMsgBox.This.ShowMessageBox(MessageType.Warning, "SPEC000", this.Text);
return;
}
this.Cursor = Cursors.WaitCursor;
SaveData();
}
catch (IDMMessageException idmEx)
{
UILogger.This.Trace(idmEx);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, idmEx.MessageKey, idmEx.LabelKey, idmEx.MessageBody);
}
catch (Exception err)
{
UILogger.This.Trace(err);
}
finally
{
UILogger.This.Log(UILogger.Query, true, "[ " + this.Name + " : Load End ]", null);
this.Cursor = Cursors.Default;
}
}
#endregion
#region SaveData
private void SaveData()
{
try
{
grdCarrierList.PageRowCount = 0;
dURABLEBindingSource.Clear();
DURABLE objDurable = new DURABLE();
if (rbtnTray.Checked)
{
//objDurable.DURABLETYPE = rbtnTray.Text;
objDurable.DURABLETYPE = "TurnOverTray"; ;
}
else if (rbtnTrayGroup.Checked)
{
objDurable.DURABLETYPE = "CoverTray";
}
else
{
objDurable.DURABLETYPE = rbtnCarrier.Text;
}
objDurable.DURABLESPECNAME = cmbCarrierSpec.Text;
objDurable.DURABLENAME = txtCarrierName.Text;
objDurable.FACTORYNAME = ConnectionInfo.FactoryName;
grdCarrierList.Retrieve("GetDurableList", "00044", objDurable, new DURABLE(), 30);
islistbysql = false;
//Collection<DURABLE> durableList = durService.GetDurableList15(objDurable);
//if (durableList != null && durableList.Count > 0)
//{
// dURABLEBindingSource.DataSource = durableList;
//}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region btnOK_Click
private void btnOK_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
try
{
if (grdCarrierList.Grid.Rows.Count > 0)
{
Collection<DURABLE> colHoldCarrier = new Collection<DURABLE>();
for (int i = 0; i < grdCarrierList.Grid.Rows.Count; i++)
{
if (this.grdCarrierList.Grid.Rows[i].Cells["CHECKBOX"].Text.Equals("True"))
{
DURABLE objdur = new DURABLE();
objdur.DURABLENAME = grdCarrierList.Grid.Rows[i].Cells["DURABLENAME"].Value.ToString();
objdur.DURABLECLEANSTATE = "Clean";
colHoldCarrier.Add(objdur);
}
}
userCommand.SetUserComment(userCommand.txtComment.Text);
if (colHoldCarrier.Count != 0)
{
if (!ExceptionMsgBox.This.ShowUserConfirmBox(CheckPrivilege))
{
return;
}
if (lotService.SetEventV1(UDFCONST.CleanCarrier, null, colHoldCarrier))
{
btnView_Click(null, null);
this.userCommand.txtComment.Text = String.Empty;
}
}
else
{
ExceptionMsgBox.This.ShowMessageBox(MessageType.Warning, "请选择要清洗的CST。", this.Name);
}
}
}
catch (IDMMessageException idmEx)
{
UILogger.This.Trace(idmEx);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, idmEx.MessageKey, idmEx.LabelKey, idmEx.MessageBody);
}
catch (Exception ex)
{
UILogger.This.Trace(ex);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, "COMM10011", this.Text, ex);
}
finally
{
this.Cursor = Cursors.Default;
UILogger.This.Log(UILogger.Query, true, "[ " + this.Name + " : Load End ]", null);
}
}
#endregion
#region btnExit_Click
private void btnExit_Click(object sender, EventArgs e)
{
try
{
this.Close();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
private void txtCarrierName_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter || string.IsNullOrEmpty(this.txtCarrierName.Text))
{
return;
}
try
{
//Annotated by LJX 2023.11.17
/* this.Cursor = Cursors.WaitCursor;
#region Validations
if (string.IsNullOrEmpty(ConnectionInfo.FactoryName))
{
return;
}
#endregion
//make checkbox true;
//foreach (UltraGridRow row in grdLotList.Rows)
//{
// if (txtTrayName.Text == row.Cells["CARRIERNAME"].Text)
// {
// row.Cells["CHECK"].Value = "true";
// txtLotID.Clear();
// return;
// }
//}
for (int i = 0; i < grdCarrierList.Grid.Rows.Count; i++)
{
if (grdCarrierList.Grid.Rows[i].Cells["DURABLENAME"].Value.Equals(txtCarrierName.Text))
{
grdCarrierList.Grid.Rows[i].Cells["CHECKBOX"].Value = "true";
txtCarrierName.Clear();
//return;
}
}
//ExceptionMsgBox.This.ShowMessageBox(MessageType.Warning, "COMM30006", this.Text);
*/
Collection<DURABLE> colCarrier = new Collection<DURABLE>();
if (grdCarrierList.Grid.Rows.Count > 0 && islistbysql == true)
{
colCarrier = (Collection<DURABLE>)grdCarrierList.Grid.DataSource;
}
DURABLE objDurable = new DURABLE();
if (rbtnTray.Checked)
{
//objDurable.DURABLETYPE = rbtnTray.Text;
objDurable.DURABLETYPE = "TurnOverTray"; ;
}
else if (rbtnTrayGroup.Checked)
{
objDurable.DURABLETYPE = "CoverTray";
}
else
{
objDurable.DURABLETYPE = rbtnCarrier.Text;
}
objDurable.DURABLESPECNAME = cmbCarrierSpec.Text;
objDurable.DURABLENAME = txtCarrierName.Text;
objDurable.FACTORYNAME = ConnectionInfo.FactoryName;
Collection<DURABLE> colCst = facService.GetQueryList(objDurable, "GetDurableList", "00044");
islistbysql = true;
if (colCst.Count > 0)
{
grdCarrierList.Grid.DataSource = new Collection<DURABLE>();
colCst[0].CHECK = true;
colCarrier.Add(colCst[0]);
grdCarrierList.DataSource = new Collection<DURABLE>(colCarrier);
for (int i = 0; i < grdCarrierList.Grid.Rows.Count; i++)
{
if (grdCarrierList.Grid.Rows[i].Cells["DURABLENAME"].Value.Equals(txtCarrierName.Text))
{
grdCarrierList.Grid.Rows[i].Cells["CHECKBOX"].Value = "true";
txtCarrierName.Clear();
//return;
}
}
}
else
{
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, "Can't Find Durable ID", this.Text);
return;
}
}
catch (IDMMessageException idmEx)
{
UILogger.This.Trace(idmEx);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, idmEx.MessageKey, idmEx.LabelKey, idmEx.MessageBody);
}
catch (System.Exception ex)
{
UILogger.This.Trace(ex);
ExceptionMsgBox.This.ShowMessageBox(MessageType.Error, "COMM10011", this.Text, ex);
}
finally
{
this.Cursor = Cursors.Default;
}
}
}
}
新增Inuse状态的bpel
public void materialKitOnline( EventInfo eventInfo,String materialID,String machineName,String unitID,String lotID,String materialQuantity,String materialType,String productSpecName,String processOperationName,String processFlowName,String materialFlag) throws CustomException
{
// SetEventName
String consumableType="";
if(StringUtils.equals("1", materialType))
{
consumableType="FPC";
}
else if(StringUtils.equals("2", materialType))
{
consumableType="ACF";
}
else if(StringUtils.equals("3", materialType))
{
consumableType="UV";
}
else if(StringUtils.equals("4", materialType))
{
consumableType="Lamination";
}
eventInfo.setEventName( GenericServiceProxy.getConstantMap().EVENTNAME_MaterialKit );
//int boxLen=0;
String boxid="";
if(StringUtils.equals("FPC", consumableType))
{
Map<String, Object> bindMapLen = new HashMap<String, Object>();
/*String sqlLen="SELECT B.DISPLAYCOLOR FROM ENUMDEFVALUE B WHERE B.ENUMNAME='FPCLengthMap' AND B.ENUMVALUE=:ENUMVALUE";
Map<String, Object> bindMapLen = new HashMap<String, Object>();
bindMapLen.put("ENUMVALUE", materialID.length());
List<Map<String, Object>> sqlLenResult = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlLen, bindMapLen);
if(sqlLenResult.size()>0)
{
boxLen=Integer.parseInt(sqlLenResult.get(0).get("DISPLAYCOLOR").toString());
}
else
{
throw new CustomException("MMS-0020");
}*/
//校验FPC空版属性及清洗QTime
String sql1=
"SELECT A.BOXID, A.PACKAGEID, A.FPCID, A.FLAG, A.CLEANTIME, A.CLEANCOUNT,ROUND((SYSDATE - A.CLEANTIME) * 24, 1) AS CLTIME\n" +
" FROM BOXFPCMAPPING A\n" +
" WHERE A.FPCID = :FPCID";
bindMapLen.put("FPCID", materialID);
List<Map<String, Object>> sqlLenResult1 = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql1, bindMapLen);
if(sqlLenResult1.size()>0)
{
boxid=sqlLenResult1.get(0).get("BOXID").toString();
//校验空版属性
String flag=sqlLenResult1.get(0).get("FLAG").toString();
//String lcCleanTime = sqlLenResult1.get(0).get("CLTIME").toString();
String lcCleanTime = sqlLenResult1.get(0).get("CLTIME")==null?"":sqlLenResult1.get(0).get("CLTIME").toString();
if(!flag.equals(materialFlag))
{
throw new CustomException("MMS-0021");//空版属性不一致
//throw new CustomException("MMS-0021", "Cannot Kitting on " + machineName + "for MaterialSpec: " + consumableData.getConsumableSpecName());
}
if (StringUtils.equals(lcCleanTime, "") )
{
throw new CustomException("MMS-0003", lcCleanTime);//清洗时间是否为空
}
//校验清洗QTime
if (new BigDecimal(lcCleanTime).doubleValue()> 4)
{
throw new CustomException("MMS-0023", lcCleanTime);//清洗QTime
}
}
else
{
throw new CustomException("MMS-0022");//FPCID未导入
}
}
ConsumableKey consumbleKey = new ConsumableKey();
if(StringUtils.equals("FPC", consumableType))
{
//consumbleKey.setConsumableName( materialID.substring(0, 12));
//consumbleKey.setConsumableName( materialID.substring(0, boxLen));
consumbleKey.setConsumableName( boxid );
}
else
{
consumbleKey.setConsumableName( materialID );
}
Consumable consumableData = ConsumableServiceProxy.getConsumableService().selectByKey( consumbleKey );
//Check ACF&UV胶 Quantity >= 0
if(StringUtils.equals("ACF", consumableType) ||
StringUtils.equals("UV", consumableType)||
StringUtils.equals("FPC", consumableType)||
StringUtils.equals("Lamination", consumableType))
{
StringBuilder sql = new StringBuilder();
sql.append("SELECT C.CONSUMABLENAME,C.CREATEQUANTITY,C.QUANTITY,C.FIRSTONMACHINETIME");
sql.append(" FROM CONSUMABLE C");
sql.append(" WHERE C.CONSUMABLETYPE=:CONSUMABLETYPE");
sql.append(" AND C.CONSUMABLENAME=:CONSUMABLENAME");
sql.append(" AND C.CREATEQUANTITY IS NOT NULL ");
sql.append(" AND C.QUANTITY<=0 ");
Map<String, Object> bindMap = new HashMap<String, Object>();
bindMap.put("CONSUMABLETYPE", consumableType);
if(StringUtils.equals("FPC", consumableType))
{
/*String sqlLen="SELECT B.DISPLAYCOLOR FROM ENUMDEFVALUE B WHERE B.ENUMNAME='FPCLengthMap' AND B.ENUMVALUE=:ENUMVALUE";
Map<String, Object> bindMapLen = new HashMap<String, Object>();
bindMapLen.put("ENUMVALUE", materialID.length());
List<Map<String, Object>> sqlLenResult = IDMFrameServiceProxy.getSqlTemplate().queryForList(sqlLen, bindMapLen);
if(sqlLenResult.size()>0)
{
int boxLen=Integer.parseInt(sqlLenResult.get(0).get("DISPLAYCOLOR").toString());
bindMap.put("CONSUMABLENAME", materialID.substring(0, boxLen));
}
else
{
throw new CustomException("MMS-0020");
}*/
bindMap.put("CONSUMABLENAME", boxid);
}
else
{
bindMap.put("CONSUMABLENAME", materialID);
}
List<Map<String, Object>> sqlResult = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql.toString(), bindMap);
if (sqlResult.size() > 0)
{
throw new CustomException("MMS-0019",consumableData.getQuantity(),consumableData.getCreateQuantity());
}
}
String firstOnMachineTime="";
//Check Material Expiry or not.
if(StringUtils.equals("ACF", consumableType) ||
StringUtils.equals("UV", consumableType) ||
StringUtils.equals("FPC", consumableType) ||
StringUtils.equals("Lamination", consumableType))
{
StringBuilder sql1 = new StringBuilder();
sql1.append("SELECT FIRSTONMACHINETIME,CONSUMABLENAME, ROUND((SYSDATE - EXPIRYDATETIME) * 24, 1) AS EXPIRYPASSTIME\n");
sql1.append(" FROM CONSUMABLE\n");
sql1.append(" WHERE CONSUMABLETYPE = :CONSUMABLETYPE\n");
sql1.append(" AND CONSUMABLENAME = :CONSUMABLENAME\n");
sql1.append(" AND EXPIRYDATETIME IS NOT NULL");
Map<String, Object> bindMap1 = new HashMap<String, Object>();
bindMap1.put("CONSUMABLETYPE", consumableType);
if(StringUtils.equals("FPC", consumableType))
{
//bindMap1.put("CONSUMABLENAME", materialID.substring(0, 12));
bindMap1.put("CONSUMABLENAME", boxid);
}
else
{
bindMap1.put("CONSUMABLENAME", materialID);
}
List<Map<String, Object>> sqlResult = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql1.toString(), bindMap1);
if (sqlResult.size() > 0)
{
String expiryPassTime = sqlResult.get(0).get("EXPIRYPASSTIME").toString();
if (new BigDecimal(expiryPassTime).longValue() >= 0)
{
throw new CustomException("MMS-0011", consumableData.getExpiryDateTime());
}
//firstOnMachineTime=sqlResult.get(0).get("FIRSTONMACHINETIME").toString(); //sqlLenResult1.get(0).get("CLTIME")==null?"":sqlLenResult1.get(0).get("CLTIME").toString();
firstOnMachineTime=sqlResult.get(0).get("FIRSTONMACHINETIME")==null?"":sqlResult.get(0).get("FIRSTONMACHINETIME").toString();
}
}
//20230336 Check 膜材正反面LOAD-INK,UNLD-TFT
if(StringUtils.equals("Lamination", consumableData.getConsumableType()))
{
String MachineUnit=StringUtils.substring(unitID, unitID.length()-4);
if(StringUtils.equals("LOAD", MachineUnit) && !StringUtils.equals("INK", materialFlag))
{
throw new CustomException("MMS-0001", materialFlag);
}
if(StringUtils.equals("UNLD", MachineUnit) && !StringUtils.equals("TFT", materialFlag))
{
throw new CustomException("MMS-0002", materialFlag);
}
}
//Check 解冻时间
if(StringUtils.equals("ACF", consumableData.getConsumableType()))
{
StringBuilder sql2 = new StringBuilder();
sql2.append("SELECT C.CONSUMABLENAME, ROUND((SYSDATE - C.FRIDGEOUTTIME) * 24, 1) AS UNFROZENTIME,\n");
sql2.append(" (ROUND((SYSDATE - C.FRIDGEOUTTIME) * 24, 1)-D.UNFROZENLIMITTIME) AS UNFROZENOVERTIME\n");
sql2.append(" FROM CONSUMABLE C ,CONSUMABLESPEC D\n");
sql2.append(" WHERE C.CONSUMABLESPECNAME=D.CONSUMABLESPECNAME\n");
sql2.append(" AND C.CONSUMABLETYPE = :CONSUMABLETYPE\n");
sql2.append(" AND C.CONSUMABLENAME = :CONSUMABLENAME\n");
sql2.append(" AND C.FRIDGEOUTTIME IS NOT NULL");
Map<String, Object> bindMap2 = new HashMap<String, Object>();
bindMap2.put("CONSUMABLENAME", materialID);
bindMap2.put("CONSUMABLETYPE", consumableType);
List<Map<String, Object>> sqlResult = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql2.toString(), bindMap2);
if (sqlResult.size() > 0)
{
String unfrozenTime = sqlResult.get(0).get("UNFROZENTIME").toString();
//解冻后有效时间
String unfrozenOverTime = sqlResult.get(0).get("UNFROZENOVERTIME").toString();
//Check Unfrozen Limit Time.(确认解冻时间是否OK)
if (StringUtil.isNotEmpty(consumableData.getUnfrozenLimitTime())
&& new BigDecimal(consumableData.getUnfrozenLimitTime()).doubleValue()> new BigDecimal(unfrozenTime).doubleValue())
{
throw new CustomException("MMS-0009", consumableData.getUnfrozenLimitTime());
}
//Check unfrozenOverLimitTime (解冻后的有效时间)
if (new BigDecimal(unfrozenOverTime).doubleValue()> new BigDecimal(consumableData.getUnfrozenOverLimitTime()).doubleValue())
{
throw new CustomException("MMS-0006", unfrozenOverTime);
}
}
}
//Check Productspec
StringBuilder sql3 = new StringBuilder();
sql3.append("SELECT DISTINCT P.PRODUCTSPECNAME, P.CONSUMABLESPECNAME");
sql3.append(" FROM BSTPFOCONSUMABLESPEC P ");
sql3.append(" WHERE P.FACTORYNAME = :FACTORYNAME ");
sql3.append(" AND P.CONSUMABLESPECNAME = :CONSUMABLESPECNAME ");
sql3.append(" AND P.PRODUCTSPECNAME=:PRODUCTSPECNAME ");
Map<String, Object> bindMap3 = new HashMap<String, Object>();
bindMap3.put("FACTORYNAME", consumableData.getFactoryName());
//bindMap.put("MACHINENAME", machineName);
bindMap3.put("CONSUMABLESPECNAME", consumableData.getConsumableSpecName());
bindMap3.put("PRODUCTSPECNAME",productSpecName);
List<Map<String, Object>> sqlResult3 = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql3.toString(), bindMap3);
if (sqlResult3.size() < 1)
{
throw new CustomException("Exception-0001", "Cannot Kitting on " + machineName + "for MaterialSpec: " + consumableData.getConsumableSpecName());
}
if ( StringUtils.isEmpty( consumableData.getMachineName() ) )
{
Map<String, String> userColumns = new HashMap<String, String>();
userColumns.put( Consumable.FIELD.machineName, machineName );
userColumns.put( Consumable.FIELD.unitName, unitID );
userColumns.put( Consumable.FIELD.materialLocationName, machineName );
userColumns.put( Consumable.FIELD.onMachineTime, eventInfo.getEventTime().toString());
userColumns.put( Consumable.FIELD.productSpecName, productSpecName );
userColumns.put( Consumable.FIELD.processFlowName, processFlowName );
userColumns.put( Consumable.FIELD.processOperationName, processOperationName );
userColumns.put( Consumable.FIELD.lotName, lotID );
ACF首次上机将上机时间写入表中
if(StringUtils.equals("ACF", consumableData.getConsumableType()))
{
if(StringUtils.equals(firstOnMachineTime, ""))
{
userColumns.put( Consumable.FIELD.firstOnMachineTime, eventInfo.getEventTime().toString() );
}
}
SetEventInfo setEventInfo = new SetEventInfo();
setEventInfo.setUserColumns( userColumns );
ConsumableServiceProxy.getConsumableService().setEvent( consumbleKey, eventInfo, setEventInfo );
log.info( "Event Name = " + eventInfo.getEventName() + " , EventTimeKey" + eventInfo.getEventTimeKey() );
}
else
{
if(StringUtils.equals("FPC", consumableData.getConsumableType()))
{
Map<String, String> userColumns = new HashMap<String, String>();
userColumns.put( Consumable.FIELD.machineName, machineName );
userColumns.put( Consumable.FIELD.unitName, unitID );
userColumns.put( Consumable.FIELD.materialLocationName, machineName );
userColumns.put( Consumable.FIELD.onMachineTime, eventInfo.getEventTime().toString());
userColumns.put( Consumable.FIELD.productSpecName, productSpecName );
userColumns.put( Consumable.FIELD.processFlowName, processFlowName );
userColumns.put( Consumable.FIELD.processOperationName, processOperationName );
userColumns.put( Consumable.FIELD.lotName, lotID );
userColumns.put(Consumable.FIELD.quantity, String.valueOf(consumableData.getQuantity()-1));//quantity in box decrease 1.
SetEventInfo setEventInfo = new SetEventInfo();
setEventInfo.setUserColumns( userColumns );
ConsumableServiceProxy.getConsumableService().setEvent( consumbleKey, eventInfo, setEventInfo );
log.info( "Event Name = " + eventInfo.getEventName() + " , EventTimeKey" + eventInfo.getEventTimeKey() );
}
else
{
throw new CustomException( "DURABLE-9011", materialID );
}
}
boolean existFlag=false;
if(StringUtils.equals("FPC", consumableData.getConsumableType()))
{
ConsumableKey newConsumableKey = new ConsumableKey();
newConsumableKey.setConsumableName( materialID );
try
{
Consumable newConsumableData = ConsumableServiceProxy.getConsumableService().selectByKey( newConsumableKey );
existFlag=true;
}
catch (Exception e)
{
CreateInfo createInfo = new CreateInfo();
createInfo.setConsumableName(materialID);
createInfo.setConsumableSpecName(consumableData.getConsumableSpecName());
createInfo.setConsumableType(consumableType);
createInfo.setFactoryName(GenericServiceProxy.getConstantMap().Factory_Module);
createInfo.setQuantity(Double.valueOf(materialQuantity));
Map<String, String> userColumns = new HashMap<String, String>();
//userColumns.put(Consumable.FIELD.superMaterialName, materialID.substring(0, 15));
userColumns.put(Consumable.FIELD.superMaterialName, boxid);
userColumns.put(Consumable.FIELD.materialLocationName, machineName);
userColumns.put(Consumable.FIELD.createTime, eventInfo.getEventTime().toString());
userColumns.put(Consumable.FIELD.createUser, eventInfo.getEventUser());
userColumns.put(Consumable.FIELD.onMachineTime, eventInfo.getEventTime().toString());
userColumns.put(Consumable.FIELD.machineName, machineName);
userColumns.put(Consumable.FIELD.unitName, unitID );
userColumns.put(Consumable.FIELD.productSpecName, productSpecName );
userColumns.put(Consumable.FIELD.consumableSpecName, consumableData.getConsumableSpecName());
userColumns.put(Consumable.FIELD.consumableState, consumableData.getConsumableState());
userColumns.put(Consumable.FIELD.consumableType, consumableType);
userColumns.put(Consumable.FIELD.quantity, materialQuantity);
userColumns.put(Consumable.FIELD.vendor, consumableData.getVendor());
userColumns.put(Consumable.FIELD.bondedflag, consumableData.getBondedflag());
userColumns.put(Consumable.FIELD.unfrozenLimitCount, String.valueOf(consumableData.getUnfrozenLimitCount()));
userColumns.put(Consumable.FIELD.unfrozenCount, String.valueOf(consumableData.getUnfrozenCount()));
userColumns.put(Consumable.FIELD.unfrozenOverLimitTime,consumableData.getUnfrozenLimitTime());
if(consumableData.getLineBinReceiveTime()!=null)
{
userColumns.put(Consumable.FIELD.lineBinReceiveTime, consumableData.getLineBinReceiveTime().toString());
}
else
{
userColumns.put(Consumable.FIELD.lineBinReceiveTime, "");
}
if(consumableData.getLineBinOutTime()!=null)
{
userColumns.put(Consumable.FIELD.lineBinOutTime, consumableData.getLineBinOutTime().toString());
}
else
{
userColumns.put(Consumable.FIELD.lineBinOutTime, "");
}
if(consumableData.getExpiryDateTime()!=null)
{
userColumns.put(Consumable.FIELD.expiryDateTime, consumableData.getExpiryDateTime().toString());
}
else
{
userColumns.put(Consumable.FIELD.expiryDateTime, "");
}
if(consumableData.getProductionDate()!=null)
{
userColumns.put(Consumable.FIELD.productionDate, consumableData.getProductionDate().toString());
}
else
{
userColumns.put(Consumable.FIELD.productionDate, "");
}
if(consumableData.getFridgeInTime()!=null)
{
userColumns.put(Consumable.FIELD.fridgeInTime, consumableData.getFridgeInTime().toString());
}
else
{
userColumns.put(Consumable.FIELD.fridgeInTime, "");
}
if(consumableData.getFridgeOutTime()!=null)
{
userColumns.put(Consumable.FIELD.fridgeOutTime, consumableData.getFridgeOutTime().toString());
}
else
{
userColumns.put(Consumable.FIELD.fridgeOutTime, "");
}
if(consumableData.getUnfrozenLimitTime()!=null)
{
userColumns.put(Consumable.FIELD.unfrozenLimitTime, consumableData.getUnfrozenLimitTime().toString());
}
else
{
userColumns.put(Consumable.FIELD.unfrozenLimitTime, "");
}
createInfo.setUserColumns(userColumns);
ConsumableServiceProxy.getConsumableService().create(newConsumableKey, eventInfo, createInfo);
log.info( "Event Name = " + eventInfo.getEventName() + " , EventTimeKey" + eventInfo.getEventTimeKey() );
}
if(existFlag)
{
throw new CustomException( "CONSUMABLE-9110", materialID );
}
}
}
/**
*
* @brief This function is materialModifyQuantity
* @author Chenxing
* @param doc
* @param eventInfo
* @throws Exception
*/
public void materialModifyQuantity( org.jdom.Document doc, EventInfo eventInfo ) throws Exception
{
Element root = doc.getDocument().getRootElement();
Element bodyElement = root.getChild( "Body" );
String consumableName = bodyElement.getChildText( "CONSUMABLENAME" );
String newQuantity = bodyElement.getChildText( "QUANTITY" );
// SetEventName
eventInfo.setEventName( GenericServiceProxy.getConstantMap().EVENTNAME_MaterialModifyQuantity );
ConsumableKey consumableKey = new ConsumableKey();
consumableKey.setConsumableName( consumableName );
Consumable consumableData = ConsumableServiceProxy.getConsumableService().selectByKey( consumableKey );
if ( !newQuantity.equals( consumableData.getQuantity() ) )
{
Map<String, String> userColumns = new HashMap<String, String>();
userColumns.put( Consumable.FIELD.quantity, newQuantity );
SetEventInfo setEventInfo = new SetEventInfo();
setEventInfo.setUserColumns( userColumns );
ConsumableServiceProxy.getConsumableService().setEvent( consumableKey, eventInfo, setEventInfo );
log.info( "Event Name = " + eventInfo.getEventName() + " , EventTimeKey" + eventInfo.getEventTimeKey() );
}
else
{
throw new CustomException( "DURABLE-9011", consumableName );
}
}