|
@@ -0,0 +1,209 @@
|
|
|
|
+package com.miniframe.bisiness.system;
|
|
|
|
+
|
|
|
|
+import java.time.ZoneId;
|
|
|
|
+import java.time.ZonedDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+import com.miniframe.core.ExecProcessFlow;
|
|
|
|
+import com.miniframe.core.exception.BusinessException;
|
|
|
|
+import com.miniframe.core.ext.UtilTools;
|
|
|
|
+import com.miniframe.generate.business.system.model.D10019BaseModel;
|
|
|
|
+import com.miniframe.generate.comm.system.D_D10019_ROWS_DATA_RECODE;
|
|
|
|
+import com.miniframe.generate.comm.system.D_D10019_ROWS_RECODE;
|
|
|
|
+import com.miniframe.generate.comm.system.D_D10019_STEPTIMES_RECODE;
|
|
|
|
+import com.miniframe.model.system.*;
|
|
|
|
+import com.miniframe.model.system.dao.DAccidentMapper;
|
|
|
|
+import com.miniframe.model.system.dao.DChecknodeValMapper;
|
|
|
|
+import com.miniframe.model.system.dao.DChecknodeValcodeMapper;
|
|
|
|
+import com.miniframe.model.system.dao.DJobMapper;
|
|
|
|
+import com.miniframe.tools.XIDateTimeUtils;
|
|
|
|
+import tk.mybatis.mapper.util.StringUtil;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 基础系统,“监测点结果批量获取”逻辑处理(重新生成不覆盖)。
|
|
|
|
+ */
|
|
|
|
+public class D10019Service extends D10019BaseModel implements ExecProcessFlow {
|
|
|
|
+
|
|
|
|
+ private static final long serialVersionUID = -7051358269847459502L;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 基础系统,“监测点结果批量获取”业务核心处理
|
|
|
|
+ */
|
|
|
|
+ public void transExecute() throws Exception {
|
|
|
|
+ Integer aid= getA_d10019().getAid();
|
|
|
|
+ String chname =getA_d10019().getChname();
|
|
|
|
+ DAccidentMapper accidentDao = UtilTools.getBean(DAccidentMapper.class);
|
|
|
|
+ DAccident accident= accidentDao.selectByPrimaryKey(aid);
|
|
|
|
+ if(accident==null){
|
|
|
|
+ throw new BusinessException("EB3000002");
|
|
|
|
+ }
|
|
|
|
+ if(accident.getJid()==null||accident.getJid()==0){
|
|
|
|
+ throw new BusinessException("EB3100012");
|
|
|
|
+ }
|
|
|
|
+ DJobMapper jobMapper =UtilTools.getBean(DJobMapper.class);
|
|
|
|
+ DJob job =jobMapper.selectByPrimaryKey(accident.getJid());
|
|
|
|
+ if(job==null){
|
|
|
|
+ throw new BusinessException("EB3100012");
|
|
|
|
+ }
|
|
|
|
+ List<D_D10019_STEPTIMES_RECODE> steptimes = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ findStepTime(job, steptimes);
|
|
|
|
+
|
|
|
|
+ List<D_D10019_ROWS_RECODE> rows =new ArrayList<>();
|
|
|
|
+ findRows(aid, chname, accident, job, rows);
|
|
|
|
+
|
|
|
|
+ this.getD_d10019().setSteptimes(steptimes);
|
|
|
|
+ this.getD_d10019().setRows(rows);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void findRows(Integer aid, String chname, DAccident accident, DJob job, List<D_D10019_ROWS_RECODE> rows) throws BusinessException {
|
|
|
|
+ DChecknodeValcodeMapper valcodeMapper =UtilTools.getBean(DChecknodeValcodeMapper.class);
|
|
|
|
+ DChecknodeValcodeSQLBuilder codesb =new DChecknodeValcodeSQLBuilder();
|
|
|
|
+ DChecknodeValcodeSQLBuilder.Criteria codesc = codesb.createCriteria();
|
|
|
|
+ codesc.andAidEqualTo(aid);
|
|
|
|
+ codesc.andJidEqualTo(accident.getJid());
|
|
|
|
+
|
|
|
|
+ List<DChecknodeValcode> valcodes = valcodeMapper.selectByExample(codesb );
|
|
|
|
+ if(valcodes.isEmpty()){
|
|
|
|
+ throw new BusinessException("EB3100026");
|
|
|
|
+ }
|
|
|
|
+ DChecknodeValcode valcode =valcodes.get(0);
|
|
|
|
+ DChecknodeValMapper valMapper =UtilTools.getBean(DChecknodeValMapper.class);
|
|
|
|
+ DChecknodeValSQLBuilder sb =new DChecknodeValSQLBuilder();
|
|
|
|
+ DChecknodeValSQLBuilder.Criteria sc = sb.createCriteria();
|
|
|
|
+ sc.andAidEqualTo(aid);
|
|
|
|
+ sc.andJidEqualTo(job.getId());
|
|
|
|
+ sc.andChnameEqualTo(chname);
|
|
|
|
+ sb.setOrderByClause("step ASC");
|
|
|
|
+ List<DChecknodeVal> vals =new ArrayList<>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(!StringUtil.isEmpty(valcode.getValCode1())){
|
|
|
|
+ D_D10019_ROWS_RECODE row =new D_D10019_ROWS_RECODE();
|
|
|
|
+ row.setCode(valcode.getValCode1());
|
|
|
|
+ List<D_D10019_ROWS_DATA_RECODE> rowdatas =new ArrayList<>();
|
|
|
|
+ for (DChecknodeVal val:vals) {
|
|
|
|
+ D_D10019_ROWS_DATA_RECODE rowdata =new D_D10019_ROWS_DATA_RECODE();
|
|
|
|
+ rowdata.setVal(val.getV1());
|
|
|
|
+ rowdatas.add(rowdata);
|
|
|
|
+ }
|
|
|
|
+ row.setData(rowdatas);
|
|
|
|
+ rows.add(row);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!StringUtil.isEmpty(valcode.getValCode2())){
|
|
|
|
+ D_D10019_ROWS_RECODE row =new D_D10019_ROWS_RECODE();
|
|
|
|
+ row.setCode(valcode.getValCode2());
|
|
|
|
+ List<D_D10019_ROWS_DATA_RECODE> rowdatas =new ArrayList<>();
|
|
|
|
+ for (DChecknodeVal val:vals) {
|
|
|
|
+ D_D10019_ROWS_DATA_RECODE rowdata =new D_D10019_ROWS_DATA_RECODE();
|
|
|
|
+ rowdata.setVal(val.getV2());
|
|
|
|
+ rowdatas.add(rowdata);
|
|
|
|
+ }
|
|
|
|
+ row.setData(rowdatas);
|
|
|
|
+ rows.add(row);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!StringUtil.isEmpty(valcode.getValCode3())){
|
|
|
|
+ D_D10019_ROWS_RECODE row =new D_D10019_ROWS_RECODE();
|
|
|
|
+ row.setCode(valcode.getValCode3());
|
|
|
|
+ List<D_D10019_ROWS_DATA_RECODE> rowdatas =new ArrayList<>();
|
|
|
|
+ for (DChecknodeVal val:vals) {
|
|
|
|
+ D_D10019_ROWS_DATA_RECODE rowdata =new D_D10019_ROWS_DATA_RECODE();
|
|
|
|
+ rowdata.setVal(val.getV3());
|
|
|
|
+ rowdatas.add(rowdata);
|
|
|
|
+ }
|
|
|
|
+ row.setData(rowdatas);
|
|
|
|
+ rows.add(row);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!StringUtil.isEmpty(valcode.getValCode4())){
|
|
|
|
+ D_D10019_ROWS_RECODE row =new D_D10019_ROWS_RECODE();
|
|
|
|
+ row.setCode(valcode.getValCode4());
|
|
|
|
+ List<D_D10019_ROWS_DATA_RECODE> rowdatas =new ArrayList<>();
|
|
|
|
+ for (DChecknodeVal val:vals) {
|
|
|
|
+ D_D10019_ROWS_DATA_RECODE rowdata =new D_D10019_ROWS_DATA_RECODE();
|
|
|
|
+ rowdata.setVal(val.getV4());
|
|
|
|
+ rowdatas.add(rowdata);
|
|
|
|
+ }
|
|
|
|
+ row.setData(rowdatas);
|
|
|
|
+ rows.add(row);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!StringUtil.isEmpty(valcode.getValCode5())){
|
|
|
|
+ D_D10019_ROWS_RECODE row =new D_D10019_ROWS_RECODE();
|
|
|
|
+ row.setCode(valcode.getValCode5());
|
|
|
|
+ List<D_D10019_ROWS_DATA_RECODE> rowdatas =new ArrayList<>();
|
|
|
|
+ for (DChecknodeVal val:vals) {
|
|
|
|
+ D_D10019_ROWS_DATA_RECODE rowdata =new D_D10019_ROWS_DATA_RECODE();
|
|
|
|
+ rowdata.setVal(val.getV5());
|
|
|
|
+ rowdatas.add(rowdata);
|
|
|
|
+ }
|
|
|
|
+ row.setData(rowdatas);
|
|
|
|
+ rows.add(row);
|
|
|
|
+ }
|
|
|
|
+ if(!StringUtil.isEmpty(valcode.getValCode6())){
|
|
|
|
+ D_D10019_ROWS_RECODE row =new D_D10019_ROWS_RECODE();
|
|
|
|
+ row.setCode(valcode.getValCode6());
|
|
|
|
+ List<D_D10019_ROWS_DATA_RECODE> rowdatas =new ArrayList<>();
|
|
|
|
+ for (DChecknodeVal val:vals) {
|
|
|
|
+ D_D10019_ROWS_DATA_RECODE rowdata =new D_D10019_ROWS_DATA_RECODE();
|
|
|
|
+ rowdata.setVal(val.getV6());
|
|
|
|
+ rowdatas.add(rowdata);
|
|
|
|
+ }
|
|
|
|
+ row.setData(rowdatas);
|
|
|
|
+ rows.add(row);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void findStepTime(DJob job, List<D_D10019_STEPTIMES_RECODE> steptimes) {
|
|
|
|
+ Integer stepnum = Integer.valueOf(job.getTotaltime())/Integer.valueOf(job.getReportstep());
|
|
|
|
+ for (int i = 1; i <= stepnum; i++) {
|
|
|
|
+ D_D10019_STEPTIMES_RECODE steptime =new D_D10019_STEPTIMES_RECODE();
|
|
|
|
+ steptime.setSteptime(getStepTimeByStep(job,i));
|
|
|
|
+ steptimes.add(steptime);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public String getStepTimeByStep(DJob job,Integer step) {
|
|
|
|
+ Date date=XIDateTimeUtils.getDateFromZonedStr(job.getAcctime());
|
|
|
|
+ Calendar calendar =Calendar.getInstance();
|
|
|
|
+ calendar.setTime(date);
|
|
|
|
+ calendar.add(Calendar.SECOND,step*Integer.valueOf(job.getReportstep()));
|
|
|
|
+ Date date2=calendar.getTime();
|
|
|
|
+ DateTimeFormatter timeFormatter =DateTimeFormatter.ofPattern("HH:mm");
|
|
|
|
+ String s =timeFormatter.format(ZonedDateTime.ofInstant(date2.toInstant(), ZoneId.systemDefault()));
|
|
|
|
+ return s;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 基础系统,“监测点结果批量获取”业务前处理
|
|
|
|
+ */
|
|
|
|
+ public void preTransFlow() throws Exception {
|
|
|
|
+ this.validater();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 基础系统,“监测点结果批量获取”业务后处理
|
|
|
|
+ */
|
|
|
|
+ public void afterTransFlow() throws Exception {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 基础系统,“监测点结果批量获取”逻辑入口处理方法
|
|
|
|
+ */
|
|
|
|
+ @SuppressWarnings("rawtypes")
|
|
|
|
+ @Override
|
|
|
|
+ public Map execute(Map vars) throws Exception {
|
|
|
|
+ this.setTransMap(vars);
|
|
|
|
+ preTransFlow();// 执行业务开始的规则检查和校验
|
|
|
|
+ transExecute();// 执行核心业务段
|
|
|
|
+ afterTransFlow();// 执行核心逻辑完成后的收尾逻辑
|
|
|
|
+ return this.getTransMap();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|