From 8f918cb6db02c39e67ce7b0d77cc1be5ed26edaf Mon Sep 17 00:00:00 2001
From: jiaosong <jiaosong6760@dingtalk.com>
Date: 星期五, 25 八月 2023 11:03:28 +0800
Subject: [PATCH] # 企业端用户

---
 server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java b/server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java
index 1c900a7..dc253be 100644
--- a/server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java
+++ b/server/src/main/java/doumeemes/service/business/impl/DeviceServiceImpl.java
@@ -111,7 +111,7 @@
     @Override
     public Device findOne(Device device) {
         QueryWrapper<Device> wrapper = new QueryWrapper<>(device);
-        return deviceMapper.selectOne(wrapper);
+        return deviceMapper.selectOne(wrapper.last("limit 1"));
     }
 
     @Override
@@ -219,11 +219,11 @@
             }
 
         }
-        QueryDeviceExtDTO queryDeviceExtDTO=new QueryDeviceExtDTO();
+        Device queryDeviceExtDTO=new Device();
         queryDeviceExtDTO.setDeleted(Constants.ZERO);
         queryDeviceExtDTO.setCode(device.getCode());
         queryDeviceExtDTO.setRootDepartId(user.getRootDepartment().getId());
-        List<DeviceExtListVO> list= deviceExtService.getListByCondition(queryDeviceExtDTO);
+        List<Device> list= this.findList(queryDeviceExtDTO);
 
        /* QueryDeviceExtDTO queryDeviceExtDTO1=new QueryDeviceExtDTO();
         queryDeviceExtDTO1.setDeleted(Constants.ZERO);
@@ -253,7 +253,7 @@
             userDeviceMapper.delete(new QueryWrapper<UserDevice>().eq("DEVICE_ID",deviceId));
         }
         if(StringUtils.isNotEmpty(userIds)){
-            String [] ids=userIds.split(",");
+            String [] ids=userIds.replace(" ","").split("[.,;锛宂");
             for (String id : ids) {
                 CompanyUser companyUser = companyUserService.findById(Integer.valueOf(id));
                 UserDevice userDevice = new UserDevice();
@@ -304,7 +304,7 @@
             QueryWrapper<Department> wrapper = new QueryWrapper<>();
             wrapper.lambda()
                     .eq(Department::getRootId,user.getRootDepartment().getId())
-                    .eq(Department::getName,departName)
+                    .eq(Department::getName,s.getDepartName())
                     .last("limit 1");
             Department department = departmentMapper.selectOne(wrapper);
             if(Objects.isNull(department)){
@@ -314,11 +314,11 @@
             QueryWrapper<Procedures> proceduresQuery = new QueryWrapper<>();
             proceduresQuery.lambda()
                     .eq(Procedures::getRootDepartId,user.getRootDepartment().getId())
-                    .eq(Procedures::getDepartId,department.getId())
+                    .eq(Procedures::getOrgId,department.getId())
                     .eq(Procedures::getName,s.getProcedureName());
             Procedures procedures = proceduresMapper.selectOne(proceduresQuery);
             if(Objects.isNull(procedures)){
-                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"宸ュ簭鍚嶇О宸插瓨鍦�");
+                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"宸ュ簭鍚嶇О涓嶅瓨鍦�");
             }
             QueryDeviceExtDTO queryDeviceExtDTO=new QueryDeviceExtDTO();
             queryDeviceExtDTO.setDeleted(Constants.ZERO);
@@ -332,7 +332,7 @@
             QueryWrapper<WarehouseLocation> warehouseLocationQuery = new QueryWrapper<>();
             warehouseLocationQuery.lambda()
                                     .eq(WarehouseLocation::getRootDepartId,department.getRootId())
-                                    .eq(WarehouseLocation::getUnionName
+                                    .in(WarehouseLocation::getUnionName
                                             ,Arrays.asList(s.getFinishWarehouseLocationName(),s.getProduceWarehouseLocationName()));
             if(Objects.equals(list.size(),2)){
                 throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"搴撲綅淇℃伅宸插瓨鍦�");
@@ -361,11 +361,11 @@
             device.setStationCode(s.getStationCode());
 //            device.setGroupId();
 //            device.setSerialNum();
-            device.setProduceWarehouseLocationId(collect.get(s.getProduceWarehouseLocationName()).getId());
-            device.setFinishWarehouseLocationId(collect.get(s.getFinishWarehouseLocationName()).getId());
+            device.setProduceWarehouseLocationId(Optional.ofNullable(collect.get(s.getProduceWarehouseLocationName())).map(m->m.getId()).orElse(null));
+            device.setFinishWarehouseLocationId(Optional.ofNullable(collect.get(s.getFinishWarehouseLocationName())).map(m->m.getId()).orElse(null));
             deviceMapper.insert(device);
             if(StringUtils.isNotBlank(s.getUserIds())){
-                this.dealDeviceUserId(Constants.ZERO,device.getUserIds(),device.getId(),user);
+                this.dealDeviceUserId(Constants.ZERO,device.getUserIds().trim(),device.getId(),user);
             }
 
         });

--
Gitblit v1.9.3