|
@@ -14,9 +14,12 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import com.hb.proj.allconfig.AccessToken;
|
|
|
import com.hb.proj.base.service.DeviceService;
|
|
|
import com.hb.proj.base.service.WellService;
|
|
|
+import com.hb.proj.base.service.WellTempService;
|
|
|
import com.hb.proj.model.BatchWell;
|
|
|
import com.hb.proj.model.DevicePO;
|
|
|
+import com.hb.proj.model.TempPO;
|
|
|
import com.hb.proj.model.Well;
|
|
|
+import com.hb.proj.model.WellTempPO;
|
|
|
import com.hb.proj.model.WellVO;
|
|
|
import com.hb.proj.utils.RespVO;
|
|
|
import com.hb.proj.utils.RespVOBuilder;
|
|
@@ -34,6 +37,9 @@ public class WellController {
|
|
|
@Autowired
|
|
|
private DeviceService deviceService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WellTempService wellTempService;
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -43,19 +49,24 @@ public class WellController {
|
|
|
*/
|
|
|
@RequestMapping("/get")
|
|
|
public RespVO<WellVO> get(@NotBlank(message = "井编号不能为空") String wellId){
|
|
|
- return RespVOBuilder.ok(service.get(wellId));
|
|
|
+ WellVO well=service.get(wellId);
|
|
|
+ WellTempPO temp=wellTempService.getWellTemp(wellId, TempPO.TYPE_SINGLE);
|
|
|
+ well.setPatrolStdTemp(temp!=null?temp.getTempId():null);
|
|
|
+ temp=wellTempService.getWellTemp(wellId, TempPO.TYPE_SINGLE_GROUP);
|
|
|
+ well.setPatrolGrpcurveTemp(temp!=null?temp.getTempId():null);
|
|
|
+ return RespVOBuilder.ok(well);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 增加新井
|
|
|
- * @param well 新井实体
|
|
|
- * @param deviceCode 采集设备编码
|
|
|
+ * @param wellVO 新井实体
|
|
|
* @param token 登录人信息,自动从请求获取
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/add")
|
|
|
- public RespVO<String> add(@Validated Well well,String deviceCode,AccessToken token){
|
|
|
+ public RespVO<String> add(@Validated WellVO wellVO,AccessToken token){
|
|
|
+ Well well=wellVO.toWell();
|
|
|
if(service.existWellName(well.getWellName(),null)) {
|
|
|
return RespVOBuilder.error("该井名已存在");
|
|
|
}
|
|
@@ -63,33 +74,43 @@ public class WellController {
|
|
|
well.setCreateBy(well.getModifyBy());
|
|
|
String wellId=service.insert(well);
|
|
|
|
|
|
- deviceService.updateBindWell(deviceCode,DevicePO.GATHER_DEV, wellId);
|
|
|
+ //设备关联
|
|
|
+ deviceService.updateBindWell(wellVO.getDeviceCode(),DevicePO.GATHER, wellId);
|
|
|
+
|
|
|
+ //模板关联
|
|
|
+ wellTempService.saveWellTemp(wellVO.getWellId(),wellVO.getPatrolStdTemp(),TempPO.TYPE_SINGLE);
|
|
|
+ wellTempService.saveWellTemp(wellVO.getWellId(),wellVO.getPatrolGrpcurveTemp(),TempPO.TYPE_SINGLE_GROUP);
|
|
|
return RespVOBuilder.ok(wellId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新井数据
|
|
|
- * @param org 井实体
|
|
|
- * @param deviceCode 采集设备编码
|
|
|
+ * @param wellVO 井实体
|
|
|
* @param token 登录人信息,自动从请求获取
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/update")
|
|
|
- public RespVO<Object> update(@Validated Well well,String deviceCode,AccessToken token){
|
|
|
+ public RespVO<Object> update(@Validated WellVO wellVO,AccessToken token){
|
|
|
+ Well well=wellVO.toWell();
|
|
|
if(service.existWellName(well.getWellName(),well.getWellId())) {
|
|
|
return RespVOBuilder.error("更换的新井名已存在");
|
|
|
}
|
|
|
well.setModifyBy(token!=null?token.getTokenId():"unknow");
|
|
|
service.update(well);
|
|
|
|
|
|
- deviceService.updateBindWell(deviceCode,DevicePO.GATHER_DEV, well.getWellId());
|
|
|
+ //设备关联
|
|
|
+ deviceService.updateBindWell(wellVO.getDeviceCode(),DevicePO.GATHER, well.getWellId());
|
|
|
+
|
|
|
+ //模板关联
|
|
|
+ wellTempService.saveWellTemp(wellVO.getWellId(),wellVO.getPatrolStdTemp(),TempPO.TYPE_SINGLE);
|
|
|
+ wellTempService.saveWellTemp(wellVO.getWellId(),wellVO.getPatrolGrpcurveTemp(),TempPO.TYPE_SINGLE_GROUP);
|
|
|
return RespVOBuilder.ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 删除单个井数据
|
|
|
- * @param orgId 被删除井id
|
|
|
+ * @param wellId 被删除井id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/delete")
|
|
@@ -101,9 +122,7 @@ public class WellController {
|
|
|
|
|
|
/**
|
|
|
* 批量加井
|
|
|
- * @param tempWellId 模板井号
|
|
|
- * @param orgId 新井所属井站
|
|
|
- * @param newWellJson
|
|
|
+ * @param batchWell 批量井信息
|
|
|
* @param token 登录人信息,自动从请求获取
|
|
|
* @return
|
|
|
* @throws Exception
|