Blame view

src/main/java/com/huaheng/pc/config/materialWarnning/controller/MaterialWarningController.java 6.5 KB
1
2
3
4
5
6
package com.huaheng.pc.config.materialWarnning.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
import com.huaheng.common.utils.security.ShiroUtils;
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.common.utils.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.pc.config.materialWarnning.domain.MaterialWarning;
import com.huaheng.pc.config.materialWarnning.service.IMaterialWarningService;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.common.support.Convert;
28
29
30
31
32
33
34
35
36
37
38
39
40
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 物料报警 信息操作处理
 *
 * @author huaheng
 * @date 2020-07-17
 */
@Controller
lector authored
41
@RequestMapping("/config/materialWarning")
42
public class MaterialWarningController extends BaseController {
lector authored
43
    private String prefix = "config/materialWarning";
44
45
46
47
48
49
50
51
52
    @Resource
    private IMaterialWarningService materialWarningService;

    @RequiresPermissions("config:materialWarning:view")
    @GetMapping()
    public String materialWarning() {
        return prefix + "/materialWarning";
    }
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
    /**
     * 查询物料报警列表
     */
    @RequiresPermissions("config:materialWarning:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MaterialWarning materialWarning) {
        LambdaQueryWrapper<MaterialWarning> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper
                .eq(StringUtils.isNotEmpty(materialWarning.getAlarmType()), MaterialWarning::getAlarmType, materialWarning.getAlarmType())
                .eq(StringUtils.isNotEmpty(materialWarning.getWarehouseCode()), MaterialWarning::getWarehouseCode, ShiroUtils.getWarehouseCode())
                .eq(StringUtils.isNotEmpty(materialWarning.getCompanyCode()), MaterialWarning::getCompanyCode, materialWarning.getCompanyCode())
                .eq(StringUtils.isNotEmpty(materialWarning.getMaterialCode()), MaterialWarning::getMaterialCode, materialWarning.getMaterialCode())
                .like(StringUtils.isNotEmpty(materialWarning.getMaterialName()), MaterialWarning::getMaterialName, materialWarning.getMaterialName())
                .eq(StringUtils.isNotEmpty(materialWarning.getMaterialSpec()), MaterialWarning::getMaterialSpec, materialWarning.getMaterialSpec())
                .eq(StringUtils.isNotEmpty(materialWarning.getMaterialUnit()), MaterialWarning::getMaterialUnit, materialWarning.getMaterialUnit())
                .eq(StringUtils.isNotNull(materialWarning.getMax()), MaterialWarning::getMax, materialWarning.getMax())
                .eq(StringUtils.isNotNull(materialWarning.getMin()), MaterialWarning::getMin, materialWarning.getMin())
                .eq(StringUtils.isNotNull(materialWarning.getUpper()), MaterialWarning::getUpper, materialWarning.getUpper())
                .eq(StringUtils.isNotNull(materialWarning.getLower()), MaterialWarning::getLower, materialWarning.getLower())
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
                .eq(StringUtils.isNotNull(materialWarning.getUserId()), MaterialWarning::getUserId, materialWarning.getUserId())
                .like(StringUtils.isNotEmpty(materialWarning.getUserName()), MaterialWarning::getUserName, materialWarning.getUserName())
                .eq(StringUtils.isNotEmpty(materialWarning.getEmail()), MaterialWarning::getEmail, materialWarning.getEmail());
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
            /*使用分页查询*/
            Page<MaterialWarning> page = new Page<>(pageNum, pageSize);
            IPage<MaterialWarning> iPage = materialWarningService.page(page, lambdaQueryWrapper);
            return getMpDataTable(iPage.getRecords(), iPage.getTotal());
        } else {
            List<MaterialWarning> list = materialWarningService.list(lambdaQueryWrapper);
            return getDataTable(list);
        }
    }
91
92
93
94
95
96
97
98
    /**
     * 新增物料报警
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }
99
100
101
102
103
104
105
106
107
108
109
    /**
     * 新增保存物料报警
     */
    @RequiresPermissions("config:materialWarning:add")
    @Log(title = "物料报警", action = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MaterialWarning materialWarning) {
        return materialWarningService.addSave(materialWarning);
    }
110
111
112
113
114
115
116
117
118
119
    /**
     * 修改物料报警
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
        MaterialWarning materialWarning = materialWarningService.getById(id);
        mmap.put("materialWarning", materialWarning);
        return prefix + "/edit";
    }
120
121
122
123
124
125
126
127
128
129
130
    /**
     * 修改保存物料报警
     */
    @RequiresPermissions("config:materialWarning:edit")
    @Log(title = "物料报警", action = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MaterialWarning materialWarning) {
        return toAjax(materialWarningService.updateById(materialWarning));
    }
131
132
133
134
135
136
137
138
139
140
141
142
143
144
    /**
     * 删除物料报警
     */
    @RequiresPermissions("config:materialWarning:remove")
    @Log(title = "物料报警", action = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        if (StringUtils.isEmpty(ids)) {
            return AjaxResult.error("id不能为空");
        }
        return toAjax(materialWarningService.removeByIds(Arrays.asList(Convert.toIntArray(ids))));
    }
145
146

}