ConsumMfcubestService.java
3.88 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
package cn.csbr.app.service;
import cn.csbr.app.exception.ApiException;
import cn.csbr.springboot.dao.mapper.MfcubestockdetailMapper;
import cn.csbr.springboot.dao.mapper.MfcubestockdetailOldMapper;
import cn.csbr.springboot.dao.mapper.TrchargingMapper;
import cn.csbr.springboot.dao.mapper.TrchargingdetailMapper;
import cn.csbr.springboot.dao.model.Mfcubestockdetail;
import cn.csbr.springboot.dao.model.MfcubestockdetailOld;
import cn.csbr.springboot.dao.model.Trcharging;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
@Service
@Log4j2
public class ConsumMfcubestService {
@Autowired
private TrchargingMapper trchargingMapper;
@Autowired
private TrchargingdetailMapper trchargingdetailMapper;
@Autowired
private MfcubestockdetailMapper mfcubestockdetailMapper;
@Autowired
private MfcubestockdetailOldMapper mfcubestockdetailOldMapper;
public String show(Map map){
System.out.println(map.get("barcode"));
return "aaa";
}
//反消耗
@Transactional(rollbackFor = {ApiException.class, Exception.class})
public String getConSum(Map map) throws Exception {
// if (map=) {
// throw new ApiException("消耗单传入数据为空");
// }
//
// log.info("===>拉取解析后的反消耗数据");
// List<ConsumMfcubest> conSum = ConsumXmlToList.getConSum(xml);
//for (int i = 0; i < conSum.size(); i++) {
//ConsumMfcubest mfcubest = conSum.get(i);
Trcharging trcharging = trchargingMapper.getTrcharging(map.get("operationNo").toString());//根据手术单号查询手术单是否存在
if (trcharging == null) {
log.info("没有该手术单" + map.get("operationNo").toString() + ",无法进行反消耗");
throw new ApiException("没有该手术单" + map.get("operationNo").toString() + ",无法进行反消耗");
}
//进行手术单删除
int count = trchargingdetailMapper.delTrchargingDetail(trcharging.getGuid());
if (count > 0) {
//删除手术单头表
trchargingMapper.delTrcharging(map.get("operationNo").toString());
log.info("手术单清除成功=>" + map.get("operationNo").toString());
}
//List<ConsumDetail> consumDetailList = mfcubest.getConsumDetailList();
// for (int j = 0; j < consumDetailList.size(); j++) {
// ConsumDetail consumDetail = consumDetailList.get(j);
MfcubestockdetailOld mfcubestockdetailOld = mfcubestockdetailOldMapper.searchDetailByBarcode(map.get("barcode").toString());
if (mfcubestockdetailOld == null) {
log.info("该耗材" + map.get("barcode").toString() + "没有消耗记录");
throw new ApiException("该耗材" + map.get("barcode").toString() + "没有消耗记录");
}
Mfcubestockdetail mfcubestockdetail = mfcubestockdetailMapper.searchDetailByBarcode(map.get("barcode").toString());
if (mfcubestockdetail != null) {
log.info("该耗材" + map.get("barcode").toString() + "还在柜中没有被消耗");
throw new ApiException("该耗材" + map.get("barcode").toString() + "还在柜中没有被消耗");
}
Mfcubestockdetail mfcubestockdetail1 = new Mfcubestockdetail();
BeanUtils.copyProperties(mfcubestockdetailOld, mfcubestockdetail1);
System.out.println(mfcubestockdetail1.toString());
int insert = mfcubestockdetailMapper.insert(mfcubestockdetail1);
if (insert > 0) {
//开始删除库存历史
mfcubestockdetailOldMapper.mfcubestockdetaildel(map.get("barcode").toString());
log.info("反消耗成功");
}
return "ok";
}
}