|
@@ -12,16 +12,15 @@ import java.util.stream.Collectors; |
|
@@ -12,16 +12,15 @@ import java.util.stream.Collectors; |
|
12
|
import javax.servlet.http.HttpServletRequest;
|
12
|
import javax.servlet.http.HttpServletRequest;
|
|
13
|
import javax.servlet.http.HttpServletResponse;
|
13
|
import javax.servlet.http.HttpServletResponse;
|
|
14
|
|
14
|
|
|
|
|
15
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
15
|
import cn.hutool.core.util.NumberUtil;
|
16
|
import cn.hutool.core.util.NumberUtil;
|
|
16
|
import cn.hutool.core.util.StrUtil;
|
17
|
import cn.hutool.core.util.StrUtil;
|
|
17
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
18
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
18
|
import org.apache.commons.lang3.StringUtils;
|
19
|
import org.apache.commons.lang3.StringUtils;
|
|
19
|
import org.apache.poi.ss.usermodel.*;
|
20
|
import org.apache.poi.ss.usermodel.*;
|
|
20
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
21
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
21
|
-import org.jeecg.modules.erp.trade.entity.TblTradeBidMaterialDetails;
|
|
|
|
22
|
-import org.jeecg.modules.erp.trade.entity.TblTradeBidSub;
|
|
|
|
23
|
-import org.jeecg.modules.erp.trade.service.ITblTradeBidMaterialDetailsService;
|
|
|
|
24
|
-import org.jeecg.modules.erp.trade.service.ITblTradeBidSubService;
|
22
|
+import org.jeecg.modules.erp.trade.entity.*;
|
|
|
|
23
|
+import org.jeecg.modules.erp.trade.service.*;
|
|
25
|
import org.jeecg.modules.erp.trade.vo.TblTradeTenderInfoVO;
|
24
|
import org.jeecg.modules.erp.trade.vo.TblTradeTenderInfoVO;
|
|
26
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
25
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
27
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
26
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
@@ -33,11 +32,7 @@ import org.apache.shiro.SecurityUtils; |
|
@@ -33,11 +32,7 @@ import org.apache.shiro.SecurityUtils; |
|
33
|
import org.jeecg.common.api.vo.Result;
|
32
|
import org.jeecg.common.api.vo.Result;
|
|
34
|
import org.jeecg.common.system.query.QueryGenerator;
|
33
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
35
|
import org.jeecg.common.util.oConvertUtils;
|
34
|
import org.jeecg.common.util.oConvertUtils;
|
|
36
|
-import org.jeecg.modules.erp.trade.entity.TblTradeTenderInfo;
|
|
|
|
37
|
-import org.jeecg.modules.erp.trade.entity.TblTradePriceInquiry;
|
|
|
|
38
|
import org.jeecg.modules.erp.trade.vo.TblTradePriceInquiryPage;
|
35
|
import org.jeecg.modules.erp.trade.vo.TblTradePriceInquiryPage;
|
|
39
|
-import org.jeecg.modules.erp.trade.service.ITblTradePriceInquiryService;
|
|
|
|
40
|
-import org.jeecg.modules.erp.trade.service.ITblTradeTenderInfoService;
|
|
|
|
41
|
import org.springframework.beans.BeanUtils;
|
36
|
import org.springframework.beans.BeanUtils;
|
|
42
|
import org.springframework.beans.factory.annotation.Autowired;
|
37
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
43
|
import org.springframework.web.bind.annotation.*;
|
38
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -72,6 +67,8 @@ public class TblTradePriceInquiryController { |
|
@@ -72,6 +67,8 @@ public class TblTradePriceInquiryController { |
|
72
|
private ITblTradeBidSubService tblTradeBidSubService;
|
67
|
private ITblTradeBidSubService tblTradeBidSubService;
|
|
73
|
@Autowired
|
68
|
@Autowired
|
|
74
|
private ITblTradeBidMaterialDetailsService tblTradeBidMaterialDetailsService;
|
69
|
private ITblTradeBidMaterialDetailsService tblTradeBidMaterialDetailsService;
|
|
|
|
70
|
+ @Autowired
|
|
|
|
71
|
+ private ITblTradeInventoryService tblTradeInventoryService;
|
|
75
|
|
72
|
|
|
76
|
/**
|
73
|
/**
|
|
77
|
* 分页列表查询
|
74
|
* 分页列表查询
|
|
@@ -236,6 +233,38 @@ public class TblTradePriceInquiryController { |
|
@@ -236,6 +233,38 @@ public class TblTradePriceInquiryController { |
|
236
|
@GetMapping(value = "/queryTblTradeTenderInfoByMainId")
|
233
|
@GetMapping(value = "/queryTblTradeTenderInfoByMainId")
|
|
237
|
public Result<IPage<TblTradeTenderInfo>> queryTblTradeTenderInfoListByMainId(@RequestParam(name = "id", required = true) String id) {
|
234
|
public Result<IPage<TblTradeTenderInfo>> queryTblTradeTenderInfoListByMainId(@RequestParam(name = "id", required = true) String id) {
|
|
238
|
List<TblTradeTenderInfo> tblTradeTenderInfoList = tblTradeTenderInfoService.selectByMainId(id);
|
235
|
List<TblTradeTenderInfo> tblTradeTenderInfoList = tblTradeTenderInfoService.selectByMainId(id);
|
|
|
|
236
|
+ if (CollectionUtil.isEmpty(tblTradeTenderInfoList)) {
|
|
|
|
237
|
+ return Result.ok();
|
|
|
|
238
|
+ }
|
|
|
|
239
|
+ //查询库存信息
|
|
|
|
240
|
+ Map<String, TblTradeTenderInfo> collect = tblTradeTenderInfoList.stream().collect(Collectors.toMap(TblTradeTenderInfo::getCode, e -> e));
|
|
|
|
241
|
+ Set<String> strings = collect.keySet();
|
|
|
|
242
|
+ QueryWrapper<TblTradeInventory> tblTradeInventoryQueryWrapper = new QueryWrapper<>();
|
|
|
|
243
|
+ tblTradeInventoryQueryWrapper.in("material_code", strings);
|
|
|
|
244
|
+ List<TblTradeInventory> list = tblTradeInventoryService.list(tblTradeInventoryQueryWrapper);
|
|
|
|
245
|
+ Map<String, TblTradeInventory> inventoryMap = list.stream().collect(Collectors.toMap(TblTradeInventory::getMaterialCode, e -> e));
|
|
|
|
246
|
+
|
|
|
|
247
|
+
|
|
|
|
248
|
+
|
|
|
|
249
|
+
|
|
|
|
250
|
+ // 库存数据、在途库存、最近中标单价、最后一次中标时间
|
|
|
|
251
|
+ for (TblTradeTenderInfo tblTradeTenderInfo : tblTradeTenderInfoList) {
|
|
|
|
252
|
+ if (inventoryMap.containsKey(tblTradeTenderInfo.getCode())) {
|
|
|
|
253
|
+ tblTradeTenderInfo.setKcsj(inventoryMap.get(tblTradeTenderInfo.getCode()).getActualInventory() == null ? "0" : inventoryMap.get(tblTradeTenderInfo.getCode()).getActualInventory().toString());
|
|
|
|
254
|
+ tblTradeTenderInfo.setZtkc(inventoryMap.get(tblTradeTenderInfo.getCode()).getQuantityInTransit() == null ? "0" : inventoryMap.get(tblTradeTenderInfo.getCode()).getQuantityInTransit().toString());
|
|
|
|
255
|
+ }else {
|
|
|
|
256
|
+ tblTradeTenderInfo.setKcsj("0");
|
|
|
|
257
|
+ tblTradeTenderInfo.setZtkc("0");
|
|
|
|
258
|
+ }
|
|
|
|
259
|
+ //查询最近中标单价、最后一次中标时间
|
|
|
|
260
|
+ TblTradeBidSub tblTradeBidSub = tblTradeBidSubService.selectZjzbInfo(tblTradeTenderInfo.getCode());
|
|
|
|
261
|
+ if (tblTradeBidSub != null) {
|
|
|
|
262
|
+ tblTradeTenderInfo.setZjzbdj(tblTradeBidSub.getZbj() == null ? "" : tblTradeBidSub.getZbj().toString());
|
|
|
|
263
|
+ tblTradeTenderInfo.setZhzbsj(tblTradeBidSub.getBidDate() == null ? "" : tblTradeBidSub.getBidDate());
|
|
|
|
264
|
+ }
|
|
|
|
265
|
+
|
|
|
|
266
|
+ }
|
|
|
|
267
|
+
|
|
239
|
IPage<TblTradeTenderInfo> page = new Page<>();
|
268
|
IPage<TblTradeTenderInfo> page = new Page<>();
|
|
240
|
page.setRecords(tblTradeTenderInfoList);
|
269
|
page.setRecords(tblTradeTenderInfoList);
|
|
241
|
page.setTotal(tblTradeTenderInfoList.size());
|
270
|
page.setTotal(tblTradeTenderInfoList.size());
|
|
@@ -336,7 +365,7 @@ public class TblTradePriceInquiryController { |
|
@@ -336,7 +365,7 @@ public class TblTradePriceInquiryController { |
|
336
|
|
365
|
|
|
337
|
//标段(包)名称 物料编码
|
366
|
//标段(包)名称 物料编码
|
|
338
|
//SRM编码 物料长描述 单位 品牌 数量 中标单价 税率(%) 总价(不含税,元) 需求单位 交货时间 合同编号 合同日期
|
367
|
//SRM编码 物料长描述 单位 品牌 数量 中标单价 税率(%) 总价(不含税,元) 需求单位 交货时间 合同编号 合同日期
|
|
339
|
-// ArrayList<TblTradeBidMaterialDetails> tblTradeBidMaterialDetails = new ArrayList<>();
|
368
|
+ ArrayList<TblTradeBidMaterialDetails> tblTradeBidMaterialDetails = new ArrayList<>();
|
|
340
|
for (int i = 10; i <= sheet.getLastRowNum(); i++) {
|
369
|
for (int i = 10; i <= sheet.getLastRowNum(); i++) {
|
|
341
|
Row row = sheet.getRow(i);
|
370
|
Row row = sheet.getRow(i);
|
|
342
|
if (row == null) continue;
|
371
|
if (row == null) continue;
|
|
@@ -398,14 +427,104 @@ public class TblTradePriceInquiryController { |
|
@@ -398,14 +427,104 @@ public class TblTradePriceInquiryController { |
|
398
|
// materialInfo.setBidNum(projectNumber);
|
427
|
// materialInfo.setBidNum(projectNumber);
|
|
399
|
// materialInfo.setBidDate(bidDate);
|
428
|
// materialInfo.setBidDate(bidDate);
|
|
400
|
// tblTradeBidMaterialDetails.add(materialInfo);
|
429
|
// tblTradeBidMaterialDetails.add(materialInfo);
|
|
401
|
-// tblTradeBidSubService.update(
|
|
|
|
402
|
-// Wrappers.lambdaUpdate(TblTradeBidSub.class)
|
|
|
|
403
|
-// .eq(TblTradeBidSub::getWlbm, materialCode)
|
|
|
|
404
|
-// .eq(TblTradeBidSub::getXjbswjh,projectNumber)
|
|
|
|
405
|
-// .set(TblTradeBidSub::getSfzb,"1")
|
|
|
|
406
|
-// );
|
430
|
+
|
|
|
|
431
|
+
|
|
|
|
432
|
+ TblTradeBidMaterialDetails materialInfo = new TblTradeBidMaterialDetails();
|
|
|
|
433
|
+ try {
|
|
|
|
434
|
+ // 设置标段(包)名称,处理可能的空单元格
|
|
|
|
435
|
+ materialInfo.setPackageName(cellTypeToString(row.getCell(1)));
|
|
|
|
436
|
+
|
|
|
|
437
|
+ // 设置物料编码
|
|
|
|
438
|
+ materialInfo.setMaterialCode(materialCode);
|
|
|
|
439
|
+
|
|
|
|
440
|
+ // 设置SRM编码,处理可能的空单元格
|
|
|
|
441
|
+ materialInfo.setSrmCode(cellTypeToString(row.getCell(3)));
|
|
|
|
442
|
+
|
|
|
|
443
|
+ // 设置物料长描述,处理可能的空单元格
|
|
|
|
444
|
+ materialInfo.setMaterialDescription(cellTypeToString(row.getCell(4)));
|
|
|
|
445
|
+
|
|
|
|
446
|
+ // 设置单位,处理可能的空单元格
|
|
|
|
447
|
+ materialInfo.setMeasurementUnit(cellTypeToString(row.getCell(5)));
|
|
|
|
448
|
+
|
|
|
|
449
|
+ // 设置品牌,处理可能的空单元格
|
|
|
|
450
|
+ materialInfo.setBrand(cellTypeToString(row.getCell(6)));
|
|
|
|
451
|
+
|
|
|
|
452
|
+ // 处理数量字段,增加异常处理
|
|
|
|
453
|
+ String value = StringUtils.defaultString(cellTypeToString(row.getCell(7)), "0"); // 默认值为0
|
|
|
|
454
|
+ try {
|
|
|
|
455
|
+ value = value.split("\\.")[0]; // 去除小数点及其后面的部分
|
|
|
|
456
|
+ int intValue = Integer.parseInt(value); // 解析为整数
|
|
|
|
457
|
+ materialInfo.setDemandQuantity(intValue); //数量
|
|
|
|
458
|
+ } catch (NumberFormatException e) {
|
|
|
|
459
|
+ materialInfo.setDemandQuantity(0); // 解析失败时设置为0
|
|
|
|
460
|
+ }
|
|
|
|
461
|
+
|
|
|
|
462
|
+ // 设置中标单价
|
|
|
|
463
|
+ materialInfo.setWinningBidPrice(zbjg);
|
|
|
|
464
|
+
|
|
|
|
465
|
+ // 设置是否中标
|
|
|
|
466
|
+ materialInfo.setIsBid(StringUtils.isBlank(cellTypeToString(row.getCell(8))) ? 2 : 1);
|
|
|
|
467
|
+
|
|
|
|
468
|
+ // 设置税率,处理可能的空单元格
|
|
|
|
469
|
+ materialInfo.setTaxRate(cellTypeToString(row.getCell(9)));
|
|
|
|
470
|
+
|
|
|
|
471
|
+ // 设置总价(不含税,元),增加异常处理
|
|
|
|
472
|
+ try {
|
|
|
|
473
|
+ String totalPriceStr = cellTypeToString(row.getCell(10));
|
|
|
|
474
|
+ materialInfo.setBidTotalPrice(StringUtils.isNotBlank(totalPriceStr) ? new BigDecimal(totalPriceStr) : BigDecimal.ZERO);
|
|
|
|
475
|
+ } catch (Exception e) {
|
|
|
|
476
|
+ materialInfo.setBidTotalPrice(BigDecimal.ZERO);
|
|
|
|
477
|
+ }
|
|
|
|
478
|
+
|
|
|
|
479
|
+ // 处理交货时间,增加空值检查
|
|
|
|
480
|
+ try {
|
|
|
|
481
|
+ Cell cell = row.getCell(12);
|
|
|
|
482
|
+ if (cell != null) {
|
|
|
|
483
|
+ Date dateCellValue = cell.getDateCellValue();
|
|
|
|
484
|
+ if (dateCellValue != null) {
|
|
|
|
485
|
+ SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
486
|
+ materialInfo.setRequiredDeliveryTime(fmt.format(dateCellValue));
|
|
|
|
487
|
+ }
|
|
|
|
488
|
+ }
|
|
|
|
489
|
+ } catch (Exception e) {
|
|
|
|
490
|
+ // 日期解析失败时不做处理,保持为null
|
|
|
|
491
|
+ }
|
|
|
|
492
|
+
|
|
|
|
493
|
+ // 设置需求单位,处理可能的空单元格
|
|
|
|
494
|
+ materialInfo.setDemandUnit(cellTypeToString(row.getCell(11)));
|
|
|
|
495
|
+
|
|
|
|
496
|
+ // 设置投标价格和差价
|
|
|
|
497
|
+ if (tblTradeBidSubInfo != null && tblTradeBidSubInfo.getTbjg() != null) {
|
|
|
|
498
|
+ try {
|
|
|
|
499
|
+ BigDecimal tbjg = new BigDecimal(tblTradeBidSubInfo.getTbjg());
|
|
|
|
500
|
+ materialInfo.setBidPrice(tbjg);
|
|
|
|
501
|
+ materialInfo.setDiffPrice(tbjg.subtract(zbjg));
|
|
|
|
502
|
+ } catch (Exception e) {
|
|
|
|
503
|
+ // 数字解析失败时不做处理
|
|
|
|
504
|
+ }
|
|
|
|
505
|
+ }
|
|
|
|
506
|
+
|
|
|
|
507
|
+ // 设置投标编号和日期
|
|
|
|
508
|
+ materialInfo.setBidNum(projectNumber);
|
|
|
|
509
|
+ materialInfo.setBidDate(bidDate);
|
|
|
|
510
|
+
|
|
|
|
511
|
+ tblTradeBidMaterialDetails.add(materialInfo);
|
|
|
|
512
|
+ } catch (Exception e) {
|
|
|
|
513
|
+ // 记录日志或处理异常
|
|
|
|
514
|
+ log.error("处理物料信息时发生错误", e);
|
|
|
|
515
|
+ // 可以根据需要决定是否添加部分处理成功的数据
|
|
|
|
516
|
+ }
|
|
|
|
517
|
+
|
|
|
|
518
|
+
|
|
|
|
519
|
+
|
|
|
|
520
|
+ tblTradeBidSubService.update(
|
|
|
|
521
|
+ Wrappers.lambdaUpdate(TblTradeBidSub.class)
|
|
|
|
522
|
+ .eq(TblTradeBidSub::getWlbm, materialCode)
|
|
|
|
523
|
+ .eq(TblTradeBidSub::getXjbswjh,projectNumber)
|
|
|
|
524
|
+ .set(TblTradeBidSub::getSfzb,"1")
|
|
|
|
525
|
+ );
|
|
407
|
}
|
526
|
}
|
|
408
|
-// tblTradeBidMaterialDetailsService.saveBatch(tblTradeBidMaterialDetails);
|
527
|
+ tblTradeBidMaterialDetailsService.saveBatch(tblTradeBidMaterialDetails);
|
|
409
|
|
528
|
|
|
410
|
} catch (Exception e) {
|
529
|
} catch (Exception e) {
|
|
411
|
log.error(e.getMessage(), e);
|
530
|
log.error(e.getMessage(), e);
|