yang_shj
3 months ago
7 changed files with 179 additions and 4 deletions
@ -0,0 +1,34 @@ |
|||||||
|
package com.hnac.hzims.operational.station.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.EqualsAndHashCode; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
import org.springblade.core.tenant.mp.TenantEntity; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
@EqualsAndHashCode(callSuper = false) |
||||||
|
@Accessors(chain = true) |
||||||
|
@TableName("hzims_user_dept_config") |
||||||
|
public class UserDeptConfigEntity extends TenantEntity { |
||||||
|
|
||||||
|
@ApiModelProperty("机构Id") |
||||||
|
private Long deptId; |
||||||
|
|
||||||
|
@ApiModelProperty("机构名称") |
||||||
|
private String deptName; |
||||||
|
|
||||||
|
@ApiModelProperty("机构类别: 4-站点 3-区域 2,1-集团") |
||||||
|
private Integer deptCategory; |
||||||
|
|
||||||
|
@ApiModelProperty("站点ID") |
||||||
|
private String stationId; |
||||||
|
|
||||||
|
@ApiModelProperty("站点名称") |
||||||
|
private String stationName; |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
package com.hnac.hzims.operational.station.controller; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||||
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||||
|
import com.hnac.hzims.operational.station.entity.UserDeptConfigEntity; |
||||||
|
import com.hnac.hzims.operational.station.entity.VideoRecordEntity; |
||||||
|
import com.hnac.hzims.operational.station.service.UserDeptConfigService; |
||||||
|
import com.hnac.hzims.operational.station.service.VideoRecordService; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import org.springblade.core.boot.ctrl.BladeController; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.validation.Valid; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
@RestController |
||||||
|
@RequestMapping("/userDept/config") |
||||||
|
@RequiredArgsConstructor |
||||||
|
@Api(value = "用户机构配置保存记录", tags = "用户机构配置保存记录") |
||||||
|
public class UserDeptConfigController extends BladeController { |
||||||
|
|
||||||
|
private final UserDeptConfigService userDeptConfigService; |
||||||
|
|
||||||
|
@PostMapping("/submit") |
||||||
|
@ApiOperationSupport(order = 1) |
||||||
|
@ApiOperation(value = "新增或修改用户机构配置记录", notes = "传入UserDeptConfigEntity") |
||||||
|
public R submit(@Valid @RequestBody UserDeptConfigEntity entity) { |
||||||
|
return R.status(userDeptConfigService.submit(entity)); |
||||||
|
} |
||||||
|
|
||||||
|
@GetMapping("/query") |
||||||
|
@ApiOperationSupport(order = 2) |
||||||
|
@ApiOperation(value = "查询站点用户机构配置保存记录", notes = "传入userId") |
||||||
|
public R query(@RequestParam("userId") String userId) { |
||||||
|
return R.data(userDeptConfigService.getOne(Wrappers.<UserDeptConfigEntity>lambdaQuery() |
||||||
|
.eq(UserDeptConfigEntity::getCreateUser,userId) |
||||||
|
)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.hnac.hzims.operational.station.mapper.UserDeptConfigMapper"> |
||||||
|
</mapper> |
@ -0,0 +1,12 @@ |
|||||||
|
package com.hnac.hzims.operational.station.mapper; |
||||||
|
|
||||||
|
import com.hnac.hzims.operational.station.entity.UserDeptConfigEntity; |
||||||
|
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
public interface UserDeptConfigMapper extends UserDataScopeBaseMapper<UserDeptConfigEntity> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
package com.hnac.hzims.operational.station.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.hnac.hzims.operational.station.entity.UserDeptConfigEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author ysj |
||||||
|
*/ |
||||||
|
public interface UserDeptConfigService extends IService<UserDeptConfigEntity> { |
||||||
|
boolean submit(UserDeptConfigEntity entity); |
||||||
|
} |
@ -0,0 +1,64 @@ |
|||||||
|
package com.hnac.hzims.operational.station.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.hnac.hzims.operational.station.entity.StationEntity; |
||||||
|
import com.hnac.hzims.operational.station.entity.UserDeptConfigEntity; |
||||||
|
import com.hnac.hzims.operational.station.mapper.UserDeptConfigMapper; |
||||||
|
import com.hnac.hzims.operational.station.service.IStationService; |
||||||
|
import com.hnac.hzims.operational.station.service.UserDeptConfigService; |
||||||
|
import lombok.RequiredArgsConstructor; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springblade.core.tool.api.R; |
||||||
|
import org.springblade.core.tool.utils.ObjectUtil; |
||||||
|
import org.springblade.system.entity.Dept; |
||||||
|
import org.springblade.system.feign.ISysClient; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author 86187 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
@RequiredArgsConstructor |
||||||
|
@Slf4j |
||||||
|
public class UserDeptConfigServiceImpl extends ServiceImpl<UserDeptConfigMapper, UserDeptConfigEntity> implements UserDeptConfigService { |
||||||
|
|
||||||
|
private final ISysClient sysClient; |
||||||
|
|
||||||
|
private final IStationService stationService; |
||||||
|
|
||||||
|
/** |
||||||
|
* 保存用户机构配置 |
||||||
|
* @param entity |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public boolean submit(UserDeptConfigEntity entity) { |
||||||
|
if(ObjectUtil.isEmpty(entity.getDeptId())){ |
||||||
|
return false; |
||||||
|
} |
||||||
|
R<Dept> dept = sysClient.getDept(entity.getDeptId()); |
||||||
|
if(!dept.isSuccess() || ObjectUtil.isEmpty(dept.getData())){ |
||||||
|
return false; |
||||||
|
} |
||||||
|
entity.setDeptName(dept.getData().getDeptName()); |
||||||
|
entity.setDeptCategory(dept.getData().getDeptCategory()); |
||||||
|
if(dept.getData().getDeptCategory() == 4){ |
||||||
|
StationEntity station = stationService.getOne(Wrappers.<StationEntity>lambdaQuery() |
||||||
|
.eq(StationEntity::getRefDept,dept.getData().getId()) |
||||||
|
); |
||||||
|
if(ObjectUtil.isNotEmpty(station)){ |
||||||
|
entity.setStationId(station.getCode()); |
||||||
|
entity.setStationName(station.getName()); |
||||||
|
}else{ |
||||||
|
entity.setStationId(null); |
||||||
|
entity.setStationName(null); |
||||||
|
} |
||||||
|
}else{ |
||||||
|
entity.setStationId(null); |
||||||
|
entity.setStationName(null); |
||||||
|
} |
||||||
|
|
||||||
|
return super.saveOrUpdate(entity); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue