Blame view

src/main/java/com/huaheng/pc/config/zone/service/ZoneServiceImpl.java 3.64 KB
pengcheng authored
1
2
package com.huaheng.pc.config.zone.service;
mahuandong authored
3
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
周鸿 authored
4
import com.huaheng.common.utils.Wrappers;
pengcheng authored
5
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
pengcheng authored
6
import com.huaheng.common.exception.service.ServiceException;
肖超群 authored
7
import com.huaheng.common.utils.StringUtils;
xqs authored
8
import com.huaheng.common.utils.security.ShiroUtils;
9
import com.huaheng.pc.config.company.domain.Company;
pengcheng authored
10
11
12
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.config.zone.mapper.ZoneMapper;
import org.springframework.stereotype.Service;
pengcheng authored
13
import org.springframework.transaction.annotation.Transactional;
pengcheng authored
14
pengcheng authored
15
import javax.annotation.Resource;
mahuandong authored
16
17
18
import java.util.List;
import java.util.Map;
pengcheng authored
19
@Service("zone")
pengcheng authored
20
21
public class ZoneServiceImpl extends ServiceImpl<ZoneMapper, Zone> implements ZoneService {
pengcheng authored
22
23
24
    @Resource
    private ZoneMapper zoneMapper;
mahuandong authored
25
26
27
    @Override
    public List<Map<String, Object>> getZoneCodeList() {
        LambdaQueryWrapper<Zone> lambda = Wrappers.lambdaQuery();
肖超群 authored
28
        lambda.select(Zone::getId, Zone::getCode, Zone::getName, Zone::getArea)
xqs authored
29
                .eq(Zone::getWarehouseCode, ShiroUtils.getWarehouseCode());
mahuandong authored
30
31
        return this.listMaps(lambda);
    }
pengcheng authored
32
33
34
35
36
37
38
39
40
41
42
43

    @Override
    @Transactional
    public boolean zoneCopy(String warehouseCode, String newWarehouseCode) {
        int i = 0;
        //复制流程主表
        i = zoneMapper.zoneCopy(warehouseCode,newWarehouseCode);
        if(i < 1){
            throw new ServiceException("复制菜单数据失败");
        }
        return true;
    }
44
45
46
47
48
49
50
51
52

    @Override
    public boolean exists(String code,String warehouseCode)
    {
        LambdaQueryWrapper<Zone> lambda = Wrappers.lambdaQuery();
        lambda.eq(Zone::getCode,code)
                .eq(Zone::getWarehouseCode, warehouseCode);
        return this.listMaps(lambda).size() != 0;
    }
53
54
55
56
57
58
59
60

    @Override
    public List<Map<String, Object>> getCode() {
        LambdaQueryWrapper<Zone> lambda = Wrappers.lambdaQuery();
        lambda.select(Zone::getCode, Zone::getId, Zone::getName)
                .eq(Zone::getWarehouseCode, ShiroUtils.getWarehouseCode());
        return this.listMaps(lambda);
    }
游杰 authored
61
62
63
64
65
66
67
    public List<Map<String, Object>> getCodeAll() {
        LambdaQueryWrapper<Zone> lambda = Wrappers.lambdaQueryNoWarehouse();
        lambda.select(Zone::getCode, Zone::getId, Zone::getName);
        return this.listMaps(lambda);
    }
游杰 authored
68
69
70
71
72
73
74
    @Override
    public Zone getZoneByArea(String area) {
        LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
        zoneLambdaQueryWrapper.eq(Zone::getArea, area);
        Zone zone = getOne(zoneLambdaQueryWrapper);
        return zone;
    }
肖超群 authored
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

    @Override
    public void dataValidation(Zone zone) throws Exception {
        if (StringUtils.isEmpty(zone.getCode())){
            throw new Exception("库区编码不能为空值!");
        }
        if (StringUtils.isEmpty(zone.getWarehouseCode())){
            throw new Exception("仓库编码不能为空值!");
        }
        LambdaQueryWrapper<Zone> query = Wrappers.lambdaQuery();
        query.eq(Zone::getCode, zone.getCode()).
                eq(Zone::getWarehouseCode, zone.getWarehouseCode());
        if (this.getOne(query) != null){
            throw new Exception("库区编码已存在!");
        }
    }
91
92
93
94
95
96
97
98

    public Zone getByArea(String area,String warehouseCode){
        LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
        zoneLambdaQueryWrapper.eq(Zone::getArea, area);
        zoneLambdaQueryWrapper.eq(Zone::getWarehouseCode,warehouseCode);
        zoneLambdaQueryWrapper.last("limit 1");
        return this.getOne(zoneLambdaQueryWrapper);
    }
pengcheng authored
99
}