|
@@ -40,10 +40,20 @@ import com.github.zuihou.security.model.SysUser;
|
|
|
import com.github.zuihou.utils.DateUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
import static java.util.stream.Collectors.toList;
|
|
|
|
|
@@ -469,5 +479,53 @@ public class OpsAppApi {
|
|
|
return R.success(save);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询可运维和可维护的设备列表
|
|
|
+ * yw->{可运维数据}
|
|
|
+ * wh->{可维护数据}
|
|
|
+ *
|
|
|
+ * @param sysUser 登录用户
|
|
|
+ * @param params 请求参数
|
|
|
+ * @return 可运维和可维护的设备列表
|
|
|
+ */
|
|
|
+ @PostMapping("/productionResourceUser/getEquList")
|
|
|
+ public R<Map<String, IPage<ProductionResource>>> pageListEquByProductResourceUser(
|
|
|
+ @LoginUser SysUser sysUser,
|
|
|
+ @RequestBody PageParams<ProductionResource> params) {
|
|
|
+ BaseContextHandler.setTenant("0000");
|
|
|
+ LbqWrapper<ProductionResource> queryWrap = Wraps.lbQ();
|
|
|
+
|
|
|
+ Map<String, IPage<ProductionResource>> resultMap = new HashMap<>();
|
|
|
+
|
|
|
+ // 查询登录用户的可运维配置信息
|
|
|
+ String productResourceUserSql = "select pu.equ_id from imcs_tenant_productresource_user pu where pu.user_id = " + sysUser.getId();
|
|
|
+ String userTypeSqlCond = " and pu.user_type = 1";
|
|
|
+
|
|
|
+ queryWrap.inSql(ProductionResource::getId, productResourceUserSql + userTypeSqlCond);
|
|
|
+ IPage<ProductionResource> ywPage = params.buildPage();
|
|
|
+ resultMap.put("yw", pageListEquByProductResourceUserImpl(ywPage, queryWrap));
|
|
|
+
|
|
|
+ // 查询登录用户的可维护配置信息
|
|
|
+ String userType2SqlCond = " and pu.user_type = 2";
|
|
|
+ queryWrap.clear();
|
|
|
+ queryWrap.inSql(ProductionResource::getId, productResourceUserSql + userType2SqlCond);
|
|
|
+ IPage<ProductionResource> whPage = params.buildPage();
|
|
|
+ resultMap.put("wh", pageListEquByProductResourceUserImpl(whPage, queryWrap));
|
|
|
+ return R.success(resultMap);
|
|
|
+ }
|
|
|
|
|
|
+ private IPage<ProductionResource> pageListEquByProductResourceUserImpl(IPage<ProductionResource> page,
|
|
|
+ LbqWrapper<ProductionResource> queryWrap) {
|
|
|
+ IPage<ProductionResource> list = productionTenantResourceService.pageList(page, queryWrap);
|
|
|
+ if (null != list.getRecords() && list.getRecords().size() > 0) {
|
|
|
+ list.getRecords().stream().forEach(item -> {
|
|
|
+ Map map = productionTenantResourceService.getEquRunInfo(item.getId());
|
|
|
+ item.setOnlineStatus(map.containsKey("equStatus") ? map.get("equStatus").toString() : "0");
|
|
|
+ item.setErrMsg(map.containsKey("errMsg") && map.get("errMsg") != null ? map.get("errMsg").toString() : "");
|
|
|
+ Integer lackCount = productionTenantResourceService.getEquLockCount(item.getId());
|
|
|
+ item.setLackCount(lackCount);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|