diff --git a/src_app_fresh/apx/com/amarsoft/als/doc/attribute/controller/LBDocAttributeController.java b/src_app_fresh/apx/com/amarsoft/als/doc/attribute/controller/LBDocAttributeController.java new file mode 100644 index 000000000..0e3179b1e --- /dev/null +++ b/src_app_fresh/apx/com/amarsoft/als/doc/attribute/controller/LBDocAttributeController.java @@ -0,0 +1,64 @@ +package apx.com.amarsoft.als.doc.attribute.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.doc.attribute.service.LBDocAttributeService; +import apx.com.amarsoft.als.doc.attribute.service.impl.LBDocAttributeServiceImpl; + +import com.amarsoft.are.ARE; +import com.amarsoft.are.jbo.JBOTransaction; +import com.amarsoft.awe.util.Transaction; +import com.base.constant.RestfullConstant; +import com.base.util.ReturnMapUtil; + +@Path("/doc/attribute/controller") +public class LBDocAttributeController { + LBDocAttributeService service = new LBDocAttributeServiceImpl(); + ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(null,null); + @Path("/query/list/attachment/by/library/id") + @POST + public Map queryAttachmentByLibrayId( + @Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca) throws Exception { + ARE.getLog().info( + "[CONTROLLER] LBDocAttributeController run ................."); + ARE.getLog() + .info("[Path] /doc/attribute/controller/query/list/attachment/by/library/id run ................."); + try { + return service.queryAttachmentByLibrayId(request, response, tx, sqlca); + } catch (Exception e) { + ARE.getLog().error(e); + ReturnMapUtil.setReturnMap(null, + RestfullConstant.baseProperty.get("CODE500").toString(), + RestfullConstant.baseProperty.get("MSG500").toString()); + return ReturnMapUtil.getReturnMap(); + } + } + + @Path("/upload") + @POST + public Map upload(@Context HttpServletRequest request, + @Context Transaction sqlca, @Context JBOTransaction tx) + throws Exception { + ARE.getLog().info( + "[CONTROLLER] ContractSignController run ................."); + ARE.getLog().info( + "[Path] /business/handler/upload run ................."); + try { + return service.upload(request, sqlca, tx); + } catch (Exception e) { + ARE.getLog().error(e); + ReturnMapUtil.setReturnMap(null, + RestfullConstant.baseProperty.get("CODE500").toString(), + RestfullConstant.baseProperty.get("MSG500").toString()); + return ReturnMapUtil.getReturnMap(); + } + } +} diff --git a/src_app_fresh/apx/com/amarsoft/als/doc/attribute/service/LBDocAttributeService.java b/src_app_fresh/apx/com/amarsoft/als/doc/attribute/service/LBDocAttributeService.java new file mode 100644 index 000000000..3acf15d2b --- /dev/null +++ b/src_app_fresh/apx/com/amarsoft/als/doc/attribute/service/LBDocAttributeService.java @@ -0,0 +1,30 @@ +package apx.com.amarsoft.als.doc.attribute.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; + +public interface LBDocAttributeService { + Map queryAttachmentByLibrayId( + @Context HttpServletRequest request, + @Context HttpServletResponse response, @Context JBOTransaction tx, + @Context Transaction sqlca) throws Exception; + + Map queryFileLibraryForChange(HttpServletRequest request, + JBOTransaction tx, Transaction sqlca) throws Exception; + + Map queryFileLibraryForCardChange( + HttpServletRequest request, JBOTransaction tx, Transaction sqlca) + throws Exception; + + Map upload(@Context HttpServletRequest request, + @Context Transaction sqlca, @Context JBOTransaction tx) + throws Exception; +// Map updateStatus(HttpServletRequest request, +// JBOTransaction tx, Transaction sqlca) throws Exception; +} diff --git a/src_app_fresh/apx/com/amarsoft/als/doc/attribute/service/impl/LBDocAttributeServiceImpl.java b/src_app_fresh/apx/com/amarsoft/als/doc/attribute/service/impl/LBDocAttributeServiceImpl.java new file mode 100644 index 000000000..6740eeef0 --- /dev/null +++ b/src_app_fresh/apx/com/amarsoft/als/doc/attribute/service/impl/LBDocAttributeServiceImpl.java @@ -0,0 +1,260 @@ +package apx.com.amarsoft.als.doc.attribute.service.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import jbo.app.tenwa.customer.CUSTOMER_INFO; +import jbo.app.tenwa.doc.LB_DOCATTRIBUTE; +import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; +import apx.com.amarsoft.als.doc.attribute.service.LBDocAttributeService; + +import com.amarsoft.are.jbo.BizObject; +import com.amarsoft.are.jbo.BizObjectManager; +import com.amarsoft.are.jbo.BizObjectQuery; +import com.amarsoft.are.jbo.JBOFactory; +import com.amarsoft.are.jbo.JBOTransaction; +import com.amarsoft.awe.util.Transaction; +import com.amarsoft.dict.als.manage.NameManager; +import com.base.constant.RestfullConstant; +import com.base.util.BizObjectUtil; +import com.base.util.ContractDocUploadUtil; +import com.base.util.MultipartDataUtil; +import com.base.util.ReturnMapUtil; + +public class LBDocAttributeServiceImpl implements LBDocAttributeService { + ReturnMapUtil ReturnMapUtil = new ReturnMapUtil(null, null); + + @SuppressWarnings("unchecked") + public Map queryAttachmentByLibrayId( + HttpServletRequest request, HttpServletResponse response, + JBOTransaction tx, Transaction sqlca) throws Exception { + Map testMap = (Map) MultipartDataUtil + .readRequestParam(request, "UTF-8"); + testMap = testMap.get("fieldMap") == null ? new HashMap() + : (Map) testMap.get("fieldMap"); + String sLibraryId = testMap.get("id".toLowerCase()) == null ? "" + : testMap.get("id".toLowerCase()).toString(); + + BizObjectManager attributeManage = JBOFactory + .getBizObjectManager(LB_DOCATTRIBUTE.CLASS_NAME); + BizObjectQuery attributeQuery = attributeManage.createQuery( + "LIBRARY_ID=:LIBRARY_ID ").setParameter( + "LIBRARY_ID", sLibraryId); + List attributeBos = attributeQuery.getResultList(false); + List> list = new ArrayList>(); + for (BizObject attributeBo : attributeBos) { + BizObjectUtil util = new BizObjectUtil(); + list.add(util.bizObject2MapValue(attributeBo)); + } + Map body = new HashMap(); + body.put("filelist", list); + ReturnMapUtil.setReturnMap(body, + RestfullConstant.baseProperty.get("SUCCESS").toString(), ""); + return ReturnMapUtil.getReturnMap(); + } + + @SuppressWarnings("unchecked") + public Map queryFileLibraryForChange( + HttpServletRequest request, JBOTransaction tx, Transaction sqlca) + throws Exception { + Map testMap = (Map) MultipartDataUtil + .readRequestParam(request, "UTF-8"); + testMap = testMap.get("fieldMap") == null ? new HashMap() + : (Map) testMap.get("fieldMap"); + String sCustomerId = testMap.get("customerid".toLowerCase()) == null ? "" + : testMap.get("customerid".toLowerCase()).toString(); + + BizObjectManager custManage = JBOFactory + .getBizObjectManager(CUSTOMER_INFO.CLASS_NAME); + BizObject cust = custManage.createQuery("customerid=:customerid") + .setParameter("customerid", sCustomerId).getSingleResult(false); + if (null == cust) { + ReturnMapUtil.setReturnMap(null, + RestfullConstant.baseProperty.get("FAIL").toString(), + "客户无效!"); + return ReturnMapUtil.getReturnMap(); + } + String sCustomerType = cust.getAttribute("customertype") == null ? "" + : cust.getAttribute("customertype").toString(); + String sObjectType = ""; + if ("03".equals(sCustomerType)) + sObjectType = "CustomerPersonChange"; + else if ("01".equals(sCustomerType)) + sObjectType = "CustomerCompanyChange"; + else { + ReturnMapUtil.setReturnMap(null, + RestfullConstant.baseProperty.get("FAIL").toString(), + "客户类型无效!"); + return ReturnMapUtil.getReturnMap(); + } + String sSql = "Select * from O where O.CUST_ID='" + sCustomerId + + "' and O.objecttype='" + sObjectType + "'"; + BizObjectManager bomRelative = JBOFactory + .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCRELATIVE"); + BizObject boRelative = bomRelative.createQuery(sSql).getSingleResult( + false); + List> list = new ArrayList>(); + if (boRelative == null) { + Map body = new HashMap(); + body.put("filelist", list); + ReturnMapUtil + .setReturnMap(body, + RestfullConstant.baseProperty.get("SUCCESS") + .toString(), ""); + return ReturnMapUtil.getReturnMap(); + } + BizObjectManager bomLibrary = JBOFactory + .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCLIBRARY"); + BizObject boLibrary = bomLibrary.createQuery( + "Select * from O where O.relative_id='" + + boRelative.getAttribute("id").getString() + "'") + .getSingleResult(false); + BizObjectManager bomAttr = JBOFactory + .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCATTRIBUTE"); + List attrList = bomAttr.createQuery( + "Select * from O where O.library_id='" + + boLibrary.getAttribute("id") + "'" + + "and status is null order by O.inputtime desc") + .getResultList(false); + for (BizObject attr : attrList) { + Map map = new HashMap(); + map.put("id", attr.getAttribute("id").getString()); + map.put("filename", attr.getAttribute("filename").getString()); + map.put("inputtime", attr.getAttribute("inputtime").getString()); + map.put("inputuser", NameManager.getUserName(attr.getAttribute( + "INPUTUSERID").getString())); + map.put("inputuserid", attr.getAttribute("INPUTUSERID").getValue()); + map.put("CONTENT_TYPE".toLowerCase(), + attr.getAttribute("CONTENT_TYPE").getString()); + map.put("fileSize", attr.getAttribute("FileSize").getString()); + list.add(map); + if ("03".equals(sCustomerType)) + break; + } + Map body = new HashMap(); + body.put("filelist", list); + ReturnMapUtil.setReturnMap(body, + RestfullConstant.baseProperty.get("SUCCESS").toString(), ""); + return ReturnMapUtil.getReturnMap(); + } + + //扣款卡信息变更列表查询 + @SuppressWarnings("unchecked") + public Map queryFileLibraryForCardChange( + HttpServletRequest request, JBOTransaction tx, Transaction sqlca) + throws Exception { + Map testMap = (Map) MultipartDataUtil + .readRequestParam(request, "UTF-8"); + testMap = testMap.get("fieldMap") == null ? new HashMap() + : (Map) testMap.get("fieldMap"); + String sContractId = testMap.get("contractId".toLowerCase()) == null ? "" + : testMap.get("contractId".toLowerCase()).toString(); + + BizObjectManager custManage = JBOFactory + .getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME);//先在合同正式表查询是否有合同 + BizObject contractId = custManage.createQuery("id=:contractId")//从前台页面获取到contractId + .setParameter("contractId", sContractId).getSingleResult(false); + if (null == contractId) {//判断是否为空 + ReturnMapUtil.setReturnMap(null, + RestfullConstant.baseProperty.get("FAIL").toString(), + "合同无效!"); + return ReturnMapUtil.getReturnMap(); + } + String sObjectType = "";//定义模版变量 + sObjectType = "AccountChange";//在此为账户变更模版 + String sSql = "Select * from O where O.CONTRACT_ID='" + sContractId + + "' and O.objecttype='" + sObjectType + "'";//根据合同id和模版类型在LB_DOCRELATIVE中查询到此数据 + BizObjectManager bomRelative = JBOFactory + .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCRELATIVE");//文件关系表 + BizObject boRelative = bomRelative.createQuery(sSql).getSingleResult( + false);//得到此对象 + List> list = new ArrayList>(); + if (boRelative == null) {//判断是否为空,如果为空,则没有上传数据。 + Map body = new HashMap(); + body.put("filelist", list); + ReturnMapUtil + .setReturnMap(body, + RestfullConstant.baseProperty.get("SUCCESS") + .toString(), ""); + return ReturnMapUtil.getReturnMap(); + } + BizObjectManager bomLibrary = JBOFactory + .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCLIBRARY");//文件字典 + BizObject boLibrary = bomLibrary.createQuery(//根据relative_id查询到此条数据。 + "Select * from O where O.relative_id='" + + boRelative.getAttribute("id").getString() + "'") + .getSingleResult(false); + BizObjectManager bomAttr = JBOFactory + .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCATTRIBUTE"); + List attrList = bomAttr.createQuery(//根据LB_DOCLIBRARY的id来和LB_DOCATTRIBUTE的library_id对应来获取到该文件。 + "Select * from O where O.library_id='" + + boLibrary.getAttribute("id") + "'" + + "and status is null order by O.inputtime desc")//status不能为空且按照上传日期倒序(降序) + .getResultList(false); + for (BizObject attr : attrList) {//对文件进行遍历,并且获取对应的属性 + Map map = new HashMap(); + map.put("id", attr.getAttribute("id").getString());//获取id + map.put("filename", attr.getAttribute("filename").getString());//获取文件名 + map.put("inputtime", attr.getAttribute("inputtime").getString());//上传时间 + map.put("inputuser", NameManager.getUserName(attr.getAttribute( + "INPUTUSERID").getString()));//上传人 + map.put("inputuserid", attr.getAttribute("INPUTUSERID").getValue());//上传人id + map.put("CONTENT_TYPE".toLowerCase(), + attr.getAttribute("CONTENT_TYPE").getString());//文件类型 + map.put("fileSize", attr.getAttribute("FileSize").getString());//文件大小 + list.add(map); + } + Map body = new HashMap(); + body.put("filelist", list); + ReturnMapUtil.setReturnMap(body, + RestfullConstant.baseProperty.get("SUCCESS").toString(), ""); + return ReturnMapUtil.getReturnMap(); + } + + @SuppressWarnings("unchecked") + public Map upload(HttpServletRequest request, + Transaction sqlca, JBOTransaction tx) throws Exception { + Map testMap = (Map) MultipartDataUtil + .readRequestParam(request, "UTF-8"); + Map fieldMap = testMap.get("fieldMap") == null ? new HashMap() + : (Map) testMap.get("fieldMap"); + List> fileList = (List>) (testMap + .get("fileList") == null ? new ArrayList>() + : testMap.get("fileList")); + String sUserId = (String) request.getSession().getAttribute("userid"); + + return ContractDocUploadUtil.contractDocUpload(fieldMap, fileList, sqlca, tx, "PROJECT", sUserId, ReturnMapUtil); + } + +// @SuppressWarnings("unchecked") +// public Map updateStatus(HttpServletRequest request, +// JBOTransaction tx, Transaction sqlca) throws Exception { +// try { +// Map testMap = (Map) MultipartDataUtil +// .readRequestParam(request, "UTF-8"); +// testMap = testMap.get("fieldMap") == null ? new HashMap() +// : (Map) testMap.get("fieldMap"); +// String sId = testMap.get("id".toLowerCase()) == null ? "" : testMap +// .get("id".toLowerCase()).toString(); +// BizObjectManager bomAttr = JBOFactory +// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCATTRIBUTE"); +// String sSql = "update o set o.status=1 where id=:id"; +// bomAttr.createQuery(sSql).setParameter("id", sId).executeUpdate(); +// } catch (Exception e) { +// ARE.getLog().error(e); +// ReturnMapUtil.setReturnMap(null, +// RestfullConstant.baseProperty.get("FAIL").toString(), +// "删除失败!"); +// return ReturnMapUtil.getReturnMap(); +// } +// ReturnMapUtil.setReturnMap(null, +// RestfullConstant.baseProperty.get("SUCCESS").toString(), +// "删除成功!"); +// return ReturnMapUtil.getReturnMap(); +// } +}