BaseService.java
14.1 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
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.*;
import cn.hutool.core.date.DateTime;
import com.csbr.util.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
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.util.CollectionUtils;
import com.csbr.mybatis.CommonMapper;
import com.csbr.util.IdUtils;
/**
* 操作流水类
*/
@Service
public class BaseService {
private static final Logger log = LoggerFactory.getLogger(BaseService.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 MfcubestockPickstatementMapper mfcubestockPickstatementMapper;
@Autowired
private MfcubestockMapper mfcubestockMapper;
@Autowired
private SpdWvdetailScendMapper spdWvdetailScendMapper;
@Autowired
private HisGoodsMapper hisGoodsMapper;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private SysOrgMapper sysOrgMapper;
public synchronized int writeLog(InboundItem item, Mfcubestockdetail cubedetail, String type) {
Mfcubestockstatement mfcubestockstatement = new Mfcubestockstatement();
mfcubestockstatement.setGuid(IdUtils.getUUID());
mfcubestockstatement.setDepotguid(cubedetail.getDepotGuid());
mfcubestockstatement.setDepotname(cubedetail.getDepotName());
mfcubestockstatement.setCubeguid(item.getAllocationGuid());
mfcubestockstatement.setCubename(item.getAllocation());
mfcubestockstatement.setLocguid(item.getAllocationGuid());
mfcubestockstatement.setLocname(item.getAllocation());
mfcubestockstatement.setLabguid(cubedetail.getLabGuid());
mfcubestockstatement.setGoodsguid(cubedetail.getGoodsGUID());
mfcubestockstatement.setGoodsname(cubedetail.getGoodsName());
mfcubestockstatement.setUnit(cubedetail.getUnit());
mfcubestockstatement.setLot(cubedetail.getLot());
mfcubestockstatement.setProductiondate(cubedetail.getProductiondate());
mfcubestockstatement.setExpiredate(cubedetail.getExpireDate());
mfcubestockstatement.setCreateTime(new Date());
mfcubestockstatement.setUpdateTime(new Date());
mfcubestockstatement.setInputdate(new Date());
mfcubestockstatement.setOperaterguid(item.getOperaterId());
mfcubestockstatement.setOperatername(item.getOperaterName());
mfcubestockstatement.setType(type);
mfcubestockstatement.setSuppliername(cubedetail.getSupplierName());
mfcubestockstatement.setSupplierguid(cubedetail.getSupplierGUID());
mfcubestockstatement.setCubeDetailGuid(cubedetail.getCubeGuid());
mfcubestockstatement.setQty(BigDecimal.ONE);
mfcubestockstatement.setBillno(cubedetail.getRkBillNo());
mfcubestockstatement.setBarcode(cubedetail.getLabGuid());
mfcubestockstatement.setSts("N");
mfcubestockstatement.setBacksts("N");
SysUser sysUser=sysUserMapper.selectByPrimaryKey(item.getOperaterId());
SysOrg sysOrg=sysOrgMapper.selectByPrimaryKey(sysUser.getOrgguid());
mfcubestockstatement.setOperaterdeptguid(sysOrg.getGuid());
mfcubestockstatement.setOperaterdeptguid(sysOrg.getOrgname());
//暂定设置 退货的时候 加上供应商区分 ,使用varchar4字段
Example example = new Example(HisGoods.class);
example.createCriteria().andEqualTo("guid", cubedetail.getGoodsGUID());
List<HisGoods> hisGoodsList = hisGoodsMapper.selectByExample(example);
HisGoods hisGoods = hisGoodsMapper.selectByPrimaryKey(cubedetail.getGoodsGUID());
// Goodscode
mfcubestockstatement.setGoodscode(hisGoods.getGoodscode());
// Goodsspec
mfcubestockstatement.setGoodsspec(hisGoods.getGoodsspec());
// Manufacturer
mfcubestockstatement.setManufacturer(hisGoods.getProducer());
// Registkey
mfcubestockstatement.setRegistkey(hisGoods.getRegistkey());
mfcubestockstatement.setStoreguid(guiContext.getStoreguid());
mfcubestockstatement.setRfiduid(item.getRfiduid());
int insertCount = mfcubestockstatementMapper.insert(mfcubestockstatement);
//增加取货表
if(type.equals("2"))
{
MfcubestockPickstatement mfcubestockPickstatement=new MfcubestockPickstatement();
BeanUtils.copyProperties(mfcubestockstatement,mfcubestockPickstatement);
insertCount = mfcubestockPickstatementMapper.insert(mfcubestockPickstatement);
}
//跟新取货记录为已还货
else if(type.equals("6")) {
Example usestatementcondition = new Example(MfcubestockPickstatement.class);
//操作的这个表数据为空,不知道有没有用到,暂时也修改一下
//usestatementcondition.createCriteria().andEqualTo("barcode",cubedetail.getLabguid()).andEqualTo("type", "2").andEqualTo("backsts", "N");
usestatementcondition.createCriteria().andEqualTo("rfiduid",cubedetail.getRfidUid()).andEqualTo("type", "2").andEqualTo("backsts", "N");
List<MfcubestockPickstatement> usemfcubestockPickstatementList = mfcubestockPickstatementMapper.selectByExample(usestatementcondition);
for (MfcubestockPickstatement mfcubestockPickstatementone : usemfcubestockPickstatementList) {
mfcubestockPickstatementone.setBacksts("Y");
mfcubestockPickstatementone.setBacktime(new DateTime());
mfcubestockPickstatementone.setBackusername(item.getOperaterName());
mfcubestockPickstatementMapper.updateByPrimaryKey(mfcubestockPickstatementone);
Mfcubestockstatement mfcubestockstatement1=new Mfcubestockstatement();
BeanUtils.copyProperties(mfcubestockPickstatementone,mfcubestockstatement1);
mfcubestockstatementMapper.updateByPrimaryKey(mfcubestockstatement1);
}
}
return insertCount;
}
public int sumNumber(InboundItem item, Mfcubestockdetail cubedetail) {
Example condition = new Example(Mfcubestock.class);
condition.createCriteria().andEqualTo("depotguid", guiContext.getLoginUser().getOrgGuid()).andEqualTo("cubeguid", cubedetail.getCubeGuid())
.andEqualTo("goodsguid", cubedetail.getGoodsGUID()).andEqualTo("lot", cubedetail.getLot()).andEqualTo("expiredate", cubedetail.getExpireDate());
// .andEqualTo("sterilantdate",cubedetail.getSterilantdate()).andEqualTo("sterilantexpdate",cubedetail.getSterilantexpdate())
// .andEqualTo("sterilantlot",cubedetail.getSterilantlot());
//这里在汇总更新
Example dataQ = new Example(Mfcubestockdetail.class);
dataQ.createCriteria().andEqualTo("depotGuid", guiContext.getLoginUser().getOrgGuid()).andEqualTo("cubeGuid", item.getAllocationGuid())
.andEqualTo("goodsGUID", item.getGoodsguid()).andEqualTo("lot", cubedetail.getLot()).andEqualTo("expireDate", cubedetail.getExpireDate());
List<Mfcubestockdetail> details = mfcubestockdetailMapper.selectByExample(dataQ);
BigDecimal number = new BigDecimal(0);
for (Mfcubestockdetail mfcubestockdetail : details) {
number = number.add(new BigDecimal(mfcubestockdetail.getNumber()));
}
List<Mfcubestock> mfcubestocks = mfcubestockMapper.selectByExample(condition);
int updateCount = 0;
if (mfcubestocks.size() > 0) {
mfcubestocks.get(0).setStocknumber(number);
updateCount = mfcubestockMapper.updateByPrimaryKey(mfcubestocks.get(0));
}
return updateCount;
}
public void writeLog(InboundItem item, SpdWvdetail wvdetail, String type) {
Mfcubestockstatement mfcubestockstatement = new Mfcubestockstatement();
mfcubestockstatement.setGuid(IdUtils.getUUID());
mfcubestockstatement.setStoreguid(guiContext.getStoreguid());
mfcubestockstatement.setDepotguid(wvdetail.getOrgguid());
mfcubestockstatement.setDepotname(wvdetail.getOrgname());
mfcubestockstatement.setCubeguid(item.getAllocationGuid());
mfcubestockstatement.setCubename(item.getAllocation());
mfcubestockstatement.setLocguid(item.getAllocationGuid());
mfcubestockstatement.setLocname(item.getAllocation());
mfcubestockstatement.setLabguid(item.getBarcode());
mfcubestockstatement.setGoodsguid(wvdetail.getGoodsguid());
mfcubestockstatement.setGoodsname(wvdetail.getGoodsname());
mfcubestockstatement.setUnit(wvdetail.getUnit());
mfcubestockstatement.setLot(wvdetail.getLot());
mfcubestockstatement.setSupplierguid(item.getSupplierGuid());
mfcubestockstatement.setSuppliername(item.getSupplierName());
mfcubestockstatement.setProductiondate(wvdetail.getProductiondate());
mfcubestockstatement.setExpiredate(wvdetail.getExpiredate());
mfcubestockstatement.setCreateTime(new Date());
mfcubestockstatement.setUpdateTime(new Date());
mfcubestockstatement.setInputdate(new Date());
mfcubestockstatement.setOperaterguid(item.getOperaterId());
mfcubestockstatement.setOperatername(item.getOperaterName());
mfcubestockstatement.setType(type);
mfcubestockstatement.setQty(wvdetail.getMvqty());
mfcubestockstatement.setBillno(item.getSrcOrderCode());
mfcubestockstatement.setBarcode(item.getBarcode());
// Goodscode
mfcubestockstatement.setGoodscode(item.getGoodscode());
// Goodsspec
mfcubestockstatement.setGoodsspec(item.getGoodsspec());
// Manufacturer
mfcubestockstatement.setManufacturer(item.getManufacturer());
// Registkey
mfcubestockstatement.setRegistkey(item.getRegistkey());
mfcubestockstatement.setRfiduid(item.getRfiduid());
mfcubestockstatement.setOperaterguid(item.getOperaterId());
mfcubestockstatement.setOperatername(item.getOperaterName());
SysUser sysUser=sysUserMapper.selectByPrimaryKey(item.getOperaterId());
SysOrg sysOrg=sysOrgMapper.selectByPrimaryKey(sysUser.getOrgguid());
mfcubestockstatement.setOperaterdeptguid(sysOrg.getGuid());
mfcubestockstatement.setOperaterdeptguid(sysOrg.getOrgname());
mfcubestockstatementMapper.insert(mfcubestockstatement);
}
public void sumNumber(SpdWvdetail wvdetail, Mfcubestockdetail cubedetail) {
Example condition = new Example(Mfcubestock.class);
condition.createCriteria().andEqualTo("depotguid", guiContext.getLoginUser().getOrgGuid()).andEqualTo("cubeguid", cubedetail.getCubeGuid()).andEqualTo("productiondate", cubedetail.getExpireDate())
.andEqualTo("goodsguid", cubedetail.getGoodsGUID()).andEqualTo("lot", cubedetail.getLot()).andEqualTo("expiredate", cubedetail.getExpireDate());
// .andEqualTo("sterilantdate",cubedetail.getSterilantdate()).andEqualTo("sterilantexpdate",cubedetail.getSterilantexpdate())
// .andEqualTo("sterilantlot",cubedetail.getSterilantlot());
int count = mfcubestockMapper.selectCountByExample(condition);
if (count == 0) {//这里预插入一条
Mfcubestock ms = new Mfcubestock();
ms.setGuid(IdUtils.getUUID());
ms.setDepotguid(guiContext.getLoginUser().getOrgGuid());
ms.setDepotname(guiContext.getLoginUser().getOrgName());
ms.setCubeguid(cubedetail.getCubeGuid());
ms.setCubename(cubedetail.getCubeName());
ms.setGoodsguid(wvdetail.getGoodsguid());
ms.setGoodsname(wvdetail.getGoodsname());
ms.setUnit(wvdetail.getUnit());
ms.setLot(wvdetail.getLot());
ms.setStocknumber(wvdetail.getMvqty());
ms.setProductiondate(wvdetail.getProductiondate());
ms.setExpiredate(wvdetail.getExpiredate());
// ms.setSterilantlot(wvdetail.getSterilantlot());
// ms.setSterilantdate(wvdetail.getSterilantdate());
// ms.setSterilantexpdate(wvdetail.getSterilantexpdate());
ms.setCreateTime(new Date());
ms.setUpdateTime(new Date());
mfcubestockMapper.insert(ms);
return;
}
//这里在汇总更新
Example dataQ = new Example(Mfcubestockdetail.class);
condition.createCriteria().andEqualTo("depotGuid", guiContext.getLoginUser().getOrgGuid()).andEqualTo("cubeGuid", cubedetail.getCubeGuid()).andEqualTo("productiondate", cubedetail.getExpireDate())
.andEqualTo("goodsGUID", cubedetail.getGoodsGUID()).andEqualTo("lot", cubedetail.getLot()).andEqualTo("expireDate", cubedetail.getExpireDate());
List<Mfcubestockdetail> details = mfcubestockdetailMapper.selectByExample(dataQ);
BigDecimal number = new BigDecimal(0);
// for (Mfcubestockdetail mfcubestockdetail : details) {
// number = number.add(mfcubestockdetail.getNumber());
// }
List<Mfcubestock> mfcubestocks = mfcubestockMapper.selectByExample(condition);
mfcubestocks.get(0).setUpdateTime(new Date());
mfcubestocks.get(0).setStocknumber(mfcubestocks.get(0).getStocknumber().add(new BigDecimal(cubedetail.getNumber())));
mfcubestockMapper.updateByPrimaryKey(mfcubestocks.get(0));
}
public List<Map> queryCabinetList(String orgid) {
String sql = "select * from cabinet where sysorgguid='" + orgid + "'";
List<Map> CabinetList = commonMapper.queryList(sql);
return CabinetList;
}
}