diff --git a/src_app_fresh/apx/com/amarsoft/als/apzl/apply/business/query/controller/CustomerQueryController.java b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/business/query/controller/CustomerQueryController.java new file mode 100644 index 000000000..df9cc4e83 --- /dev/null +++ b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/business/query/controller/CustomerQueryController.java @@ -0,0 +1,38 @@ +package apx.com.amarsoft.als.apzl.apply.business.query.controller; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Context; + +import apx.com.amarsoft.als.apzl.apply.business.query.service.CustomerQueryService; +import apx.com.amarsoft.als.apzl.apply.business.query.service.impl.CustomerQueryServiceImpl; + +import com.amarsoft.are.ARE; +import com.amarsoft.are.jbo.JBOTransaction; +import com.amarsoft.awe.util.Transaction; +import com.base.util.ReturnMapUtil; + +@Path("/customer") +public class CustomerQueryController { + @Path("/query/info") + @POST + public Map info(@Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca) throws Exception { + ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(tx, sqlca); + ARE.getLog().info( + "[CONTROLLER] CustomerQueryController run ................."); + ARE.getLog().info("[Path] /customer/query/info" + " run ................."); + + CustomerQueryService service = new CustomerQueryServiceImpl(); + try { + return service.info(request, response, tx, sqlca, ReturnMapUtil); + } catch (Exception e) { + return ReturnMapUtil.rollback(e); + } + } +} diff --git a/src_app_fresh/apx/com/amarsoft/als/apzl/apply/business/query/service/CustomerQueryService.java b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/business/query/service/CustomerQueryService.java new file mode 100644 index 000000000..fba4bce96 --- /dev/null +++ b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/business/query/service/CustomerQueryService.java @@ -0,0 +1,17 @@ +package apx.com.amarsoft.als.apzl.apply.business.query.service; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.Context; + +import com.amarsoft.are.jbo.JBOTransaction; +import com.amarsoft.awe.util.Transaction; +import com.base.util.ReturnMapUtil; + +public interface CustomerQueryService { + Map info(@Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca, ReturnMapUtil ReturnMapUtil) throws Exception; +} diff --git a/src_app_fresh/apx/com/amarsoft/als/apzl/apply/business/query/service/impl/CustomerQueryServiceImpl.java b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/business/query/service/impl/CustomerQueryServiceImpl.java new file mode 100644 index 000000000..4ce6e7832 --- /dev/null +++ b/src_app_fresh/apx/com/amarsoft/als/apzl/apply/business/query/service/impl/CustomerQueryServiceImpl.java @@ -0,0 +1,66 @@ +package apx.com.amarsoft.als.apzl.apply.business.query.service.impl; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import jbo.app.tenwa.customer.CUSTOMER_INFO_TEMP; +import apx.com.amarsoft.als.apzl.apply.business.query.service.CustomerQueryService; +import apx.com.amarsoft.als.base.awe.controller.DefaultDoManage; +import apx.com.amarsoft.als.base.awe.execute.method.BusinessCustomerMethod; + +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.JBOFactory; +import com.amarsoft.are.jbo.JBOTransaction; +import com.amarsoft.awe.util.Transaction; +import com.base.util.MultipartDataUtil; +import com.base.util.ReturnMapUtil; + +public class CustomerQueryServiceImpl implements CustomerQueryService { + private Map fieldMap; + + @SuppressWarnings("unchecked") + public Map info(HttpServletRequest request, + HttpServletResponse response, JBOTransaction tx, Transaction sqlca, + ReturnMapUtil ReturnMapUtil) throws Exception { + Map testMap = (Map) MultipartDataUtil + .readRequestParam(request, "UTF-8"); + fieldMap = (Map) testMap.get("fieldMap"); + + String flowUnid = fieldMap.get("objectno") == null ? "" : fieldMap.get( + "objectno").toString(); + + BusinessCustomerMethod mm = new BusinessCustomerMethod(); + String customerId = mm.getCustomerIdByFlowUnid(flowUnid); + BizObjectManager bom = JBOFactory + .getBizObjectManager(CUSTOMER_INFO_TEMP.CLASS_NAME); + String customerType = ((BizObject) bom + .createQuery("customerid=:customerid") + .setParameter("customerid", customerId).getResultList(false)) + .getAttribute("CUSTOMERTYPE").toString(); + fieldMap.put("flowUnid".toLowerCase(), flowUnid); + fieldMap.put("flowUnid".toUpperCase(), flowUnid); + fieldMap.put("flow_Unid".toLowerCase(), flowUnid); + fieldMap.put("flow_Unid".toUpperCase(), flowUnid); + fieldMap.put("objectno".toLowerCase(), flowUnid); + fieldMap.put("objectno".toUpperCase(), flowUnid); + + fieldMap.put("customerid".toLowerCase(), customerId); + fieldMap.put("customerid".toUpperCase(), customerId); + + String dono = ""; + if ("01".equals(customerType)) { + dono = "AppBusinessApplyInfo3"; + } else if ("03".equals(customerType)) { + dono = "AppBusinessApplyInfo2"; + } + + DefaultDoManage manage = new DefaultDoManage(); + manage.setDono(dono); + manage.setFieldMap(fieldMap); + return manage.queryDefaultDo(request, sqlca, tx, ReturnMapUtil); + } + +}