WarehouseServiceImpl.java
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.huaheng.pc.config.warehouse.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.config.warehouse.domain.Warehouse;
import com.huaheng.pc.config.warehouse.mapper.WarehouseMapper;
import com.huaheng.pc.config.warehouseCompany.domain.WarehouseCompany;
import com.huaheng.pc.config.warehouseCompany.service.WarehouseCompanyService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("WarehouseService")
public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse> implements WarehouseService {
@Resource
private WarehouseMapper warehouseMapper;
@Resource
private WarehouseCompanyService warehouseCompanyService;
@Override
public List<Map<String, Object>> getWarehouseList(Integer id) {
/**
* 查询仓库的code、name、enable
*/
LambdaQueryWrapper<Warehouse> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.select(Warehouse::getCode, Warehouse::getName, Warehouse::getEnable);
List<Map<String, Object>> warehouseList = warehouseMapper.selectMaps(lambdaQueryWrapper);
LambdaQueryWrapper<WarehouseCompany> lambdaQueryWrapper1 = Wrappers.lambdaQuery();
lambdaQueryWrapper1.select(WarehouseCompany::getCompanyCode)
.eq(WarehouseCompany::getCompanyId,id);
List<Map<String, Object>> warehouseCompanies = warehouseCompanyService.listMaps(lambdaQueryWrapper1);
for(Map<String, Object> item : warehouseList){
item.put("flag",false);
item.put("value", item.get("code").toString());
for (Map<String, Object> warehouseId:warehouseCompanies) {
if (item.get("code").toString().equals(warehouseId.get("warehouseCode").toString())) {
item.put("flag",true);
break;
}
}
}
return warehouseList;
}
@Override
public List<Warehouse> selectWarehouseByUserId(Integer userId)
{
List<Warehouse> userWarhouses = warehouseMapper.selectWarehouseByUserId(userId);
List<Warehouse> warehouses = warehouseMapper.selectWarehouseAll();
for (Warehouse warehouse : warehouses)
{
for (Warehouse userWarehouse: userWarhouses)
{
if (warehouse.getCode().equals(userWarehouse.getCode()))
{
warehouse.setFlag(true);
break;
}
}
}
return warehouses;
}
}