DiliServiceCoverageServiceImpl.java
3.84 KB
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
package com.diligrp.website.service.impl;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.diligrp.website.domain.DataDictionary;
import com.diligrp.website.domain.DataDictionaryValue;
import com.diligrp.website.domain.DiliServiceCoverage;
import com.diligrp.website.manager.DiliServiceCoverageManager;
import com.diligrp.website.service.DataDictionaryService;
import com.diligrp.website.service.DiliServiceCoverageService;
import com.diligrp.website.util.dao.BaseQuery;
import com.diligrp.website.util.domain.Result;
import com.diligrp.website.util.web.BeanUtils;
/**
* <B>Description</B> <br />
* <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br />
* 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br />
* <B>Company</B> 地利集团
* @createTime 2014-6-3 11:33:00
* @author template
*/
@Service
public class DiliServiceCoverageServiceImpl implements DiliServiceCoverageService {
/**
* 交割地, 提货点
*/
private final static String CODE_THD = "DIC_PACKUP_ADDRESS";
@Autowired
private DiliServiceCoverageManager diliServiceCoverageManager;
@Autowired
private DataDictionaryService dataDictionaryService;
public Result findOne(Long pk) {
return Result.create(diliServiceCoverageManager.findOne(pk));
}
public Result save(DiliServiceCoverage diliServiceCoverage) {
diliServiceCoverage.setCreated(new Timestamp(new Date().getTime()));
diliServiceCoverage.setModified(new Timestamp(new Date().getTime()));
return Result.create(diliServiceCoverageManager.save(diliServiceCoverage));
}
public Result update(DiliServiceCoverage diliServiceCoverage) {
DiliServiceCoverage up = diliServiceCoverageManager.findOne(diliServiceCoverage.getId());
if (up == null) {
return Result.create(false);
}
up = BeanUtils.merge(up, diliServiceCoverage);
up.setModified(new Timestamp(new Date().getTime()));
return Result.create(diliServiceCoverageManager.update(up));
}
@Override
public Result findByService(Long serviceId) {
return Result.create(diliServiceCoverageManager.findByService(serviceId));
}
public Result findByServiceInfo(Long serviceId) {
Result result = Result.create();
List<Long> coverages = new ArrayList<Long>();
if (serviceId != null && serviceId > 0) {
List<DiliServiceCoverage> list = diliServiceCoverageManager.findByService(serviceId);
for (DiliServiceCoverage dsc : list) {
coverages.add(dsc.getCoverageId());
}
}
DataDictionary data = dataDictionaryService.getDataDictionaryByCode(CODE_THD);
if (data != null && data.getId() != null) {
List<DataDictionaryValue> vals = dataDictionaryService.getDataDictionaryValue(data.getId());
for (DataDictionaryValue ddv : vals) {
if (coverages.contains(ddv.getId())) {
ddv.setDdId(1);
} else {
ddv.setDdId(0);
}
}
result.addResult(Result.RESULT_KEY_DEFAULT_VALUE, vals);
}
return result;
}
public Result find(BaseQuery bq) {
return Result.create(diliServiceCoverageManager.find(bq));
}
public Result del(Long id){
return Result.create(diliServiceCoverageManager.del(id));
}
/* (non-Javadoc)
* @see com.diligrp.website.service.DiliServiceCoverageService#findServiceByPickId(java.lang.Long)
*/
@Override
public List<DiliServiceCoverage> findServiceByPickId(Long id) {
return diliServiceCoverageManager.findServiceByPickId(id);
}
}