日期:2014-05-16 浏览次数:20350 次
CREATE OR REPLACE PROCEDURE CASE_ACLINE_TEMP_INSERT AS SQL_STMT VARCHAR2(1000) ; TYPE T_CUR IS REF CURSOR; V_PCUR T_CUR; TYPE CASE_IDS_TBL IS TABLE OF CASE_INFO_TEMP.ID%TYPE INDEX BY PLS_INTEGER; CASE_IDS CASE_IDS_TBL ; RESULTCOUNT INTEGER ; BEGIN SQL_STMT := 'SELECT ID FROM CASE_INFO_TEMP WHERE ID > 725' ; EXECUTE IMMEDIATE 'SELECT COUNT(1) FROM ('||SQL_STMT||') ' INTO RESULTCOUNT ; IF RESULTCOUNT = 0 THEN RETURN ; END IF ; OPEN V_PCUR FOR SQL_STMT; FETCH V_PCUR BULK COLLECT INTO CASE_IDS; FOR I IN CASE_IDS.FIRST .. CASE_IDS.LAST LOOP SQL_STMT := 'INSERT INTO CASE_ACLINE_TEMP SELECT ID,NAME,VALID,I_NODE ,'; SQL_STMT := SQL_STMT || 'J_NODE,I_OFF,J_OFF,NOTE,'||CASE_IDS(I)||',R,X,B,UPDATETIME,I_P,I_Q,'; SQL_STMT := SQL_STMT || 'J_P,J_Q,I_QC,J_QC FROM CASE_ACLINE WHERE CASE_ID=725' ; --DBMS_OUTPUT.PUT_LINE(SQL_STMT); EXECUTE IMMEDIATE SQL_STMT ; COMMIT ; END LOOP; CLOSE V_PCUR ; END CASE_ACLINE_TEMP_INSERT;
@Service public class CaseAclineServiceImpl extends CaseServiceImpl<CaseAcline> implements CaseAclineService { @Autowired private CaseAclineDao aclineDao; public void insertTemp(int caseID, CountDownLatch counter) { long l1 = System.currentTimeMillis() ; this.aclineDao.insertTemp(caseID); counter.countDown() ; long l2 = System.currentTimeMillis() ; System.out.println("编号 "+caseID+ "插入消耗:"+(l2-l1)+"毫秒"); } public void queryTemp(int caseID, CountDownLatch counter) { long l1 = System.currentTimeMillis() ; Query q = new Query() ; q.addQueryParam("caseID", caseID) ; //PagingResult<CaseAcline> pr = this.aclineDao.queryTemp(q); this.aclineDao.insertTemp(caseID); //PagingResult<CaseAcline> caseAcline = this.aclineDao.queryTemp(q) ; long l2 = System.currentTimeMillis() ; System.out.println("编号 "+caseID+ " 查询消耗:"+((l2-l1)/1000)+"秒"); counter.countDown() ; } } /** * @filename: TestWorker * @description: TODO * @author java 小生 * @date 2013-2-27 上午11:32:28 */ public class TestWorker extends Thread{ private CaseAclineService caseAclineService; private CountDownLatch counter; private int caseID ; TestWorker(CaseAclineService caseAclineService,CountDownLatch counter,int caseID ){ this.caseAclineService = caseAclineService ; this.counter = counter ; this.caseID = caseID ; } @Override public void run(){ //System.out.println(caseID); caseAclineService.queryTemp(caseID, counter); } } /** * @filename: CaseAclineServiceTest * @description: TODO * @author java 小生 * @date 2013-2-26 下午11:27:50 */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath:applicationContext.xml"}) public class CaseAclineServiceTest{ CountDownLatch coun