app附件资料清单上传。

This commit is contained in:
fengys 2018-07-16 17:29:19 +08:00
parent c239dd0760
commit a723a50e7b
3 changed files with 354 additions and 0 deletions

View File

@ -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<String, Object> 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<String, Object> 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();
}
}
}

View File

@ -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<String, Object> queryAttachmentByLibrayId(
@Context HttpServletRequest request,
@Context HttpServletResponse response, @Context JBOTransaction tx,
@Context Transaction sqlca) throws Exception;
Map<String, Object> queryFileLibraryForChange(HttpServletRequest request,
JBOTransaction tx, Transaction sqlca) throws Exception;
Map<String, Object> queryFileLibraryForCardChange(
HttpServletRequest request, JBOTransaction tx, Transaction sqlca)
throws Exception;
Map<String, Object> upload(@Context HttpServletRequest request,
@Context Transaction sqlca, @Context JBOTransaction tx)
throws Exception;
// Map<String, Object> updateStatus(HttpServletRequest request,
// JBOTransaction tx, Transaction sqlca) throws Exception;
}

View File

@ -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<String, Object> queryAttachmentByLibrayId(
HttpServletRequest request, HttpServletResponse response,
JBOTransaction tx, Transaction sqlca) throws Exception {
Map<String, Object> testMap = (Map<String, Object>) MultipartDataUtil
.readRequestParam(request, "UTF-8");
testMap = testMap.get("fieldMap") == null ? new HashMap<String, Object>()
: (Map<String, Object>) 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<BizObject> attributeBos = attributeQuery.getResultList(false);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
for (BizObject attributeBo : attributeBos) {
BizObjectUtil util = new BizObjectUtil();
list.add(util.bizObject2MapValue(attributeBo));
}
Map<String, Object> body = new HashMap<String, Object>();
body.put("filelist", list);
ReturnMapUtil.setReturnMap(body,
RestfullConstant.baseProperty.get("SUCCESS").toString(), "");
return ReturnMapUtil.getReturnMap();
}
@SuppressWarnings("unchecked")
public Map<String, Object> queryFileLibraryForChange(
HttpServletRequest request, JBOTransaction tx, Transaction sqlca)
throws Exception {
Map<String, Object> testMap = (Map<String, Object>) MultipartDataUtil
.readRequestParam(request, "UTF-8");
testMap = testMap.get("fieldMap") == null ? new HashMap<String, Object>()
: (Map<String, Object>) 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<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
if (boRelative == null) {
Map<String, Object> body = new HashMap<String, Object>();
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<BizObject> 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<String, Object> map = new HashMap<String, Object>();
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<String, Object> body = new HashMap<String, Object>();
body.put("filelist", list);
ReturnMapUtil.setReturnMap(body,
RestfullConstant.baseProperty.get("SUCCESS").toString(), "");
return ReturnMapUtil.getReturnMap();
}
//扣款卡信息变更列表查询
@SuppressWarnings("unchecked")
public Map<String, Object> queryFileLibraryForCardChange(
HttpServletRequest request, JBOTransaction tx, Transaction sqlca)
throws Exception {
Map<String, Object> testMap = (Map<String, Object>) MultipartDataUtil
.readRequestParam(request, "UTF-8");
testMap = testMap.get("fieldMap") == null ? new HashMap<String, Object>()
: (Map<String, Object>) 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<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
if (boRelative == null) {//判断是否为空如果为空则没有上传数据
Map<String, Object> body = new HashMap<String, Object>();
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<BizObject> 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<String, Object> map = new HashMap<String, Object>();
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<String, Object> body = new HashMap<String, Object>();
body.put("filelist", list);
ReturnMapUtil.setReturnMap(body,
RestfullConstant.baseProperty.get("SUCCESS").toString(), "");
return ReturnMapUtil.getReturnMap();
}
@SuppressWarnings("unchecked")
public Map<String, Object> upload(HttpServletRequest request,
Transaction sqlca, JBOTransaction tx) throws Exception {
Map<String, Object> testMap = (Map<String, Object>) MultipartDataUtil
.readRequestParam(request, "UTF-8");
Map<String, Object> fieldMap = testMap.get("fieldMap") == null ? new HashMap<String, Object>()
: (Map<String, Object>) testMap.get("fieldMap");
List<Map<String, Object>> fileList = (List<Map<String, Object>>) (testMap
.get("fileList") == null ? new ArrayList<Map<String, Object>>()
: testMap.get("fileList"));
String sUserId = (String) request.getSession().getAttribute("userid");
return ContractDocUploadUtil.contractDocUpload(fieldMap, fileList, sqlca, tx, "PROJECT", sUserId, ReturnMapUtil);
}
// @SuppressWarnings("unchecked")
// public Map<String, Object> updateStatus(HttpServletRequest request,
// JBOTransaction tx, Transaction sqlca) throws Exception {
// try {
// Map<String, Object> testMap = (Map<String, Object>) MultipartDataUtil
// .readRequestParam(request, "UTF-8");
// testMap = testMap.get("fieldMap") == null ? new HashMap<String, Object>()
// : (Map<String, Object>) 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();
// }
}