WarehouseBiz.java
1.8 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
package com.cjs.site.biz.user.pick;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;
import com.cjs.site.biz.ServiceException;
import com.cjs.site.model.user.pick.WarehouseInfo;
/**
* 仓库
*
* @author tongyufu
*
*/
@Service
public class WarehouseBiz {
Logger log = LogManager.getLogger();
DateFormat time1 = new SimpleDateFormat("HHmmss");
DateFormat time2 = new SimpleDateFormat("HH:mm");
public WarehouseInfo parseWarehouseTime(WarehouseInfo warehouseInfo) {
String time = parseWarehouseTime(warehouseInfo.getBusinessStartTime());
warehouseInfo.setBusinessStartTime(time);
time = parseWarehouseTime(warehouseInfo.getBusinessEndTime());
warehouseInfo.setBusinessEndTime(time);
return warehouseInfo;
}
public Integer getHour(String time) {
try {
if (time.length() == 5) {
time = "0" + time;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(time1.parse(time));
return calendar.get(Calendar.HOUR_OF_DAY);
} catch (ParseException e) {
throw new ServiceException("获取网点营业时间出错", e);
}
}
private String parseWarehouseTime(String time) {
if (StringUtils.isBlank(time)) {
return "";
}
if (time.length() == 5) {
time = "0" + time;
}
try {
time = time2.format(time1.parse(time));
} catch (ParseException e) {
log.error("", e);
}
return time;
}
}