diff --git a/src_tenwa/com/tenwa/apzl/discount/AssetsOffCallBack.java b/src_tenwa/com/tenwa/apzl/discount/AssetsOffCallBack.java index c5b958e51..84ddd122d 100644 --- a/src_tenwa/com/tenwa/apzl/discount/AssetsOffCallBack.java +++ b/src_tenwa/com/tenwa/apzl/discount/AssetsOffCallBack.java @@ -1,8 +1,11 @@ package com.tenwa.apzl.discount; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; +import java.util.UUID; import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO; import jbo.voucher.LB_DISCOUNT; @@ -13,6 +16,7 @@ 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.amarsoft.dict.als.cache.CacheLoaderFactory; import com.tenwa.comm.exception.BusinessException; import com.tenwa.officetempalte.importcallback.impl.BaseImportExcelCallBack; @@ -95,7 +99,6 @@ public class AssetsOffCallBack extends BaseImportExcelCallBack{ throw new BusinessException(e.getMessage()); } - //查询该合同号是否存在 BizObjectManager contractInfoManager = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME,tx); BizObject contractInfo = contractInfoManager.createQuery("CONTRACT_NO=:CONTRACT_NO").setParameter("CONTRACT_NO", contractNo).getSingleResult(true); @@ -116,9 +119,13 @@ public class AssetsOffCallBack extends BaseImportExcelCallBack{ } // public void runBefore(ASUser CurUser, Map model, List importObjects, JBOTransaction tx,Transaction Sqlca) throws Exception { + Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource()); String error=""; boolean flag = false; String insertSql=""; + Date date = new Date(); + String date1 = new SimpleDateFormat("YYYY/MM/dd HH:mm:ss").format(date); + /** * 校验重复导入 */ @@ -135,15 +142,21 @@ public class AssetsOffCallBack extends BaseImportExcelCallBack{ if(!contractNo.contains(CONTRACT_NO)){ contractNo.add(CONTRACT_NO); }else { - insertSql="INSERT INTO li_assets_off(id,CONTRACT_NO,inputuser,inputtime,updateuser,updatetime) values()"; + String uuids = UUID.randomUUID().toString(); + String uuid = uuids.replaceAll("-", ""); + insertSql="INSERT INTO li_assets_off(id,CONTRACT_NO,inputuser,inputtime,updateuser,updatetime) values('"+uuid+"','"+CONTRACT_NO+"','administrator','"+date1+"','administrator','"+date1+"')"; Sqlca.executeSQL(insertSql); error+=",【"+CONTRACT_NO+"】"; flag=true; } } + Sqlca.commit(); if(flag) { error = error.substring(1); throw new BusinessException("该合同号:"+error+"已存在<<资产转出方>> 请勿重复导入!"); } + if(Sqlca !=null){ + Sqlca.disConnect(); + } } }