hjg
2024-01-20 4a3404efc438b16044fd9170814e6545a3f86fae
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package com.mandi.fendan.controller;
 
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.mandi.common.Jacksonmethod;
import com.mandi.common.RequestParam;
import com.mandi.common.SessionMethod;
import com.mandi.dao.common.ObjectResult;
import com.mandi.dao.common.PageRequest;
import com.mandi.dao.common.PageResult;
import com.mandi.fendan.mapper.Fd_fhdqMapper;
import com.mandi.fendan.persist.Fd_Company;
import com.mandi.fendan.service.IAreaService;
import com.mandi.fendan.service.IFd_fhdqService;
 
/**
 * 发货地区controller
 *
 */
@Controller("fd_areacontroller")
@RequestMapping(value="/area",method={RequestMethod.POST})
public class Fd_AreaController {
    
    @Resource
    private IAreaService arser;
    @Resource
    private IFd_fhdqService fhdqser;
    @Resource
    private Fd_fhdqMapper dqper;
    
    /**
     * 获取发货地址列表
     * @param r
     * @param re
     * @return
     */
    @RequestMapping(value = "/getList.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String getList(HttpServletRequest r,HttpServletResponse re){
        String search=RequestParam.getSqlString(r, "search");
        int state=RequestParam.getInt(r, "state");
        int page=RequestParam.getInt(r, "page");
        int pagesize=RequestParam.getInt(r, "pagesize");
        int pages=RequestParam.getInt(r, "pages");
        PageRequest pr=new PageRequest(page, pagesize, null);
        pr.setNeedPages(pages>0?true:false);
        PageResult<Map<String, Object>> prr=fhdqser.getList(pr, search, state);
        String str=Jacksonmethod.tojson(prr, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
    
    /**
     * 获得所有的物流公司
     * @param r
     * @param re
     * @return
     */
    @RequestMapping(value = "/getallCMlist.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String getallcmList(HttpServletRequest r,HttpServletResponse re){
        PageResult<Fd_Company> prr=arser.getallcmList();
        String str=Jacksonmethod.tojson(prr, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
    
    /**
     * 保存配货地址及物流公司关系表
     * @param r
     * @param re
     * @return
     */
    @RequestMapping(value = "/saveItem.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String saveItem(HttpServletRequest r,HttpServletResponse re){
        //GLXJ //是否修改下级
        //物流公司编号 companyNos  
        // code 地区编号
        String fhdqNo =RequestParam.getSqlString(r, "code");//发货地区编号
        String wlgsNos =RequestParam.getSqlString(r, "companyNos");//物流公司编号 物流公司1,物流公司2
        String ywdyNo =RequestParam.getSqlString(r, "ywdyNo");//物流公司编号 物流公司1,物流公司2
        boolean xgxj=RequestParam.getBool(r, "GLXJ");
        ObjectResult<Boolean> or=new ObjectResult<Boolean>();
        try {
            or=this.fhdqser.savewlgs_fhdq(fhdqNo, wlgsNos,ywdyNo,xgxj);
        } catch (Exception e) {
            e.printStackTrace();
            or.setCode(1);
            or.setErrmsg(e.getMessage());
        }
        String str=Jacksonmethod.tojson(or, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
    
    
//    /**
//     * 保存配货地址及物流公司关系表
//     * @param r
//     * @param re
//     * @return
//     */
//    @RequestMapping(value = "/saveItem.htm", method = {RequestMethod.POST })
//    @ResponseBody
//    public String saveItem(HttpServletRequest r,HttpServletResponse re){
//        String name =RequestParam.getSqlString(r, "name");//名字
//        String bianhao =RequestParam.getSqlString(r, "bianhao");//编号
//        int jishu =RequestParam.getInt(r, "jishu");//级数
//        String companyNos =RequestParam.getSqlString(r, "companyNos");//物流公司
//        boolean GLXJ=RequestParam.getBool(r, "GLXJ");//关联操作下级地区
//        ObjectResult<Boolean> or=new ObjectResult<Boolean>();
//        try {
//            or=arser.saveItem(name, bianhao, jishu, companyNos,GLXJ);
//        } catch (Exception e) {
//            e.printStackTrace();
//            or.setCode(1);
//            or.setErrmsg(e.getMessage());
//        }
//        String str=Jacksonmethod.tojson(or, false);
//        SessionMethod.writeresp(re, str);
//        return null;
//    }
    
    
//    /**
//     * 删除配货地址及物流公司关系表
//     * @param r
//     * @param re
//     * @return
//     */
//    @RequestMapping(value = "/delItem.htm", method = {RequestMethod.POST })
//    @ResponseBody
//    public String delItem(HttpServletRequest r,HttpServletResponse re){
//        String bianhao =RequestParam.getSqlString(r, "bianhao");//编号
//        ObjectResult<Boolean> or=new ObjectResult<Boolean>();
//        try {
//            or=arser.delItem(bianhao);
//        } catch (Exception e) {
//            e.printStackTrace();
//            or.setCode(1);
//            or.setErrmsg(e.getMessage());
//        }
//        String str=Jacksonmethod.tojson(or, false);
//        SessionMethod.writeresp(re, str);
//        return null;
//    }
 
    /**
     * 获得配货地址及物流公司
     * @param r
     * @param re
     * @return
     */
    @RequestMapping(value = "/getcmList.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String getcmList(HttpServletRequest r,HttpServletResponse re){
        String bianhao =RequestParam.getSqlString(r, "bianhao");//编号
        String ywdyNo =RequestParam.getSqlString(r, "ywdyNo");//业务单元
        List<Fd_Company> cl=this.dqper.getCbyNo(bianhao,ywdyNo);
        ObjectResult<String> or=new ObjectResult<String>();
        String resl="";
        if(cl!=null){
            for (Fd_Company fd_Company : cl) {
                if(StringUtils.isNotBlank(resl)){
                    resl+=","+fd_Company.getCompanyNo();
                }else{
                    resl+=fd_Company.getCompanyNo();
                }
            }
        }
        or.setCode(0);
        or.setItem(resl);
        String str=Jacksonmethod.tojson(or, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
}