Browse Source

Merge remote-tracking branch 'origin/master'

lipenghui 2 weeks ago
parent
commit
3bb7601700

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/iotmaintenancebom/vo/IotMaintenanceBomPageReqVO.java

@@ -117,4 +117,6 @@ public class IotMaintenanceBomPageReqVO extends PageParam {
     private List<Long> deviceIds;
     @Schema(description = "保养项节点id集合")
     private List<Long> bomNodeIds;
+    @Schema(description = "保养项节点名称集合")
+    private List<String> bomNodeNames;
 }

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/iotmaintenancebom/IotMaintenanceBomMapper.java

@@ -73,6 +73,7 @@ public interface IotMaintenanceBomMapper extends BaseMapperX<IotMaintenanceBomDO
                 .eqIfPresent(IotMaintenanceBomDO::getNextNaturalDate, reqVO.getNextNaturalDate())
                 .inIfPresent(IotMaintenanceBomDO::getBomNodeId, reqVO.getBomNodeIds())
                 .likeIfPresent(IotMaintenanceBomDO::getName, reqVO.getName())
+                .inIfPresent(IotMaintenanceBomDO::getName, reqVO.getBomNodeNames())
                 .eqIfPresent(IotMaintenanceBomDO::getCode, reqVO.getCode())
                 .eqIfPresent(IotMaintenanceBomDO::getParentId, reqVO.getParentId())
                 .eqIfPresent(IotMaintenanceBomDO::getChildIds, reqVO.getChildIds())

+ 65 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/iotmainworkorder/IotMainWorkOrderServiceImpl.java

@@ -1436,12 +1436,19 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
         order.setOrderNumber(createWorkOrderNumber());
         order.setType(2);
         order.setResult(2);
-        // order.setActualStartTime(LocalDateTime.now());
-        // order.setActualEndTime(LocalDateTime.now());
         iotMainWorkOrderMapper.insert(order);
         // 保养工单明细
+        Set<Long> bomNodeIds = new HashSet<>();
+        Set<Long> deviceIds = new HashSet<>();
+        Set<String> bomNodeNames = new HashSet<>();
+        // key设备id-保养项id   value保养工单明细对象(包含累计公里/时长)
+        Map<String, IotMainWorkOrderBomSaveReqVO> bomAccumulatedValuePair = new HashMap<>();
+        // key设备id-保养项名称   value保养工单明细对象(包含累计公里/时长)
+        Map<String, IotMainWorkOrderBomSaveReqVO> bomNameAccumulatedValuePair = new HashMap<>();
         List<IotMainWorkOrderBomDO> workOrderBomDOS = new ArrayList<>();
         workOrderBOMs.forEach(bom -> {
+            bomAccumulatedValuePair.put(StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId()), bom);
+            bomNameAccumulatedValuePair.put(StrUtil.join("-", bom.getDeviceId(), bom.getName()), bom);
             IotMainWorkOrderBomDO tempBom = BeanUtils.toBean(bom, IotMainWorkOrderBomDO.class);
             tempBom.setWorkOrderId(order.getId());
             tempBom.setLastRunningTime(bom.getTotalRunTime());
@@ -1450,8 +1457,63 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
             tempBom.setDeviceCategoryId(bom.getAssetClass());
             tempBom.setStatus(1);
             workOrderBomDOS.add(tempBom);
+            bomNodeIds.add(bom.getBomNodeId());
+            deviceIds.add(bom.getDeviceId());
+            bomNodeNames.add(bom.getName());
         });
         iotMainWorkOrderBomMapper.insertBatch(workOrderBomDOS);
+        // 查找各保养项对应的保养计划中的保养项 根据保养计划中的保养规则 更新 上次保养里程 or 上次保养时长 or 上次保养时间
+        if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(bomNodeIds) && CollUtil.isNotEmpty(bomNodeNames)
+                && CollUtil.isNotEmpty(bomAccumulatedValuePair)) {
+            IotMaintenanceBomPageReqVO reqVO = new IotMaintenanceBomPageReqVO();
+            reqVO.setDeviceIds(new ArrayList<>(deviceIds));
+            reqVO.setBomNodeIds(new ArrayList<>(bomNodeIds));   // 保养项id 可能变化 重新生成设备BOM
+            List<IotMaintenanceBomDO> planBomS = iotMaintenanceBomService.getIotMainPlanBomList(reqVO);
+            if (CollUtil.isNotEmpty(planBomS)) {
+                planBomS.forEach(bom -> {
+                    String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
+                    if (bomAccumulatedValuePair.containsKey(uniqueKey)) {
+                        IotMainWorkOrderBomSaveReqVO saveReqVO = bomAccumulatedValuePair.get(uniqueKey);
+                        if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0==bom.getRunningTimeRule()) {
+                            bom.setLastRunningTime(saveReqVO.getTotalRunTime());
+                        }
+                        if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0==bom.getMileageRule()) {
+                            bom.setLastRunningKilometers(saveReqVO.getTotalMileage());
+                        }
+                        if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0==bom.getNaturalDateRule()) {
+                            bom.setLastNaturalDate(LocalDateTime.now());
+                        }
+                    }
+                });
+                // 批量更新保养计划明细
+                iotMaintenanceBomMapper.updateBatch(planBomS);
+            }
+            // 根据保养项名称更新上次保养 公里数 时长
+            IotMaintenanceBomPageReqVO bomReqVO = new IotMaintenanceBomPageReqVO();
+            bomReqVO.setDeviceIds(new ArrayList<>(deviceIds));
+            bomReqVO.setBomNodeNames(new ArrayList<>(bomNodeNames));   // 保养项id 可能变化 重新生成设备BOM
+            List<IotMaintenanceBomDO> planBomNames = iotMaintenanceBomService.getIotMainPlanBomList(bomReqVO);
+            if (CollUtil.isNotEmpty(planBomNames)) {
+                planBomNames.forEach(bom -> {
+                    String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getName());
+                    if (bomNameAccumulatedValuePair.containsKey(uniqueKey)) {
+                        IotMainWorkOrderBomSaveReqVO saveReqVO = bomNameAccumulatedValuePair.get(uniqueKey);
+                        if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0==bom.getRunningTimeRule()) {
+                            bom.setLastRunningTime(saveReqVO.getTotalRunTime());
+                        }
+                        if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0==bom.getMileageRule()) {
+                            bom.setLastRunningKilometers(saveReqVO.getTotalMileage());
+                        }
+                        if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0==bom.getNaturalDateRule()) {
+                            bom.setLastNaturalDate(LocalDateTime.now());
+                        }
+                    }
+                });
+                // 批量更新保养计划明细
+                iotMaintenanceBomMapper.updateBatch(planBomNames);
+            }
+        }
+
         // 保养工单 bom 明细关联的物料消耗
         List<IotMainWorkOrderBomMaterialDO> workOrderBomMaterialDOS = new ArrayList<>();
         Set<Long> factoryIds = new HashSet<>();
@@ -1495,6 +1557,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
             reqVO.setCostCenterIds(costCenterIds);
             reqVO.setMaterialCodes(materialCodes);
             processLockStock(reqVO, lockStockPair);
+            // 记录出库
         }
     }
 

+ 8 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java

@@ -59,6 +59,14 @@ public class UserController {
         return success(id);
     }
 
+    @GetMapping("/batchSetUserPwd")
+    @Operation(summary = "批量设置导入用户加密密码")
+    @PreAuthorize("@ss.hasPermission('system:user:create')")
+    public CommonResult<Long> batchSetUserPwd() {
+        Long id = userService.batchSetUserPwd();
+        return success(id);
+    }
+
     @PutMapping("update")
     @Operation(summary = "修改用户")
     @PreAuthorize("@ss.hasPermission('system:user:update')")

+ 6 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java

@@ -9,6 +9,7 @@ import lombok.NoArgsConstructor;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
 
@@ -44,4 +45,9 @@ public class UserPageReqVO extends PageParam {
     @Schema(description = "角色编号", example = "1024")
     private Long roleId;
 
+    /**
+     * 扩展字段
+     */
+    @Schema(description = "部门编号集合,同时筛选子部门", example = "[1024,123]")
+    private List<Long> deptIds;
 }

+ 7 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java

@@ -226,4 +226,11 @@ public interface AdminUserService {
      * @return 用户列表
      */
     List<AdminUserDO> getSimpleUserList(UserPageReqVO reqVO);
+
+    /**
+     * 批量设置用户密码
+     *
+     * @return 用户列表
+     */
+    Long batchSetUserPwd();
 }

+ 40 - 8
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.user;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.ObjUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.exception.ServiceException;
@@ -36,7 +37,6 @@ import cn.iocoder.yudao.module.system.service.permission.PermissionService;
 import cn.iocoder.yudao.module.system.service.tenant.TenantService;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
 import com.mzt.logapi.context.LogRecordContext;
 import com.mzt.logapi.service.impl.DiffParseFunction;
 import com.mzt.logapi.starter.annotation.LogRecord;
@@ -185,6 +185,8 @@ public class AdminUserServiceImpl implements AdminUserService {
         return user.getId();
     }
 
+
+
     @Override
     public Long registerUser(AuthRegisterReqVO registerReqVO) {
         // 1.1 校验账户配合
@@ -346,7 +348,7 @@ public class AdminUserServiceImpl implements AdminUserService {
                 permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId())) : null;
 
         // 分页查询
-        return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds);
+        return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId(), null), userIds);
     }
 
     @Override
@@ -413,13 +415,24 @@ public class AdminUserServiceImpl implements AdminUserService {
      * @param deptId 部门编号
      * @return 部门编号集合
      */
-    private Set<Long> getDeptCondition(Long deptId) {
-        if (deptId == null) {
+    private Set<Long> getDeptCondition(Long deptId, List<Long> deptIdList) {
+        if (deptId == null && CollUtil.isEmpty(deptIdList)) {
             return Collections.emptySet();
         }
-        Set<Long> deptIds = convertSet(deptService.getChildDeptList(deptId), DeptDO::getId);
-        deptIds.add(deptId); // 包括自身
-        return deptIds;
+        Set<Long> resultDeptIds = new HashSet<>();
+        if (ObjUtil.isNotEmpty(deptId)) {
+            Set<Long> deptIds = convertSet(deptService.getChildDeptList(deptId), DeptDO::getId);
+            deptIds.add(deptId); // 包括自身
+            resultDeptIds.addAll(deptIds);
+        }
+        if (CollUtil.isNotEmpty(deptIdList)) {
+            deptIdList.forEach(departmentId -> {
+                Set<Long> deptIds = convertSet(deptService.getChildDeptList(departmentId), DeptDO::getId);
+                deptIds.add(departmentId);
+                resultDeptIds.addAll(deptIds);
+            });
+        }
+        return resultDeptIds;
     }
 
     private AdminUserDO validateUserForCreateOrUpdate(Long id, String username, String mobile, String email,
@@ -595,7 +608,26 @@ public class AdminUserServiceImpl implements AdminUserService {
 
     @Override
     public List<AdminUserDO> getSimpleUserList(UserPageReqVO reqVO) {
-        return userMapper.selectSimpleList(getDeptCondition(reqVO.getDeptId()));
+        return userMapper.selectSimpleList(getDeptCondition(reqVO.getDeptId(), reqVO.getDeptIds()));
+    }
+
+    @Override
+    public Long batchSetUserPwd() {
+        // 查询出用户密码为空 的所有 用户 设置加密密码后 更新
+        List<AdminUserDO> emptyPwdUsers = userMapper.selectEmptyPwd();
+        AdminUserDO tobeUpdatedUser = new AdminUserDO();
+        if (CollUtil.isNotEmpty(emptyPwdUsers)) {
+            emptyPwdUsers.forEach(user -> {
+                // if ("0031890".equals(user.getUsername())) {
+                    user.setPassword(encodePassword("yf654321"));
+                    // System.out.println("当前用户是" + user.getUsername());
+                   // BeanUtils.copyProperties(user, tobeUpdatedUser);
+                // }
+            });
+            // userMapper.updateById(tobeUpdatedUser);
+            userMapper.updateBatch(emptyPwdUsers);
+        }
+        return 0l;
     }
 
     /**