hjg
2023-11-22 975c04c0181b3da82a79cb04abe6a2f1799eb363
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
package com.mandi.fendan.service.impl;
 
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
 
import com.mandi.dao.common.PageResult;
import com.mandi.fendan.mapper.Fd_CompanyMapper;
import com.mandi.fendan.persist.Fd_Company;
import com.mandi.fendan.service.IAreaService;
 
@Service
public class AreaService implements IAreaService{
    
//    @Resource
//    private IDDBMSSQLDao ddao;
//    @Resource
//    private Fd_ErpconfigMapper erpper;
    
    @Resource
    private Fd_CompanyMapper fdcper;
    
    @Override
    public PageResult<Fd_Company> getallcmList() {
        PageResult<Fd_Company> prr=new PageResult<Fd_Company>();
        List<Fd_Company> fcl=fdcper.getall();
        prr.setCode(0);
        prr.setList(fcl);
        return prr;
    }
    
    
 
//    @Override
//    public PageResult<Map<String, Object>> getList() {
//        PageResult<Map<String, Object>> prr=new PageResult<Map<String,Object>>();
//        String sql=SqlTxt.FHDQsql+" ORDER BY PP0XSDHDD_BH  ";
//        List<Fd_Erpconfig> l=erpper.getall();
//        if(l!=null&&l.size()>0){
//            Fd_Erpconfig erpdb=l.get(0);
//            String url="jdbc:jtds:sqlserver://"+erpdb.getUri()+":"+erpdb.getPost()+";databaseName="+erpdb.getDb();
//            Connection con=ddao.open(url, erpdb.getUsername(), erpdb.getPwd(),erpdb.getDbsign());
//            if(con==null){
//                prr.setCode(1);
//                prr.setErrmsg("erp数据库链接失败,请查询erp配置是否正确!");
//                return prr;
//            }
//            List<Map<String, Object>> d=new ArrayList<Map<String,Object>>();
//            try {
//                d=ddao.getmaps(sql, erpdb.getDbsign());
//            } catch (Exception e) {
//                e.printStackTrace();
//            }finally{
//                ddao.close();
//            }
//            List<Map<String, Object>> rel=new ArrayList<Map<String,Object>>();
//            for (Map<String, Object> map : d) {
//                String bianhao =map.get("bianhao")+"";//编号
//                String name =map.get("name")+"";//名称
//                int jishu =Integer.parseInt(map.get("jishu")+"");//层级
//                Map<String, Object> rem=new HashMap<String, Object>();
//                rem.put("bianhao", bianhao);
//                rem.put("name", name);
//                rem.put("jishu", jishu);
//                rem.put("xsbianhao", bianhao.substring(bianhao.length()-2, bianhao.length()));
//                rel.add(rem);
//            }
//            prr.setCode(0);
//            prr.setList(rel);
//        }else{
//            prr.setCode(1);
//            prr.setErrmsg("数据库未配置ERP数据源!");
//        }
//        return prr;
//    }
//
//    
//
//    @Override
//    public ObjectResult<String> getsecmList(String bianhao) {
//        ObjectResult<String> or=new ObjectResult<String>();
//        String sql=SqlTxt.FHWLsql+" where XSDQWL_DQBH='"+bianhao+"' ";
//        List<Fd_Erpconfig> l=erpper.getall();
//        if(l!=null&&l.size()>0){
//            Fd_Erpconfig erpdb=l.get(0);
//            String url="jdbc:jtds:sqlserver://"+erpdb.getUri()+":"+erpdb.getPost()+";databaseName="+erpdb.getDb();
//            Connection con=ddao.open(url, erpdb.getUsername(), erpdb.getPwd(),erpdb.getDbsign());
//            if(con==null){
//                or.setCode(1);
//                or.setErrmsg("erp数据库链接失败,请查询erp配置是否正确!");
//                return or;
//            }
//            List<Map<String, Object>> d=new ArrayList<Map<String,Object>>();
//            try {
//                d=ddao.getmaps(sql, erpdb.getDbsign());
//            } catch (Exception e) {
//                e.printStackTrace();
//            }finally{
//                ddao.close();
//            }
//            String ss="";
//            for (Map<String, Object> map : d) {
//                if(map.get("XSDQWL_WLBH")!=null){
//                    String XSDQWL_WLBH =map.get("XSDQWL_WLBH")+"";//编号
//                    if(StringUtils.isEmpty(ss)){
//                        ss=XSDQWL_WLBH;
//                    }else{
//                        ss=ss+","+XSDQWL_WLBH;
//                    }
//                }
//            }
//            or.setCode(0);
//            or.setItem(ss);
//        }else{
//            or.setCode(1);
//            or.setErrmsg("数据库未配置ERP数据源!");
//        }
//        return or;
//    }
//
//    @Override
//    @Transactional(rollbackOn=Exception.class)
//    public ObjectResult<Boolean> saveItem(String name, String bianhao,int jishu, String companyNos,boolean GLXJ) throws Exception {
//        ObjectResult<Boolean> or=new ObjectResult<Boolean>();
//        if(StringUtils.isEmpty(name)){
//            or.setCode(1);
//            or.setErrmsg("地区名称不能为空!");
//            return or;
//        }
//        if(StringUtils.isEmpty(bianhao)){
//            or.setCode(1);
//            or.setErrmsg("地区编号不能为空!");
//            return or;
//        }
//        if(bianhao.length()!=jishu*2){
//            or.setCode(1);
//            or.setErrmsg("地区编号不正确,请输入2的倍数的编号!");
//            return or;
//        }
//        List<Fd_Erpconfig> l=erpper.getall();
//        if(l==null||l.size()<=0){
//            or.setCode(1);
//            or.setErrmsg("数据库未配置ERP数据源!");
//            return or;
//        }
//        if(!StringUtils.isEmpty(companyNos)){
//            for (String cmstr : companyNos.split(",")) {
//                Fd_Company fdc=fdcper.getByCompanyNo(cmstr);
//                if(fdc==null){
//                    or.setCode(1);
//                    or.setErrmsg("物流公司设置不正确!");
//                    return or;
//                }
//            }
//        }
//        int ismx=1;
//        try {
//            for (Fd_Erpconfig erpdb : l) {
//                String url="jdbc:jtds:sqlserver://"+erpdb.getUri()+":"+erpdb.getPost()+";databaseName="+erpdb.getDb();
//                Connection con=ddao.open(url, erpdb.getUsername(), erpdb.getPwd(),erpdb.getDbsign());
//                if(con==null){
//                    throw new Exception("数据库连接失败!");
//                }
//                String FHDQsql=SqlTxt.FHDQsql+" where PP0XSDHDD_BH='"+bianhao+"' ";
//                Map<String, Object> mm=ddao.getmapnoclose(FHDQsql, erpdb.getDbsign());
//                if(mm!=null){
//                    FHDQsql=SqlTxt.FHDQsql+" where PP0XSDHDD_BH like '"+bianhao+"%' ";
//                    List<Map<String, Object>> cheo=ddao.getmapsnoclose(FHDQsql, erpdb.getDbsign());
//                    if(cheo!=null&&cheo.size()>1){
//                        ismx=0;
//                    }
//                    FHDQsql=SqlTxt.XGFHDQsql;
//                }else{
//                    FHDQsql=SqlTxt.XZFHDQsql;
//                }
//                List<Object> ll=new ArrayList<Object>();
//                ll.add(jishu);
//                ll.add(name);
//                ll.add(ismx);
//                ll.add(bianhao);
//                ddao.modifySql(FHDQsql, ll, erpdb.getDbsign());
//                
//                
//                ll.clear();
//                ll.add(0);
//                ll.add(bianhao.substring(0, bianhao.length()-2));
//                ddao.modifySql(SqlTxt.XGFHDQMXsql, ll, erpdb.getDbsign());
//                
//                String XZFHDQsql=SqlTxt.SCFHWLsql;
//                if(!GLXJ){
//                    XZFHDQsql+=" where XSDQWL_DQBH='"+bianhao+"' ";
//                }else{
//                    XZFHDQsql+=" where XSDQWL_DQBH like '"+bianhao+"%' ";
//                }
//                ddao.modifySql(XZFHDQsql, erpdb.getDbsign());
//                
//                if(!StringUtils.isEmpty(companyNos)){
//                    for (String cmstr : companyNos.split(",")) {
//                        if(!GLXJ){
//                            XZFHDQsql=SqlTxt.XZFHWLsql;
//                            ll.clear();
//                            ll.add(bianhao);
//                            ll.add(cmstr);
//                            ddao.modifySql(XZFHDQsql, ll, erpdb.getDbsign());
//                        }else{
//                            XZFHDQsql="insert into XSDQWL (XSDQWL_DQBH,XSDQWL_WLBH) select PP0XSDHDD_BH,'"+cmstr+"'  from PP0XSDHDD where PP0XSDHDD_BH LIKE '"+bianhao+"%' ";
////                            ll.clear();
////                            ll.add(bianhao);
////                            ll.add(cmstr);
////                            ddao.modifySql(XZFHDQsql, ll, erpdb.getDbsign());
//                            ddao.modifySql(XZFHDQsql, erpdb.getDbsign());
//                        }
//                    }
//                }
//            }
//        } catch (Exception e) {
//            ddao.robackclose();
//            throw new Exception(e.getMessage());
//        }finally{
//            ddao.close();
//        }
//        or.setCode(0);
//        or.setItem(true);
//        return or;
//    }
//
//    @Override
//    @Transactional(rollbackOn=Exception.class)
//    public ObjectResult<Boolean> delItem(String bianhao) throws Exception {
//        ObjectResult<Boolean>  or=new ObjectResult<Boolean>();
//        if(StringUtils.isEmpty(bianhao)){
//            or.setCode(1);
//            or.setErrmsg("地区编号不能为空!");
//            return or;
//        }
//        List<Fd_Erpconfig> l=erpper.getall();
//        if(l==null||l.size()<=0){
//            or.setCode(1);
//            or.setErrmsg("数据库未配置ERP数据源!");
//            return or;
//        }
//        
//        try {
//            for (Fd_Erpconfig erpdb : l) {
//                String url="jdbc:jtds:sqlserver://"+erpdb.getUri()+":"+erpdb.getPost()+";databaseName="+erpdb.getDb();
//                Connection con=ddao.open(url, erpdb.getUsername(), erpdb.getPwd(),erpdb.getDbsign());
//                if(con==null){
//                    throw new Exception("数据库连接失败!");
//                }
//                String FHDQsql=SqlTxt.FHDQsql+" where PP0XSDHDD_BH like '"+bianhao+"%' ";
//                List<Map<String, Object>> cheo=ddao.getmapsnoclose(FHDQsql, erpdb.getDbsign());
//                if(cheo!=null&&cheo.size()>1){
//                    throw new Exception("有下级不能删除!");
//                }
//                
//                String XZFHDQsql=SqlTxt.SCFHWLsql+" where XSDQWL_DQBH='"+bianhao+"' ";
//                ddao.modifySql(XZFHDQsql, erpdb.getDbsign());
//            
//                ddao.modifySql(SqlTxt.SCFHDQsql+" where PP0XSDHDD_BH='"+bianhao+"'", erpdb.getDbsign());
//                
//                FHDQsql=SqlTxt.FHDQsql+" where PP0XSDHDD_BH like '"+bianhao.substring(0, bianhao.length()-2)+"%' ";
//                cheo=ddao.getmapsnoclose(FHDQsql, erpdb.getDbsign());
//                if(cheo!=null&&cheo.size()<=1){
//                    List<Object> ll=new ArrayList<Object>();
//                    ll.add(0);
//                    ll.add(bianhao.substring(0, bianhao.length()-2));
//                    ddao.modifySql(SqlTxt.XGFHDQMXsql, ll, erpdb.getDbsign());
//                }
//            }
//        } catch (Exception e) {
//            ddao.robackclose();
//            throw new Exception(e.getMessage());
//        }finally{
//            ddao.close();
//        }
//        
//        or.setCode(0);
//        or.setItem(true);
//        return or;
//    }
 
}