HisCtMedicineMaterialService.java
2.34 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
package com.phxl.modules.goods.service.hisCtMedicineMaterial;
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 org.springframework.transaction.annotation.Transactional;
import com.phxl.common.utils.BaseException;
import com.phxl.common.utils.IdUtil;
import com.phxl.modules.goods.dao.hisCtMedicineMaterial.HisCtMedicineMaterialDao;
import com.phxl.modules.goods.entity.hisCtMedicineMaterial.HisCtMedicineMaterial;
@Service
public class HisCtMedicineMaterialService{
@Autowired
private HisCtMedicineMaterialDao hisCtMedicineMaterialDao;
/**
* 日志对象
*/
protected Logger logger = LoggerFactory.getLogger(getClass());
/**
* 同步药品目录信息
*/
@Transactional
public String saveMedicine(HisCtMedicineMaterial materials) {
try {
checkMaterial(materials);
if(hisCtMedicineMaterialDao.get(materials)!=null){
hisCtMedicineMaterialDao.update(materials);
}else{
materials.setId(IdUtil.uuid());
hisCtMedicineMaterialDao.insert(materials);
}
} catch (Exception e) {
logger.error(e.getMessage());
throw new BaseException(e.getMessage());
}
return "1";
}
private void checkMaterial(HisCtMedicineMaterial materials) {
String medCode = materials.getMedCode();
String medName = materials.getMedName();
if (StringUtils.isEmpty(medCode) || StringUtils.isEmpty(medName)) {
logger.error("前置机:药品目录医疗机构编码以及医疗机构名称不能为空");
throw new BaseException("前置机:药品目录医疗机构编码以及医疗机构名称不能为空");
}
String goodsCode = materials.getGoodsCode();
String goodsName = materials.getGoodsName();
if (StringUtils.isEmpty(goodsCode) || StringUtils.isEmpty(goodsName)) {
logger.error("前置机:药品目录商品编码以及商品名称不能为空");
throw new BaseException("前置机:药品目录商品编码以及商品名称不能为空");
}
String goodsSpec = materials.getGoodsSpec();
if (StringUtils.isEmpty(goodsSpec)) {
logger.error("前置机:药品目录商品规格不能为空");
throw new BaseException("前置机:药品目录商品规格不能为空");
}
}
public String createRequest() {
return null;
}
}