|
@@ -20,6 +20,7 @@ import com.hb.proj.model.DevicePO;
|
|
|
import com.hb.proj.model.SideTreeNode;
|
|
|
import com.hb.proj.model.Well;
|
|
|
import com.hb.proj.model.WellParamPO;
|
|
|
+import com.hb.proj.model.WellTempPO;
|
|
|
import com.hb.proj.model.WellVO;
|
|
|
import com.hb.xframework.dao.core.PreparedSQLArgs;
|
|
|
import com.hb.xframework.dao.core.SpringJdbcDAO;
|
|
@@ -42,6 +43,10 @@ public class WellService {
|
|
|
private DeviceService deviceService;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WellTempService wellTempService;
|
|
|
+
|
|
|
+
|
|
|
private String tabName="tzl_well";
|
|
|
|
|
|
|
|
@@ -148,12 +153,9 @@ public class WellService {
|
|
|
public WellVO get(String wellId){
|
|
|
String sql="""
|
|
|
|
|
|
- select w.*,g.org_name belong_org_name,d.device_code,
|
|
|
- p.temp_name patrol_std_temp_name
|
|
|
+ select w.*,g.org_name belong_org_name
|
|
|
from tzl_well w
|
|
|
left join tsys_org g on w.org_id=g.org_id and g.del_if=false
|
|
|
- left join tzl_gather_device d on d.well_id=w.well_id and d.del_if=false
|
|
|
- left join tzl_temp p on w.patrol_std_temp=p.temp_id and p.del_if=false
|
|
|
where w.well_id=?
|
|
|
|
|
|
""";
|
|
@@ -193,10 +195,11 @@ public class WellService {
|
|
|
BeanUtils.copyProperties(well, wpo);
|
|
|
this.insert(wpo);
|
|
|
well.setWellId(wpo.getWellId());
|
|
|
- deviceService.updateBindWell(well.getDeviceCode(),DevicePO.GATHER_DEV, well.getWellId());
|
|
|
+ deviceService.updateBindWell(well.getDeviceCode(),DevicePO.GATHER, well.getWellId());
|
|
|
}
|
|
|
copyWellParam(wells,tempWellId);
|
|
|
copyWellAlarm(wells,tempWellId);
|
|
|
+ copyWellTemp(wells,tempWellId);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -277,6 +280,7 @@ public class WellService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void addBatchWellParam(String wellId,List<WellParamPO> wparams,Map<String,Field> fieldMap,List<String> paramNames,String sql) throws Exception {
|
|
|
List<Object> argVals=null;
|
|
|
List<Object[]> sqlArgs=new ArrayList<Object[]>(wparams.size());
|
|
@@ -301,6 +305,52 @@ public class WellService {
|
|
|
|
|
|
dao.getJdbcTemplate().batchUpdate(sql, sqlArgs);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制模板井的显示模板
|
|
|
+ * @param wells
|
|
|
+ * @param tempWellId
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private void copyWellTemp(List<WellVO> wells,String tempWellId) throws Exception {
|
|
|
+ List<WellTempPO> wellTemps=wellTempService.loadWellTemp(tempWellId);
|
|
|
+ if(wellTemps==null||wellTemps.size()==0) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ PreparedSQLArgs batchArgs=UpdateHandler.getInsertPreparedSQL(wellTemps.get(0), "tzl_well_temp");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ for(Well well: wells) {
|
|
|
+
|
|
|
+ addBatchWellTemp(well.getWellId(),wellTemps,batchArgs.getParamNames(),batchArgs.getSql());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void addBatchWellTemp(String wellId,List<WellTempPO> temps,List<String> paramNames,String sql) throws Exception {
|
|
|
+ List<Object> argVals=null;
|
|
|
+ List<Object[]> sqlArgs=new ArrayList<Object[]>(temps.size());
|
|
|
+ Map<String,Field> fieldMap=getFieldMap(WellTempPO.class);
|
|
|
+ Field fd=null;
|
|
|
+ UUIDHexGenerator uuid = UUIDHexGenerator.getInstance();
|
|
|
+ for(WellTempPO temp : temps) {
|
|
|
+ temp.setRecordId(uuid.generate()); //设为新记录id
|
|
|
+ temp.setWellId(wellId); //设为目标井
|
|
|
+ argVals=new ArrayList<Object>();
|
|
|
+ for(String pn:paramNames) { //准备批量参数值
|
|
|
+ fd=fieldMap.get(pn);
|
|
|
+ fd.setAccessible(true);
|
|
|
+ argVals.add(fd.get(temp));
|
|
|
+ }
|
|
|
+ sqlArgs.add(argVals.toArray());
|
|
|
+ }
|
|
|
+
|
|
|
+ dao.getJdbcTemplate().batchUpdate(sql, sqlArgs);
|
|
|
+ }
|
|
|
|
|
|
private <T> Map<String,Field> getFieldMap(Class<T> cls){
|
|
|
Field[] fields=cls.getDeclaredFields();
|