Files
matrix/src/matrix/nimble/edp/tools/controller/EDPTools.java
2025-04-19 17:50:17 +05:30

190 lines
7.8 KiB
Java

package matrix.nimble.edp.tools.controller;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import matrix.nimble.edp.tools.model.DelCaseGrid;
import matrix.nimble.edp.tools.model.EdpToolsHandler;
import matrix.nimble.edp.tools.model.AddEditProduct;
import matrix.nimble.edp.tools.model.CutoffPending;
import matrix.nimble.model.Session;
import matrix.nimble.utilities.GlobalClass;
import matrix.nimble.utilities.ModuleFunctions;
import matrix.nimble.utilities.DBFunctions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;
@Controller
@SessionAttributes({"Sessvals"})
public class EDPTools
{
@RequestMapping(value="cutoffpending",method=RequestMethod.POST )
public String PendingProcess(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals,HttpSession session)
{
CutoffPending PList=new CutoffPending();
PList.setErrCode("1010");
String UUID=GlobalClass.GenerateUUID();
session.setAttribute("UUID", UUID);
PList.setSessUUID(UUID);
model.addAttribute("cutoffpending", PList.getPList(Sessvals.getCompanyID(), Sessvals.getBranchID(), Sessvals.getUserID()));
model.addAttribute("Sessvals",Sessvals);
return "edp/tools/edpprocesspanel";
}
@RequestMapping(value="savecutoffpending",method=RequestMethod.POST )
public String SavePendingProcess(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals,@ModelAttribute(value="cutoffpending") CutoffPending CPend,HttpSession session)
{
CPend.setErrCode("1010");
if(session.getAttribute("UUID").toString().equals(CPend.getSessUUID()))
{
CPend.FinalizeCutoffPending(Sessvals.getUserID(),Sessvals.getCompanyID(), Sessvals.getBranchID(),CPend);
}
else
{
CPend.setProcessFlag(true);
CPend.setErrMsg("");
}
if(CPend.isProcessFlag())
{
CutoffPending PList=new CutoffPending();
String UUID=GlobalClass.GenerateUUID();
session.setAttribute("UUID", UUID);
PList.setSessUUID(UUID);
model.addAttribute("cutoffpending", PList.getPList(Sessvals.getCompanyID(), Sessvals.getBranchID(), Sessvals.getUserID()));
PList.setErrCode(CPend.getErrCode());
PList.setErrMsg(CPend.getErrMsg());
model.addAttribute("cutoffpending", PList);
model.addAttribute("Sessvals",Sessvals);
}
else
{
model.addAttribute("cutoffpending",CPend);
}
model.addAttribute("Sessvals",Sessvals);
return "edp/tools/edpprocesspanel";
}
@RequestMapping(value="delcutoffgrid",method=RequestMethod.POST )
public String OpenEditGrid(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals)
{
String [][]CaseList=null;
DelCaseGrid CG=new DelCaseGrid();
model.addAttribute("Sessvals",Sessvals);
model.addAttribute("caseList",CaseList);
model.addAttribute("portlist",FillPortList(Sessvals.getBranchID()));
model.addAttribute("caseGrid",CG);
return "edp/tools/delcutoffcases";
}
@RequestMapping(value="delcaselist",method=RequestMethod.POST )
public String ListCases(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals,@ModelAttribute(value="caseGrid") DelCaseGrid delcaseGrid)
{
DelCaseGrid DCG=new DelCaseGrid();
DCG.setErrCode("1011");
DCG.setPortfolioId(delcaseGrid.getPortfolioId());
model.addAttribute("portlist",FillPortList(Sessvals.getBranchID()));
String [][]CaseList=DCG.FillCaseList(delcaseGrid.getPortfolioId(), Sessvals.getBranchID());
if(DCG.isProcessFlag())
{
model.addAttribute("caseList",CaseList);
model.addAttribute("caseGrid",DCG);
}
else
{
delcaseGrid.setErrMsg(DCG.getErrMsg());
model.addAttribute("caseList",CaseList);
model.addAttribute("caseGrid",delcaseGrid);
}
model.addAttribute("Sessvals",Sessvals);
return "edp/tools/delcutoffcases";
}
@RequestMapping(value="deletecases",method=RequestMethod.POST )
public String DelCases(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals,@ModelAttribute(value="caseGrid") DelCaseGrid delcaseGrid)
{
String Cond="",Temp="";
delcaseGrid.setErrCode("1011");
Cond=delcaseGrid.getDelStat();
String [][]CaseList=null;
DelCaseGrid CG=new DelCaseGrid();
model.addAttribute("Sessvals",Sessvals);
model.addAttribute("caseList",CaseList);
model.addAttribute("portlist",FillPortList(Sessvals.getBranchID()));
DBFunctions DBF=new DBFunctions(delcaseGrid.getErrCode());
DBF.setProcessFlag(true);
if(!Cond.equals(""))
{
Cond=Cond.substring(0,Cond.length()-1);
Cond=Cond.replace(",", " or uuid=");
Cond=" uuid="+Cond+GlobalClass.ColDelim;
Temp=DBF.FetchRunQuery(55, Cond.split(GlobalClass.ColDelim));
if(DBF.isProcessFlag())
{
delcaseGrid.setErrMsg("Record Deleted Successfully...."+delcaseGrid.getErrMsg());
CG.setErrCode(delcaseGrid.getErrCode());
CG.setErrMsg(delcaseGrid.getErrMsg());
}
else
{
delcaseGrid.setErrMsg("Record Deleted Failed...."+delcaseGrid.getErrMsg());
CG.setErrCode(delcaseGrid.getErrCode());
CG.setErrMsg(delcaseGrid.getErrMsg());
}
}
model.addAttribute("caseGrid",CG);
return "edp/tools/delcutoffcases";
}
public HashMap<String,String> FillPortList(String BranchID)
{
return new ModuleFunctions("1011").GetDDHashMap(3,(BranchID+GlobalClass.ColDelim).split(GlobalClass.ColDelim));
}
public String [][] FillBranchCityList(String CompanyID,String BranchID)
{
return new ModuleFunctions("1013").GetResultArray(78,(CompanyID+GlobalClass.ColDelim+BranchID+GlobalClass.ColDelim).split(GlobalClass.ColDelim));
}
@RequestMapping(value="initaddproduct",method=RequestMethod.POST )
public String AddProduct(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals,HttpSession session)
{
model.addAttribute("addproduct", new AddEditProduct());
model.addAttribute("portlist", new ModuleFunctions("1011").GetResultArray(3,(Sessvals.getBranchID()+GlobalClass.ColDelim).split(GlobalClass.ColDelim)));
model.addAttribute("Sessvals",Sessvals);
return "edp/tools/addproduct";
}
@RequestMapping(value="getproducts",method=RequestMethod.POST )
public String GetProduct(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals,HttpSession session,@ModelAttribute(value="addproduct") AddEditProduct addEditProduct)
{
EdpToolsHandler etl = new EdpToolsHandler();
etl.setErrCode("0002");
etl.setProcessFlag(true);
etl.getMappedProducts(addEditProduct);
model.addAttribute("addproduct", addEditProduct);
model.addAttribute("portlist", new ModuleFunctions("1011").GetResultArray(3,(Sessvals.getBranchID()+GlobalClass.ColDelim).split(GlobalClass.ColDelim)));
model.addAttribute("Sessvals",Sessvals);
return "edp/tools/addproduct";
}
@RequestMapping(value="addremoveproduct",method=RequestMethod.POST )
public String addRemoveProduct(ModelMap model,HttpServletRequest request,@ModelAttribute(value="Sessvals") Session Sessvals,HttpSession session,@ModelAttribute(value="addproduct") AddEditProduct addEditProduct)
{
EdpToolsHandler etl = new EdpToolsHandler();
etl.setErrCode("0002");
etl.setProcessFlag(true);
addEditProduct.setUserid(Sessvals.getUserID());
etl.addRemoveProduct(addEditProduct);
model.addAttribute("addproduct", addEditProduct);
model.addAttribute("portlist", new ModuleFunctions("1011").GetResultArray(3,(Sessvals.getBranchID()+GlobalClass.ColDelim).split(GlobalClass.ColDelim)));
model.addAttribute("Sessvals",Sessvals);
return "edp/tools/addproduct";
}
}