瀏覽代碼

Merge branch '2302-4月份需求' of http://106.14.142.95:3000/wangyuanbo/bt

zhuhao 2 年之前
父節點
當前提交
a98a45b63f

+ 60 - 2
imcs-bt-be/imcs-authority-server/src/main/java/com/github/zuihou/api/OpsAppApi.java

@@ -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;
+    }
 }

+ 9 - 1
imcs-bt-be/imcs-business-biz/src/main/java/com/github/zuihou/business/tenantProductUser/dao/ImcsTenantProductresourceUserMapper.java

@@ -2,9 +2,10 @@ package com.github.zuihou.business.tenantProductUser.dao;
 
 import com.github.zuihou.base.mapper.SuperMapper;
 import com.github.zuihou.business.tenantProductUser.entity.ImcsTenantProductresourceUser;
-
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
  * <p>
  * Mapper 接口
@@ -17,4 +18,11 @@ import org.springframework.stereotype.Repository;
 @Repository
 public interface ImcsTenantProductresourceUserMapper extends SuperMapper<ImcsTenantProductresourceUser> {
 
+    /**
+     * 根据设备ID查询人员
+     *
+     * @param equId 设备ID
+     * @return 人员列表
+     */
+    List<ImcsTenantProductresourceUser> listUserByEquId(Long equId);
 }

+ 9 - 0
imcs-bt-be/imcs-business-biz/src/main/java/com/github/zuihou/business/tenantProductUser/service/ImcsTenantProductresourceUserService.java

@@ -3,6 +3,8 @@ package com.github.zuihou.business.tenantProductUser.service;
 import com.github.zuihou.base.service.SuperService;
 import com.github.zuihou.business.tenantProductUser.entity.ImcsTenantProductresourceUser;
 
+import java.util.List;
+
 /**
  * <p>
  * 业务接口
@@ -14,4 +16,11 @@ import com.github.zuihou.business.tenantProductUser.entity.ImcsTenantProductreso
  */
 public interface ImcsTenantProductresourceUserService extends SuperService<ImcsTenantProductresourceUser> {
 
+    /**
+     * 根据设备ID查询人员
+     *
+     * @param equId 设备ID
+     * @return 人员列表
+     */
+    List<ImcsTenantProductresourceUser> listUserByEquId(Long equId);
 }

+ 6 - 0
imcs-bt-be/imcs-business-biz/src/main/java/com/github/zuihou/business/tenantProductUser/service/impl/ImcsTenantProductresourceUserServiceImpl.java

@@ -9,6 +9,8 @@ import com.github.zuihou.base.service.SuperServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 业务实现类
@@ -22,4 +24,8 @@ import org.springframework.stereotype.Service;
 @Service
 
 public class ImcsTenantProductresourceUserServiceImpl extends SuperServiceImpl<ImcsTenantProductresourceUserMapper, ImcsTenantProductresourceUser> implements ImcsTenantProductresourceUserService {
+    @Override
+    public List<ImcsTenantProductresourceUser> listUserByEquId(Long equId) {
+        return baseMapper.listUserByEquId(equId);
+    }
 }

+ 11 - 0
imcs-bt-be/imcs-business-biz/src/main/resources/mapper_business/base/tenantProductUser/ImcsTenantProductresourceUserMapper.xml

@@ -20,4 +20,15 @@
         equ_id, user_type, user_id
     </sql>
 
+    <select id="listUserByEquId" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>,userName
+        from (
+            SELECT
+                itpu.*,cau.name as userName
+            from imcs_tenant_productresource_user itpu
+            left join c_auth_user cau on itpu.user_id = cau.id
+            WHERE itpu.equ_id = #{equId}
+        ) s
+    </select>
 </mapper>

+ 21 - 3
imcs-bt-be/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/productionresource/ProductionResourceController.java

@@ -1,7 +1,6 @@
 package com.github.zuihou.business.controller.productionresource;
 
 import cn.hutool.core.bean.BeanUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.zuihou.base.R;
@@ -19,6 +18,7 @@ import com.github.zuihou.business.productionresource.service.EquAndGoodsService;
 import com.github.zuihou.business.productionresource.service.ProductionTenantResourceService;
 import com.github.zuihou.business.spe.entity.Spe;
 import com.github.zuihou.business.spe.service.SpeService;
+import com.github.zuihou.business.tenantProductUser.service.ImcsTenantProductresourceUserService;
 import com.github.zuihou.business.util.CommonUtil;
 import com.github.zuihou.common.util.DateUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
@@ -33,9 +33,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
-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.math.BigDecimal;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -67,6 +71,9 @@ public class ProductionResourceController extends SuperController<ProductionTena
     @Autowired
     private OrderService orderService;
 
+    @Autowired
+    private ImcsTenantProductresourceUserService productresourceUserService;
+
     /**
      * Excel导入后的操作
      *
@@ -111,9 +118,20 @@ public class ProductionResourceController extends SuperController<ProductionTena
             item.setIncomeToday(incomeToday);
             Map<String, String> resultMap = baseService.getEquRunInfo(item.getId());
             item.setOnlineStatus(resultMap.get("equStatus"));
+            // 2023-05 新需求:设备的运维和维护人员; 循环查询有时间在优化!
+            appendProductResourceUserList(item);
         });
     }
 
+    /**
+     * 追加设备的运维和维护人员
+     *
+     * @param productionResource 设备的运维和维护人员
+     */
+    private void appendProductResourceUserList(ProductionResource productionResource) {
+        productionResource.setProductresourceUserList(productresourceUserService
+                .listUserByEquId(productionResource.getId()));
+    }
 
     @PostMapping("/updateStatus")
     public R<Integer> updateStatus(@RequestBody Map<String, Object> paramMap) {

+ 36 - 8
imcs-bt-be/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/tenantProductUser/ImcsTenantProductresourceUserController.java

@@ -1,22 +1,28 @@
 package com.github.zuihou.business.controller.tenantProductUser;
 
-import com.github.zuihou.business.tenantProductUser.entity.ImcsTenantProductresourceUser;
+import com.github.zuihou.base.R;
+import com.github.zuihou.base.controller.SuperController;
+import com.github.zuihou.business.tenantProductUser.dto.ImcsTenantProductresourceUserPageDTO;
 import com.github.zuihou.business.tenantProductUser.dto.ImcsTenantProductresourceUserSaveDTO;
 import com.github.zuihou.business.tenantProductUser.dto.ImcsTenantProductresourceUserUpdateDTO;
-import com.github.zuihou.business.tenantProductUser.dto.ImcsTenantProductresourceUserPageDTO;
+import com.github.zuihou.business.tenantProductUser.entity.ImcsTenantProductresourceUser;
 import com.github.zuihou.business.tenantProductUser.service.ImcsTenantProductresourceUserService;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import com.github.zuihou.base.controller.SuperController;
-import com.github.zuihou.base.R;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.security.annotation.PreAuth;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
-import com.github.zuihou.security.annotation.PreAuth;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 
 /**
  * <p>
@@ -50,4 +56,26 @@ public class ImcsTenantProductresourceUserController extends SuperController<Imc
 
         return R.success(baseService.saveBatch(imcsTenantProductresourceUserList));
     }
+
+    /**
+     * 批量设置运维或维护人员
+     *
+     * @param productresourceUserList 人员关系列表
+     * @return 保存后的人员关系数据
+     */
+    @ApiOperation(value = "批量设置运维或维护人员", notes = "批量设置运维或维护人员")
+    @PostMapping("/saveBatch")
+    public R<List<ImcsTenantProductresourceUser>> saveOrUpdateBatchProductresourceUser(
+            @RequestParam(name = "equId") Long equId,
+            @RequestParam(name = "userType") String userType,
+            @RequestBody List<ImcsTenantProductresourceUser> productresourceUserList) {
+        baseService.remove(
+                Wraps.<ImcsTenantProductresourceUser>lbQ()
+                        .eq(ImcsTenantProductresourceUser::getEquId, equId)
+                        .eq(ImcsTenantProductresourceUser::getUserType, userType)
+        );
+        baseService.saveBatch(productresourceUserList);
+        return success(productresourceUserList);
+    }
+
 }

+ 9 - 0
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/productionresource/entity/ProductionResource.java

@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.github.zuihou.base.entity.Entity;
+import com.github.zuihou.business.tenantProductUser.entity.ImcsTenantProductresourceUser;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.*;
@@ -11,6 +12,7 @@ import lombok.experimental.Accessors;
 import org.hibernate.validator.constraints.Length;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 import static com.baomidou.mybatisplus.annotation.SqlCondition.EQUAL;
 import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
@@ -334,6 +336,13 @@ public class ProductionResource extends Entity<Long> {
     @TableField(exist = false)
     private Integer lackCount;
 
+    /**
+     * 设备人员关系
+     */
+    @ApiModelProperty(value = "设备人员关系")
+    @TableField(exist = false)
+    private List<ImcsTenantProductresourceUser> productresourceUserList;
+
     @Builder
     public ProductionResource(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
                               Long compnayId, String moduleId, String areaId, String name, String resourcesCategory,

+ 10 - 10
imcs-bt-be/imcs-business-entity/src/main/java/com/github/zuihou/business/tenantProductUser/entity/ImcsTenantProductresourceUser.java

@@ -1,17 +1,11 @@
 package com.github.zuihou.business.tenantProductUser.entity;
 
 import cn.afterturn.easypoi.excel.annotation.Excel;
-import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.github.zuihou.base.entity.Entity;
-import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-import org.hibernate.validator.constraints.Length;
-import org.hibernate.validator.constraints.Range;
-import java.time.LocalDateTime;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -19,10 +13,9 @@ import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import lombok.ToString;
 import lombok.experimental.Accessors;
-import com.github.zuihou.common.constant.DictionaryType;
-import static com.github.zuihou.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
 
-import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
 
 /**
  * <p>
@@ -72,6 +65,13 @@ public class ImcsTenantProductresourceUser extends Entity<Long> {
     @Excel(name = "人员ID")
     private Long userId;
 
+    /**
+     * 人员姓名
+     */
+    @ApiModelProperty(value = "人员姓名")
+    @TableField(exist = false)
+    private String userName;
+
 
     @Builder
     public ImcsTenantProductresourceUser(Long id, Long createUser, LocalDateTime createTime, Long updateUser, LocalDateTime updateTime,