zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.shlanbao.tzsc.pms.cos.disabled.controller;
 
import java.util.List;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.shlanbao.tzsc.base.controller.BaseController;
import com.shlanbao.tzsc.base.mapping.CosPartWeight;
import com.shlanbao.tzsc.base.model.DataGrid;
import com.shlanbao.tzsc.base.model.Json;
import com.shlanbao.tzsc.base.model.PageParams;
import com.shlanbao.tzsc.pms.cos.disabled.bean.CosPartWeightBean;
import com.shlanbao.tzsc.pms.cos.disabled.service.CosPartWeightServiceI;
import com.shlanbao.tzsc.utils.tools.StringUtil;
/**
 * 
* @ClassName: CosPartWeightController 
* @Description: 烟支重量维护
* @author luoliang
* @date 2015-1-5 下午02:53:20 
*
 */
@Controller
@RequestMapping("/pms/partWeight")
public class CosPartWeightController extends BaseController {
    @Autowired
    private CosPartWeightServiceI cosPartWeightService;
    
    //跳转到添加界面
    @RequestMapping("/gotoPartWeight")
    public String gotoDis(){
        return "/pms/cos/disabled/addOrUpdatePartWidth";
    }
    
    @RequestMapping("/gotoEditPartWeight")
    public String gotoEditPartWeight(HttpServletRequest request,String id){
        try {
            request.setAttribute("bean",cosPartWeightService.getBeanById(id));
            request.setAttribute("id","i");
        } catch (Exception e) {
            e.printStackTrace();
            log.error("修改烟支重量配置信息时读取信息异常。", e);
        }
        return "/pms/cos/disabled/addOrUpdatePartWidth";
    }
    
    @ResponseBody
    @RequestMapping("/queryPartWeight")
    public DataGrid queryPartWeight(CosPartWeightBean bean,PageParams pageParams){
        try {
            DataGrid gd = cosPartWeightService.queryCosPartWeight(bean, pageParams);
            System.out.println(gd.toString());
            return gd;
        } catch (Exception e) {
            log.error("查询烟支重量配置信息异常。", e);
        }
        return null;
    }
    
    @ResponseBody
    @RequestMapping("/addOrUpdatePartWeight")
    public Json addOrUpdatePartWeight(CosPartWeight bean){
        Json json = new Json();
        try {
            boolean isNotNull=false;
            //当前牌号单支重量是否存在验证
            if(StringUtil.notNull(bean.getId())){
                List<CosPartWeight> b=cosPartWeightService.getBeanByPartNumber(bean.getPartNumber());
                for(CosPartWeight c:b){
                    if(!c.getId().equals(bean.getId())){
                        isNotNull=true;
                        break;
                    }
                }
            }else{
                CosPartWeight b=cosPartWeightService.getBeanByPartNumber(null,bean.getPartNumber());
                if(b!=null){
                    isNotNull=true;
                }
            }
            if(isNotNull){
                json.setMsg("此牌号的单支烟支重量信息已存在!");
                json.setSuccess(false);
                return json;
            }
            if(cosPartWeightService.addOrUpdateBean(bean)){
                json.setMsg("操作成功!");
                json.setSuccess(true);
            }else{
                json.setMsg("操作失败!");
                json.setSuccess(false);
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error("添加或修改残烟丝配置信息异常。", e);
            json.setMsg("操作失败!");
            json.setSuccess(false);
        }
        return json;
    }
    
}