cec59e663bedbf9bc29554d7bfa28de351f41e24.svn-base
6.5 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
package com.phxl.modules.goods.service.suoutstore;
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.utils.BaseException;
import com.phxl.common.utils.IdUtil;
import com.phxl.modules.goods.dao.suoutstore.SuOutStoreDao;
import com.phxl.modules.goods.dao.suoutstore.SuOutStoreDetailDao;
import com.phxl.modules.goods.entity.suoutstore.SuOutStore;
import com.phxl.modules.goods.entity.suoutstore.SuOutStoreDetail;
import com.phxl.modules.goods.entity.suoutstore.SuOutStoreWithDetail;
@Service
public class SuOutStoreService {
@Autowired
private SuOutStoreDao suOutStoreDao;
@Autowired
private SuOutStoreDetailDao suOutStoreDetailDao;
/**
* 日志对象
*/
protected Logger logger = LoggerFactory.getLogger(getClass());
public boolean batchSave(List<SuOutStoreWithDetail> suOutStoreWithDetailList) {
boolean result = true;
try {
checkSuOutStore(suOutStoreWithDetailList);
} catch (Exception e) {
throw new BaseException("前置机:"+e.getMessage());
}
for (SuOutStoreWithDetail suOutStore : suOutStoreWithDetailList) {
List<SuOutStoreDetail> details = suOutStore.getBill().getBilldetaillist();
String id = IdUtil.uuid();
SuOutStore su = suOutStore.getBill();
su.setId(id);
if(details != null && details.size() != 0){
for (SuOutStoreDetail suOutStoreDetail : details) {
suOutStoreDetail.setBillNo(suOutStore.getBill().getBillNo());
suOutStoreDetail.setId(id);
}
suOutStoreDao.insert(su);
suOutStoreDetailDao.batchInsert(details);
}
}
return result;
}
private void checkSuOutStore(List<SuOutStoreWithDetail> suOutStoreWithDetailsList) {
if(suOutStoreWithDetailsList == null || suOutStoreWithDetailsList.size() == 0){
logger.error("前置机:无相应供应商出库单据信息");
throw new BaseException("前置机:无相应供应商出库单据信息");
}
for (SuOutStoreWithDetail suOutStoreWithDetails : suOutStoreWithDetailsList) {
String billNo = suOutStoreWithDetails.getBill().getBillNo();
if (StringUtils.isEmpty(billNo)) {
logger.error("前置机:供应商出库单单据编号不能为空");
throw new BaseException("前置机:供应商出库单单据编号不能为空");
}
String medGuid = suOutStoreWithDetails.getBill().getMedGuid();
String medName = suOutStoreWithDetails.getBill().getMedName();
if (StringUtils.isEmpty(medGuid) || StringUtils.isEmpty(medName)) {
logger.error("前置机:供应商出库单单据编号:"+billNo+"医疗机构代码以及医疗机构名称不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+"医疗机构代码以及医疗机构名称不能为空");
}
List<SuOutStoreDetail> details = suOutStoreWithDetails.getBill().getBilldetaillist();
if(details == null || details.size() == 0){
logger.error("前置机:供应商出库单单据编号:"+billNo+"出库单单据明细不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+"出库单单据明细不能为空");
}
for (SuOutStoreDetail suOutStoreDetail : details) {
String detailBillNo = suOutStoreDetail.getBillNo();
if (StringUtils.isEmpty(detailBillNo)) {
logger.error("前置机:供应商出库单单据编号:"+billNo+"出库单单据明细单据编号不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+"出库单单据明细单据编号不能为空");
}
int rowNo = suOutStoreDetail.getRowNo();
if (rowNo == 0) {
logger.error("前置机:供应商出库单单据编号:"+billNo+"出库单单据明细行号不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+"出库单单据明细行号不能为空");
}
int medPlanRowNo = suOutStoreDetail.getMedPlanRowNo();
if (medPlanRowNo == 0) {
logger.error("前置机:供应商出库单单据编号:"+billNo+"出库单单据明细补货计划单据原行号不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+"出库单单据明细补货计划单据原行号不能为空");
}
String goodsGuid = suOutStoreDetail.getGoodsGuid();
String goodsName = suOutStoreDetail.getGoodsName();
if (StringUtils.isEmpty(goodsGuid) || StringUtils.isEmpty(goodsName)) {
logger.error("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细商品编码以及商品名称不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细商品编码以及商品名称不能为空");
}
String goodsSpec = suOutStoreDetail.getGoodsSpec();
if (StringUtils.isEmpty(goodsSpec)) {
logger.error("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细商品规格不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细商品规格不能为空");
}
String lot = suOutStoreDetail.getLot();
if (StringUtils.isEmpty(lot)) {
logger.error("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细批号不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细批号不能为空");
}
Date productionDate = suOutStoreDetail.getProductionDate();
Date expireDate = suOutStoreDetail.getExpireDate();
if (productionDate == null || expireDate == null) {
logger.error("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细生产日期以及有效期不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细生产日期以及有效期不能为空");
}
BigDecimal arrivalqty = suOutStoreDetail.getArrivalqty();
if (arrivalqty == null) {
logger.error("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细出库数不能为空");
throw new BaseException("前置机:供应商出库单单据编号:"+billNo+",行号:"+rowNo+"出库单单据明细出库数不能为空");
}
}
}
}
}