InboundService.java
25.2 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
package cn.csbr.app.service;
import cn.csbr.app.config.FxConfigure;
import cn.csbr.app.gui.GUIContext;
import cn.csbr.app.model.Inbound;
import cn.csbr.app.model.InboundItem;
import cn.csbr.springboot.dao.mapper.*;
import cn.csbr.springboot.dao.model.*;
//import com.sun.tools.javac.util.Convert;
import com.csbr.util.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
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;
import com.github.pagehelper.Page;
/**
* 入库业务类
*/
@Service
public class InboundService {
private static Logger logger = LoggerFactory.getLogger(InboundService.class);
private static Logger log = LoggerFactory.getLogger(InboundService.class);
@Autowired
private CommonMapper commonMapper;
@Autowired
private CabinetService cabinetService;
@Autowired
private GUIContext guiContext;
@Autowired
private SpdWvdetailMapper spdWvdetailMapper;
@Autowired
private SpdWvdetailScendMapper spdWvdetailScendMapper;
@Autowired
private SpdWvMapper spdWvMapper;
//移库
@Autowired
private SpdWvLogMapper spdWvLogMapper;
@Autowired
private SpdWvdetailLogMapper spdWvdetailLogMapper;
@Autowired
private SpdWvdetailScendLogMapper spdWvdetailScendLogMapper;
@Autowired
private FxConfigure fxConfigure;
@Autowired
private MfcubestockdetailMapper mfcubestockdetailMapper;
@Autowired
private MfcubestockstatementMapper mfcubestockstatementMapper;
@Autowired
private MfcubestockMapper mfcubestockMapper;
@Autowired
private BaseService baseService;
//供应商标识
@Value("${PrimarySupplierName:gyls}")
private String primarySupplierName;
public List<Inbound> queryInbound() {
String sql = "select distinct BillNo from spd_wvdetail a where PrintState='Y'and "
+ "BarCode not in( select barcode from mfcubestockstatement b where b.BillNo=a.BillNo )"
+ " and BillNo in (select BillNo from spd_wv c where MedDeptGuid ='"
+ guiContext.getLoginUser().getOrgGuid() + "'and c.BillNo=a.BillNo) ";
List<Inbound> inbounds = new ArrayList();
List<Map> billNoes = commonMapper.queryList(sql);
for (Map billno : billNoes) {
Inbound inbound = new Inbound();
inbound.setSrcOrderCode(billno.get("BillNo").toString());
inbounds.add(inbound);
}
return inbounds;
}
/**
* SELECT BillNo,Manufacturer,MvDate FROM hcg.spd_wvdetail group by
* BillNo,Manufacturer,MvDate;
*
* @param condition
*
* @return
*/
public Page<Map> queryInboundPage(String condition) {
String sql = "SELECT a.BillNo,a.SupplierName,date_format(a.MvDate, '%Y-%m-%d') as MvDate FROM spd_wvdetail a INNER JOIN spd_wv C ON C.BILLNO=A.BillNo ";
sql += "WHERE c.BillState ='N' and c.MedDeptGuid='" + guiContext.getLoginUser().getOrgGuid() + "' ";
if (!StringUtils.isEmpty(condition)) {
sql += " and( a.BillNo like '%" + condition + "%' or a.Manufacturer like '%" + condition + "%')";
}
sql += " and a.guid NOT IN (SELECT b.rdguid FROM spd_wvdetail_scend b WHERE b.printstate = 'N' )";
sql += "group by a.BillNo,a.SupplierName, date_format(a.MvDate, '%Y-%m-%d') order by date_format(MvDate, '%Y-%m-%d') desc";
Page<Map> billNoes = (Page<Map>) commonMapper.queryList(sql);
return billNoes;
}
public synchronized List<InboundItem> queryInboundItem(String inboundNo, Map<Cabinet, List<String>> scanData, String goodsInfo) {
String sql = "SELECT A.GUID,A.BillNo,A.RowNo,A.GoodsGuid,A.GoodsCode,A.GoodsName,A.GoodsSpec,A.Unit,A.Price,A.RegistKey,A.Manufacturer,A.SupplierGUID,A.SupplierName,A.GoodsType,1 MVQty,A.PRICE * 1 Amount,A.Lot,A.ProductionDate,A.ExpireDate,A.SterilantLot,A.SterilantDate,A.SterilantEXPDate,A.Cargoposition,A.MvDate,A.Memo,A.OrgGUID,A.OrgName, b.rfiduid AS temprfiduid,b.barcode as barcode FROM Spd_wvdetail a inner JOIN spd_wvdetail_scend b ON A.BILLNO=B.BILLNO AND a.guid = b.rdguid and a.rowno =b.RowNo WHERE "
+ " a.billno = '" + inboundNo + "' and a.BillNo in (select billno from spd_wv c where c.MedDeptGuid='"
+ guiContext.getLoginUserVali().getOrgGuid()+ "' ) ";
if (!StringUtils.isEmpty(goodsInfo)) {
goodsInfo = "%" + goodsInfo + "%";
sql += " and (a.goodscode like '' or a.GoodsName like '' or b.BarCode like '')";
}
sql += " order by a.mvdate";
List<Map> maps = commonMapper.queryList(sql);
List<InboundItem> inboundItems = new ArrayList<>();
Set<Cabinet> cabinets = scanData.keySet();
for (Map map : maps) {
SpdWvdetail data = JSON.parseObject(JSON.toJSONString(map), SpdWvdetail.class);
InboundItem inboundItem = new InboundItem();
inboundItems.add(inboundItem);
inboundItem.setRowNo(data.getRowno());
inboundItem.setScanQty(data.getMvqty().intValue());
inboundItem.setSrcOrderCode(data.getBillno());
inboundItem.setQty(data.getAmount().intValue());
inboundItem.setGoodsguid(data.getGoodsguid());
inboundItem.setGoodscode(data.getGoodscode());
inboundItem.setGoodsname(data.getGoodsname());
inboundItem.setGoodsspec(data.getGoodsspec());
inboundItem.setUnit(data.getUnit());
inboundItem.setIfScand((byte) 0);
inboundItem.setSupplierName(data.getSuppliername());
inboundItem.setSupplierGuid(data.getSupplierguid());
inboundItem.setBacthCode(data.getLot());
inboundItem.setSrcInboundDate(data.getMvdate());
inboundItem.setTraceCode(data.getBarcode());
inboundItem.setBarcode(data.getBarcode());
inboundItem.setGuid(data.getGuid());
inboundItem.setRegistkey(data.getRegistkey());
inboundItem.setManufacturer(data.getManufacturer());
inboundItem.setProductiondate(data.getProductiondate());
inboundItem.setExpiredate(data.getExpiredate());
inboundItem.setRfiduid(data.getTemprfiduid());
log.info("------------------------ 扫描并核对入柜数据 ------------------------");
// log.info(JSON.toJSONString(cabinets));
log.info("=====" + inboundItem.getRfiduid());
for (Cabinet cabinet : cabinets) {
List<String> results = scanData.get(cabinet);
if (results.contains(inboundItem.getRfiduid())) {
inboundItem.setAllocation(cabinet.getCabinetcode());
inboundItem.setAllocationGuid(cabinet.getGuid());
inboundItem.setIfInCabinet((byte) 1);
inboundItem.setIfScand((byte) 1);
}
}
}
return inboundItems;
}
public synchronized List<InboundItem> ActionqueryInboundItem(String UserGuid,String UserName,String inboundNo, String cubeGuid, String rfidData) {
String sql = "SELECT A.GUID,A.BillNo,A.RowNo,A.GoodsGuid,A.GoodsCode,A.GoodsName,A.GoodsSpec,A.Unit,A.Price,A.RegistKey,A.Manufacturer,A.SupplierGUID,A.SupplierName,A.GoodsType,1 MVQty,A.PRICE * 1 Amount,A.Lot,A.ProductionDate,A.ExpireDate,A.SterilantLot,A.SterilantDate,A.SterilantEXPDate,A.Cargoposition,A.MvDate,A.Memo,A.OrgGUID,A.OrgName, b.rfiduid AS temprfiduid,b.barcode as barcode FROM Spd_wvdetail a inner JOIN spd_wvdetail_scend b ON a.billno=b.billno and a.guid = b.rdguid and a.rowno =b.RowNo WHERE "
+ " a.billno = '" + inboundNo + "' and a.BillNo in (select billno from spd_wv c where c.MedDeptGuid='"
+ guiContext.getLoginUser().getOrgGuid() + "' ) " + " AND rfiduid IN (" + rfidData + ")";
;
List<Map> maps = commonMapper.queryList(sql);
List<InboundItem> inboundItems = new ArrayList<>();
for (Map map : maps) {
SpdWvdetail data = JSON.parseObject(JSON.toJSONString(map), SpdWvdetail.class);
InboundItem inboundItem = new InboundItem();
inboundItem.setOperaterId(UserGuid);
inboundItem.setOperaterName(UserName);
inboundItems.add(inboundItem);
inboundItem.setRowNo(data.getRowno());
inboundItem.setScanQty(data.getMvqty().intValue());
inboundItem.setSrcOrderCode(data.getBillno());
inboundItem.setQty(data.getAmount().intValue());
inboundItem.setGoodsguid(data.getGoodsguid());
inboundItem.setGoodscode(data.getGoodscode());
inboundItem.setGoodsname(data.getGoodsname());
inboundItem.setGoodsspec(data.getGoodsspec());
inboundItem.setUnit(data.getUnit());
inboundItem.setIfScand((byte) 0);
inboundItem.setSupplierName(data.getSuppliername());
inboundItem.setSupplierGuid(data.getSupplierguid());
inboundItem.setBacthCode(data.getLot());
inboundItem.setSrcInboundDate(data.getMvdate());
inboundItem.setTraceCode(data.getBarcode());
inboundItem.setBarcode(data.getBarcode());
inboundItem.setGuid(data.getGuid());
inboundItem.setRegistkey(data.getRegistkey());
inboundItem.setManufacturer(data.getManufacturer());
inboundItem.setProductiondate(data.getProductiondate());
inboundItem.setExpiredate(data.getExpiredate());
inboundItem.setRfiduid(data.getTemprfiduid());
log.info("------------------------ 扫描并核对入柜数据 ------------------------");
// log.info(JSON.toJSONString(cabinets));
log.info("=====" + inboundItem.getRfiduid());
if (rfidData.contains(data.getTemprfiduid())) {
inboundItem.setIfInCabinet((byte) 1);
inboundItem.setIfScand((byte) 1);
for (Cabinet cabinet : guiContext.getCabinets()) {
if (cabinet.getCabinetcode().equals(cubeGuid)) {
inboundItem.setAllocation(cabinet.getCabinetcode());
inboundItem.setAllocationGuid(cabinet.getGuid());
break;
}
}
}
}
return inboundItems;
}
public List<InboundItem> queryRejectItem() {
Random r = new Random(100);
List<InboundItem> inboundItems = new ArrayList();
for (int i = 0; i <= 20; i++) {
InboundItem inboundItem = new InboundItem();
inboundItem.setSrcOrderCode("入库单00" + i);
inboundItem.setGoods(null);
inboundItem.setQty(i);
inboundItem.setScanQty(i);
inboundItem.setAllocation("002:" + i + ":" + Math.random() * 100);
if (i % 2 == 0) {
inboundItem.setIfInCabinet((byte) 1);
}
inboundItems.add(inboundItem);
}
return inboundItems;
}
/**
* 手工标记入库
*
* @param item
*/
public void markInbound(InboundItem item) {
log.debug("-----------------mark inbound");
}
@Transactional(rollbackFor = Exception.class)
public boolean saveInCabinetInfo(List<InboundItem> inboundItems) {
for (InboundItem item : inboundItems) {
if (item.getIfInCabinet() == null || item.getIfInCabinet() != 1) {
return false;
}
}
for (InboundItem item : inboundItems) {
if (item.getIfInCabinet() == null || item.getIfInCabinet() != 1) {
continue;
}
Example scondition = new Example(SpdWvdetail.class);
Example wvExample = new Example(SpdWv.class);
wvExample.createCriteria().andEqualTo("billno", inboundItems.get(0).getSrcOrderCode());
SpdWv wv = spdWvMapper.selectByExample(wvExample).get(0);
wv.setBillstate("Y");
spdWvMapper.updateByPrimaryKeySelective(wv);
scondition.createCriteria().andEqualTo("guid", item.getGuid()).andEqualTo("rowno", item.getRowNo());
//增加标识
// scondition.createCriteria().andEqualTo("guid", item.getGuid()).andEqualTo("rowno", item.getRowNo()).andEqualTo("memo", primarySupplierName);
List<SpdWvdetail> wvdetails = spdWvdetailMapper.selectByExample(scondition);
SpdWvdetail wvdetail = wvdetails.get(0);
Mfcubestockdetail cubedetail = new Mfcubestockdetail();
cubedetail.setGuid(IdUtils.getUUID());
cubedetail.setDepotGuid(guiContext.getLoginUser().getOrgGuid());
cubedetail.setDepotName(guiContext.getLoginUser().getOrgName());
cubedetail.setCubeGuid(item.getAllocationGuid());
cubedetail.setCubeName(item.getAllocation());
cubedetail.setLocGuid(item.getAllocationGuid());
cubedetail.setLocName(item.getAllocation());
cubedetail.setRfidUid(item.getRfiduid());
cubedetail.setLabGuid(item.getBarcode());
cubedetail.setGoodsGUID(wvdetail.getGoodsguid());
cubedetail.setGoodsName(wvdetail.getGoodsname());
cubedetail.setUnit(wvdetail.getUnit());
cubedetail.setLot(wvdetail.getLot());
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = df.format(wvdetail.getProductiondate());
String time1 = df.format(wvdetail.getExpiredate());
String time2=null;
String time3=null;
if(wvdetail.getSterilantdate()!=null){
time2 = df.format(wvdetail.getSterilantdate());
cubedetail.setSterilantDate(Timestamp.valueOf(time2));
}
if(wvdetail.getSterilantexpdate()!=null){
time3 = df.format(wvdetail.getSterilantexpdate());
cubedetail.setSterilantEXPDate(Timestamp.valueOf(time3));
}
cubedetail.setProductiondate(Timestamp.valueOf(time));
cubedetail.setExpireDate(Timestamp.valueOf(time1));
cubedetail.setSterilantLot(wvdetail.getSterilantlot());
cubedetail.setNumber(BigDecimal.ONE.toString());
cubedetail.setSupplierGUID(wvdetail.getSupplierguid());
cubedetail.setSupplierName(wvdetail.getSuppliername());
cubedetail.setRkBillNo(wvdetail.getBillno());
cubedetail.setPriceBuy(wvdetail.getPrice().toString());
cubedetail.setAmountBuy(wvdetail.getAmount().toString());
cubedetail.setCreateTime(new Timestamp(System.currentTimeMillis()));
cubedetail.setUpdateTime(new Timestamp(System.currentTimeMillis()));
cubedetail.setBillState("Y");
//增加标识
cubedetail.setVarchar1(primarySupplierName);
int count= mfcubestockdetailMapper.insert(cubedetail);
System.out.println("入库记录数量"+count);
baseService.writeLog(item, wvdetail, "1");
// 逻辑联合主键 是 科室id+耗材柜id+商品id+批号+有效期至
baseService.sumNumber(wvdetail, cubedetail);
}
return true;
}
//弹窗保存入库数据
@Transactional(rollbackFor = Exception.class)
public boolean saveInCabinetByPop(List<InboundItem> inboundItems) {
for (InboundItem item : inboundItems) {
if (item.getIfInCabinet() == null || item.getIfInCabinet() != 1) {
return false;
}
}
//创建当前入库订单号key和数量value的map
Map<String,Integer> billnoMap = new HashMap<>();
try{
for (InboundItem item : inboundItems) {
if (item.getIfInCabinet() == null || item.getIfInCabinet() != 1) {
continue;
}
//更新second表的状态为Y
Example secondExample = new Example(SpdWvdetailScend.class);
log.info("更新second表的状态为Y,rfiduid:"+item.getRfiduid());
//使用barcode查询spdWvdetailScend表改为根据rfid查询
//secondExample.createCriteria().andEqualTo("barcode",item.getBarcode());
secondExample.createCriteria().andEqualTo("rfiduid",item.getRfiduid());
List<SpdWvdetailScend> spdWvdetailScends = spdWvdetailScendMapper.selectByExample(secondExample);
SpdWvdetailScend spdWvdetailScend = spdWvdetailScends.get(0);
spdWvdetailScend.setBillstate("Y");
spdWvdetailScendMapper.updateByPrimaryKey(spdWvdetailScend);
Example scondition = new Example(SpdWvdetail.class);
scondition.createCriteria().andEqualTo("guid", item.getGuid()).andEqualTo("rowno", item.getRowNo());
List<SpdWvdetail> wvdetails = spdWvdetailMapper.selectByExample(scondition);
SpdWvdetail wvdetail = wvdetails.get(0);
Mfcubestockdetail cubedetail = new Mfcubestockdetail();
cubedetail.setGuid(IdUtils.getUUID());
cubedetail.setDepotGuid(wvdetail.getOrgguid());
cubedetail.setDepotName(wvdetail.getOrgname());
cubedetail.setCubeGuid(item.getAllocationGuid());
cubedetail.setCubeName(item.getAllocation());
cubedetail.setLocGuid(item.getAllocationGuid());
cubedetail.setLocName(item.getAllocation());
cubedetail.setRfidUid(item.getRfiduid());
cubedetail.setLabGuid(item.getBarcode());
cubedetail.setGoodsGUID(wvdetail.getGoodsguid());
cubedetail.setGoodsName(wvdetail.getGoodsname());
cubedetail.setUnit(wvdetail.getUnit());
cubedetail.setLot(wvdetail.getLot());
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = df.format(wvdetail.getProductiondate());
String time1 = df.format(wvdetail.getExpiredate());
String time2=null;
String time3=null;
if(wvdetail.getSterilantdate()!=null){
time2 = df.format(wvdetail.getSterilantdate());
cubedetail.setSterilantDate(Timestamp.valueOf(time2));
}
if(wvdetail.getSterilantexpdate()!=null){
time3 = df.format(wvdetail.getSterilantexpdate());
cubedetail.setSterilantEXPDate(Timestamp.valueOf(time3));
}
cubedetail.setProductiondate(Timestamp.valueOf(time));
cubedetail.setExpireDate(Timestamp.valueOf(time1));
cubedetail.setSterilantLot(wvdetail.getSterilantlot());
cubedetail.setNumber(BigDecimal.ONE.toString());
cubedetail.setSupplierGUID(wvdetail.getSupplierguid());
cubedetail.setSupplierName(wvdetail.getSuppliername());
cubedetail.setRkBillNo(wvdetail.getBillno());
cubedetail.setPriceBuy(wvdetail.getPrice().toString());
if(wvdetail.getAmount()!=null){
cubedetail.setAmountBuy(wvdetail.getAmount().toString());
}
cubedetail.setCreateTime(new Timestamp(System.currentTimeMillis()));
cubedetail.setUpdateTime(new Timestamp(System.currentTimeMillis()));
cubedetail.setBillState("Y");
cubedetail.setStoreguid(guiContext.getStoreguid());
cubedetail.setStorename(guiContext.getStorename());
//添加到库存表
int count = mfcubestockdetailMapper.insert(cubedetail);
System.out.println("添加库存状态"+count);
baseService.writeLog(item, wvdetail, "1");
// 逻辑联合主键 是 科室id+耗材柜id+商品id+批号+有效期至
// baseService.sumNumber(wvdetail, cubedetail);
Example secondUpExample = new Example(SpdWvdetailScend.class);
secondUpExample.createCriteria().andEqualTo("billno", wvdetail.getBillno()).andNotEqualTo("billstate","Y").andEqualTo("printstate","Y");
List<SpdWvdetailScend> spdupWvdetailScends = spdWvdetailScendMapper.selectByExample(secondUpExample);
// String sql = "SELECT * FROM SPD_WVDETAIL_SCEND WHERE "
// + " billno = '" + wvdetail.getBillno() + "' and BILLSTATE<>'Y' AND PRINTSTATE='Y'"; ;
// List<Map> maps = commonMapper.queryList(sql);
if(spdupWvdetailScends.size()==0)
{
Example wvExample = new Example(SpdWv.class);
wvExample.createCriteria().andEqualTo("billno", wvdetail.getBillno());
SpdWv wv = spdWvMapper.selectByExample(wvExample).get(0);
wv.setBillstate("Y");
spdWvMapper.updateByPrimaryKeySelective(wv);
//根据单号移入log库
log.info("该订单已全部入柜,开始移入log,billno:"+wvdetail.getBillno());
this.moveWvLog(wvdetail.getBillno());
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
log.info(ex.getMessage());
}
//若属于当前订单已全部入库,则更新wv表的状态
// Example secondExample = new Example(SpdWvdetailScend.class);
// Example wvExample = new Example(SpdWv.class);
//查询second表中此订单的详情信息
//遍历billnoMap取出key值
// for(String key:billnoMap.keySet()) {
// secondExample.createCriteria().andEqualTo("billno", key);
// List<SpdWvdetailScend> spdWvdetailScends = spdWvdetailScendMapper.selectByExample(secondExample);
// int incabinet = 0;
// //获取当前订单已入库数量
// for(SpdWvdetailScend spdWvdetailScend:spdWvdetailScends) {
// if(spdWvdetailScend.getBillstate().equals("Y")) {
// incabinet++;
// }
// }
// //若总数等于已入库加上当前存入数量,则更新wv表的状态
// if(spdWvdetailScends.size() == incabinet + billnoMap.get(key)) {
// wvExample.createCriteria().andEqualTo("billno", key);
// SpdWv wv = spdWvMapper.selectByExample(wvExample).get(0);
// wv.setBillstate("Y");
// spdWvMapper.updateByPrimaryKeySelective(wv);
// }
// }
return true;
}
public boolean moveWvLog(String billno) {
try {
Example example1 = new Example(SpdWv.class);
example1.createCriteria().andEqualTo("billno",billno);
List<SpdWv> spdWvs = spdWvMapper.selectByExample(example1);
SpdWv spdWv = spdWvs.get(0);
SpdWvLog spdWvLog = new SpdWvLog();
BeanUtils.copyProperties(spdWv,spdWvLog);
//spdWv 添加到log表,删除原表数据
spdWvLogMapper.insert(spdWvLog);
spdWvMapper.delete(spdWv);
//spdWvDetail表
Example example2 = new Example(SpdWvdetail.class);
example2.createCriteria().andEqualTo("billno",billno);
List<SpdWvdetail> spdWvdetails = spdWvdetailMapper.selectByExample(example2);
List<SpdWvdetailLog> spdWvdetailLogs = new ArrayList<>();
for (SpdWvdetail spdWvdetail : spdWvdetails) {
SpdWvdetailLog spdWvdetailLog = new SpdWvdetailLog();
BeanUtils.copyProperties(spdWvdetail,spdWvdetailLog);
spdWvdetailLogs.add(spdWvdetailLog);
//删除源
spdWvdetailMapper.delete(spdWvdetail);
}
if(spdWvdetailLogs.size()>0){
spdWvdetailLogMapper.insertList(spdWvdetailLogs);
}
//spdWvDetailScend表
Example example3 = new Example(SpdWvdetailScend.class);
example3.createCriteria().andEqualTo("billno",billno);
List<SpdWvdetailScend> spdWvdetailScends = spdWvdetailScendMapper.selectByExample(example3);
List<SpdWvdetailScendLog> spdWvdetailScendLogs = new ArrayList<>();
for (SpdWvdetailScend spdWvdetailScend : spdWvdetailScends) {
SpdWvdetailScendLog spdWvdetailScendLog = new SpdWvdetailScendLog();
BeanUtils.copyProperties(spdWvdetailScend,spdWvdetailScendLog);
spdWvdetailScendLogs.add(spdWvdetailScendLog);
//删除源
spdWvdetailScendMapper.delete(spdWvdetailScend);
}
if(spdWvdetailScendLogs.size()>0){
spdWvdetailScendLogMapper.insertList(spdWvdetailScendLogs);
}
log.info("写入WvLog成功,单号[ "+billno+" ]");
return true;
} catch (Exception e) {
log.error("写入WvLog失败"+e.toString());
return false;
}
}
}