资产转出导入excel

This commit is contained in:
liuzhao 2019-03-16 16:09:18 +08:00
parent a9ae1b4015
commit 6e90528ea5
4 changed files with 216 additions and 6 deletions

View File

@ -63,6 +63,8 @@ String sButtons[][] =null;
sButtons=new String[][]{
//0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标CSS层叠样式 10、风格
{"true","","Button","修改","修改资产转出信息","viewAndEdit()","","","","btn_icon_edit"},
{"true","","Button","excel导入","excel导入","importExcel()","","","","btn_icon_import"},
{"true","","Button","资产转出登记模版下载","资产转出登记模版下载","DiscountDownload()","","","","btn_icon_down",""},
};
%>
@ -76,11 +78,21 @@ String sButtons[][] =null;
<%/*~END~*/%>
<%/*~BEGIN~可编辑区~[Editable=false;CodeAreaID=List06;Describe=定义按钮事件;]~*/%>
<iframe name="MyAtt" src="<%=com.amarsoft.awe.util.Escape.getBlankJsp(sWebRootPath,"正在下载附件,请稍候...")%>" style="background-color: blue" width=100% height=100% frameborder=0 hspace=0 vspace=0 marginwidth=0 marginheight=0 scrolling="no">
</iframe>
<form name=form1 method=post action="<%=sWebRootPath%>/servlet/view/fileTemplateView?CompClientID=<%=sCompClientID%>" target=MyAtt>
<div style="display:none">
<input id="sqlString" name=sqlString value="">
</div>
</form>
<script type="text/javascript">
function viewAndEdit(){
var sUrl = "/Tenwa/Lease/Flow/Comm/LBAssetTransferRegistration/LBEquipmentInfo.jsp";
var IDs = getItemValueArray(0,'ID')+","+TablePage.getCheckedItemValueArrayWithOtherPage("ID",s_c_p[0]);
if(typeof(IDs) == "undefined" || IDs.length == 0 ){alert("请选择一条信息!");return ;}
var IDs = getItemValueArray(0,'ID');//+","+TablePage.getCheckedItemValueArrayWithOtherPage("ID",s_c_p[0]);
if(typeof(IDs) == "undefined" || IDs.length == 0 ){
alert("请选择一条信息!");
return ;
}
var sParam = "ids="+IDs;
AsDialog.PopView(sUrl,sParam,
"dialogWidth=500px;dialogHeight=300px;resizable=no;scrollbars=no;status:yes;maximize:no;help:no;",function(sReturnInfo){
@ -93,6 +105,34 @@ String sButtons[][] =null;
},"资产转出登记修改");
reloadSelf();
}
//模板下载
function DiscountDownload(){
var sId="522b89b1329c46f2af20daced778e366";
if (typeof(sId)=="undefined" || sId.length==0){
return;
}else{
$("#sqlString").val("save@"+sId);
form1.submit();
}
}
function downloadFile(id){
if(!frames["downloadTemplate"]) $("<iframe name='downloadTemplate' style='display:none;'></iframe>").appendTo("body");
window.open(sWebRootPath+"/servlet/view/docDownloadServlet?CompClientID=<%=sCompClientID%>&sqlString=save@"+id, "downloadTemplate");
}
//excel导入
function importExcel(){
var importCondition={};//导入配置
importCondition["templateNo"]="522b89b1329c46f2af20daced778e366";//导入的模板编号必填s
//增加其他配置参数
importCondition["inputuserid"]="<%=CurUser.getUserID()%>";
importCondition["inputorgid"]="<%=CurUser.getOrgID()%>";
var sparam=JSON.stringify(importCondition).replace(/,/g,"@");//生成模板的参数据
AsDialog.PopView("/Tenwa/Core/OfficeTemplate/TemplateManager/BFTemplateTest/uploadExcel.jsp","importparam="+sparam,
{width:"350px",height:"40px",title:"上传资产转出数据"},function(){
importExcelNew();
reloadSelf();});
}
</script>

View File

@ -18,10 +18,10 @@
String sTempletNo = "LbFileArchivingInfoTemp";//--Ä£°åºÅ--
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
doTemp.setColTips("", "");
doTemp.setDefaultValue("CONTRACT_NUMBER", contractNumber);
/* doTemp.setDefaultValue("CONTRACT_NUMBER", contractNumber);
doTemp.setDefaultValue("CONTRACT_ID", contractId);
doTemp.setDefaultValue("FLOWUNID", flowunid);
doTemp.setDefaultValue("ARCHIVING_PERSON", CurUser.getUserName());
doTemp.setDefaultValue("ARCHIVING_PERSON", CurUser.getUserName()); */
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
dwTemp.Style = "2";//freeform
dwTemp.ReadOnly = "0";//Ö»¶Áģʽ
@ -34,6 +34,28 @@
sButtonPosition = "south";
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
<script type="text/javascript">
window.onload=function(){
setItemValue(0,getRow(),"INPUTUSERID","<%=inputuserid%>");
setItemValue(0,getRow(),"UPDATEUSERID","<%=inputuserid%>");
setItemValue(0,getRow(),"INPUTORGID","<%=inputorgid%>");
setItemValue(0,getRow(),"UPDATEORGID","<%=inputorgid%>");
setItemValue(0,getRow(),"CONTRACT_NUMBER","<%=contractNumber%>");
setItemValue(0,getRow(),"CONTRACT_ID","<%=contractId%>");
setItemValue(0,getRow(),"FLOWUNID","<%=flowunid%>");
setItemValue(0,getRow(),"ARCHIVING_PERSON","<%=inputusername%>");
var date = new Date();
var updatetime = date.toJSON().substring(0,10).replace(/-/g,"/")+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
var inputtime = date.toJSON().substring(0,10).replace(/-/g,"/")+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
var inputtimes = getItemValue(0,getRow(),"INPUTTIME");
if(inputtimes==null||inputtimes==""){
setItemValue(0,getRow(),"INPUTTIME",inputtime);
}
setItemValue(0,getRow(),"UPDATETIME",updatetime);
}
function returnList(){
AsControl.OpenView("/Tenwa/Lease/Flow/FileManager/MortgageFile/LbFileArchivingListTemp.jsp", "","_self","");
}

View File

@ -4974,12 +4974,48 @@
</attributes>
<manager>
<managerProperties>
<property name="table" value="vi_business_query" />
<property name="table" value="VI_PAY_APPLY" />
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
</package>
<class name="VI_PAY_APPLY_QUERY" label="" keyAttributes="flow_key">
<attributes>
<attribute name="relativeserialno" label="上一流水号" type="STRING"/>
<attribute name="serialno" label="流水号" type="STRING"/>
<attribute name="contract_id" label="合同编号" type="STRING"/>
<attribute name="proj_id" label="项目编号" type="STRING"/>
<attribute name="flow_unid" label="流程编号" type="STRING"/>
<attribute name="phaseno" label="当前阶段号" type="STRING"/>
<attribute name="flowname" label="当前流程名称" type="STRING"/>
<attribute name="applytype" label="申请类型" type="STRING"/>
<attribute name="phasetype" label="阶段类型" type="STRING"/>
<attribute name="objectno" label="对象编号" type="STRING"/>
<attribute name="objecttype" label="对象类型" type="STRING"/>
<attribute name="USERID" label="承办人编号" type="STRING"/>
<attribute name="flowno" label="当前流程号" type="STRING"/>
<attribute name="flow_key" label="项目/合同号" type="STRING"/>
<attribute name="CUSTOMER_NAME" label="承租人名称" type="STRING"/>
<attribute name="DISTRIBUTOR_NAME" label="经销商名称" type="STRING"/>
<attribute name="PHASENAME" label="当前任务名称" type="STRING"/>
<attribute name="USERNAME" label="当前处理人" type="STRING"/>
<attribute name="BEGINTIME" label="任务开始时间" type="STRING"/>
<attribute name="ENDTIME" label="任务结束时间" type="STRING"/>
<attribute name="is_pay" label="是否放款" type="STRING"/>
<attribute name="fact_date" label="起租日" type="STRING"/>
<attribute name="is_ARCHIVING" label="是否归档" type="STRING"/>
<attribute name="ARCHIVING_TIME" label="归档时间" type="STRING"/>
<attribute name="contract_status" label="合同状态" type="STRING"/>
<attribute name="flowstate" label="是否已退回" type="STRING"/>
</attributes>
<manager>
<managerProperties>
<property name="table" value="vi_pay_apply_query" />
<property name="createKey" value="true" />
</managerProperties>
</manager>
</class>
</package>
<package name="jbo.com.tenwa.lease.carbrand" >
<class name="LB_CLAIMS_BOOK_DETAIL" label="索赔申请书详情表" keyAttributes="ID">
<attributes>

View File

@ -0,0 +1,112 @@
package com.tenwa.apzl.discount;
import java.util.Map;
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO;
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.amarsoft.context.ASUser;
import com.tenwa.comm.exception.BusinessException;
import com.tenwa.officetempalte.importcallback.impl.BaseImportExcelCallBack;
public class AssetsOffCallBack extends BaseImportExcelCallBack{
@Override
public void run(ASUser CurUser, BizObject importObject,
Map<String, String> model, Integer rowIndex, JBOTransaction tx,
Transaction Sqlca) throws Exception {
//合同号
String contractNo = importObject.getAttribute("CONTRACT_NO")==null?"":importObject.getAttribute("CONTRACT_NO").toString();
//资产转出方
String assettransferer = importObject.getAttribute("ASSETTRANSFERER")==null?"":importObject.getAttribute("ASSETTRANSFERER").toString();
//转出日期
String transferdate = importObject.getAttribute("TRANSFERDATE")==null?"":importObject.getAttribute("TRANSFERDATE").toString();
//转出备注
String turnoutremarks = importObject.getAttribute("TURNOUTREMARKS")==null?"":importObject.getAttribute("TURNOUTREMARKS").toString();
if (contractNo=="" || assettransferer=="" || transferdate=="") {
throw new BusinessException("合同号或资产转出方或转出如期为空!");
}
//将yyyy-mm-dd这种日期格式改为yyyy/mm/dd
// 如果是8位 20000101
if(transferdate.indexOf("/") != -1){
String[] date = transferdate.split("/");
transferdate = "";
for(String d:date){
if(d.length() == 1){
d = "0"+d;
}
transferdate += d+"/";
}
transferdate = transferdate.substring(0,transferdate.length()-1);
}else if(transferdate.length()==8){
StringBuffer sb1=new StringBuffer(transferdate);
// 在3位置插入"/"
String s1=sb1.insert(4,"/").toString(); // 2000/0101
StringBuffer sb2=new StringBuffer(s1);
transferdate=sb2.insert(7,"/").toString(); // 2000/01/01
}else if(transferdate.contains("-")){
transferdate=transferdate.replaceAll("-", "/");
}else if(transferdate.contains("")&&transferdate.contains("")&&transferdate.contains("")){
transferdate=transferdate.replaceAll("", "/").replaceAll("","/").replaceAll("","");
}
String[] checkDate = transferdate.split("/");
try{
int year = Integer.parseInt(checkDate[0]);
int month = Integer.parseInt(checkDate[1]);
int day = Integer.parseInt(checkDate[2]);
int num = 28;
if(day <= 0){
throw new RuntimeException(""+(rowIndex+1)+"行日期不正确,不存在'"+day+"'这样的日期!");
}
String mes = "平年";
if((year%4 == 0 && year%100 != 0) || year%400 == 0){
num = 29;
mes = "闰年";
}
switch(month){
case 1:case 3:case 5:case 7:case 8:case 10:case 12:
if(day > 31 || day <= 0){
throw new RuntimeException(""+(rowIndex+1)+"行日期不正确,"+month+"月份没有"+day+"天!");
}
break;
case 2:
if(day > num || day <=0){
throw new RuntimeException(""+(rowIndex+1)+"行日期不正确,"+mes+month+"月份没有"+day+"天!");
}
break;
case 4:case 6:case 9:case 11:
if(day > 30 || day <=0){
throw new RuntimeException(""+(rowIndex+1)+"行日期不正确,"+month+"月份没有"+day+"天!");
}
break;
default:
throw new RuntimeException(""+(rowIndex+1)+"行月份错误,没有'"+month+"'月份!");
}
}catch(NumberFormatException e){
throw new BusinessException(""+(rowIndex+1)+"行日期格式不正确!");
}catch(RuntimeException e){
throw new BusinessException(e.getMessage());
}
//importObject.setAttributeValue("stores_day", stores_day);
//查询该合同号是否存在
BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME,tx);
BizObject contractInfo = contractInfoManager.createQuery("CONTRACT_NO=:CONTRACT_NO").setParameter("CONTRACT_NO", contractNo).getSingleResult(true);
if (contractInfo==null) {
throw new BusinessException("该合同号 "+contractNo+" 不存在!");
}
contractInfo.setAttributeValue("ASSETTRANSFERER", assettransferer);
contractInfo.setAttributeValue("TRANSFERDATE", transferdate);
contractInfo.setAttributeValue("TURNOUTREMARKS", turnoutremarks);
contractInfoManager.saveObject(contractInfo);
}
}