apzl_leasing/src_app_fresh/com/base/util/ContractDocUploadUtil.java
liujiaji 6397d906b5 src_app 移除
src_app_fresh 添加
2018-06-11 13:40:56 +08:00

476 lines
21 KiB
Java

//package com.base.util;
//
//import java.io.DataOutputStream;
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.InputStream;
//import java.net.URLDecoder;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//
//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.are.util.SpecialTools;
//import com.amarsoft.are.util.StringFunction;
//import com.amarsoft.awe.Configure;
//import com.amarsoft.awe.util.Transaction;
//import com.amarsoft.context.ASUser;
//import com.base.constant.RestfullConstant;
//
//public class ContractDocUploadUtil {
//
// // 提前结清上传
// public static Map<String, Object> adjustUpload(
// Map<String, Object> fieldMap, List<Map<String, Object>> fileList,
// Transaction sqlca, JBOTransaction tx, String sObjectType,
// String sUserId, ReturnMapUtil ReturnMapUtil) throws Exception {
// ASUser oCurUser = ASUser.getUser(SpecialTools.real2Amarsoft(sUserId),
// sqlca);
// String sCurDate = DateUtil.getSystemTimeByFormat(new Date(),
// "yyyy/MM/dd HH:mm:ss");
// String sContractId = fieldMap.get("contract_id") == null ? ""
// : fieldMap.get("contract_id").toString(); // 合同编号
// String sApplyld = fieldMap.get("flowunid") == null ? "" : fieldMap.get(
// "flowunid").toString(); // 中间表id
// for (Map<String, Object> map : fileList) {
// String sFileName, sFileContentType, sFileSize;
// sFileName = map.get("fileName") == null ? "" : map.get("fileName")
// .toString();
// InputStream file = (InputStream) map.get("file");
// sFileContentType = map.get("fileContentType") == null ? "" : map
// .get("fileContentType").toString();
// sFileSize = map.get("fileSize") == null ? "" : map.get("fileSize")
// .toString();
// BizObjectManager relaBm = JBOFactory
// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCRELATIVE");
// BizObjectManager libBm = JBOFactory
// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCLIBRARY");
// BizObjectManager attrBm = JBOFactory
// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCATTRIBUTE");
//
// BizObject lib = null;
//
// String sql = "select * from O left join jbo.app.tenwa.doc.LB_DOCRELATIVE rela on O.Relative_Id=rela.id where rela.contract_id=:contract_id and rela.objecttype=:objecttype and rela.flow_unid=:flow_unid";
//
// BizObjectQuery query = libBm.createQuery(sql);
// query.setParameter("contract_id", sContractId);
// query.setParameter("objecttype", sObjectType);
// query.setParameter("flow_unid", sApplyld);
// lib = query.getSingleResult(true);
//
// String libraryId = "";
// if (lib != null) {
// libBm.saveObject(lib);
// libraryId = lib.getAttribute("id").getString();
// } else {
// sql = "select * from O left join jbo.app.tenwa.doc.LB_DOCLIBRARY lib on O.id=lib.Relative_Id where O.contract_id=:contract_id and O.objecttype=:objecttype and O.flow_unid=:flow_unid";
// query = relaBm.createQuery(sql);
// query.setParameter("contract_id", sContractId);
// query.setParameter("objecttype", sObjectType);
// query.setParameter("flow_unid", sApplyld);
// BizObject rela = query.getSingleResult(true);
// String relativeid = "";
// if (rela == null) {
// // 初始化附件关联对象
// rela = relaBm.newObject();
// rela.setAttributeValue("ObjectType", sObjectType);
// rela.setAttributeValue("contract_id", sContractId);
// rela.setAttributeValue("flow_unid", sApplyld);
// relaBm.saveObject(rela);
// relativeid = rela.getAttribute("id").getString();
// } else {
// relativeid = rela.getAttribute("id").getString();
// }
// // 初始化附件
// lib = libBm.newObject();
// lib.setAttributeValue("Relative_Id", relativeid);
// libBm.saveObject(lib);
// libraryId = lib.getAttribute("id").getString();
// }
// BizObject attr = attrBm.newObject();
// attr.setAttributeValue("Library_Id", libraryId);
// attr.setAttributeValue("FileName", sFileName);
// attr.setAttributeValue("InputUserId", oCurUser.getUserID());
// attr.setAttributeValue("InputOrgId", oCurUser.getOrgID());
// attr.setAttributeValue("InputTime", sCurDate);
// attr.setAttributeValue("ObjectType", sObjectType);
//
// @SuppressWarnings("deprecation")
// Configure CurConfig = Configure.getInstance();
// String sFileSavePath = CurConfig.getConfigure("FileSavePath");
//
// String uuid = java.util.UUID.randomUUID().toString()
// .replaceAll("-", "");
// String sFullPath = com.tenwa.officetempalte.util.FileOperatorUtil
// .getuploadFileDir(sFileSavePath) + uuid + "_" + sFileName;
//
// String sFilePath = sFullPath.replace(sFileSavePath, "");
//
// attr.setAttributeValue("FilePath", sFilePath);
// attr.setAttributeValue("FullPath", sFullPath);
// attr.setAttributeValue("Content_Type", sFileContentType);
// attr.setAttributeValue("FileSize", sFileSize);
// attrBm.saveObject(attr);
//
// File f = new File(sFullPath);
// DataOutputStream fileout = new DataOutputStream(
// new FileOutputStream(f));
// byte b[] = new byte[Integer.valueOf(sFileSize)];
// @SuppressWarnings("unused")
// int i = file.read(b, 0, Integer.valueOf(sFileSize) - 1);
// fileout.write(b, 0, b.length); // 将文件数据存盘
// fileout.close();
// }
// tx.commit();
// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
// .get("SUCCESS") == null ? "SUCCESS"
// : RestfullConstant.baseProperty.get("SUCCESS").toString(),
// "上传成功!");
// return ReturnMapUtil.getReturnMap();
// }
//
// // 账号变更上传
// public static Map<String, Object> contractUpload(
// Map<String, Object> fieldMap, List<Map<String, Object>> fileList,
// Transaction sqlca, JBOTransaction tx, String sObjectType,
// String sUserId, ReturnMapUtil ReturnMapUtil) throws Exception {
// ASUser oCurUser = ASUser.getUser(SpecialTools.real2Amarsoft(sUserId),
// sqlca);
// String sCurDate = DateUtil.getSystemTimeByFormat(new Date(),
// "yyyy/MM/dd HH:mm:ss");
// String sContractId = fieldMap.get("id") == null ? "" : fieldMap.get(
// "id").toString(); // 合同编号
// for (Map<String, Object> map : fileList) {
// String sFileName, sFileContentType, sFileSize;
// sFileName = map.get("fileName") == null ? "" : map.get("fileName")
// .toString();
// InputStream file = (InputStream) map.get("file");
// sFileContentType = map.get("fileContentType") == null ? "" : map
// .get("fileContentType").toString();
// sFileSize = map.get("fileSize") == null ? "" : map.get("fileSize")
// .toString();
// BizObjectManager relaBm = JBOFactory
// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCRELATIVE");
// BizObjectManager libBm = JBOFactory
// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCLIBRARY");
// BizObjectManager attrBm = JBOFactory
// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCATTRIBUTE");
//
// BizObject lib = null;
// String sql = "select * from O left join jbo.app.tenwa.doc.LB_DOCRELATIVE rela on O.Relative_Id=rela.id where rela.contract_id=:contractId and rela.objecttype=:objecttype ";
// BizObjectQuery query = libBm.createQuery(sql);
// query.setParameter("contractId", sContractId);
// query.setParameter("objecttype", sObjectType);
// lib = query.getSingleResult(true);
// String libraryId = "";
// if (lib != null) {
// libBm.saveObject(lib);
// libraryId = lib.getAttribute("id").getString();
// } else {
// sql = "select * from O left join jbo.app.tenwa.doc.LB_DOCLIBRARY lib on O.id=lib.Relative_Id where O.contract_id=:contractId and O.objecttype=:objecttype ";
// query = relaBm.createQuery(sql);
// query.setParameter("contractId", sContractId);
// query.setParameter("objecttype", sObjectType);
// BizObject rela = query.getSingleResult(true);
// String relativeid = "";
// if (rela == null) {
// // 初始化附件关联对象
// rela = relaBm.newObject();
// rela.setAttributeValue("ObjectType", sObjectType);
// rela.setAttributeValue("contract_id", sContractId);
// relaBm.saveObject(rela);
// relativeid = rela.getAttribute("id").getString();
// }
// // 初始化附件
// lib = libBm.newObject();
// lib.setAttributeValue("Relative_Id", relativeid);
// libBm.saveObject(lib);
// libraryId = lib.getAttribute("id").getString();
// }
//
// BizObject attr = attrBm.createQuery(
// "library_id='" + libraryId + "'").getSingleResult(true);
// if (attr == null) {
// attr = attrBm.newObject();
// }
// attr.setAttributeValue("Library_Id", libraryId);
// attr.setAttributeValue("FileName", sFileName);
// attr.setAttributeValue("InputUserId", oCurUser.getUserID());
// attr.setAttributeValue("InputOrgId", oCurUser.getOrgID());
// attr.setAttributeValue("InputTime", sCurDate);
// attr.setAttributeValue("ObjectType", sObjectType);
//
// @SuppressWarnings("deprecation")
// Configure CurConfig = Configure.getInstance();
// String sFileSavePath = CurConfig.getConfigure("FileSavePath");
//
// String uuid = java.util.UUID.randomUUID().toString()
// .replaceAll("-", "");
// String sFullPath = com.tenwa.officetempalte.util.FileOperatorUtil
// .getuploadFileDir(sFileSavePath) + uuid + "_" + sFileName;
//
// String sFilePath = sFullPath.replace(sFileSavePath, "");
// attr.setAttributeValue("FilePath", sFilePath);
// attr.setAttributeValue("FullPath", sFullPath);
// attr.setAttributeValue("Content_Type", sFileContentType);
// attr.setAttributeValue("FileSize", sFileSize);
// attrBm.saveObject(attr);
//
// File f = new File(sFullPath);
// DataOutputStream fileout = new DataOutputStream(
// new FileOutputStream(f));
// byte b[] = new byte[Integer.valueOf(sFileSize)];
// @SuppressWarnings("unused")
// int i = file.read(b, 0, Integer.valueOf(sFileSize) - 1);
// fileout.write(b, 0, b.length); // 将文件数据存盘
// fileout.close();
// }
// tx.commit();
// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
// .get("SUCCESS") == null ? "SUCCESS"
// : RestfullConstant.baseProperty.get("SUCCESS").toString(),
// "上传成功!");
// return ReturnMapUtil.getReturnMap();
// }
//
// // 合同签约上传
// public static Map<String, Object> contractDocUpload(
// Map<String, Object> fieldMap, List<Map<String, Object>> fileList,
// Transaction sqlca, JBOTransaction tx, String sObjectType,
// String sUserId, ReturnMapUtil ReturnMapUtil) throws Exception {
// ASUser oCurUser = ASUser.getUser(SpecialTools.real2Amarsoft(sUserId),
// sqlca);
// String sCurDate = DateUtil.getSystemTimeByFormat(new Date(),
// "yyyy/MM/dd HH:mm:ss");
// String sLibraryId = fieldMap.get("library_id") == null ? "" : fieldMap
// .get("library_id").toString();
//
// for (Map<String, Object> map : fileList) {
// BizObjectManager libBm = JBOFactory
// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCLIBRARY");
// BizObjectManager attrBm = JBOFactory
// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCATTRIBUTE");
//
// BizObjectQuery query = libBm.createQuery("ID=:ID").setParameter(
// "ID", sLibraryId);
// BizObject lib = query.getSingleResult(true);
// lib.setAttributeValue("Remark", fieldMap.get("remark"));
// libBm.saveObject(lib);
//
// String sFileName, sFileContentType, sFileSize;
// sFileName = map.get("fileName") == null ? "" : map.get("fileName")
// .toString();
// InputStream file = (InputStream) map.get("file");
// sFileContentType = map.get("fileContentType") == null ? "" : map
// .get("fileContentType").toString();
// sFileSize = map.get("fileSize") == null ? "" : map.get("fileSize")
// .toString();
//
// BizObject attr = attrBm.newObject();
//
// attr.setAttributeValue("Library_Id", sLibraryId);
// attr.setAttributeValue("FileName", sFileName);
// attr.setAttributeValue("InputUserId", oCurUser.getUserID());
// attr.setAttributeValue("InputOrgId", oCurUser.getOrgID());
// attr.setAttributeValue("InputTime", sCurDate);
// attr.setAttributeValue("objectType", sObjectType);
// if (null != fieldMap.get("channelapplyid")) {
// attr.setAttributeValue("APPLY_ID",
// fieldMap.get("channelapplyid"));
// }
//
// // 得到不带路径的文件名
// sFileName = StringFunction.getFileName(sFileName);
// sFileName = URLDecoder.decode(
// URLDecoder.decode(sFileName, "UTF-8"), "UTF-8");
// // 取得真实的表名
// // String sAttachmentNo = DBKeyHelp.getSerialNo(trueTable, "Id");
//
// // 得到不带路径的文件名
// sFileName = StringFunction.getFileName(sFileName);
// sFileName = URLDecoder.decode(
// URLDecoder.decode(sFileName, "UTF-8"), "UTF-8");
// // 定义数据库操作变量
// // 获取配置文件的参数
// @SuppressWarnings("deprecation")
// Configure CurConfig = Configure.getInstance();
// String sFileSavePath = CurConfig.getConfigure("FileSavePath");
//
// String uuid = java.util.UUID.randomUUID().toString()
// .replaceAll("-", "");
// String sFullPath = com.tenwa.officetempalte.util.FileOperatorUtil
// .getuploadFileDir(sFileSavePath) + uuid + "_" + sFileName;
//
// String sFilePath = sFullPath.replace(sFileSavePath, "");
// attr.setAttributeValue("FilePath", sFilePath);
// attr.setAttributeValue("FullPath", sFullPath);
// attr.setAttributeValue("Content_Type", sFileContentType);
// attr.setAttributeValue("FileSize", sFileSize);
// attrBm.saveObject(attr);
// File f = new File(sFullPath);
// DataOutputStream fileout = new DataOutputStream(
// new FileOutputStream(f));
// byte b[] = new byte[Integer.valueOf(sFileSize)];
// @SuppressWarnings("unused")
// int i = file.read(b, 0, Integer.valueOf(sFileSize) - 1);
// fileout.write(b, 0, b.length); // 将文件数据存盘
// fileout.close();
// }
//
// tx.commit();
// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
// .get("SUCCESS") == null ? "SUCCESS"
// : RestfullConstant.baseProperty.get("SUCCESS").toString(),
// "上传成功!");
// return ReturnMapUtil.getReturnMap();
// }
////
//// // 客户变更上传营业执照
//// public static Map<String, Object> companyBusinessLicenseDocUpload(
//// Map<String, Object> fieldMap, List<Map<String, Object>> fileList,
//// Transaction sqlca, JBOTransaction tx, String sObjectType,
//// String sUserId, ReturnMapUtil ReturnMapUtil) throws Exception {
//// ASUser oCurUser = ASUser.getUser(SpecialTools.real2Amarsoft(sUserId),
//// sqlca);
//// String sCurDate = DateUtil.getSystemTimeByFormat(new Date(),
//// "yyyy/MM/dd HH:mm:ss");
//// String sCustomerId = fieldMap.get("customerid") == null ? "" : fieldMap
//// .get("customerid").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").toString();
//// if ("03".equals(sCustomerType))
//// sObjectType = "CustomerPersonChange";
//// JBOTransaction tx1 = JBOFactory.createJBOTransaction();
//// JBOTransaction tx2 = JBOFactory.createJBOTransaction();
//// JBOTransaction tx3 = JBOFactory.createJBOTransaction();
//// BizObjectManager libBm = JBOFactory
//// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCLIBRARY");
//// tx1.join(libBm);
//// String sql = "select * from O left join jbo.app.tenwa.doc.LB_DOCRELATIVE rela on O.Relative_Id=rela.id where rela.cust_id=:cust_id and rela.objecttype=:objecttype ";
//// BizObjectQuery query = libBm.createQuery(sql);
//// query.setParameter("cust_id", sCustomerId);
//// query.setParameter("objecttype", sObjectType);
//// BizObject lib = query.getSingleResult(true);
//// String libraryId = "";
//// if (null == lib) {
//// BizObjectManager relaBm = JBOFactory
//// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCRELATIVE");
//// tx2.join(relaBm);
//// sql = "select * from O left join jbo.app.tenwa.doc.LB_DOCLIBRARY lib on O.id=lib.Relative_Id where O.cust_id=:cust_id and O.objecttype=:objecttype ";
//// query = relaBm.createQuery(sql);
//// query.setParameter("cust_id", sCustomerId);
//// query.setParameter("objecttype", sObjectType);
//// BizObject rela = query.getSingleResult(true);
//// String relativeid = "";
//// if (rela == null) {
//// // 初始化附件关联对象
//// rela = relaBm.newObject();
//// rela.setAttributeValue("ObjectType", sObjectType);
//// rela.setAttributeValue("cust_id", sCustomerId);
//// relaBm.saveObject(rela);
//// relativeid = rela.getAttribute("id").getString();
//// tx2.commit();
//// } else {
//// relativeid = rela.getAttribute("id").getString();
//// }
//// // 初始化附件
//// lib = libBm.newObject();
//// lib.setAttributeValue("Relative_Id", relativeid);
//// libBm.saveObject(lib);
//// tx1.commit();
//// libraryId = lib.getAttribute("id").getString();
//// } else {
//// libraryId = lib.getAttribute("id").getString();
//// }
//// BizObjectManager attrBm = JBOFactory
//// .getBizObjectManager("jbo.app.tenwa.doc.LB_DOCATTRIBUTE");
//// tx3.join(attrBm);
//// if ("03".equals(sCustomerType)) {
////// attrBm.createQuery(
////// "UPDATE O SET STATUS=1 WHERE LIBRARY_ID=:LIBRARY_ID")
////// .setParameter("LIBRARY_ID", libraryId).executeUpdate();
//// attrBm.createQuery(
//// "UPDATE O SET STATUS=1 WHERE LIBRARY_ID=:LIBRARY_ID")
//// .setParameter("LIBRARY_ID", libraryId).executeUpdate();
//// tx3.commit();
//// }
////
//// for (Map<String, Object> map : fileList) {
//// String sFileName, sFileContentType, sFileSize;
//// sFileName = map.get("fileName") == null ? "" : map.get("fileName")
//// .toString();
//// InputStream file = (InputStream) map.get("file");
//// sFileContentType = map.get("fileContentType") == null ? "" : map
//// .get("fileContentType").toString();
//// sFileSize = map.get("fileSize") == null ? "" : map.get("fileSize")
//// .toString();
//// BizObject attr = attrBm.newObject();
//// attr.setAttributeValue("Library_Id", libraryId);
//// attr.setAttributeValue("FileName", sFileName);
//// attr.setAttributeValue("InputUserId", oCurUser.getUserID());
//// attr.setAttributeValue("InputOrgId", oCurUser.getOrgID());
//// attr.setAttributeValue("InputTime", sCurDate);
//// attr.setAttributeValue("objectType", sObjectType);
//// // attr.setAttributeValue("STATUS", 1);
////
//// // 得到不带路径的文件名
//// sFileName = StringFunction.getFileName(sFileName);
//// sFileName = URLDecoder.decode(
//// URLDecoder.decode(sFileName, "UTF-8"), "UTF-8");
//// // 取得真实的表名
//// // String sAttachmentNo = DBKeyHelp.getSerialNo(trueTable, "Id");
////
//// // 得到不带路径的文件名
//// sFileName = StringFunction.getFileName(sFileName);
//// sFileName = URLDecoder.decode(
//// URLDecoder.decode(sFileName, "UTF-8"), "UTF-8");
//// // 定义数据库操作变量
//// // 获取配置文件的参数
//// @SuppressWarnings("deprecation")
//// Configure CurConfig = Configure.getInstance();
//// String sFileSavePath = CurConfig.getConfigure("FileSavePath");
////
//// String uuid = java.util.UUID.randomUUID().toString()
//// .replaceAll("-", "");
//// String sFullPath = com.tenwa.officetempalte.util.FileOperatorUtil
//// .getuploadFileDir(sFileSavePath) + uuid + "_" + sFileName;
////
//// String sFilePath = sFullPath.replace(sFileSavePath, "");
//// attr.setAttributeValue("FilePath", sFilePath);
//// attr.setAttributeValue("FullPath", sFullPath);
//// attr.setAttributeValue("Content_Type", sFileContentType);
//// attr.setAttributeValue("FileSize", sFileSize);
//// attrBm.saveObject(attr);
//// tx3.commit();
//// File f = new File(sFullPath);
//// DataOutputStream fileout = new DataOutputStream(
//// new FileOutputStream(f));
//// byte b[] = new byte[Integer.valueOf(sFileSize)];
//// @SuppressWarnings("unused")
//// int i = file.read(b, 0, Integer.valueOf(sFileSize) - 1);
//// fileout.write(b, 0, b.length); // 将文件数据存盘
//// fileout.close();
//// }
//// ReturnMapUtil ReturnMapUtil = new ReturnMapUtil();
//// ReturnMapUtil.setReturnMap(null, RestfullConstant.baseProperty
//// .get("SUCCESS") == null ? "SUCCESS"
//// : RestfullConstant.baseProperty.get("SUCCESS").toString(),
//// "上传成功!");
//// return ReturnMapUtil.getReturnMap();
//// }
//}