自定义组件代码bug解决

This commit is contained in:
2022-09-13 14:39:32 +08:00
parent 56182aa79c
commit da281bfde5
11 changed files with 93 additions and 28 deletions

View File

@@ -334,6 +334,17 @@ public class InfluxDBResultMapperCn {
return true;
}
if (LocalDateTime.class.isAssignableFrom(fieldType)) {
LocalDateTime localDateTime;
if (value instanceof String) {
localDateTime = LocalDateTime.ofInstant(Instant.from(DateTimeFormatter.ISO_DATE_TIME.parse(String.valueOf(value))), ZoneId.systemDefault());
} else {
throw new InfluxDBMapperException("Unsupported type " + field.getClass() + " for field " + field.getName());
}
field.set(object, localDateTime);
return true;
}
return false;
}

View File

@@ -130,10 +130,12 @@ public class DeviceInfoParam implements Serializable {
@ApiModelProperty("开始时间")
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
@NotBlank(message = "起始时间不可为空")
private String searchBeginTime;
@ApiModelProperty("结束时间")
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
@NotBlank(message = "结束时间不可为空")
private String searchEndTime;
@ApiModelProperty("时间范围标志 0.查询展示天 1.查询展示月")
@@ -146,10 +148,12 @@ public class DeviceInfoParam implements Serializable {
public static class CompareBusinessParam extends BusinessParam{
@ApiModelProperty("比较开始时间")
@NotBlank(message = "比较开始时间不可为空")
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
private String periodBeginTime;
@ApiModelProperty("比较结束时间")
@NotBlank(message = "比较结束时间不可为空")
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
private String periodEndTime;

View File

@@ -1,7 +1,9 @@
package com.njcn.device.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -12,6 +14,8 @@ import java.math.BigDecimal;
* @date 2022/6/29
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AreaLineInfoVO implements Serializable {
@ApiModelProperty(name = "lineId",value = "监测点id")

View File

@@ -68,7 +68,6 @@ public class TerminalTreeController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
@PostMapping("getTerminalTreeForFive")
@ApiImplicitParam(name = "deviceInfoParam", value = "台账查询参数", required = true)
@Validated
public HttpResult<List<TerminalTree>> getTerminalTreeForFive(@RequestBody @Validated DeviceInfoParam deviceInfoParam){
String methodDescribe = getMethodDescribe("getTerminalTreeForFive");
List<TerminalTree> tree = terminalTreeService.getTerminalTreeForFive(deviceInfoParam);

View File

@@ -6,6 +6,7 @@ import org.influxdb.annotation.Measurement;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.Instant;
import java.time.LocalDateTime;
/**
* @author cdf
@@ -22,7 +23,7 @@ public class EventDetailNew {
@Column(name = "time")
@DateTimeFormat(pattern = "yyyy-mm-dd")
private Instant timeId;
private LocalDateTime timeId;
@Column(name = "event_describe")
private String eventDescribe;

View File

@@ -1,6 +1,7 @@
package com.njcn.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.user.pojo.po.Role;
import com.njcn.user.pojo.po.UserRole;
import org.apache.ibatis.annotations.Param;
@@ -21,4 +22,14 @@ public interface UserRoleMapper extends BaseMapper<UserRole> {
* @return
*/
List<UserRole> selectUserRole(@Param("ids")List<String> ids);
/**
* 根据用户id获取角色详情
* @param userId 用户id
* @author cdf
* @date 2022/9/8
* @return 角色结果集
*/
List<Role> getRoleListByUserId(String userId);
}

View File

@@ -10,4 +10,12 @@
#{item}
</foreach>
</select>
<select id="getRoleListByUserId" resultType="Role">
select b.* from sys_user_role a
inner join sys_role b on a.role_id = b.id
where a.user_id = #{userId}
and b.state = 1
</select>
</mapper>

View File

@@ -78,4 +78,6 @@ public interface IRoleService extends IService<Role> {
boolean deleteRole(List<String> ids);
Boolean selectRelevance(List<String> ids);
}

View File

@@ -1,6 +1,7 @@
package com.njcn.user.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.user.pojo.po.Role;
import com.njcn.user.pojo.po.UserRole;
import java.util.List;
@@ -45,4 +46,14 @@ public interface IUserRoleService extends IService<UserRole> {
* @date 2022/1/13 14:14
*/
boolean updateUserRole(String id,List<String> roles);
/**
* 根据用户id获取角色详情
* @param userId 用户id
* @author cdf
* @date 2022/9/8
* @return 角色结果集
*/
List<Role> getRoleListByUserId(String userId);
}

View File

@@ -11,10 +11,12 @@ import com.njcn.user.pojo.constant.FunctionState;
import com.njcn.user.pojo.dto.ComponentDTO;
import com.njcn.user.pojo.param.ComponentParam;
import com.njcn.user.pojo.po.Component;
import com.njcn.user.pojo.po.Role;
import com.njcn.user.pojo.vo.ComponentVO;
import com.njcn.user.service.IComponentService;
import com.njcn.user.service.IRoleComponentService;
import com.njcn.user.service.IRoleService;
import com.njcn.user.service.IUserRoleService;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -40,6 +42,8 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
private final IRoleService roleService;
private final IUserRoleService iUserRoleService;
private final IRoleComponentService roleComponentService;
@Override
@@ -102,11 +106,16 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
public List<ComponentVO> getUserComponentTree() {
List<ComponentVO> result = new ArrayList<>();
List<ComponentVO> componentVOList = new ArrayList<>();
List<String> roleList = roleService.getIdByUserId(RequestUtil.getUserIndex());
List<Role> roleList = iUserRoleService.getRoleListByUserId(RequestUtil.getUserIndex());
if (!CollectionUtils.isEmpty(roleList)) {
List<String> componentList = roleComponentService.selectRoleComponent(roleList);
if (!CollectionUtils.isEmpty(componentList)){
List<ComponentDTO> list = componentMapper.getComponentByList(componentList);
List<ComponentDTO> list;
if (roleList.stream().anyMatch(item -> "root".equals(item.getCode()))) {
list = componentMapper.getAllComponent();
} else {
List<String> componentList = roleComponentService.selectRoleComponent(roleList.stream().map(Role::getId).collect(Collectors.toList()));
list = componentMapper.getComponentByList(componentList);
}
list.forEach(item -> {
ComponentVO componentVO = new ComponentVO();
BeanUtil.copyProperties(item, componentVO);
@@ -118,7 +127,6 @@ public class ComponentServiceImpl extends ServiceImpl<ComponentMapper, Component
.peek(funS -> funS.setChildren(getChildCategoryList(funS, componentVOList)))
.collect(Collectors.toList());
}
}
return result;
}

View File

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.njcn.user.mapper.UserMapper;
import com.njcn.user.mapper.UserRoleMapper;
import com.njcn.user.pojo.po.Role;
import com.njcn.user.pojo.po.UserRole;
import com.njcn.user.service.IUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -94,4 +95,9 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i
// }
return true;
}
@Override
public List<Role> getRoleListByUserId(String userId) {
return this.baseMapper.getRoleListByUserId(userId);
}
}