LoseAndOverService.java
10 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package cn.csbr.app.service;
import cn.csbr.app.config.FxConfigure;
import cn.csbr.app.gui.GUIContext;
import cn.csbr.app.model.InboundItem;
import cn.csbr.springboot.dao.mapper.*;
import cn.csbr.springboot.dao.model.Mfcubestockcout;
import cn.csbr.springboot.dao.model.Mfcubestockdetail;
import tk.mybatis.mapper.entity.Example;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
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 org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.csbr.mybatis.CommonMapper;
import com.csbr.util.IdUtils;
/**
* 损益业务类
*/
@Service
public class LoseAndOverService {
private static Logger logger = LoggerFactory.getLogger(StockCountService.class);
@Autowired
private CommonMapper commonMapper;
@Autowired
private CabinetService cabinetService;
@Autowired
private GUIContext guiContext;
@Autowired
private SpdWvdetailMapper spdWvdetailMapper;
@Autowired
private FxConfigure fxConfigure;
@Autowired
private MfcubestockdetailMapper mfcubestockdetailMapper;
@Autowired
private MfcubestockstatementMapper mfcubestockstatementMapper;
@Autowired
private MfcubestockMapper mfcubestockMapper;
@Autowired
private MfcubestockcoutMapper mfcubestockcoutMapper;
@Autowired
private BaseService baseService;
public synchronized List<InboundItem> queryInboundItem(String inboundNo, String goodsInfo) {
List<String> dataTypes = new ArrayList();
dataTypes.add("2");
dataTypes.add("3");
String goodsInfol = null;
Example condition = new Example(Mfcubestockcout.class);
Example.Criteria cr = condition.createCriteria().andEqualTo("rkbillno", inboundNo);
cr.andEqualTo("processflag", "0");
cr.andIn("datatype", dataTypes);
if (!StringUtils.isEmpty(goodsInfo)) {
goodsInfol = "%" + goodsInfo + "%";
String sql = " GoodsName like '" + goodsInfol + "' or LabGuid like'" + goodsInfol + "'";
cr.andCondition("(" + sql + ")");
}
cr.andCondition(" CubeGuid in (select guid from cabinet where groupcode='" + fxConfigure.getCabinetGroupCode() + "')");
List<Mfcubestockcout> mfcubestockdetails = mfcubestockcoutMapper.selectByExample(condition);
List<InboundItem> inboundItems = new ArrayList();
//转换库存对象到vo
for (Mfcubestockcout data : mfcubestockdetails) {
InboundItem inboundItem = new InboundItem();
inboundItems.add(inboundItem);
inboundItem.setScanQty(data.getNumber().intValue());
inboundItem.setSrcOrderCode(data.getRkbillno());
inboundItem.setQty(data.getNumber().intValue());
inboundItem.setGoodsguid(data.getGoodsguid());
inboundItem.setGoodsname(data.getGoodsname());
inboundItem.setUnit(data.getUnit());
inboundItem.setIfScand((byte) 0);
inboundItem.setSupplierName(data.getSuppliername());
inboundItem.setSupplierGuid(data.getSupplierguid());
inboundItem.setBacthCode(data.getLot());
inboundItem.setTraceCode(data.getLabguid());
inboundItem.setBarcode(data.getLabguid());
inboundItem.setGuid(data.getGuid());
inboundItem.setAllocation(data.getCubename());
inboundItem.setAllocationGuid(data.getCubeguid());
inboundItem.setIfInCabinet((byte) 1);
inboundItem.setGuid(data.getGuid());
inboundItem.setIfScand((byte) 1);
inboundItem.setCheckType(data.getDatatype());
inboundItem.setGuid(data.getGuid());
inboundItem.setProductiondate(data.getProductiondate());
inboundItem.setExpiredate(data.getExpiredate());
}
return inboundItems;
}
@Transactional
public List<InboundItem> ActionqueryInboundItem(String cubeGuid, String rfidData) {
String goodsInfol = "";
// ActionBacknboundItem(cubeGuid,rfidData);
String sql = " select * from mfcubestockdetail where billstate!='O' AND CubeGuid in (select guid from cabinet where groupcode='" + fxConfigure.getCabinetGroupCode() + "') " +
" AND DepotGuid='" + guiContext.getLoginUser().getOrgGuid() + "' AND CubeName=" + "'" + cubeGuid + "' AND rfiduid NOT IN (" + rfidData + ")";
List<Map> maps = commonMapper.queryList(sql);
List<InboundItem> inboundItems = new ArrayList<>();
for (Map map : maps) {
InboundItem inboundItem = new InboundItem();
Mfcubestockdetail data = JSON.parseObject(JSON.toJSONString(map), Mfcubestockdetail.class);
inboundItem.setScanQty(Double.valueOf(data.getNumber()).intValue());
inboundItem.setSrcOrderCode(data.getRkBillNo());
inboundItem.setQty(Double.valueOf(data.getNumber()).intValue());
inboundItem.setGoodsguid(data.getGoodsGUID());
inboundItem.setGoodsname(data.getGoodsName());
inboundItem.setUnit(data.getUnit());
inboundItem.setIfScand((byte) 0);
inboundItem.setSupplierName(data.getSupplierName());
inboundItem.setSupplierGuid(data.getSupplierGUID());
inboundItem.setBacthCode(data.getLot());
inboundItem.setTraceCode(data.getLabGuid());
inboundItem.setBarcode(data.getLabGuid());
inboundItem.setGuid(data.getGuid());
inboundItem.setAllocation(data.getCubeName());
inboundItem.setAllocationGuid(data.getCubeGuid());
inboundItem.setIfInCabinet((byte) 1);
inboundItem.setIfScand((byte) 1);
inboundItem.setProductiondate(data.getProductiondate());
inboundItem.setExpiredate(data.getExpireDate());
inboundItem.setRfiduid(data.getRfidUid());
inboundItems.add(inboundItem);
}
return inboundItems;
}
public void saveBanlance(List<InboundItem> items) {
for (InboundItem item : items) {
Mfcubestockcout mfcubestockcout = mfcubestockcoutMapper.selectByPrimaryKey(item.getGuid());
Mfcubestockdetail detail = null;
String logType = "";
System.out.println("------------------------------------item checktype:" + item.getCheckType());
if (item.getCheckType().equals("2")) {
System.out.println("----------------------------22222222222--------item checktype:" + item.getCheckType());
Example condition = new Example(Mfcubestockdetail.class);
condition.createCriteria().andEqualTo("labguid", item.getBarcode());
List<Mfcubestockdetail> details = mfcubestockdetailMapper.selectByExample(condition);
if (details.size() > 0) {
detail = details.get(0);
mfcubestockdetailMapper.deleteByExample(condition);
} else {
detail = toMfCubstockdetail(mfcubestockcout);
}
logType = "5";
} else if (item.getCheckType().equals("3")) {
detail = toMfCubstockdetail(mfcubestockcout);
mfcubestockdetailMapper.insert(detail);
logType = "4";
} else {
continue;
}
baseService.writeLog(item, detail, logType);
// baseService.sumNumber(item, detail);
mfcubestockcout.setProcessflag("1");
mfcubestockcout.setProcessoperaterguid(guiContext.getLoginUser().getOrgGuid());
mfcubestockcout.setProcessoperatername(guiContext.getLoginUser().getRealName());
mfcubestockcout.setProcessTime(new Date());
mfcubestockcoutMapper.updateByPrimaryKey(mfcubestockcout);
}
}
private Mfcubestockdetail toMfCubstockdetail(Mfcubestockcout cubedetail) {
Mfcubestockdetail cubedetailout = new Mfcubestockdetail();
cubedetailout.setDepotGuid(cubedetail.getDepotguid());
cubedetailout.setDepotName(cubedetail.getDepotname());
cubedetailout.setCubeGuid(cubedetail.getCubeguid());
cubedetailout.setCubeName(cubedetail.getCubename());
cubedetailout.setLocGuid(cubedetail.getLocguid());
cubedetailout.setLocName(cubedetail.getLocname());
cubedetailout.setLabGuid(cubedetail.getLabguid());
cubedetailout.setGoodsGUID(cubedetail.getGoodsguid());
cubedetailout.setGoodsName(cubedetail.getGoodsname());
cubedetailout.setUnit(cubedetail.getUnit());
cubedetailout.setLot(cubedetail.getLot());
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String time = df.format(cubedetail.getProductiondate());
String time2 = df.format(cubedetail.getExpiredate());
String time3 = df.format(cubedetail.getSterilantdate());
String time4 = df.format(cubedetail.getSterilantexpdate());
cubedetailout.setProductiondate(Timestamp.valueOf(time));
cubedetailout.setExpireDate(Timestamp.valueOf(time2));
cubedetailout.setSterilantLot(cubedetail.getSterilantlot());
cubedetailout.setSterilantDate(Timestamp.valueOf(time3));
cubedetailout.setSterilantEXPDate(Timestamp.valueOf(time4));
cubedetailout.setNumber(cubedetail.getNumber().toString());
cubedetailout.setSupplierGUID(cubedetail.getSupplierguid());
cubedetailout.setSupplierName(cubedetail.getSuppliername());
cubedetailout.setRkBillNo(cubedetail.getRkbillno());
cubedetailout.setPriceBuy(cubedetail.getPricebuy().toString());
cubedetailout.setAmountBuy(cubedetail.getAmountbuy().toString());
cubedetailout.setCreateTime(new Timestamp(System.currentTimeMillis()));
cubedetailout.setUpdateTime(new Timestamp(System.currentTimeMillis()));
cubedetailout.setGuid(IdUtils.getUUID());
return cubedetailout;
}
}