Commit 3380454f authored by manohar's avatar manohar

supp_code__mfg of stock considered


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@92452 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 36b9836a
...@@ -277,7 +277,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -277,7 +277,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
Connection conn = null; Connection conn = null;
String lotNo = "", lotSl = "", lotNoIssue = "", considerLotNoIssue = "N", locGroup = "", locUsageType = ""; String lotNo = "", lotSl = "", lotNoIssue = "", considerLotNoIssue = "N", locGroup = "", locUsageType = "",suppCodeMfg = "";
StringBuffer sqlSB = new StringBuffer(); StringBuffer sqlSB = new StringBuffer();
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n"); StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
...@@ -318,11 +318,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -318,11 +318,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
} }
pstmt.close(); pstmt.close();
rs.close(); rs.close();
lotNoIssue = lotNoIssue==null?" ":lotNoIssue;
considerLotNoIssue = considerLotNoIssue==null?" ":considerLotNoIssue;
locUsageType = locUsageType==null?" ":locUsageType;
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0) if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{ {
String lotNoList[]; String lotNoList[];
...@@ -378,7 +373,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -378,7 +373,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
pstmt.close(); pstmt.close();
rs.close(); rs.close();
sql = "SELECT DIMENSION,USE_INVSTATUS FROM BOMDET WHERE BOM_CODE = ? AND ITEM_CODE = ? AND ITEM_REF = ?"; sql = "SELECT DIMENSION,USE_INVSTATUS,SUPP_CODE__MFG FROM BOMDET WHERE BOM_CODE = ? AND ITEM_CODE = ? AND ITEM_REF = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, bomCode); pstmt.setString(1, bomCode);
pstmt.setString(2, itemCodeMain); pstmt.setString(2, itemCodeMain);
...@@ -388,6 +383,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -388,6 +383,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
{ {
dimension = rs.getString(1)==null?"":rs.getString(1); dimension = rs.getString(1)==null?"":rs.getString(1);
useInvStatus = rs.getString(2)==null?"U":rs.getString(2); useInvStatus = rs.getString(2)==null?"U":rs.getString(2);
suppCodeMfg = rs.getString(3)==null?" ":rs.getString(3);
} }
else else
{ {
...@@ -398,246 +394,34 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -398,246 +394,34 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
rs.close(); rs.close();
pstmt = null; pstmt = null;
sql = ""; sql = "";
useInvStatus = useInvStatus==null?" ":useInvStatus; if (suppCodeMfg != null && !"null".equals(suppCodeMfg) && suppCodeMfg.trim().length() > 0)
dimension = dimension==null?" ":dimension;
trackShelfLife = trackShelfLife==null?" ":trackShelfLife;
autoQcReqd = autoQcReqd==null?" ":autoQcReqd;
//trimWidth = trimWidth==null?" ":trimWidth;
qcReqd = qcReqd==null?" ":qcReqd;
System.out.println("dimension :: " + dimension + " trimWidth :: " + trimWidth);
System.out.println("qcRecd :: " + qcReqd + " autoQcReqd :: " + autoQcReqd);
System.out.println("trackShelfLife :: " + trackShelfLife + " useInvStatus :: " + useInvStatus);
if (dimension.trim().length() == 0)
{ {
// check whether any valid record in stock exist for the item String supCodeList[];
// TO CHECK USE_INVSTATUS FROM BOMDET -- IF IT IS B THEN CHECK STAT_TYPE FROM INVSTAT String suppCodeTemp = "";
// to check all condition for auto_reqc
// Added Location code join to invstat supCodeList = suppCodeMfg.split(",");
if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("Y") && trackShelfLife.equalsIgnoreCase("Y") && useInvStatus.equalsIgnoreCase("U")) suppCodeMfg = "";
{ for(int ctr = 0;ctr < supCodeList.length;ctr++)
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND "
+ " A.ITEM_CODE = ? AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND ( A.EXP_DATE > ? OR A.EXP_DATE IS NULL) AND A.RETEST_DATE > ?";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setTimestamp(4, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
}
else if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("Y") && useInvStatus.equalsIgnoreCase("U"))
{
sql = "SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT "
+ " AND A.ITEM_CODE = ? AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND (A.EXP_DATE > ? OR A.EXP_DATE IS NULL)";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
}
else if (qcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("Y") && useInvStatus.equalsIgnoreCase("U"))
{
sql = "SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ "WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ "AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ "AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ "(CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ "AND (A.EXP_DATE > ? OR A.EXP_DATE IS NULL) ";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
}
else if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("Y") && trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("U"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND A.RETEST_DATE > ? ";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
}
else if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("U"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 ";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
}
else if (qcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("U"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 ";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
}
else if (qcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("B"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.STAT_TYPE <> 'S' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, dimension);
pstmt.setDouble(4, trimWidth);
}
else if (trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("B"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.STAT_TYPE <> 'S' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 ";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
}
else if (trackShelfLife.equalsIgnoreCase("Y") && useInvStatus.equalsIgnoreCase("B"))
{ {
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C " suppCodeTemp = supCodeList[ctr];
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? " if (suppCodeMfg.trim().length() > 0)
+ " AND A.SITE_CODE = ? AND C.STAT_TYPE <> 'S' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND (A.EXP_DATE > ? OR A.EXP_DATE IS NULL) ";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{ {
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") "; suppCodeMfg = suppCodeMfg + ",'".concat(suppCodeTemp).concat("'");
} }
// end 18/02/12 manoharan else
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{ {
sql = sql + " AND b.loc_group = '" + locGroup + "' "; suppCodeMfg = suppCodeMfg + "'".concat(suppCodeTemp).concat("'");
} }
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
} }
} }
else System.out.println("dimension :: " + dimension + " trimWidth :: " + trimWidth);
System.out.println("qcRecd :: " + qcReqd + " autoQcReqd :: " + autoQcReqd);
System.out.println("trackShelfLife :: " + trackShelfLife + " useInvStatus :: " + useInvStatus);
if (dimension != null && dimension.trim().length() > 0)
{ {
fgItem = genericUtility.getColumnValue("item_code", dom1); fgItem = genericUtility.getColumnValue("item_code", dom1);
sql = "SELECT A.TRIM_WIDTH FROM ITEM_TYPE A, ITEM B WHERE A.ITEM_TYPE = B.ITEM_TYPE AND B.ITEM_CODE = ?"; sql = "SELECT A.TRIM_WIDTH FROM ITEM_TYPE A, ITEM B WHERE A.ITEM_TYPE = B.ITEM_TYPE AND B.ITEM_CODE = ?";
...@@ -650,258 +434,74 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -650,258 +434,74 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
} }
pstmt.close(); pstmt.close();
rs.close(); rs.close();
System.out.println("dimension :: " + dimension + " trimWidth :: " + trimWidth);
// TO CHECK USE_INVSTATUS FROM BOMDET
// IF IT IS B THEN CHECK STAT_TYPE FROM INVSTAT
if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("Y") && trackShelfLife.equalsIgnoreCase("Y") && useInvStatus.equalsIgnoreCase("U"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND "
+ " A.ITEM_CODE = ? AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND ( A.EXP_DATE > ? OR A.EXP_DATE IS NULL) AND A.RETEST_DATE > ?"
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setTimestamp(4, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setString(5, dimension);
pstmt.setDouble(6, trimWidth);
}
else if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("Y") && useInvStatus.equalsIgnoreCase("U"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT "
+ " AND A.ITEM_CODE = ? AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND (A.EXP_DATE > ? OR A.EXP_DATE IS NULL)"
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setString(4, dimension);
pstmt.setDouble(5, trimWidth);
}
else if (qcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("Y") && useInvStatus.equalsIgnoreCase("U"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND (A.EXP_DATE > ? OR A.EXP_DATE IS NULL) "
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setString(4, dimension);
pstmt.setDouble(5, trimWidth);
}
else if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("Y") && trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("U"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND A.RETEST_DATE > ? "
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setString(4, dimension);
pstmt.setDouble(5, trimWidth);
}
else if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("U"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, dimension);
pstmt.setDouble(4, trimWidth);
}
else if (qcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("U"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.AVAILABLE = 'Y' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, dimension);
pstmt.setDouble(4, trimWidth);
}
else if (qcReqd.equalsIgnoreCase("N") && trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("B"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.STAT_TYPE <> 'S' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, dimension);
pstmt.setDouble(4, trimWidth);
}
else if (trackShelfLife.equalsIgnoreCase("N") && useInvStatus.equalsIgnoreCase("B"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.STAT_TYPE <> 'S' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setString(3, dimension);
pstmt.setDouble(4, trimWidth);
}
else if (trackShelfLife.equalsIgnoreCase("Y") && useInvStatus.equalsIgnoreCase("B"))
{
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND A.ITEM_CODE = ? "
+ " AND A.SITE_CODE = ? AND C.STAT_TYPE <> 'S' "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 "
+ " AND (A.EXP_DATE > ? OR A.EXP_DATE IS NULL) "
+ " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setString(4, dimension);
pstmt.setDouble(5, trimWidth);
}
} }
System.out.println("SQL :" + sql); // 27/12/12 manoharan
sql = " SELECT COUNT(A.ITEM_CODE) FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND "
+ " A.ITEM_CODE = ? AND A.SITE_CODE = ? "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 ";
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
if (suppCodeMfg != null && !"null".equals(suppCodeMfg) && suppCodeMfg.trim().length() > 0)
{
sql = sql + " AND A.supp_code__mfg IN (" + suppCodeMfg + ") ";
}
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
if ( "U".equalsIgnoreCase(useInvStatus))
{
sql = sql + " AND C.AVAILABLE = 'Y' ";
}
if ("Y".equalsIgnoreCase(trackShelfLife))
{
sql = sql + " AND ( A.EXP_DATE > ? OR A.EXP_DATE IS NULL) ";
}
if ("Y".equalsIgnoreCase(qcReqd) && "Y".equalsIgnoreCase(autoQcReqd))
{
sql = sql + " AND A.RETEST_DATE > ?";
}
if (dimension != null && dimension.trim().length() > 0)
{
sql = sql + " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
if ("Y".equalsIgnoreCase(trackShelfLife) && ("Y".equalsIgnoreCase(qcReqd) && "Y".equalsIgnoreCase(autoQcReqd)) && dimension != null && dimension.trim().length() > 0 )
{
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setTimestamp(4, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setString(5, dimension);
pstmt.setDouble(6, trimWidth);
}
else if (!"Y".equalsIgnoreCase(trackShelfLife) && ("Y".equalsIgnoreCase(qcReqd) && "Y".equalsIgnoreCase(autoQcReqd)) && dimension != null && dimension.trim().length() > 0 )
{
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setString(4, dimension);
pstmt.setDouble(5, trimWidth);
}
else if ("Y".equalsIgnoreCase(trackShelfLife) && (!"Y".equalsIgnoreCase(qcReqd) || !"Y".equalsIgnoreCase(autoQcReqd)) && dimension != null && dimension.trim().length() > 0 )
{
pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
pstmt.setString(4, dimension);
pstmt.setDouble(5, trimWidth);
}
else if (!"Y".equalsIgnoreCase(trackShelfLife) && (!"Y".equalsIgnoreCase(qcReqd) || !"Y".equalsIgnoreCase(autoQcReqd)) && dimension != null && dimension.trim().length() > 0 )
{
pstmt.setString(3, dimension);
pstmt.setDouble(4, trimWidth);
}
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next()) {
countItemCode = rs.getInt(1); countItemCode = rs.getInt(1);
...@@ -945,70 +545,52 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -945,70 +545,52 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
useInvStatus = "U"; useInvStatus = "U";
} }
if (useInvStatus == null || useInvStatus.trim().length()==0 || useInvStatus.equalsIgnoreCase("U"))
{
sqlSB.append(" SELECT A.ITEM_SER, A.ITEM_CODE, A.UNIT, A.LOC_CODE, A.LOT_NO, A.LOT_SL, ");
sqlSB.append(" A.QUANTITY - A.ALLOC_QTY AS QUANTITY, A.SITE_CODE, A.EXP_DATE, A.RETEST_DATE, ");
sqlSB.append(" A.DIMENSION, A.RATE, A.CREA_DATE, ");
sqlSB.append(" CASE WHEN LENGTH(RTRIM(A.LOT_SL)) = 1 THEN '0' || RTRIM(A.LOT_SL) ELSE RTRIM(A.LOT_SL) END ");
sqlSB.append(" FROM STOCK A, INVSTAT B, LOCATION C WHERE ( A.LOC_CODE = C.LOC_CODE ) AND ");
sqlSB.append(" ( C.INV_STAT = B.INV_STAT ) AND (A.ITEM_CODE = ?) AND (A.SITE_CODE = ?) AND ");
sqlSB.append(" (A.QUANTITY - A.ALLOC_QTY > 0) AND (B.AVAILABLE = 'Y') AND (B.STAT_TYPE <> 'S') ");
if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("Y")) // 27/12/12 manoharan
{ sql = " SELECT A.ITEM_SER, A.ITEM_CODE, A.UNIT, A.LOC_CODE, A.LOT_NO, A.LOT_SL, "
sqlSB.append("AND (A.RETEST_DATE IS NULL OR A.RETEST_DATE > ?)"); + " A.QUANTITY - A.ALLOC_QTY AS QUANTITY, A.SITE_CODE, A.EXP_DATE, A.RETEST_DATE, "
} + " A.DIMENSION, A.RATE, A.CREA_DATE, "
+ " CASE WHEN LENGTH(RTRIM(A.LOT_SL)) = 1 THEN '0' || RTRIM(A.LOT_SL) ELSE RTRIM(A.LOT_SL) END "
+ " FROM STOCK A, LOCATION B, INVSTAT C "
+ " WHERE A.LOC_CODE = B.LOC_CODE AND B.INV_STAT = C.INV_STAT AND "
+ " A.ITEM_CODE = ? AND A.SITE_CODE = ? "
+ " AND ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 ";
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
} }
else if (useInvStatus.equalsIgnoreCase("B")) if (suppCodeMfg != null && !"null".equals(suppCodeMfg) && suppCodeMfg.trim().length() > 0)
{ {
sqlSB.append(" SELECT A.ITEM_SER, A.ITEM_CODE, A.UNIT, A.LOC_CODE, A.LOT_NO, A.LOT_SL, "); sql = sql + " AND A.supp_code__mfg IN (" + suppCodeMfg + ") ";
sqlSB.append(" A.QUANTITY - A.ALLOC_QTY AS QUANTITY, A.SITE_CODE, A.EXP_DATE, A.RETEST_DATE, ");
sqlSB.append(" A.DIMENSION, A.RATE, A.CREA_DATE, ");
sqlSB.append(" CASE WHEN LENGTH(RTRIM(A.LOT_SL)) = 1 THEN '0' || RTRIM(A.LOT_SL) ELSE RTRIM(A.LOT_SL) END ");
sqlSB.append(" FROM STOCK A, INVSTAT B, LOCATION C WHERE (C.LOC_CODE = C.LOC_CODE) AND (C.INV_STAT = B.INV_STAT) AND ( A.ITEM_CODE = ?) ");
sqlSB.append(" AND (A.SITE_CODE = ? ) AND (A.QUANTITY - A.ALLOC_QTY > 0 ) AND ( B.STAT_TYPE <> 'S' ) ");
sqlSB.append(" AND NOT EXISTS (SELECT 1 FROM QC_ORDER C WHERE A.SITE_CODE = C.SITE_CODE ");
sqlSB.append(" AND A.ITEM_CODE = C.ITEM_CODE AND A.LOT_NO = C.LOT_NO AND A.LOC_CODE = C.LOC_CODE ");
sqlSB.append(" AND CASE WHEN C.STATUS IS NULL THEN 'U' ELSE C.STATUS END) = 'U' " );
sqlSB.append(" AND (A.LOT_SL = C.LOT_SL OR C.LOT_SL IS NULL))");
} }
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
if (trackShelfLife.equalsIgnoreCase("Y"))
{ {
sqlSB.append(" AND (A.EXP_DATE IS NULL OR A.EXP_DATE > ?)"); sql = sql + " AND b.loc_group = '" + locGroup + "' ";
} }
if ( "U".equalsIgnoreCase(useInvStatus))
if (dimension.trim().length() > 0)
{ {
sqlSB.append("AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, 0) = 'Y'"); sql = sql + " AND C.AVAILABLE = 'Y' ";
} }
sql = sqlSB.toString(); if ("Y".equalsIgnoreCase(trackShelfLife))
// 18/02/12 manoharan
if ("Y".equals(considerLotNoIssue) && lotNoIssue != null && !"null".equals(lotNoIssue) && lotNoIssue.trim().length() > 0)
{ {
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") "; sql = sql + " AND ( A.EXP_DATE > ? OR A.EXP_DATE IS NULL) ";
} }
// end 18/02/12 manoharan if ("Y".equalsIgnoreCase(qcReqd) && "Y".equalsIgnoreCase(autoQcReqd))
// 26/03/12 manoharan {
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) ) sql = sql + " AND A.RETEST_DATE > ?";
}
if (dimension != null && dimension.trim().length() > 0)
{ {
sql = sql + " AND C.loc_group = '" + locGroup + "' "; sql = sql + " AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'";
} }
// end 26/03/12 manoharan // end 26/03/12 manoharan
// 02/04/12 manoharan sorting to be doen as per PB logic // 02/04/12 manoharan sorting to be doen as per PB logic
//changes done by cpandey additin condition for track shelf life on 20/08/12 //changes done by cpandey additin condition for track shelf life on 20/08/12
if("N".equalsIgnoreCase(trackShelfLife)) sql = sql + " order by partial_used,decode('N','P',decode(rtrim(b.loc_group),rtrim(''),'A','B'),'0'), " ;
{
sql = sql + " order by partial_used,decode('N','P',decode(rtrim(c.loc_group),rtrim(''),'A','B'),'0'), " ;
System.out.println("sql If track self life is N ["+sql+"]>>");
}
if("Y".equalsIgnoreCase(trackShelfLife))
{
sql = sql + " order by partial_used,decode('N','P',decode(rtrim(c.loc_group),rtrim(''),'A','B'),'0'), " ;
System.out.println("sql sql If track self life is Y--["+sql+"]>>");
}
//end of changes on 20/08/12 //end of changes on 20/08/12
//commented by cpandey //commented by cpandey
//sql = sql + " order by partial_used, (case when '" + locUsageType + "' = 'P' then (case when rtrim(c.loc_group) = rtrim('" + locGroup + "') Then 'A' else 'B' end) else '0' end), " ; //sql = sql + " order by partial_used, (case when '" + locUsageType + "' = 'P' then (case when rtrim(c.loc_group) = rtrim('" + locGroup + "') Then 'A' else 'B' end) else '0' end), " ;
...@@ -1032,44 +614,33 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -1032,44 +614,33 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
" 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) - 1)) ,rtrim(a.lot_sl)) )) "; " 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) - 1)) ,rtrim(a.lot_sl)) )) ";
} }
// end 02/04/12 manoharan // end 02/04/12 manoharan
System.out.println("sqlSB converted ::: "+ sql);
StringTokenizer st = new StringTokenizer(sql, "?");
cntQ = st.countTokens();
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
flag1 = false; flag2 = false;
pstmt.setString(1, itemCode); pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode); pstmt.setString(2, siteCode);
System.out.println("itemCode :: " + itemCode + " siteCode :: " + siteCode);
for (int i=3; i<cntQ; i++) if ("Y".equalsIgnoreCase(trackShelfLife) && ("Y".equalsIgnoreCase(qcReqd) && "Y".equalsIgnoreCase(autoQcReqd)) && dimension != null && dimension.trim().length() > 0 )
{ {
if ((useInvStatus == null || useInvStatus.trim().length()==0 || useInvStatus.equalsIgnoreCase("U")) && flag1 == false) pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
{ pstmt.setTimestamp(4, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
if (qcReqd.equalsIgnoreCase("Y") && autoQcReqd.equalsIgnoreCase("Y")) pstmt.setString(5, dimension);
{ pstmt.setDouble(6, trimWidth);
pstmt.setTimestamp(i, Timestamp.valueOf(genericUtility.getValidDateString(retestDt, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())+ " 00:00:00")); }
System.out.println ("retestDate set"); else if (!"Y".equalsIgnoreCase(trackShelfLife) && ("Y".equalsIgnoreCase(qcReqd) && "Y".equalsIgnoreCase(autoQcReqd)) && dimension != null && dimension.trim().length() > 0 )
flag1 = true; {
continue; pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
} pstmt.setString(4, dimension);
} pstmt.setDouble(5, trimWidth);
}
if (trackShelfLife.equalsIgnoreCase("Y") && flag2 == false) else if ("Y".equalsIgnoreCase(trackShelfLife) && (!"Y".equalsIgnoreCase(qcReqd) || !"Y".equalsIgnoreCase(autoQcReqd)) && dimension != null && dimension.trim().length() > 0 )
{ {
pstmt.setTimestamp(i, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00")); pstmt.setTimestamp(3, Timestamp.valueOf(genericUtility.getValidDateString(effDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00"));
System.out.println ("effDate set"); pstmt.setString(4, dimension);
flag2 = true; pstmt.setDouble(5, trimWidth);
continue; }
else if (!"Y".equalsIgnoreCase(trackShelfLife) && (!"Y".equalsIgnoreCase(qcReqd) || !"Y".equalsIgnoreCase(autoQcReqd)) && dimension != null && dimension.trim().length() > 0 )
} {
if (dimension.trim().length() > 0) pstmt.setString(3, dimension);
{ pstmt.setDouble(4, trimWidth);
pstmt.setString(i, dimension);
pstmt.setDouble(i+1, trimWidth);
break;
}
} }
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
...@@ -1362,7 +933,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -1362,7 +933,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
double stockQuantity = 0d; double stockQuantity = 0d;
String retNoArt = null, locGroup = "", locUsageType = ""; String retNoArt = null, locGroup = "", locUsageType = "", suppCodeMfg = "";
ArrayList noArtDetArrLst = new ArrayList(); ArrayList noArtDetArrLst = new ArrayList();
PreparedStatement pstmt = null, pstmt1 = null, cpstmt1 = null; PreparedStatement pstmt = null, pstmt1 = null, cpstmt1 = null;
Connection conn = null; Connection conn = null;
...@@ -1469,7 +1040,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -1469,7 +1040,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
{ {
itemCodeMain = rs.getString(1); itemCodeMain = rs.getString(1);
itemCodeRef = rs.getString(2); itemCodeRef = rs.getString(2);
sql = "SELECT DIMENSION, USE_INVSTATUS FROM BOMDET WHERE BOM_CODE = ? AND ITEM_CODE = ? AND ITEM_REF = ?"; sql = "SELECT DIMENSION, USE_INVSTATUS,SUPP_CODE__MFG FROM BOMDET WHERE BOM_CODE = ? AND ITEM_CODE = ? AND ITEM_REF = ?";
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, bomCode); pstmt1.setString(1, bomCode);
pstmt1.setString(2, itemCodeMain); pstmt1.setString(2, itemCodeMain);
...@@ -1482,15 +1053,37 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -1482,15 +1053,37 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
{ {
dimension = rs1.getString(1)==null?"":rs1.getString(1); dimension = rs1.getString(1)==null?"":rs1.getString(1);
useInvStatus = rs1.getString(2)==null?"U":rs1.getString(2); useInvStatus = rs1.getString(2)==null?"U":rs1.getString(2);
suppCodeMfg = rs1.getString(3)==null?"U":rs1.getString(3);
} }
pstmt1.close(); pstmt1.close();
rs1.close(); rs1.close();
} }
useInvStatus = useInvStatus==null?" ":useInvStatus;
dimension = dimension==null?" ":dimension;
pstmt.close(); pstmt.close();
rs.close(); rs.close();
if (suppCodeMfg != null && !"null".equals(suppCodeMfg) && suppCodeMfg.trim().length() > 0)
{
String supCodeList[];
String suppCodeTemp = "";
supCodeList = suppCodeMfg.split(",");
suppCodeMfg = "";
for(int ctr = 0;ctr < supCodeList.length;ctr++)
{
suppCodeTemp = supCodeList[ctr];
if (suppCodeMfg.trim().length() > 0)
{
suppCodeMfg = suppCodeMfg + ",'".concat(suppCodeTemp).concat("'");
}
else
{
suppCodeMfg = suppCodeMfg + "'".concat(suppCodeTemp).concat("'");
}
}
}
// NOT TO BE INCLUDED AS RND NOT CONSIDERED -- ALKA // NOT TO BE INCLUDED AS RND NOT CONSIDERED -- ALKA
// sql = "SELECT ORDER_TYPE FROM WORKORDER WHERE WORK_ORDER = ?"; // sql = "SELECT ORDER_TYPE FROM WORKORDER WHERE WORK_ORDER = ?";
...@@ -1625,8 +1218,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -1625,8 +1218,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
System.out.println("locCode ::: " + locCode + "trackShelfLife ::: " + trackShelfLife ); System.out.println("locCode ::: " + locCode + "trackShelfLife ::: " + trackShelfLife );
System.out.println("useInvStatus ::: " + useInvStatus + "dimension ::: " + dimension ); System.out.println("useInvStatus ::: " + useInvStatus + "dimension ::: " + dimension );
useInvStatus = useInvStatus==null?" ":useInvStatus;
dimension = dimension==null?" ":dimension;
if ((locCode == null || locCode.trim().length() == 0) || (lotNo == null || lotNo.trim().length() == 0)) if ((locCode == null || locCode.trim().length() == 0) || (lotNo == null || lotNo.trim().length() == 0))
{ {
...@@ -1662,12 +1253,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -1662,12 +1253,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
{ {
sql = sql + " AND c.loc_group = '" + locGroup + "' "; sql = sql + " AND c.loc_group = '" + locGroup + "' ";
} }
// added by cpatil start on 9/11/12
//sql = sql + "order by (CASE WHEN SUM(A.QUANTITY - A.ALLOC_QTY) IS NULL THEN 0 ELSE SUM(A.QUANTITY - A.ALLOC_QTY) END) ";
// " order by sum( (case when quantity is null then 0 else quantity end) " +
// " - (case when alloc_qty is null then 0 else alloc_qty end) " +
// " - (case when hold_qty is null then 0 else hold_qty end) )";
// end by cpatil
// end 26/03/12 manoharan // end 26/03/12 manoharan
System.out.println("sqlSB converted ::: "+ sql); System.out.println("sqlSB converted ::: "+ sql);
StringTokenizer st = new StringTokenizer(sql, "?"); StringTokenizer st = new StringTokenizer(sql, "?");
...@@ -1764,32 +1349,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -1764,32 +1349,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
{ {
sql = sql + " AND c.loc_group = '" + locGroup + "' "; sql = sql + " AND c.loc_group = '" + locGroup + "' ";
} }
// 22/12/12 manoharan
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME))
{
sql = sql + " nvl(a.exp_date,a.crea_date),a.crea_date,a.lot_no ";
//System.out.println("after sql db converted --["+sql+"]->.");
}
else
{
sql = sql + " order by a.partial_used,nvl(a.exp_date,a.crea_date),a.crea_date,a.lot_no, "
+ " decode(length(decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) ," +
" 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) - 1)) ,rtrim(a.lot_sl)) ), "
+ " 1, '00' || decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) , " +
"'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) )) ,rtrim(a.lot_sl)), "
+" decode(length(decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) , 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) - 1)) ,rtrim(a.lot_sl)) ), "
+ " 2, '0' || decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) , 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) )) ,rtrim(a.lot_sl)), "
+" decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) ," +
" 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) - 1)) ,rtrim(a.lot_sl)) )) ";
}
// added by cpatil start on 9/11/12
//sql = sql + " order by (A.QUANTITY - A.ALLOC_QTY) ";
//" order by sum( (case when quantity is null then 0 else quantity end) " +
//" - (case when alloc_qty is null then 0 else alloc_qty end) " +
// " - (case when hold_qty is null then 0 else hold_qty end) )";
// end by cpatil
// end 26/03/12 manoharan // end 26/03/12 manoharan
System.out.println("sqlSB1 converted ::: "+ sql); System.out.println("sqlSB1 converted ::: "+ sql);
...@@ -1995,30 +1554,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL ...@@ -1995,30 +1554,6 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
{ {
sql = sql + " AND c.loc_group = '" + locGroup + "' "; sql = sql + " AND c.loc_group = '" + locGroup + "' ";
} }
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME))
{
sql = sql + " order by a.partial_used,nvl(a.exp_date,a.crea_date),a.crea_date,a.lot_no ";
//System.out.println("after sql db converted --["+sql+"]->.");
}
else
{
sql = sql + " order by a.partial_used,nvl(a.exp_date,a.crea_date),a.crea_date,a.lot_no, "
+ " decode(length(decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) ," +
" 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) - 1)) ,rtrim(a.lot_sl)) ), "
+ " 1, '00' || decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) , " +
"'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) )) ,rtrim(a.lot_sl)), "
+" decode(length(decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) , 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) - 1)) ,rtrim(a.lot_sl)) ), "
+ " 2, '0' || decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) , 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) )) ,rtrim(a.lot_sl)), "
+" decode( substr(rtrim(a.lot_sl), length(rtrim(a.lot_sl))) ," +
" 'S',(substr(rtrim(a.lot_sl),1,length(rtrim(a.lot_sl)) - 1)) ,rtrim(a.lot_sl)) )) ";
}
// added by cpatil start on 9/11/12
//sql = sql + " order by (CASE WHEN SUM(A.QUANTITY-A.ALLOC_QTY) IS NULL THEN 0 ELSE SUM(A.QUANTITY-A.ALLOC_QTY) END) ";
//" order by sum( (case when quantity is null then 0 else quantity end) " +
//" - (case when alloc_qty is null then 0 else alloc_qty end) " +
//" - (case when hold_qty is null then 0 else hold_qty end) )";
// end by cpatil
// end 26/03/12 manoharan // end 26/03/12 manoharan
System.out.println("sqlSB converted ::: "+ sql); System.out.println("sqlSB converted ::: "+ sql);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment