7f4766be 张雷

积木报表厂区接口修改

1 个父辈 c2ab605c
......@@ -56,5 +56,7 @@ public interface CommonSqlMapper {
String getChildFactorys(@Param(value="departId") String departId);
String getChildDeparts(@Param(value="departId") String departId);
String getChildDepartByUserId(@Param(value="userId") String userId);
}
......
......@@ -94,6 +94,28 @@
</foreach>
))
</select>
<select id="getChildDeparts" resultType="java.lang.String">
SELECT
GROUP_CONCAT( id SEPARATOR ',' ) AS depart_ids
FROM
sys_depart
WHERE
parent_id IN
<foreach item="item" index="index" collection="departId.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
OR id IN
<foreach item="item" index="index" collection="departId.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
OR parent_id IN ( SELECT id FROM sys_depart WHERE parent_id IN
<foreach item="item" index="index" collection="departId.split(',')" open="(" separator="," close=")">
'${item}'
</foreach>
)
</select>
<select id="getChildDepartByUserId" resultType="java.lang.String">
select CONCAT(dep_id,',',dep_ids) AS ids
from sys_user_depart
......
......@@ -100,17 +100,18 @@ public class ThreeDController {
return result;
}
@CustomExceptionAnno(description = "三维-厂区在线状态")
@AutoLog(value = "三维-厂区在线状态")
@ApiOperation(value = "三维-厂区在线状态", notes = "三维-厂区在线状态")
@CustomExceptionAnno(description = "厂区在线状态")
@AutoLog(value = "厂区在线状态")
@ApiOperation(value = "厂区在线状态", notes = "厂区在线状态")
@GetMapping(value = "/factoryOnLine")
public Result<SysFactoryInfoVO> factoryOnLine(@RequestParam(name = "departId", defaultValue = "f2df9193c8bc4e7a9cef0e4b98dd9e95") String departId, @RequestParam(name = "departType", defaultValue = "1", required = false) String departType) {
Result result = new Result<>();
result.setSuccess(true);
result.setResult(new HashMap<>());
QueryWrapper<SysDepart> sysDepartQueryWrapper = new QueryWrapper<>();
sysDepartQueryWrapper.eq("depart_type", departType).eq("del_flag", 1);
List<Map<String, Object>> deviceList = sysDepartService.queryFactoryDevice(sysDepartQueryWrapper);
JdbcTemplate pgDb = (JdbcTemplate) SpringContextUtils.getBean("pg-db");
int onlineCount = 0;
if (!CollectionUtils.isEmpty(deviceList)) {
List<Object> list = new ArrayList<>();
......@@ -138,8 +139,6 @@ public class ThreeDController {
resultMaps.put("offlineCount", deviceList.size() - onlineCount > 0 ? deviceList.size() - onlineCount : 0);
result.setSuccess(true);
result.setResult(resultMaps);
} else {
result.error500("500");
}
return result;
......
......@@ -159,7 +159,9 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
@Anonymous
SysDepart getById(@Param("pid") String pid);
@Anonymous
List<SysDepart> getChildDepartList(@Param("departIds") String departIds);
@Anonymous
List<SysDepart> queryDepartsByIds(@Param("ids") String ids);
}
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.system.entity.SysUser;
import com.skua.tool.annotation.Anonymous;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -76,5 +77,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
List<SysUser> operationUserList(@Param("departId") String departId);
@Anonymous
String queryDepartIdsByUserId(@Param("userId") String userId);
}
......
......@@ -12,6 +12,7 @@ import com.skua.core.api.vo.SysUserCacheInfo;
import com.skua.core.constant.CommonConstant;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.common.mapper.CommonSqlMapper;
import com.skua.modules.system.entity.*;
import com.skua.modules.system.mapper.*;
import com.skua.modules.system.service.ISysUserDepartService;
......@@ -48,6 +49,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private ISysBaseAPI sysBaseAPI;
@Autowired
private SysDepartMapper sysDepartMapper;
@Resource
private CommonSqlMapper commonSqlMapper;
@Autowired
WebSocket webSocket;
......@@ -173,7 +176,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
// 根据角色Id查询
@Override
public IPage<SysUser> getUserByRoleId(Page<SysUser> page, String roleId, String username) {
String departIds = userMapper.queryDepartIdsByUserId(BaseContextHandler.getUserId());
// String departIds = userMapper.queryDepartIdsByUserId(BaseContextHandler.getUserId());
String ids = commonSqlMapper.getChildDepartByUserId(BaseContextHandler.getUserId());
String departIds = commonSqlMapper.getChildDeparts(ids);
return userMapper.getUserByRoleId(page, roleId, username, departIds);
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!