|  | @@ -3,12 +3,11 @@ package com.miniframe.bisiness.system;
 | 
	
		
			
				|  |  |  import com.miniframe.core.ExecProcessFlow;
 | 
	
		
			
				|  |  |  import com.miniframe.core.ext.UtilTools;
 | 
	
		
			
				|  |  |  import com.miniframe.generate.business.system.model.D00008BaseModel;
 | 
	
		
			
				|  |  | -import com.miniframe.model.system.DAccident;
 | 
	
		
			
				|  |  | -import com.miniframe.model.system.DAccidentSQLBuilder;
 | 
	
		
			
				|  |  | -import com.miniframe.model.system.DJob;
 | 
	
		
			
				|  |  | -import com.miniframe.model.system.DJobSQLBuilder;
 | 
	
		
			
				|  |  | +import com.miniframe.model.system.*;
 | 
	
		
			
				|  |  |  import com.miniframe.model.system.dao.DAccidentMapper;
 | 
	
		
			
				|  |  |  import com.miniframe.model.system.dao.DJobMapper;
 | 
	
		
			
				|  |  | +import com.miniframe.model.system.dao.DNodeMapper;
 | 
	
		
			
				|  |  | +import com.miniframe.model.system.dao.DNodeValMapper;
 | 
	
		
			
				|  |  |  import com.miniframe.service.impl.FileServiceImpl;
 | 
	
		
			
				|  |  |  import com.miniframe.template.TemplateGenerator;
 | 
	
		
			
				|  |  |  import com.miniframe.tools.XIDateTimeUtils;
 | 
	
	
		
			
				|  | @@ -19,6 +18,7 @@ import java.io.BufferedReader;
 | 
	
		
			
				|  |  |  import java.io.IOException;
 | 
	
		
			
				|  |  |  import java.io.InputStream;
 | 
	
		
			
				|  |  |  import java.io.InputStreamReader;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  import java.util.concurrent.CompletableFuture;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -47,30 +47,22 @@ public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
 | 
	
		
			
				|  |  |  		String dx =this.getA_d00008().getDx();
 | 
	
		
			
				|  |  |  		String reportstep =this.getA_d00008().getReportstep();
 | 
	
		
			
				|  |  |  		String interactionstep =this.getA_d00008().getInteractionstep();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +		String acctime =this.getA_d00008().getAcctime();
 | 
	
		
			
				|  |  |  		DAccidentMapper accidentDao  = UtilTools.getBean(DAccidentMapper.class);
 | 
	
		
			
				|  |  |  		DAccident accident= accidentDao.selectByPrimaryKey(aid);
 | 
	
		
			
				|  |  |  		DJobMapper dJobDao = UtilTools.getBean(DJobMapper.class);
 | 
	
		
			
				|  |  | -		DJob job =new DJob();
 | 
	
		
			
				|  |  | -		job.setAid(aid);
 | 
	
		
			
				|  |  | -		job.setTotaltime(totaltime);
 | 
	
		
			
				|  |  | -		job.setDt(dt);
 | 
	
		
			
				|  |  | -		job.setDx(dx);
 | 
	
		
			
				|  |  | -		job.setReportstep(reportstep);
 | 
	
		
			
				|  |  | -		job.setInteractionstep(interactionstep);
 | 
	
		
			
				|  |  | -		job.setStarttime(XIDateTimeUtils.getNowStr());
 | 
	
		
			
				|  |  | -		job.setState("0");//未执行
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		DJob job = CreateJob(aid, totaltime, dt, dx, reportstep, interactionstep, acctime);
 | 
	
		
			
				|  |  |  		dJobDao.insertSelective(job);
 | 
	
		
			
				|  |  |  		//获取最新JOB
 | 
	
		
			
				|  |  | -		DJobSQLBuilder jsb = new DJobSQLBuilder();
 | 
	
		
			
				|  |  | -		DJobSQLBuilder.Criteria jsc =jsb.createCriteria();
 | 
	
		
			
				|  |  | -		jsc.andAidEqualTo(aid);
 | 
	
		
			
				|  |  | -		jsb.setOrderByClause("starttime desc");
 | 
	
		
			
				|  |  | -		DJob newJob= dJobDao.selectByExample(jsb).get(0);
 | 
	
		
			
				|  |  | +		DJob newJob = getNewJob(aid, dJobDao);
 | 
	
		
			
				|  |  |  		Integer jid =newJob.getId();
 | 
	
		
			
				|  |  |  		//存储最新求解ID
 | 
	
		
			
				|  |  | -		accident.setJid(jid);
 | 
	
		
			
				|  |  | -		accidentDao.updateByPrimaryKey(accident);
 | 
	
		
			
				|  |  | +		changeAccident(accidentDao, accident, jid);
 | 
	
		
			
				|  |  | +		//获取传感器数据
 | 
	
		
			
				|  |  | +		//TODO:  需要从第三方获取
 | 
	
		
			
				|  |  | +		initDNodeVal(aid);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if(accident.getStype().equals("Fire")){
 | 
	
		
			
				|  |  |  			TemplateGenerator.createFireControl(aid,jid,totaltime,dt,dx,reportstep,interactionstep);
 | 
	
	
		
			
				|  | @@ -86,6 +78,57 @@ public class D00008Service extends D00008BaseModel implements ExecProcessFlow {
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private DJob CreateJob(Integer aid, String totaltime, String dt, String dx, String reportstep, String interactionstep, String acctime) {
 | 
	
		
			
				|  |  | +		DJob job =new DJob();
 | 
	
		
			
				|  |  | +		job.setAid(aid);
 | 
	
		
			
				|  |  | +		job.setAcctime(acctime);
 | 
	
		
			
				|  |  | +		job.setTotaltime(totaltime);
 | 
	
		
			
				|  |  | +		job.setDt(dt);
 | 
	
		
			
				|  |  | +		job.setDx(dx);
 | 
	
		
			
				|  |  | +		job.setReportstep(reportstep);
 | 
	
		
			
				|  |  | +		job.setInteractionstep(interactionstep);
 | 
	
		
			
				|  |  | +		job.setStarttime(XIDateTimeUtils.getNowStr());
 | 
	
		
			
				|  |  | +		job.setState("0");//未执行
 | 
	
		
			
				|  |  | +		return job;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private DJob getNewJob(Integer aid, DJobMapper dJobDao) {
 | 
	
		
			
				|  |  | +		DJobSQLBuilder jsb = new DJobSQLBuilder();
 | 
	
		
			
				|  |  | +		DJobSQLBuilder.Criteria jsc =jsb.createCriteria();
 | 
	
		
			
				|  |  | +		jsc.andAidEqualTo(aid);
 | 
	
		
			
				|  |  | +		jsb.setOrderByClause("starttime desc");
 | 
	
		
			
				|  |  | +		DJob newJob= dJobDao.selectByExample(jsb).get(0);
 | 
	
		
			
				|  |  | +		return newJob;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void changeAccident(DAccidentMapper accidentDao, DAccident accident, Integer jid) {
 | 
	
		
			
				|  |  | +		accident.setJid(jid);
 | 
	
		
			
				|  |  | +		accidentDao.updateByPrimaryKey(accident);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private void initDNodeVal(Integer aid) {
 | 
	
		
			
				|  |  | +		DNodeValMapper dnvm= UtilTools.getBean(DNodeValMapper.class);
 | 
	
		
			
				|  |  | +		DNodeValSQLBuilder sb =new DNodeValSQLBuilder();
 | 
	
		
			
				|  |  | +		DNodeValSQLBuilder.Criteria sc =sb.createCriteria();
 | 
	
		
			
				|  |  | +		sc.andAidEqualTo(aid);
 | 
	
		
			
				|  |  | +		dnvm.deleteByExample(sb);
 | 
	
		
			
				|  |  | +		DNodeMapper dnm = UtilTools.getBean(DNodeMapper.class);
 | 
	
		
			
				|  |  | +		List<DNode> nlist = dnm.selectAll();
 | 
	
		
			
				|  |  | +		for (DNode dn:nlist) {
 | 
	
		
			
				|  |  | +			DNodeVal nv = new DNodeVal();
 | 
	
		
			
				|  |  | +			nv.setAid(aid);
 | 
	
		
			
				|  |  | +			nv.setNid(dn.getId());
 | 
	
		
			
				|  |  | +			nv.setNname(dn.getName());
 | 
	
		
			
				|  |  | +			nv.setVal1(0.0f);
 | 
	
		
			
				|  |  | +			nv.setVal2(300.0f);
 | 
	
		
			
				|  |  | +			nv.setVal3(0.0f);
 | 
	
		
			
				|  |  | +			nv.setVal4(0.0f);
 | 
	
		
			
				|  |  | +			nv.setNtype(dn.getNtype());
 | 
	
		
			
				|  |  | +			dnvm.insertSelective(nv);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	//异步执行
 | 
	
		
			
				|  |  |  	@SneakyThrows
 | 
	
		
			
				|  |  |  	public void exeWater(Integer aid,Integer jid) throws Exception{
 |