Commit 7cc2a9f3 authored by jiawei's avatar jiawei

修改 TBoxOperationController==》》getTBoxOperationPageList 返回区域名称和用户名

parent 3a0ac7eb
......@@ -82,6 +82,10 @@ public class TBoxOperation implements Serializable {
@TableField(exist = false)
private String organName;
@ApiModelProperty("用户名")
@TableField(exist = false)
private String userName;
@ApiModelProperty("机构名")
@TableField(exist = false)
private String organCode;
......
......@@ -6,12 +6,15 @@ import cn.chnmuseum.party.common.log.OperType;
import cn.chnmuseum.party.common.util.ExportExcelUtil;
import cn.chnmuseum.party.common.util.RSAUtils;
import cn.chnmuseum.party.common.validator.groups.Update;
import cn.chnmuseum.party.model.TAppVersion;
import cn.chnmuseum.party.model.TArea;
import cn.chnmuseum.party.model.TBoxOperation;
import cn.chnmuseum.party.model.TUser;
import cn.chnmuseum.party.service.TAreaService;
import cn.chnmuseum.party.service.TBoxOperationService;
import cn.chnmuseum.party.service.impl.TUserServiceImpl;
import cn.chnmuseum.party.web.controller.base.BaseController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
......@@ -22,17 +25,19 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
/**
* <pre>
......@@ -58,6 +63,9 @@ public class TBoxOperationController extends BaseController {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Autowired
TAreaService areaService;
private static final String SHIRO_JWT_TOKEN = "shiro:jwt:token:";
@ApiImplicitParams(value = {
......@@ -70,8 +78,8 @@ public class TBoxOperationController extends BaseController {
@PostMapping("/selectPageList")
@RequiresAuthentication //@RequiresPermissions("/boxOperation/selectPageList")
@ApiOperation(value = "获取机顶盒基础信息分页列表", notes = "获取机顶盒基础信息分页列表")
@MethodLog(operModule = OperModule.STBBASE,operType = OperType.SELECT)
public Map<String, Object> selectPageList(String organId, String areaId, LocalDate beginDate,LocalDate endDate) {
@MethodLog(operModule = OperModule.STBBASE, operType = OperType.SELECT)
public Map<String, Object> selectPageList(String organId, String areaId, LocalDate beginDate, LocalDate endDate) {
TUser user1 = getcurUser();
TUser user = new TUser();
if (StringUtils.isNotBlank(organId)) {
......@@ -104,7 +112,7 @@ public class TBoxOperationController extends BaseController {
@PostMapping("/add")
@RequiresAuthentication //@RequiresPermissions("/boxOperation/add")
@ApiOperation(value = "添加机顶盒运维信息", notes = "添加机顶盒运维信息")
@MethodLog(operModule = OperModule.STBOPERATION,operType = OperType.ADD)
@MethodLog(operModule = OperModule.STBOPERATION, operType = OperType.ADD)
public Map<String, Object> saveTBoxOperation(TBoxOperation tBoxOperation) {
// 保存业务节点信息
boolean result;
......@@ -130,36 +138,36 @@ public class TBoxOperationController extends BaseController {
@PutMapping("/update")
@RequiresAuthentication //@RequiresPermissions("/boxOperation/update")
@ApiOperation(value = "修改机顶盒运维信息", notes = "修改机顶盒运维信息")
@MethodLog(operModule = OperModule.STBOPERATION,operType = OperType.ACTIVATION)
@MethodLog(operModule = OperModule.STBOPERATION, operType = OperType.ACTIVATION)
public Map<String, Object> updateTBoxOperation(@Validated(value = Update.class) TBoxOperation tBoxOperation) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
try {
if (tBoxOperation != null && StringUtils.isNotBlank(tBoxOperation.getMac())) {
tBoxOperation.setMac(tBoxOperation.getMac().toUpperCase());
}
if (2==tBoxOperation.getStatus()) {
if (2 == tBoxOperation.getStatus()) {
TBoxOperation byId = tBoxOperationService.getById(tBoxOperation.getId());
if (byId.getMac()!=null&&!"".equals(byId.getMac())&&!byId.getMac().equals(tBoxOperation.getMac())){
if (byId.getMac() != null && !"".equals(byId.getMac()) && !byId.getMac().equals(tBoxOperation.getMac())) {
resultMap.put("resultCode", "400");
resultMap.put("message", "此账号已绑定机顶盒!");
return resultMap;
}
UpdateWrapper<TBoxOperation> wrapper = new UpdateWrapper<>();
wrapper.eq("mac",tBoxOperation.getMac());
wrapper.eq("mac", tBoxOperation.getMac());
TBoxOperation one = tBoxOperationService.getOne(wrapper);
if (one!=null&&!one.getOrganId().equals(tBoxOperation.getOrganId())){
if (one != null && !one.getOrganId().equals(tBoxOperation.getOrganId())) {
resultMap.put("resultCode", "400");
resultMap.put("message", "此mac地址已绑定账号!");
return resultMap;
}
}
if (3==tBoxOperation.getStatus()) {
if (3 == tBoxOperation.getStatus()) {
tBoxOperation.setMac(null);
TUser u = userService.getOne(new UpdateWrapper<TUser>().eq("org_id",tBoxOperation.getOrganId()).eq("type", 3).eq("is_deleted", false));
TUser u = userService.getOne(new UpdateWrapper<TUser>().eq("org_id", tBoxOperation.getOrganId()).eq("type", 3).eq("is_deleted", false));
Set<String> keys = stringRedisTemplate.keys(SHIRO_JWT_TOKEN + "*");
ValueOperations<String, String> value = stringRedisTemplate.opsForValue();
for (String key : keys) {
if (u.getId().equals(value.get(key))){
if (u.getId().equals(value.get(key))) {
stringRedisTemplate.delete(key);
}
}
......@@ -185,7 +193,7 @@ public class TBoxOperationController extends BaseController {
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "标识ID", paramType = "query", dataType = "String")
})
@MethodLog(operModule = OperModule.STBOPERATION,operType = OperType.DELETE)
@MethodLog(operModule = OperModule.STBOPERATION, operType = OperType.DELETE)
public Map<String, Object> deleteTBoxOperation(String id) {
boolean result;
try {
......@@ -203,7 +211,7 @@ public class TBoxOperationController extends BaseController {
@GetMapping("/getList")
@RequiresAuthentication //@RequiresPermissions("/boxOperation/getList")
@ApiOperation(value = "获取机顶盒运维信息全部列表(无分页)", notes = "获取机顶盒运维信息全部列表(无分页)")
@MethodLog(operModule = OperModule.STBOPERATION,operType = OperType.SELECT)
@MethodLog(operModule = OperModule.STBOPERATION, operType = OperType.SELECT)
public Map<String, Object> getTBoxOperationList(String status) {
List<TBoxOperation> tBoxOperationList = null;
TUser user = getcurUser();
......@@ -213,7 +221,7 @@ public class TBoxOperationController extends BaseController {
//设置数据权限
String areaId = user.getAreaId();
tBoxOperationList = tBoxOperationService.getList(status, getAreaId(areaId));
}else {
} else {
tBoxOperationList = tBoxOperationService.getList(status, null);
}
......@@ -234,7 +242,7 @@ public class TBoxOperationController extends BaseController {
@PostMapping("/getPageList")
@RequiresAuthentication //@RequiresPermissions("/boxOperation/getPageList")
@ApiOperation(value = "获取机顶盒运维信息分页列表", notes = "获取机顶盒运维信息分页列表")
@MethodLog(operModule = OperModule.STBOPERATION,operType = OperType.SELECT)
@MethodLog(operModule = OperModule.STBOPERATION, operType = OperType.SELECT)
public Map<String, Object> getTBoxOperationPageList(String organId, Integer status, String areaId) {
TUser user = getcurUser();
TBoxOperation tBoxOperation = new TBoxOperation();
......@@ -245,7 +253,7 @@ public class TBoxOperationController extends BaseController {
tBoxOperation.setStatus(status);
}
if (StringUtils.isNotBlank(areaId)) {
tBoxOperation.setAreaId(areaId);
tBoxOperation.setAreaId(areaId);
}
if (StringUtils.isNotBlank(user.getAreaId())) {
if ("4".equals(user.getType())) {
......@@ -253,13 +261,16 @@ public class TBoxOperationController extends BaseController {
tBoxOperation.setAreaName(getAreaId(user.getAreaId()));
}
}
if (user.getRoleList().size()>0&&!user.getRoleList().contains("1")) {
if (user.getRoleList().size() > 0 && !user.getRoleList().contains("1")) {
//设置用户数据权限
tBoxOperation.setOrganCode(user.getOrgCode());
}
Page<TBoxOperation> page = null;
try {
page = this.tBoxOperationService.selectPage(getPage(), tBoxOperation);
//
List<TBoxOperation> records = page.getRecords();
fillAreaName(records);
return getResult(page);
} catch (Exception e) {
e.printStackTrace();
......@@ -267,10 +278,32 @@ public class TBoxOperationController extends BaseController {
return getFailResult();
}
private void fillAreaName(List<TBoxOperation> records) {
if (CollectionUtils.isEmpty(records)) {
return;
}
List<String> areaIds = records.stream().map(TBoxOperation::getAreaId).collect(Collectors.toList());
LambdaQueryWrapper<TArea> wrapper = new QueryWrapper<TArea>().lambda()
.select(TArea::getId, TArea::getFullName, TArea::getName)
.in(TArea::getId, areaIds);
List<TArea> tAreas = areaService.list(wrapper);
//设置区域名称
records.stream().forEach(r -> {
tAreas.stream().forEach(a -> {
if (r.getAreaId() != null && r.getAreaId().equals(String.valueOf(a.getId()))) {
//设置地区全名
r.setAreaName(a.getFullName());
}
});
});
}
@ApiOperation(value = "获取机顶盒运维信息详情", notes = "获取机顶盒运维信息详情")
@GetMapping("/getById")
@RequiresAuthentication //@RequiresPermissions("/boxOperation/getById")
@MethodLog(operModule = OperModule.STBOPERATION,operType = OperType.SELECT)
@MethodLog(operModule = OperModule.STBOPERATION, operType = OperType.SELECT)
public Map<String, Object> getById(String id) {
TBoxOperation tBoxOperation = null;
try {
......@@ -283,7 +316,6 @@ public class TBoxOperationController extends BaseController {
}
@PostMapping("/export")
@RequiresAuthentication //@RequiresPermissions("/boxOperation/selectPageList")
@ApiOperation(value = "导出机顶盒基础信息列表", notes = "导出机顶盒基础信息列表")
......@@ -311,11 +343,11 @@ public class TBoxOperationController extends BaseController {
}
try {
List<TBoxOperation> list = tBoxOperationService.selectBoxList(user);
String[] title = {"序号","MAc地址","所属单位","展板播放次数","到期时间"};
String[] keys = {"id","mac","organName","num","macStatus"};
String[] title = {"序号", "MAc地址", "所属单位", "展板播放次数", "到期时间"};
String[] keys = {"id", "mac", "organName", "num", "macStatus"};
HSSFWorkbook hssfWorkbook = ExportExcelUtil.getHSSFWorkbook(title, list, keys);
response.setContentType("application/octet-stream;charset=ISO8859-1");
response.setHeader("Content-Disposition", "attachment;filename="+ "机顶盒基础信息表.xls");
response.setHeader("Content-Disposition", "attachment;filename=" + "机顶盒基础信息表.xls");
response.addHeader("Pargam", "no-cache");
response.addHeader("Cache-Control", "no-cache");
OutputStream os = response.getOutputStream();
......
......@@ -16,6 +16,7 @@
<result column="update_time" property="updateTime"/>
<result column="organ_name" property="organName"/>
<result column="area_name" property="areaName"/>
<result column="user_name" property="userName"></result>
<result column="permanent" property="permanent"/>
<result column="effective_date" property="effectiveDate"/>
<result column="exired_date" property="exiredDate"/>
......@@ -74,7 +75,7 @@
</select>
<select id="selectPageList" resultMap="BaseResultMap">
SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,u.user_name organ_name
SELECT b.id,b.organ_id,b.mac,b.status,b.area_id,b.create_time,b.update_time,r.name organ_name ,u.user_name
FROM t_box_operation b
left join t_organ r on r.id = b.organ_id
left join t_user u on u.org_id = b.organ_id and u.type = '3'
......
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