ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
package com.vci.server.portal.service;
 
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
 
import com.vci.server.base.persistence.dao.BaseService;
import com.vci.server.portal.dao.impl.PLActionClsEntityDaoImp;
import com.vci.server.portal.dao.impl.PLActionEntityDaoImpl;
import com.vci.server.portal.dao.impl.PLActionParamEntityDaoImp;
import com.vci.server.portal.entity.PLActionClsEntity;
import com.vci.server.portal.entity.PLActionEntity;
import com.vci.server.portal.entity.PLActionParamEntity;
import com.vci.common.utility.ObjectUtility;
import com.vci.corba.portal.data.Constraint;
 
public class PLActionEntityService extends BaseService{
    private static PLActionEntityService instance = null;
    private DateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd");
    
    private PLActionEntityService(){
        
    }
    
    public static PLActionEntityService getInstance(){
        if(instance == null){
            instance = new PLActionEntityService();
        }
        return instance;
    }
    /**
     * 新增action对象
     * @param obj
     * @throws Throwable 
     */
    public boolean savePLActionEntity(PLActionEntity obj) throws Throwable {
 
        try {
            PLActionEntityDaoImpl daoImpl = new PLActionEntityDaoImpl();
            daoImpl.saveOrUpdate(obj);
            return true;
        } catch(Throwable e){
            throw e;
        }
    }
    
    /**
     * 更新action对象
     * @param obj
     * @return
     * @throws Throwable 
     */
    public boolean updatePLActionEntity(PLActionEntity obj) throws Throwable{
        try {
            PLActionEntityDaoImpl daoImpl = new PLActionEntityDaoImpl();
            PLActionEntity objGet = daoImpl.getById(obj.getId());
            if (objGet == null) {
                daoImpl.saveOrUpdate(obj);
            } else {
                // objGet.setId(obj.getId());
                objGet.setPlCode(obj.getPlCode());
                objGet.setPlName(obj.getPlName());
                objGet.setPlBSUrl(obj.getPlBSUrl());
                objGet.setPlCSClass(obj.getPlCSClass());
                objGet.setPlDesc(obj.getPlDesc());
                objGet.setPlTypeType(obj.getPlTypeType());
//                objGet.setPlCreateTime(obj.getPlCreateTime());
                objGet.setPlCreateUser(obj.getPlCreateUser());
                objGet.setPlModifyTime(obj.getPlModifyTime());
                objGet.setPlModifyUser(obj.getPlModifyUser());
                objGet.setPlLicensOrs(obj.getPlLicensOrs());
                objGet.setPlActionCls(obj.getPlActionCls());
                daoImpl.saveOrUpdate(objGet);
            }
            return true;
        } catch(Throwable e){
            throw e;
        }
        
    }
    
    /**
     * 删除action对象
     * @param obj
     * @return
     * @throws Throwable 
     */
    public boolean deletePLActionEntity(PLActionEntity obj) throws Throwable{
        try {
            PLActionEntityDaoImpl daoImpl = new PLActionEntityDaoImpl();
            daoImpl.delete(obj);
            return true;
        } catch(Throwable e){
            throw e;
        }
        
    }
 
    /**
     * 根据Id删除指定的action对象 
     * @param id
     * @return
     * @throws Throwable 
     */
    public boolean deletePLActionEntityById(String id) throws Throwable{
        try {
            PLActionEntityDaoImpl daoImpl = new PLActionEntityDaoImpl();
            PLActionEntity obj = daoImpl.getById(id);
            if (obj != null) {
                daoImpl.delete(obj);
            }
            return true;
        } catch(Throwable e){
            throw e;
        }
        
    }
 
    /**
     * 根据ID获取指定的PLAction
     * @param plOId
     * @return
     * @throws Throwable 
     */
    public PLActionEntity getPLActionEntityById(String plOId) throws Throwable {
        try {
            PLActionEntityDaoImpl daoImpl = new PLActionEntityDaoImpl();
            return daoImpl.getById(plOId);
        } catch(Throwable e){
            throw e;
        }
        
    }
    
    /**
     * 获取所有PLAction
     * @return
     * @throws Throwable 
     */
    public List<PLActionEntity> getAllPLActionEntity() throws Throwable{
        try {
            PLActionEntityDaoImpl daoImpl = new PLActionEntityDaoImpl();
            StringBuilder sql = new StringBuilder("select * from PLAction p order by plCode");
            List<PLActionEntity> loadAll = daoImpl.findEntites(sql.toString(), new Object[0], "", PLActionEntity.class);
            return loadAll;
        } catch(Throwable e){
            throw e;
        }
        
    }
 
    /**
     * 根据约束条件组查询数组, 查询PLActions
     * @throws Throwable 
     */
    public List<PLActionEntity> getPLActionEntitysByConsMap(Constraint[] consArray) throws Throwable {
        try {
            PLActionEntityDaoImpl daoImpl = new PLActionEntityDaoImpl();
            StringBuilder sql = new StringBuilder("select * from PLAction p where 1 = 1 ");
            for(int i = 0; i < consArray.length; i++){
                Constraint cons = consArray[i];
                if(cons.value == null || cons.value.equals("")){
                    if(!cons.key.equalsIgnoreCase("plactioncls")) {
                        continue;
                    }
                }
                
                if(cons.key.equalsIgnoreCase("plCreateTime") || cons.key.equalsIgnoreCase("plModifyTime")){
                    sql.append(" and p.");
                    sql.append(cons.key + " = ");
                    sql.append(dFormat.parse(cons.value));
                } else if (cons.key.equalsIgnoreCase("plactioncls") && cons.value.equals("")) {
                    sql.append(" and (p.");
                    sql.append(cons.key + " is null or p." + cons.key + "= '') ");
                } else {
                    sql.append(" and p.");
                    sql.append(cons.key + " like ");
                    sql.append("'%" + cons.value + "%'");
                }
                
            }
            List<PLActionEntity> list = daoImpl.findEntites(sql.toString(), new Object[0], "", PLActionEntity.class);
            return list;
        } catch(Throwable e){
            e.printStackTrace();
            throw e;
        }
    }
    
    /**
     * 查询所有分类
     * @return
     */
    public List<PLActionClsEntity> getAllActionCls() {
        PLActionClsEntityDaoImp daoImpl = new PLActionClsEntityDaoImp();
        return daoImpl.loadAll();
    }
    
    /**
     * 创建分类
     * @param entity
     * @return
     */
    public synchronized String createPLActionCls(PLActionClsEntity entity) {
        try {
            PLActionClsEntityDaoImp daoImpl = new PLActionClsEntityDaoImp();
            //判断分类id是否正确 Add By ZhongGY 2015-06-12
            if (entity.getOid().trim().equals("")) {
                entity.setOid(ObjectUtility.getNewObjectID36());
            }else {
                List<PLActionClsEntity> loadAll = daoImpl.findEntites(
                        "select * from plactioncls t where t.oid = '" + entity.getOid() + "'",
                        new Object[0], "", PLActionClsEntity.class);
                if(loadAll != null && !loadAll.isEmpty()) {
                    //entity.setOid(ObjectUtility.getNewObjectID36());
                    return "00";
                }
            }
            //判断分类能否创建
            List<PLActionClsEntity> loadAll = daoImpl.findEntites(
                    "select * from plactioncls t where t.name = '" + entity.getName() + "'",
                    new Object[0], "", PLActionClsEntity.class);
            if(loadAll != null && !loadAll.isEmpty()) {
                return "01";
            }
            //判断同级分类下是否存在相同的编号
            String condition = "";
            if(entity.getPid().equals("")) {
                condition = " or t.pid is null";
            }
            List<PLActionClsEntity> queryList = daoImpl.findEntites(
                    "select * from plactioncls t where (t.pid = '" + entity.getPid() 
                    + "' " + condition + ") and t.serialno = " + entity.getSerialNo(),
                    new Object[0], "", PLActionClsEntity.class);
            if(queryList != null && !queryList.isEmpty()) {
                return "02";
            }
            //保存分类
            daoImpl.save(entity);
        } catch (Exception e) {
            e.printStackTrace();
            return "0" + e.getMessage();
        }
        return "1";
    }
    
    /**
     * 修改分类
     * @param entity
     * @return
     */
    public synchronized String editPLActionCls(PLActionClsEntity entity) {
        try {
            PLActionClsEntityDaoImp daoImpl = new PLActionClsEntityDaoImp();
            //判断分类id是否正确 Add By ZhongGY 2015-06-12
            if (entity.getOid().trim().equals("")) {
                //entity.setOid(ObjectUtility.getNewObjectID36());
                return "001";    //修改保存分类对象id不能为空,修改保存失败!
            }else {
                List<PLActionClsEntity> loadAll = daoImpl.findEntites(
                        "select * from plactioncls t where t.oid = '" + entity.getOid() + "'",
                        new Object[0], "", PLActionClsEntity.class);
                if(loadAll == null || loadAll.isEmpty()) {
                    //entity.setOid(ObjectUtility.getNewObjectID36());
                    return "002";//修改保存分类对象id不存在,修改保存失败!
                }
            }
            //判断分类能否创建
            List<PLActionClsEntity> loadAll = daoImpl.findEntites(
                    "select * from plactioncls t where t.name = '" + entity.getName()
                    + "' and t.oid != '" + entity.getOid() + "'",
                    new Object[0], "", PLActionClsEntity.class);
            if(loadAll != null && !loadAll.isEmpty()) {
                return "01";
            }
            //判断同级分类下是否存在相同的编号
            String condition = "";
            if(entity.getPid().equals("")) {
                condition = " or t.pid is null";
            }
            List<PLActionClsEntity> queryList = daoImpl.findEntites(
                    "select * from plactioncls t where (t.pid = '" + entity.getPid() 
                    + "' " + condition + ") and t.serialno = " + entity.getSerialNo()
                    + " and t.oid != '" + entity.getOid() + "'",
                    new Object[0], "", PLActionClsEntity.class);
            if(queryList != null && !queryList.isEmpty()) {
                return "02";
            }
            //保存分类
            //entity.setOid(ObjectUtility.getNewObjectID36());
            daoImpl.merge(entity);
        } catch (Exception e) {
            e.printStackTrace();
            return "0" + e.getMessage();
        }
        return "1";
    }
    
    /**
     * 删除分类
     * @param id
     * @return
     */
    public synchronized String deletePLActionCls(String id) {
        try {
            PLActionClsEntityDaoImp daoImpl = new PLActionClsEntityDaoImp();
            daoImpl.deleteByKey(id);
            //更新所有Action分类为"";
            PLActionEntityDaoImpl actionDao = new PLActionEntityDaoImpl();
            String sql = "update plaction t set t.plactioncls = null where t.plactioncls = '" + id + "'";
            actionDao.createSQLQuery(sql);
        } catch (Exception e) {
            e.printStackTrace();
            return "0" + e.getMessage();
        }
        return "1";
    }
    
    /**
     * 查询Action参数配置信息
     * @return
     */
    public List<PLActionParamEntity> getActionParamsById(String actionId) {
        PLActionParamEntityDaoImp daoImpl = new PLActionParamEntityDaoImp();
        return daoImpl.loadByActionId(actionId);
    }
    
    public List<PLActionParamEntity> getActionParams() {
        PLActionParamEntityDaoImp daoImpl = new PLActionParamEntityDaoImp();
        return daoImpl.loadAll();
    }
    
    /**
     * 创建Action参数
     * @param entity
     * @return
     */
    public synchronized String createPLActionParam(PLActionParamEntity entity) {
        try {
            PLActionParamEntityDaoImp daoImpl = new PLActionParamEntityDaoImp();
            //判断分类能否创建
            List<PLActionParamEntity> loadAll = daoImpl.findEntites(
                    "select * from plactionparam t where t.name = '" + entity.getName() 
                    + "' and t.action = '" + entity.getAction() + "'",
                    new Object[0], "", PLActionParamEntity.class);
            if(loadAll != null && !loadAll.isEmpty()) {
                return "01";
            }
            //保存分类
            entity.setOid(ObjectUtility.getNewObjectID36());
            daoImpl.save(entity);
        } catch (Exception e) {
            e.printStackTrace();
            return "0" + e.getMessage();
        }
        return "1";
    }
    
    /**
     * 修改Action参数
     * @param entity
     * @return
     */
    public synchronized String editPLActionParam(PLActionParamEntity entity) {
        try {
            PLActionParamEntityDaoImp daoImpl = new PLActionParamEntityDaoImp();
            //判断分类能否创建
            List<PLActionParamEntity> loadAll = daoImpl.findEntites(
                    "select * from plactionparam t where t.name = '" + entity.getName()
                    + "' and t.oid != '" + entity.getOid() + "' and t.action = '" + entity.getAction() + "'",
                    new Object[0], "", PLActionClsEntity.class);
            if(loadAll != null && !loadAll.isEmpty()) {
                return "01";
            }
            //保存分类
            daoImpl.update(entity);
        } catch (Exception e) {
            e.printStackTrace();
            return "0" + e.getMessage();
        }
        return "1";
    }
    
    /**
     * 删除Action参数
     * @param id
     * @return
     */
    public synchronized String deletePLActionParam(String id) {
        try {
            PLActionParamEntityDaoImp daoImpl = new PLActionParamEntityDaoImp();
            daoImpl.deleteByKey(id);
        } catch (Exception e) {
            e.printStackTrace();
            return "0" + e.getMessage();
        }
        return "1";
    }
 
    public PLActionClsEntity getPLActionCls(String objId) throws Throwable{
        try {
            PLActionClsEntityDaoImp actionClsEntityDaoImp = new PLActionClsEntityDaoImp();
            return actionClsEntityDaoImp.getById(objId);
        } catch (Throwable e) {
            throw e;
        }
    }
 
    public PLActionParamEntity getPLActionParam(String objId) throws Throwable{
        try {
            PLActionParamEntityDaoImp plActionParamEntityDaoImp = new PLActionParamEntityDaoImp();
            return plActionParamEntityDaoImp.getById(objId);
        } catch (Throwable e) {
            throw e;
        }
    }
}