bb351e3e3628db9a15d76312d57f681d5b8983ba.svn-base
3.86 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
package com.phxl.modules.goods.service.spills;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.phxl.common.util.JsonMapper;
import com.phxl.common.utils.BaseException;
import com.phxl.common.utils.IdUtil;
import com.phxl.modules.goods.dao.spills.HisSpillsDao;
import com.phxl.modules.goods.entity.spills.HisSpills;
import com.phxl.modules.goods.entity.spills.HisSpillsList;
@Service
public class HisSpillsService {
@Autowired
private HisSpillsDao hisSpillsDao;
/**
* 日志对象
*/
protected Logger logger = LoggerFactory.getLogger(getClass());
public boolean batchSave(List<HisSpillsList> spills) {
boolean result = false;
if (spills != null && spills.size() != 0) {
for (HisSpillsList hisSpillsList : spills) {
HisSpills hisSpills = hisSpillsList.getData();
try {
checkSpills(hisSpills);
} catch (Exception e) {
String json = JsonMapper.toJsonString(hisSpills);
logger.error("同步医院盘点损溢单:" + json + "信息异常");
throw new BaseException(e.getMessage());
}
hisSpills.setId(IdUtil.uuid());
hisSpillsDao.insert(hisSpills);
}
result = true;
}
return result;
}
private void checkSpills(HisSpills hisSpills) {
// 获取库存信息中供应商信息
String medCode = hisSpills.getMedCode();
String medName = hisSpills.getMedName();
String supplierCode = hisSpills.getSupplierCode();
String supplierName = hisSpills.getSupplierName();
String stockbillno = hisSpills.getTackStockBillNo();
if (StringUtils.isEmpty(medCode) || StringUtils.isEmpty(medName)) {
logger.error("盘点损溢信息医疗机构编码以及名称不能为空");
throw new BaseException("盘点损溢信息医疗机构编码以及名称不能为空");
}
if (StringUtils.isEmpty(supplierCode) || StringUtils.isEmpty(supplierName)) {
logger.error("盘点损溢信息供应商编码以及名称不能为空");
throw new BaseException("盘点损溢信息供应商编码以及名称不能为空");
}
if (StringUtils.isEmpty(stockbillno)) {
logger.error("盘点单号不能为空");
throw new BaseException("盘点单号不能为空");
}
Date tackStockDate = hisSpills.getTackStockDate();
if (tackStockDate == null) {
logger.error("盘点损溢信息报溢时间不能为空");
throw new BaseException("盘点损溢信息报溢时间不能为空");
}
String operaterName = hisSpills.getOperaterName();
if (StringUtils.isEmpty(operaterName)) {
logger.error("盘点损溢信息审核人不能为空");
throw new BaseException("盘点损溢信息审核人不能为空");
}
String goodsCode = hisSpills.getGoodsCode();
if (StringUtils.isEmpty(goodsCode)) {
logger.error("盘点损溢信息商品编码不能为空");
throw new BaseException("盘点损溢信息商品编码不能为空");
}
String lot = hisSpills.getLot();
if (StringUtils.isEmpty(lot)) {
logger.error("盘点损溢信息批号不能为空");
throw new BaseException("盘点损溢信息批号不能为空");
}
BigDecimal number = hisSpills.getNumber();
if (number == null) {
logger.error("盘点损溢信息库存数量不能为空");
throw new BaseException("盘点损溢信息库存数量不能为空");
}
BigDecimal storckNum = hisSpills.getStorckNum();
if (storckNum == null) {
logger.error("盘点损溢信息盘点数量不能为空");
throw new BaseException("盘点损溢信息盘点数量不能为空");
}
BigDecimal differenceNum = hisSpills.getDifferenceNum();
if (differenceNum == null) {
logger.error("盘点损溢信息损溢数量不能为空");
throw new BaseException("盘点损溢信息损溢数量不能为空");
}
}
}