shudonghui há 1 ano atrás
pai
commit
1f02ea4634

+ 2 - 1
sop-api/src/main/java/com/qmth/sop/server/api/SysDeviceController.java

@@ -7,6 +7,7 @@ import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.result.SysDeviceResult;
 import com.qmth.sop.business.entity.SysDevice;
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBTask;
 import com.qmth.sop.business.service.SysDeviceService;
 import com.qmth.sop.business.service.TBTaskService;
@@ -17,6 +18,7 @@ import com.qmth.sop.common.enums.InOutTypeEnum;
 import com.qmth.sop.common.enums.TaskTypeEnum;
 import com.qmth.sop.common.util.Result;
 import com.qmth.sop.common.util.ResultUtil;
+import com.qmth.sop.common.util.ServletUtil;
 import io.swagger.annotations.*;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
@@ -118,7 +120,6 @@ public class SysDeviceController {
         return ResultUtil.ok(sysDeviceService.delete(ids));
     }
 
-    @Aac(auth=false)
     @ApiOperation(value = "设备导入")
     @RequestMapping(value = "/import", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})

+ 15 - 5
sop-business/src/main/java/com/qmth/sop/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -239,13 +239,18 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     sysCustom.setProvince(e.getProvince());
                     sysCustom.setPeoperDay(e.getPeoperDay());
                     SysUser sysUser = sysUserService.getOne(new QueryWrapper<SysUser>().lambda().eq(SysUser::getRealName, e.getManager()));
+                    if (Objects.isNull(sysUser)) {
+                        throw ExceptionResultEnum.ERROR.exception("客户经理不存在!");
+                    }
                     sysCustom.setManagerId(sysUser.getId());
                     SysLevel sysLevel = sysLevelService.getOne(new QueryWrapper<SysLevel>().lambda().eq(SysLevel::getLevel, e.getLevel()).eq(SysLevel::getType, type));
+                    if (Objects.isNull(sysLevel)) {
+                        throw ExceptionResultEnum.ERROR.exception("服务档位不存在!");
+                    }
                     sysCustom.setLevelId(sysLevel.getId());
                     sysCustom.setSync(false);
                     sysCustom.setEnable(true);
-                    SysUser ssysUser = (SysUser) ServletUtil.getRequestUser();
-                    sysCustom.setCreateId(ssysUser.getId());
+                    sysCustom.setCreateId(((SysUser)map.get("account")).getId());
                     sysCustom.setCreateTime(System.currentTimeMillis());
                     sysCustomService.saveOrUpdate(sysCustom);
 
@@ -381,7 +386,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
 
             if (errorSize == 0) {
                 List<SysDevice> sysDevices = new ArrayList<>();
-                SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+//                SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
                 List<SysSupplier> supplierList = sysSupplierService.list(new QueryWrapper<SysSupplier>().lambda().eq(SysSupplier::getType, SupplierTypeEnum.DEVICE));
                 Objects.requireNonNull(customImportDtoLinkedMultiValueMap.get(BasicExcelListener.SUCCESS)).forEach(e -> {
                     SysDevice device = new SysDevice();
@@ -389,21 +394,26 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     InOutTypeEnum bound = InOutTypeEnum.IN.getTitle().equals(e.getBound()) ? InOutTypeEnum.IN : InOutTypeEnum.OUT;
                     device.setBound(bound);
                     device.setBrand(e.getBrand());
+                    device.setModel(e.getModel());
                     device.setLocation(e.getLocation());
                     device.setEnable(true);
                     //日期字符串转换时间戳
                     try {
                         device.setBuyTime(new SimpleDateFormat("yyyy/MM/dd").parse(e.getBuyTime()).getTime());
                     } catch (ParseException ex) {
-                        throw new RuntimeException(ex);
+                        throw ExceptionResultEnum.ERROR.exception("购买时间格式错误");
                     }
+
                     device.setScanCount(e.getScanCount());
+                    if (supplierList.stream().noneMatch(s -> s.getName().equals(e.getSupplier()))) {
+                        throw ExceptionResultEnum.ERROR.exception("供应商不存在!");
+                    }
                     device.setSupplierId(supplierList.stream().filter(s -> s.getName().equals(e.getSupplier())).findFirst().get().getId());
                     device.setSerialNo(e.getSerialNo());
                     DeviceStatusEnum status = DeviceStatusEnum.NORMAL.getTitle().equals(e.getStatus()) ? DeviceStatusEnum.NORMAL : DeviceStatusEnum.BREAK_DOWN;
                     device.setStatus(status);
                     device.setSync(false);
-                    device.insertInfo(sysUser.getId());
+                    device.insertInfo(((SysUser)map.get("account")).getId());
                     sysDevices.add(device);
                 });
                 sysDeviceService.saveSysDevice(sysDevices);

+ 5 - 2
sop-business/src/main/resources/db/log/shudonghui_update_log.sql

@@ -301,5 +301,8 @@ UPDATE `sys_privilege` SET `name` = '启用', `url` = 'enable', `type` = 'BUTTON
 UPDATE `sys_privilege` SET `name` = '禁用', `url` = 'disable', `type` = 'BUTTON', `parent_id` = 5, `sequence` = 5, `property` = 'AUTH', `related` = '272', `enable` = 1, `default_auth` = 0, `front_display` = 1 WHERE `id` = 1049;
 UPDATE `sys_privilege` SET `name` = '导入', `url` = 'import', `type` = 'BUTTON', `parent_id` = 5, `sequence` = 6, `property` = 'AUTH', `related` = '1046', `enable` = 1, `default_auth` = 0, `front_display` = 1 WHERE `id` = 1050;
 
-
-INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1051, '获取SOP用户', '/api/admin/sop/user/list', 'URL', 64, 32, 'SYS', NULL, 1, 1, 0);
+--2023.9.28
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES (1051, '获取SOP用户', '/api/admin/sop/user/list', 'URL', 64, 32, 'SYS', NULL, 1, 1, 0);
+UPDATE `sys_privilege` SET `name` = '批量启用', `url` = 'BatchEnable', `type` = 'BUTTON', `parent_id` = 5, `sequence` = 4, `property` = 'AUTH', `related` = '1046', `enable` = 1, `default_auth` = 0, `front_display` = 1 WHERE `id` = 1048;
+UPDATE `sys_privilege` SET `name` = '批量禁用', `url` = 'BatchUnEnable', `type` = 'BUTTON', `parent_id` = 5, `sequence` = 5, `property` = 'AUTH', `related` = '272', `enable` = 1, `default_auth` = 0, `front_display` = 1 WHERE `id` = 1049;
+UPDATE `sys_privilege` SET `name` = '批量导入', `url` = 'BatchImport', `type` = 'BUTTON', `parent_id` = 5, `sequence` = 6, `property` = 'AUTH', `related` = '1047', `enable` = 1, `default_auth` = 0, `front_display` = 1 WHERE `id` = 1050;