Commit 54b8274f authored by tangwei's avatar tangwei

修改车辆绑定逻辑

parent 783f02de
...@@ -28,4 +28,6 @@ public class UserCar extends BaseEntity { ...@@ -28,4 +28,6 @@ public class UserCar extends BaseEntity {
private String carNum; private String carNum;
@TableField("car_id") @TableField("car_id")
private Long carId; private Long carId;
@TableField("team_id")
private String teamId;
} }
...@@ -12,6 +12,7 @@ public interface IUserCarService { ...@@ -12,6 +12,7 @@ public interface IUserCarService {
UserCar selectByAmosUserId(Long id); UserCar selectByAmosUserId(Long id);
UserCar selectByCarId(Long id);
List<UserCar> selectList(); List<UserCar> selectList();
String selectListid(); String selectListid();
void add(UserCar userCar); void add(UserCar userCar);
......
...@@ -1377,6 +1377,10 @@ public class CommandController extends BaseController { ...@@ -1377,6 +1377,10 @@ public class CommandController extends BaseController {
map.put("data", null); map.put("data", null);
return ResponseHelper.buildResponse(null); return ResponseHelper.buildResponse(null);
} }
if(teamId==null){
return ResponseHelper.buildResponse(null);
}
ResponseModel<Page<CarInfoDto>> data = equipFeignClient.equipmentCarList(teamId, name, code, pageNum, pageSize, id, isNo); ResponseModel<Page<CarInfoDto>> data = equipFeignClient.equipmentCarList(teamId, name, code, pageNum, pageSize, id, isNo);
List<CarInfoDto> array=null; List<CarInfoDto> array=null;
if(data != null && data.getResult()!=null){ if(data != null && data.getResult()!=null){
...@@ -1422,7 +1426,10 @@ public class CommandController extends BaseController { ...@@ -1422,7 +1426,10 @@ public class CommandController extends BaseController {
AgencyUserModel agencyUserModel = getUserInfo(); AgencyUserModel agencyUserModel = getUserInfo();
userCar.setAmosUserId(Long.valueOf(agencyUserModel.getUserId())); userCar.setAmosUserId(Long.valueOf(agencyUserModel.getUserId()));
userCar.setAmosUserName(agencyUserModel.getRealName()); userCar.setAmosUserName(agencyUserModel.getRealName());
if ("1".equals(type)) { if ("1".equals(type)) {
Firefighters orgUsr= firefightersService.selectByAmosOrgId(Long.valueOf(agencyUserModel.getUserId()));
userCar.setTeamId(orgUsr.getFireTeamId()+"");
userCarService.add(userCar); userCarService.add(userCar);
} else { } else {
userCarService.delete(userCar); userCarService.delete(userCar);
......
...@@ -33,6 +33,7 @@ import org.springframework.context.annotation.Lazy; ...@@ -33,6 +33,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
...@@ -279,6 +280,7 @@ public class CarController extends AbstractBaseController { ...@@ -279,6 +280,7 @@ public class CarController extends AbstractBaseController {
* @return * @return
*/ */
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@Transactional
@ApiOperation(httpMethod = "PUT", value = "编辑车辆信息(<font color='blue'>release</font>)", notes = "编辑车辆信息") @ApiOperation(httpMethod = "PUT", value = "编辑车辆信息(<font color='blue'>release</font>)", notes = "编辑车辆信息")
@PostMapping(value = "/update", produces = "application/json;charset=UTF-8") @PostMapping(value = "/update", produces = "application/json;charset=UTF-8")
public Car updateCar(@ApiParam(value = "车辆对象", required = true) @RequestBody Car car) { public Car updateCar(@ApiParam(value = "车辆对象", required = true) @RequestBody Car car) {
...@@ -295,6 +297,10 @@ public class CarController extends AbstractBaseController { ...@@ -295,6 +297,10 @@ public class CarController extends AbstractBaseController {
// Set<CarProperty> carpList = carRequest.getCarPropertyList(); // Set<CarProperty> carpList = carRequest.getCarPropertyList();
// carInstance = iCarService.saveCar(getUserInfo(), carInstance, carInfo, carpList); // carInstance = iCarService.saveCar(getUserInfo(), carInstance, carInfo, carpList);
// saveFile(carInstance);视频图片文件后期统一处理 // saveFile(carInstance);视频图片文件后期统一处理
//用来解绑车辆
jcsFeign.getUserCar(car.getId(),car.getTeamId());
EquipmentSpecificSerivceImpl.registerMqttTopic(car.getIotCode(), equipmentIotMqttReceiveConfig); EquipmentSpecificSerivceImpl.registerMqttTopic(car.getIotCode(), equipmentIotMqttReceiveConfig);
Car oldCar = iCarService.getById(car.getId()); Car oldCar = iCarService.getById(car.getId());
Car car1 = iCarService.updateOneById(car); Car car1 = iCarService.updateOneById(car);
......
...@@ -81,6 +81,16 @@ public interface JcsFeign { ...@@ -81,6 +81,16 @@ public interface JcsFeign {
@RequestParam(value = "type", required = false) String type, @RequestParam(value = "type", required = false) String type,
@RequestParam(value = "method", required = false) String method); @RequestParam(value = "method", required = false) String method);
@RequestMapping(value = "/firefighters/getUserCar/{carId}/{teamId}", method = RequestMethod.GET, consumes = "application/json")
void getUserCar(
@PathVariable(value = "carId") Long carId,
@PathVariable(value = "teamId") String teamId);
/** /**
* <pre> * <pre>
* 根据值班区域ID查询当前值班人 * 根据值班区域ID查询当前值班人
......
...@@ -12,6 +12,8 @@ import com.yeejoin.amos.boot.module.common.api.core.framework.PersonIdentify; ...@@ -12,6 +12,8 @@ import com.yeejoin.amos.boot.module.common.api.core.framework.PersonIdentify;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto; import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
import com.yeejoin.amos.boot.module.common.api.enums.OrgPersonEnum; import com.yeejoin.amos.boot.module.common.api.enums.OrgPersonEnum;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.entity.UserCar;
import com.yeejoin.amos.boot.module.jcs.api.service.IUserCarService;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -104,7 +106,8 @@ public class FirefightersController extends BaseController { ...@@ -104,7 +106,8 @@ public class FirefightersController extends BaseController {
@Value("${auth-key-fire-fighters:fire_fighters_info}") @Value("${auth-key-fire-fighters:fire_fighters_info}")
private String authKey; private String authKey;
@Autowired
IUserCarService userCarService;
/** /**
* 新增消防队员 * 新增消防队员
...@@ -193,6 +196,27 @@ public class FirefightersController extends BaseController { ...@@ -193,6 +196,27 @@ public class FirefightersController extends BaseController {
} }
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/getUserCar/{carId}/{teamId}", method = RequestMethod.GET)
@ApiOperation(httpMethod = "POST", value = "获取绑定车辆", notes = "获取绑定车辆")
@Transactional
public void getUserCar(@PathVariable Long carId,@PathVariable String teamId) {
try {
UserCar userCar =userCarService.selectByCarId(carId);
if(userCar!=null&&!userCar.getTeamId().equals(teamId)){
userCarService.delete(userCar);
}
} catch (Exception e) {
throw new RuntimeException("系统异常");
}
}
/** /**
* 修改消防队员 * 修改消防队员
* *
...@@ -205,6 +229,14 @@ public class FirefightersController extends BaseController { ...@@ -205,6 +229,14 @@ public class FirefightersController extends BaseController {
public ResponseModel<Object> updateByIdFirefighters(HttpServletRequest request, public ResponseModel<Object> updateByIdFirefighters(HttpServletRequest request,
@RequestBody FirefightersInfoDto firefighters) { @RequestBody FirefightersInfoDto firefighters) {
try { try {
//判断此消防人员所属队伍是否变换,
//获取用户已绑定车辆id、
UserCar userCar = userCarService.selectByAmosUserId(Long.valueOf(firefighters.getFirefighters().getAmosUserId()));
if(userCar!=null&&!userCar.getTeamId().equals(firefighters.getFirefighters().getFireTeamId()+"")){
userCarService.delete(userCar);
}
Firefighters firefighter = firefighters.getFirefighters(); Firefighters firefighter = firefighters.getFirefighters();
// BUG2168 居住地户籍所在地为空判断 bykongfm // BUG2168 居住地户籍所在地为空判断 bykongfm
if (firefighter.getResidenceDetails() != null) { if (firefighter.getResidenceDetails() != null) {
......
...@@ -38,6 +38,13 @@ public class UserCarServiceImpl extends BaseService<AircraftDto, UserCar, UserCa ...@@ -38,6 +38,13 @@ public class UserCarServiceImpl extends BaseService<AircraftDto, UserCar, UserCa
} }
@Override @Override
public UserCar selectByCarId(Long id) {
QueryWrapper<UserCar> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("car_id", id);
return UserCarMapper.selectOne(queryWrapper);
}
@Override
public List<UserCar> selectList() { public List<UserCar> selectList() {
return this.list(); return this.list();
} }
......
...@@ -2828,5 +2828,20 @@ ...@@ -2828,5 +2828,20 @@
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="tw" id="2022-03-25">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="jc_user_car" columnName="team_id"/>
</not>
</preConditions>
<comment>jc_user_car add column team_id 队伍id</comment>
<sql>
ALTER TABLE jc_user_car ADD team_id varchar(100) NULL COMMENT '队伍id';
</sql>
</changeSet>
</databaseChangeLog> </databaseChangeLog>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment