//Added by Naren
public HashMap searchAppointmentExecute() {
// ArrayList<String> orderStatusVal = new ArrayList<String>();//Added by Bush Adimulapu :: 11-Aug-2022
HashMap<String, String> orderStatusValMap =
new HashMap<String, String>(); //Added by Madhavi Bolloju :: 11-Oct-2022
HashMap shipOrderMap = null;
TWCYMTAppointmentDashboardSearchVOImpl appointmentSearchVO = this.getTWCYMTAppointmentDashboardSearchVO1();
TWCYMTAppointmentDashboardSearchVORowImpl appointmentSearchRow =
(TWCYMTAppointmentDashboardSearchVORowImpl) appointmentSearchVO.getCurrentRow();
_logger.info("Organization_code: " + appointmentSearchRow.getOrganizationCode() + " appointment_date: " +
appointmentSearchRow.getAppointmentDate() + " service_type: " +
appointmentSearchRow.getServiceType() + " Appointment Number: " +
appointmentSearchRow.getAppointmentNum() + " Sales order number: " +
appointmentSearchRow.getSalesOrdNum() + " AppointmentTodate: " +
appointmentSearchRow.getAppointmentTodate());
ADFContext adfCtx = null;
adfCtx = ADFContext.getCurrent();
long noOfDays = (Long)adfCtx.getPageFlowScope().get("NOOFDAYS");
System.out.println("AM noOfDays@@"+noOfDays);
if(noOfDays==0L){
TWCYMTAppointmentDashboardVOImpl appointmentVO = this.getTWCYMTAppointmentDashboardVO1(); //Pivot query
appointmentVO.setNamedWhereClauseParam("pfacility", appointmentSearchRow.getOrganizationCode());
appointmentVO.setNamedWhereClauseParam("pplannedstartdate", appointmentSearchRow.getAppointmentDate());
_logger.info("appointmentVO getQuery " + appointmentVO.getQuery());
appointmentVO.executeQuery();
// _logger.info("appointmentVO estimatedRowCount "+appointmentVO.getEstimatedRowCount());
//HashMap shipOrderMap = null;
shipOrderMap = new HashMap();
RowSet rs = appointmentVO.getRowSet();
RowSetIterator rowIter = rs.createRowSetIterator(null);
while (rowIter.hasNext()) {
Row row = rowIter.next();
shipOrderMap.put(row.getAttribute("Orders"), row.getAttribute("ShipCode"));
//_logger.info("map values " + row.getAttribute("Orders") + " - " + row.getAttribute("ShipCode"));
}
}
//rowIter.closeRowSetIterator();
//rs.closeRowSet();
_logger.info("AMImpl shipOrderMap " + shipOrderMap);
/* TWCYMTDraftAppointmentsVOImpl draftAppointmentVO = this.getTWCYMTDraftAppointmentsVO1();
draftAppointmentVO.setNamedWhereClauseParam("pfacility",appointmentSearchRow.getOrganizationCode());
draftAppointmentVO.setNamedWhereClauseParam("pplannedstartdate", appointmentSearchRow.getAppointmentDate());
draftAppointmentVO.setNamedWhereClauseParam("pservicetype", appointmentSearchRow.getServiceType());
//#828-TMS Enhancements-48- Added by Manasa Yalamarthy on 18th Dec,2020
draftAppointmentVO.setNamedWhereClauseParam("psales_order_number", appointmentSearchRow.getSalesOrdNum());
draftAppointmentVO.setNamedWhereClauseParam("pappointmentnum", appointmentSearchRow.getAppointmentNum());
draftAppointmentVO.setNamedWhereClauseParam("pwmsordernumber", appointmentSearchRow.getWmsOrderNum()); // Added by Jayanand for TMS 1A Issues 02-06-2021
draftAppointmentVO.setNamedWhereClauseParam("pShipmentNo", appointmentSearchRow.getShipmentNum()); // Added by Muzammil :: OTM TMS changes
_logger.info("draftAppointmentVO getQuery "+ draftAppointmentVO.getQuery());
draftAppointmentVO.executeQuery();
_logger.info("draftAppointmentVO estimatedRowCount "+draftAppointmentVO.getEstimatedRowCount()); */
TWCYMTAppointmentVOImpl appointmentHdrVO = this.getTWCYMTAppointmentVO1();
ViewCriteria vc = appointmentHdrVO.getViewCriteria("TWCYMTAppointmentVOCriteria");
appointmentHdrVO.applyViewCriteria(vc);
appointmentHdrVO.setNamedWhereClauseParam("pAppointmentNumber", appointmentSearchRow.getAppointmentNum());
appointmentHdrVO.setNamedWhereClauseParam("pFacility", appointmentSearchRow.getOrganizationCode());
appointmentHdrVO.setNamedWhereClauseParam("pDock", "");
appointmentHdrVO.setNamedWhereClauseParam("pFromDate", appointmentSearchRow.getAppointmentDate());
appointmentHdrVO.setNamedWhereClauseParam("pToDate", appointmentSearchRow.getAppointmentTodate());
appointmentHdrVO.setNamedWhereClauseParam("pStatus", appointmentSearchRow.getStatus());
appointmentHdrVO.setNamedWhereClauseParam("pServiceType", appointmentSearchRow.getServiceType());
appointmentHdrVO.setNamedWhereClauseParam("pLoadNumber", appointmentSearchRow.getShipmentNum());
appointmentHdrVO.setNamedWhereClauseParam("pSalesOrderNbr", appointmentSearchRow.getSalesOrdNum());
appointmentHdrVO.setNamedWhereClauseParam("pWmsorderNum", appointmentSearchRow.getWmsOrderNum());
_logger.info("appointmentHdrVO getQuery " + appointmentHdrVO.getQuery());
appointmentHdrVO.executeQuery();
//Get Order Status with API :: Added by Bush Adimulapu
this.getWMSEnvDetails();
// RowSetIterator draftRowIter = draftAppointmentVO.createRowSetIterator(null);
RowSetIterator draftRowIter = appointmentHdrVO.createRowSetIterator(null);
ArrayList<String> salesOrderNumArray = new ArrayList<String>();
while (draftRowIter.hasNext()) {
Row row = draftRowIter.next();
String salesOrderNum = (String) row.getAttribute("SalesOrderNbr");
_logger.info("SalesOrderNbr " + salesOrderNum);
if (!salesOrderNumArray.contains(salesOrderNum)) {
salesOrderNumArray.add((String) row.getAttribute("SalesOrderNbr"));
}
}
//Below logic added by Janardhan on Oct 18,2022
String orderList = salesOrderNumArray.toString();
orderList = orderList.replace("[", "")
.replace("]", "")
.replace(" ", "");
_logger.info("order list is " + orderList);
//Get order Status With single API call:: Added By Madhavi Bolloju
orderStatusValMap = this.getAppointmentStatus(orderList);
_logger.info("orderStatusVal.size(): " + orderStatusValMap.size());
draftRowIter.reset();
while (draftRowIter.hasNext()) {
//Row row = draftRowIter.next();
TWCYMTAppointmentVORowImpl row = (TWCYMTAppointmentVORowImpl)draftRowIter.next();
String salesOrderNum = (String) row.getAttribute("SalesOrderNbr");
_logger.info("SalesOrderNbr " + salesOrderNum);
//String statusId = orderStatusValMap.get(salesOrderNum);
//Added by Janardhan Chilukuri :: 06 Jan 2023 for Order Status
String statusId = "";
String status = "";
if (salesOrderNum!=null && salesOrderNum.contains(",") && !orderStatusValMap.isEmpty()) {
String[] salesOrders = salesOrderNum.split(",");
for (String order : salesOrders) {
_logger.info("Sales Order Number is " + order);
System.out.println("Sales Order Number is " + order);
status = orderStatusValMap.get(order);
System.out.println("status is " + status);
RowIterator ordIter = row.getTWCYMTAppointmentOrdersVO();
while(ordIter.hasNext()){
Row row1 = (Row) ordIter.next();
System.out.println(order+":order @@SalesOrderNumber@@"+row1.getAttribute("SalesOrderNumber").toString());
if(row1.getAttribute("SalesOrderNumber").toString().equalsIgnoreCase(order)){
status = status == null ? "0" : status;
if (status != null) {
if (status.equalsIgnoreCase("0")) {
row1.setAttribute("Description", "Created"); //SalesOrderStatus
} else if (status.equalsIgnoreCase("90")) {
row1.setAttribute("Description", "Shipped");
} else {
row1.setAttribute("Description", "In Progress");
}
}
//row1.setAttribute("Description", status);
}
}
}
} else {
statusId = orderStatusValMap.get(salesOrderNum);
}
statusId = statusId == null ? "0" : statusId;
if (statusId != null) {
if (statusId.equalsIgnoreCase("0")) {
row.setAttribute("SalesOrderStatus", "Created"); //SalesOrderStatus
} else if (statusId.equalsIgnoreCase("90")) {
row.setAttribute("SalesOrderStatus", "Shipped");
} else {
row.setAttribute("SalesOrderStatus", "In Progress");
}
}
}
draftRowIter.closeRowSetIterator();
return shipOrderMap;
}