|
@@ -212,6 +212,8 @@ func (c *StockManagerApiController) CreateWarehouse() {
|
212
|
212
|
|
213
|
213
|
manufacturer := int64(items["manufacturer"].(float64))
|
214
|
214
|
dealer := int64(items["dealer"].(float64))
|
|
215
|
+
|
|
216
|
+ license_number, _ := items["license_number"].(string)
|
215
|
217
|
warehouseInfo := &models.WarehousingInfo{
|
216
|
218
|
WarehousingOrder: warehousing.WarehousingOrder,
|
217
|
219
|
WarehousingId: warehousing.ID,
|
|
@@ -231,6 +233,7 @@ func (c *StockManagerApiController) CreateWarehouse() {
|
231
|
233
|
Manufacturer: manufacturer,
|
232
|
234
|
StockCount: warehousing_count,
|
233
|
235
|
Dealer: dealer,
|
|
236
|
+ LicenseNumber: license_number,
|
234
|
237
|
}
|
235
|
238
|
warehousingInfo = append(warehousingInfo, warehouseInfo)
|
236
|
239
|
|
|
@@ -429,9 +432,11 @@ func (c *StockManagerApiController) GetWarehouseList() {
|
429
|
432
|
goodids = append(goodids, item.ID)
|
430
|
433
|
//入库详情但里面查询
|
431
|
434
|
}
|
432
|
|
- info, _ := service.GetWarehoureOrderInfoByGoodId(goodids, startTime, endTime, adminUserInfo.CurrentOrgId)
|
433
|
|
- for _, it := range info {
|
434
|
|
- ids = append(ids, it.WarehousingId)
|
|
435
|
+ if len(goodids) > 0 {
|
|
436
|
+ info, _ := service.GetWarehoureOrderInfoByGoodId(goodids, startTime, endTime, adminUserInfo.CurrentOrgId)
|
|
437
|
+ for _, it := range info {
|
|
438
|
+ ids = append(ids, it.WarehousingId)
|
|
439
|
+ }
|
435
|
440
|
}
|
436
|
441
|
}
|
437
|
442
|
|
|
@@ -446,10 +451,8 @@ func (c *StockManagerApiController) GetWarehouseList() {
|
446
|
451
|
}
|
447
|
452
|
}
|
448
|
453
|
func (c *StockManagerApiController) GetWarehouseInfoList() {
|
449
|
|
- //id, _ := c.GetInt64("id", 0)
|
450
|
454
|
|
451
|
455
|
id := c.GetString("id")
|
452
|
|
-
|
453
|
456
|
idArray := strings.Split(id, ",")
|
454
|
457
|
warehousing, err := service.FindWarehousingByIdOne(idArray)
|
455
|
458
|
|
|
@@ -595,7 +598,7 @@ func (c *StockManagerApiController) EditWarehouse() {
|
595
|
598
|
|
596
|
599
|
manufacturer := int64(items["manufacturer"].(float64))
|
597
|
600
|
dealer := int64(items["dealer"].(float64))
|
598
|
|
-
|
|
601
|
+ license_number, _ := items["license_number"].(string)
|
599
|
602
|
if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
600
|
603
|
utils.ErrorLog("id")
|
601
|
604
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
@@ -623,6 +626,7 @@ func (c *StockManagerApiController) EditWarehouse() {
|
623
|
626
|
Manufacturer: manufacturer,
|
624
|
627
|
Dealer: dealer,
|
625
|
628
|
StockCount: warehousing_count,
|
|
629
|
+ LicenseNumber: license_number,
|
626
|
630
|
}
|
627
|
631
|
warehousingInfo = append(warehousingInfo, warehouseInfo)
|
628
|
632
|
|
|
@@ -647,6 +651,7 @@ func (c *StockManagerApiController) EditWarehouse() {
|
647
|
651
|
Manufacturer: manufacturer,
|
648
|
652
|
Dealer: dealer,
|
649
|
653
|
StockCount: warehousing_count,
|
|
654
|
+ LicenseNumber: license_number,
|
650
|
655
|
}
|
651
|
656
|
upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
|
652
|
657
|
}
|
|
@@ -1082,6 +1087,7 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1082
|
1087
|
operation_time := time.Now().Unix()
|
1083
|
1088
|
creater := adminUserInfo.AdminUser.Id
|
1084
|
1089
|
|
|
1090
|
+ _, errcode := service.FindStockOutByIsSys(adminUserInfo.CurrentOrgId, 0, operation_time)
|
1085
|
1091
|
warehouseOut := models.WarehouseOut{
|
1086
|
1092
|
WarehouseOutOrderNumber: warehousing_out_order,
|
1087
|
1093
|
OperationTime: operation_time,
|
|
@@ -1092,7 +1098,10 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1092
|
1098
|
WarehouseOutTime: warehousingOutDate.Unix(),
|
1093
|
1099
|
Type: types,
|
1094
|
1100
|
}
|
1095
|
|
- service.AddSigleWarehouseOut(&warehouseOut)
|
|
1101
|
+ if errcode == gorm.ErrRecordNotFound {
|
|
1102
|
+ service.AddSigleWarehouseOut(&warehouseOut)
|
|
1103
|
+ }
|
|
1104
|
+
|
1096
|
1105
|
dataBody := make(map[string]interface{}, 0)
|
1097
|
1106
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
1098
|
1107
|
if err != nil {
|
|
@@ -1145,8 +1154,35 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1145
|
1154
|
|
1146
|
1155
|
manufacturer := int64(items["manufacturer"].(float64))
|
1147
|
1156
|
|
|
1157
|
+ dealer := int64(items["dealer"].(float64))
|
1148
|
1158
|
number := items["number"].(string)
|
1149
|
|
- fmt.Println("number22222222222222", number)
|
|
1159
|
+
|
|
1160
|
+ expiry_date := items["expiry_date"].(string)
|
|
1161
|
+
|
|
1162
|
+ timeLayout := "2006-01-02"
|
|
1163
|
+ loc, _ := time.LoadLocation("Local")
|
|
1164
|
+ var expiryDate int64
|
|
1165
|
+ if len(expiry_date) > 0 {
|
|
1166
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
|
|
1167
|
+ if err != nil {
|
|
1168
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1169
|
+ return
|
|
1170
|
+ }
|
|
1171
|
+ expiryDate = theTime.Unix()
|
|
1172
|
+ }
|
|
1173
|
+
|
|
1174
|
+ product_date := items["product_date"].(string)
|
|
1175
|
+
|
|
1176
|
+ var productDate int64
|
|
1177
|
+ if len(product_date) > 0 {
|
|
1178
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
|
|
1179
|
+ if err != nil {
|
|
1180
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1181
|
+ return
|
|
1182
|
+ }
|
|
1183
|
+ productDate = theTime.Unix()
|
|
1184
|
+ }
|
|
1185
|
+
|
1150
|
1186
|
warehouseOutInfo := &models.WarehouseOutInfo{
|
1151
|
1187
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
1152
|
1188
|
WarehouseOutId: warehouseOut.ID,
|
|
@@ -1162,6 +1198,9 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1162
|
1198
|
Type: types,
|
1163
|
1199
|
Manufacturer: manufacturer,
|
1164
|
1200
|
Number: number,
|
|
1201
|
+ ExpiryDate: expiryDate,
|
|
1202
|
+ ProductDate: productDate,
|
|
1203
|
+ Dealer: dealer,
|
1165
|
1204
|
}
|
1166
|
1205
|
warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
|
1167
|
1206
|
|
|
@@ -1183,25 +1222,39 @@ func (c *StockManagerApiController) CreateWarehouseOut() {
|
1183
|
1222
|
}
|
1184
|
1223
|
}
|
1185
|
1224
|
|
1186
|
|
- //查询库存
|
|
1225
|
+ //出库逻辑
|
1187
|
1226
|
for _, item := range warehousingOutInfo {
|
1188
|
|
- parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count)
|
1189
|
|
- fmt.Println(parseDateErr)
|
1190
|
|
- }
|
|
1227
|
+ //查询库存
|
|
1228
|
+ warehouse, err := service.FindFirstWarehousingInfoByStockTwo(item.GoodId, item.GoodTypeId)
|
|
1229
|
+ fmt.Println("库存数量组吗", warehouse.Count)
|
|
1230
|
+ if err != nil {
|
|
1231
|
+ goodObj, _ := service.GetGoodInformationByGoodId(item.GoodId)
|
|
1232
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1233
|
+ "msg": "1",
|
|
1234
|
+ "good_name": goodObj.GoodName,
|
|
1235
|
+ "specification_name": goodObj.SpecificationName,
|
|
1236
|
+ })
|
|
1237
|
+ return
|
|
1238
|
+ } else {
|
|
1239
|
+ parseDateErr := service.ConsumablesDeliveryOne(adminUserInfo.CurrentOrgId, warehousingOutDate.Unix(), item, &warehouseOut, item.Count)
|
|
1240
|
+ fmt.Println(parseDateErr)
|
|
1241
|
+ if parseDateErr != nil {
|
|
1242
|
+ utils.ErrorLog(parseDateErr.Error())
|
|
1243
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
|
|
1244
|
+ return
|
|
1245
|
+ }
|
|
1246
|
+
|
|
1247
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1248
|
+ "msg": "2",
|
|
1249
|
+ "good_name": "",
|
|
1250
|
+ "specification_name": "",
|
|
1251
|
+ })
|
|
1252
|
+ }
|
1191
|
1253
|
|
1192
|
|
- errs := service.CreateWarehousingOutInfo(warehousingOutInfo)
|
1193
|
|
- info, _ := service.FindLastWarehousingOutInfo(warehouseOut.WarehouseOutOrderNumber)
|
1194
|
|
- if errs != nil {
|
1195
|
|
- utils.ErrorLog(errs.Error())
|
1196
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
|
1197
|
|
- return
|
1198
|
1254
|
}
|
1199
|
1255
|
|
1200
|
|
- c.ServeSuccessJSON(map[string]interface{}{
|
1201
|
|
- "msg": "出库成功",
|
1202
|
|
- "info": info,
|
1203
|
|
- "warehousing_out_order": warehousing_out_order,
|
1204
|
|
- })
|
|
1256
|
+ //errs := service.CreateWarehousingOutInfo(warehousingOutInfo)
|
|
1257
|
+ //info, _ := service.FindLastWarehousingOutInfo(warehouseOut.WarehouseOutOrderNumber)
|
1205
|
1258
|
|
1206
|
1259
|
}
|
1207
|
1260
|
func (c *StockManagerApiController) GetWarehouseOutList() {
|
|
@@ -1235,7 +1288,25 @@ func (c *StockManagerApiController) GetWarehouseOutList() {
|
1235
|
1288
|
}
|
1236
|
1289
|
|
1237
|
1290
|
adminUserInfo := c.GetAdminUserInfo()
|
1238
|
|
- warehouseOutList, total, err := service.FindAllWarehouseOutList(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords)
|
|
1291
|
+ var ids []int64
|
|
1292
|
+ var goodids []int64
|
|
1293
|
+ if len(keywords) > 0 {
|
|
1294
|
+ //查询商品名称
|
|
1295
|
+ list, _ := service.GetGoodInforByGoodName(keywords, adminUserInfo.CurrentOrgId)
|
|
1296
|
+ for _, item := range list {
|
|
1297
|
+ goodids = append(goodids, item.ID)
|
|
1298
|
+ }
|
|
1299
|
+
|
|
1300
|
+ if len(goodids) > 0 {
|
|
1301
|
+ //出库详情但里面查询
|
|
1302
|
+ info, _ := service.GetWarehoureOrderOutByGoodId(goodids, startTime, endTime, adminUserInfo.CurrentOrgId)
|
|
1303
|
+ for _, it := range info {
|
|
1304
|
+ ids = append(ids, it.WarehouseOutId)
|
|
1305
|
+ }
|
|
1306
|
+ }
|
|
1307
|
+
|
|
1308
|
+ }
|
|
1309
|
+ warehouseOutList, total, err := service.FindAllWarehouseOutListOne(adminUserInfo.CurrentOrgId, page, limit, startTime, endTime, types, keywords, ids)
|
1239
|
1310
|
fmt.Println(err)
|
1240
|
1311
|
if err == nil {
|
1241
|
1312
|
c.ServeSuccessJSON(map[string]interface{}{
|
|
@@ -1386,7 +1457,35 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1386
|
1457
|
|
1387
|
1458
|
manufacturer := int64(items["manufacturer"].(float64))
|
1388
|
1459
|
|
|
1460
|
+ dealer := int64(items["dealer"].(float64))
|
|
1461
|
+
|
1389
|
1462
|
number := items["number"].(string)
|
|
1463
|
+
|
|
1464
|
+ timeLayout := "2006-01-02"
|
|
1465
|
+ loc, _ := time.LoadLocation("Local")
|
|
1466
|
+ expiry_date := items["expiry_date"].(string)
|
|
1467
|
+ var expiryDate int64
|
|
1468
|
+ if len(expiry_date) > 0 {
|
|
1469
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
|
|
1470
|
+ if err != nil {
|
|
1471
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1472
|
+ return
|
|
1473
|
+ }
|
|
1474
|
+ expiryDate = theTime.Unix()
|
|
1475
|
+ }
|
|
1476
|
+
|
|
1477
|
+ product_date := items["product_date"].(string)
|
|
1478
|
+
|
|
1479
|
+ var productDate int64
|
|
1480
|
+ if len(product_date) > 0 {
|
|
1481
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
|
|
1482
|
+ if err != nil {
|
|
1483
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1484
|
+ return
|
|
1485
|
+ }
|
|
1486
|
+ productDate = theTime.Unix()
|
|
1487
|
+ }
|
|
1488
|
+
|
1390
|
1489
|
if id == 0 {
|
1391
|
1490
|
warehouseOutInfo := &models.WarehouseOutInfo{
|
1392
|
1491
|
WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
|
|
@@ -1404,6 +1503,10 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1404
|
1503
|
IsSys: 0,
|
1405
|
1504
|
SysRecordTime: 0,
|
1406
|
1505
|
Number: number,
|
|
1506
|
+ ExpiryDate: expiryDate,
|
|
1507
|
+ ProductDate: productDate,
|
|
1508
|
+ Dealer: dealer,
|
|
1509
|
+ Manufacturer: manufacturer,
|
1407
|
1510
|
}
|
1408
|
1511
|
warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
|
1409
|
1512
|
|
|
@@ -1441,6 +1544,9 @@ func (c *StockManagerApiController) EditWarehouseOut() {
|
1441
|
1544
|
IsSys: is_sys,
|
1442
|
1545
|
SysRecordTime: sys_record_time,
|
1443
|
1546
|
Number: number,
|
|
1547
|
+ ExpiryDate: expiryDate,
|
|
1548
|
+ ProductDate: productDate,
|
|
1549
|
+ Dealer: dealer,
|
1444
|
1550
|
}
|
1445
|
1551
|
upDateWarehouseOutInfos = append(upDateWarehouseOutInfos, warehouseOutInfo)
|
1446
|
1552
|
}
|