DiliServiceServiceImpl.java
5.19 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
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
package com.diligrp.website.service.impl;
import java.sql.Timestamp;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.diligrp.website.domain.DiliService;
import com.diligrp.website.manager.DiliServiceManager;
import com.diligrp.website.rpc.UserRPCService;
import com.diligrp.website.service.DataDictionaryService;
import com.diligrp.website.service.DiliServiceCoverageService;
import com.diligrp.website.service.DiliServiceService;
import com.diligrp.website.service.PickUpPointService;
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 DiliServiceServiceImpl implements DiliServiceService {
private final static Logger LOG = LoggerFactory
.getLogger(DiliServiceServiceImpl.class);
@Autowired
private DiliServiceManager diliServiceManager;
@Autowired
private DataDictionaryService dataDictionaryService;
@Autowired
private DiliServiceCoverageService diliServiceCoverageService;
@Autowired
private UserRPCService userRPCService;
@Autowired
private PickUpPointService pickUpPointService;
public Result findOne(Long pk) {
return Result.create(diliServiceManager.findOne(pk));
}
public Result show(Long pk) {
Result result = Result.create();
DiliService service = diliServiceManager.findOne(pk);
result.addResult(Result.RESULT_KEY_DEFAULT_VALUE, service);
try{
result.addResult("coverage", diliServiceCoverageService.findByService(pk).getAllResult());
result.addResult("datas", pickUpPointService.getAllMarketPickUpInfo());
}catch(Exception e){
e.printStackTrace();
}
// try {
// UserInfoResp user = userRPCService.getUserInfoById(service.getCreator());
// result.addResult("creator", user);
// } catch (Exception e) {
// LOG.warn("查询用户信息出错");
// }
return result;
}
public Result save(DiliService diliService, Long[] coverages) {
diliService.setCreated(new Timestamp(new Date().getTime()));
diliService.setModified(new Timestamp(new Date().getTime()));
if (diliService.getCode() == null || diliService.getCode().equals("")) {
LOG.warn("必须填写CODE!");
return Result.create(false);
}
DiliService item = diliServiceManager.findByCode(diliService.getCode());
if (item != null) {
LOG.warn("服务已存在");
return Result.create(false);
}
//默认上架
diliService.setPutawayDate(new Timestamp(new Date().getTime()));
// diliService.setStatus(DiliService.STATUS_PUTAWAY);
return Result.create(diliServiceManager.save(diliService, coverages));
}
public Result update(DiliService diliService, Long[] coverages) {
DiliService up = diliServiceManager.findOne(diliService.getId());
if (up == null) {
return Result.create(false);
}
diliService.setCode(null);
up = BeanUtils.merge(up, diliService);
up.setModified(new Timestamp(new Date().getTime()));
return Result.create(diliServiceManager.update(up, coverages));
}
@Override
public Result updateStatus(DiliService ser, Long type, Timestamp date) {
if (ser == null || ser.getId() == null) {
return Result.create(false);
}
DiliService service = diliServiceManager.findOne(ser.getId());
if (service == null) {
return Result.create(false);
}
if (type == null || type == 0) {
if (ser.getStatus().equals(DiliService.STATUS_PUTAWAY)) {
service.setPutawayDate(new Timestamp(new Date().getTime()));
} else{
service.setDownDate(new Timestamp(new Date().getTime()));
}
} else {
if (date == null) {
date = new Timestamp(new Date().getTime());
}
if (ser.getStatus().equals(DiliService.STATUS_PUTAWAY)) {
service.setPutawayDate(date);
} else{
service.setDownDate(date);
}
}
service.setModified(new Timestamp(new Date().getTime()));
return Result.create(diliServiceManager.update(service));
}
public Result find(BaseQuery bq) {
return Result.create(diliServiceManager.find(bq));
}
public Result findAll(BaseQuery baseQuery) {
return Result.create(diliServiceManager.findAll(baseQuery));
}
@Override
public Result findByCode(String code) {
return Result.create(diliServiceManager.findByCode(code));
}
public Result del(Long id){
return Result.create(diliServiceManager.del(id));
}
}