|
...
|
...
|
@@ -12,16 +12,15 @@ import java.util.stream.Collectors; |
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.jeecg.modules.erp.trade.entity.TblTradeBidMaterialDetails;
|
|
|
|
import org.jeecg.modules.erp.trade.entity.TblTradeBidSub;
|
|
|
|
import org.jeecg.modules.erp.trade.service.ITblTradeBidMaterialDetailsService;
|
|
|
|
import org.jeecg.modules.erp.trade.service.ITblTradeBidSubService;
|
|
|
|
import org.jeecg.modules.erp.trade.entity.*;
|
|
|
|
import org.jeecg.modules.erp.trade.service.*;
|
|
|
|
import org.jeecg.modules.erp.trade.vo.TblTradeTenderInfoVO;
|
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
...
|
...
|
@@ -33,11 +32,7 @@ import org.apache.shiro.SecurityUtils; |
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
|
import org.jeecg.modules.erp.trade.entity.TblTradeTenderInfo;
|
|
|
|
import org.jeecg.modules.erp.trade.entity.TblTradePriceInquiry;
|
|
|
|
import org.jeecg.modules.erp.trade.vo.TblTradePriceInquiryPage;
|
|
|
|
import org.jeecg.modules.erp.trade.service.ITblTradePriceInquiryService;
|
|
|
|
import org.jeecg.modules.erp.trade.service.ITblTradeTenderInfoService;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
...
|
...
|
@@ -72,6 +67,8 @@ public class TblTradePriceInquiryController { |
|
|
|
private ITblTradeBidSubService tblTradeBidSubService;
|
|
|
|
@Autowired
|
|
|
|
private ITblTradeBidMaterialDetailsService tblTradeBidMaterialDetailsService;
|
|
|
|
@Autowired
|
|
|
|
private ITblTradeInventoryService tblTradeInventoryService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页列表查询
|
|
...
|
...
|
@@ -236,6 +233,38 @@ public class TblTradePriceInquiryController { |
|
|
|
@GetMapping(value = "/queryTblTradeTenderInfoByMainId")
|
|
|
|
public Result<IPage<TblTradeTenderInfo>> queryTblTradeTenderInfoListByMainId(@RequestParam(name = "id", required = true) String id) {
|
|
|
|
List<TblTradeTenderInfo> tblTradeTenderInfoList = tblTradeTenderInfoService.selectByMainId(id);
|
|
|
|
if (CollectionUtil.isEmpty(tblTradeTenderInfoList)) {
|
|
|
|
return Result.ok();
|
|
|
|
}
|
|
|
|
//查询库存信息
|
|
|
|
Map<String, TblTradeTenderInfo> collect = tblTradeTenderInfoList.stream().collect(Collectors.toMap(TblTradeTenderInfo::getCode, e -> e));
|
|
|
|
Set<String> strings = collect.keySet();
|
|
|
|
QueryWrapper<TblTradeInventory> tblTradeInventoryQueryWrapper = new QueryWrapper<>();
|
|
|
|
tblTradeInventoryQueryWrapper.in("material_code", strings);
|
|
|
|
List<TblTradeInventory> list = tblTradeInventoryService.list(tblTradeInventoryQueryWrapper);
|
|
|
|
Map<String, TblTradeInventory> inventoryMap = list.stream().collect(Collectors.toMap(TblTradeInventory::getMaterialCode, e -> e));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 库存数据、在途库存、最近中标单价、最后一次中标时间
|
|
|
|
for (TblTradeTenderInfo tblTradeTenderInfo : tblTradeTenderInfoList) {
|
|
|
|
if (inventoryMap.containsKey(tblTradeTenderInfo.getCode())) {
|
|
|
|
tblTradeTenderInfo.setKcsj(inventoryMap.get(tblTradeTenderInfo.getCode()).getActualInventory() == null ? "0" : inventoryMap.get(tblTradeTenderInfo.getCode()).getActualInventory().toString());
|
|
|
|
tblTradeTenderInfo.setZtkc(inventoryMap.get(tblTradeTenderInfo.getCode()).getQuantityInTransit() == null ? "0" : inventoryMap.get(tblTradeTenderInfo.getCode()).getQuantityInTransit().toString());
|
|
|
|
}else {
|
|
|
|
tblTradeTenderInfo.setKcsj("0");
|
|
|
|
tblTradeTenderInfo.setZtkc("0");
|
|
|
|
}
|
|
|
|
//查询最近中标单价、最后一次中标时间
|
|
|
|
TblTradeBidSub tblTradeBidSub = tblTradeBidSubService.selectZjzbInfo(tblTradeTenderInfo.getCode());
|
|
|
|
if (tblTradeBidSub != null) {
|
|
|
|
tblTradeTenderInfo.setZjzbdj(tblTradeBidSub.getZbj() == null ? "" : tblTradeBidSub.getZbj().toString());
|
|
|
|
tblTradeTenderInfo.setZhzbsj(tblTradeBidSub.getBidDate() == null ? "" : tblTradeBidSub.getBidDate());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
IPage<TblTradeTenderInfo> page = new Page<>();
|
|
|
|
page.setRecords(tblTradeTenderInfoList);
|
|
|
|
page.setTotal(tblTradeTenderInfoList.size());
|
|
...
|
...
|
@@ -336,7 +365,7 @@ public class TblTradePriceInquiryController { |
|
|
|
|
|
|
|
//标段(包)名称 物料编码
|
|
|
|
//SRM编码 物料长描述 单位 品牌 数量 中标单价 税率(%) 总价(不含税,元) 需求单位 交货时间 合同编号 合同日期
|
|
|
|
// ArrayList<TblTradeBidMaterialDetails> tblTradeBidMaterialDetails = new ArrayList<>();
|
|
|
|
ArrayList<TblTradeBidMaterialDetails> tblTradeBidMaterialDetails = new ArrayList<>();
|
|
|
|
for (int i = 10; i <= sheet.getLastRowNum(); i++) {
|
|
|
|
Row row = sheet.getRow(i);
|
|
|
|
if (row == null) continue;
|
|
...
|
...
|
@@ -398,14 +427,104 @@ public class TblTradePriceInquiryController { |
|
|
|
// materialInfo.setBidNum(projectNumber);
|
|
|
|
// materialInfo.setBidDate(bidDate);
|
|
|
|
// tblTradeBidMaterialDetails.add(materialInfo);
|
|
|
|
// tblTradeBidSubService.update(
|
|
|
|
// Wrappers.lambdaUpdate(TblTradeBidSub.class)
|
|
|
|
// .eq(TblTradeBidSub::getWlbm, materialCode)
|
|
|
|
// .eq(TblTradeBidSub::getXjbswjh,projectNumber)
|
|
|
|
// .set(TblTradeBidSub::getSfzb,"1")
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
TblTradeBidMaterialDetails materialInfo = new TblTradeBidMaterialDetails();
|
|
|
|
try {
|
|
|
|
// 设置标段(包)名称,处理可能的空单元格
|
|
|
|
materialInfo.setPackageName(cellTypeToString(row.getCell(1)));
|
|
|
|
|
|
|
|
// 设置物料编码
|
|
|
|
materialInfo.setMaterialCode(materialCode);
|
|
|
|
|
|
|
|
// 设置SRM编码,处理可能的空单元格
|
|
|
|
materialInfo.setSrmCode(cellTypeToString(row.getCell(3)));
|
|
|
|
|
|
|
|
// 设置物料长描述,处理可能的空单元格
|
|
|
|
materialInfo.setMaterialDescription(cellTypeToString(row.getCell(4)));
|
|
|
|
|
|
|
|
// 设置单位,处理可能的空单元格
|
|
|
|
materialInfo.setMeasurementUnit(cellTypeToString(row.getCell(5)));
|
|
|
|
|
|
|
|
// 设置品牌,处理可能的空单元格
|
|
|
|
materialInfo.setBrand(cellTypeToString(row.getCell(6)));
|
|
|
|
|
|
|
|
// 处理数量字段,增加异常处理
|
|
|
|
String value = StringUtils.defaultString(cellTypeToString(row.getCell(7)), "0"); // 默认值为0
|
|
|
|
try {
|
|
|
|
value = value.split("\\.")[0]; // 去除小数点及其后面的部分
|
|
|
|
int intValue = Integer.parseInt(value); // 解析为整数
|
|
|
|
materialInfo.setDemandQuantity(intValue); //数量
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
materialInfo.setDemandQuantity(0); // 解析失败时设置为0
|
|
|
|
}
|
|
|
|
|
|
|
|
// 设置中标单价
|
|
|
|
materialInfo.setWinningBidPrice(zbjg);
|
|
|
|
|
|
|
|
// 设置是否中标
|
|
|
|
materialInfo.setIsBid(StringUtils.isBlank(cellTypeToString(row.getCell(8))) ? 2 : 1);
|
|
|
|
|
|
|
|
// 设置税率,处理可能的空单元格
|
|
|
|
materialInfo.setTaxRate(cellTypeToString(row.getCell(9)));
|
|
|
|
|
|
|
|
// 设置总价(不含税,元),增加异常处理
|
|
|
|
try {
|
|
|
|
String totalPriceStr = cellTypeToString(row.getCell(10));
|
|
|
|
materialInfo.setBidTotalPrice(StringUtils.isNotBlank(totalPriceStr) ? new BigDecimal(totalPriceStr) : BigDecimal.ZERO);
|
|
|
|
} catch (Exception e) {
|
|
|
|
materialInfo.setBidTotalPrice(BigDecimal.ZERO);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 处理交货时间,增加空值检查
|
|
|
|
try {
|
|
|
|
Cell cell = row.getCell(12);
|
|
|
|
if (cell != null) {
|
|
|
|
Date dateCellValue = cell.getDateCellValue();
|
|
|
|
if (dateCellValue != null) {
|
|
|
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
materialInfo.setRequiredDeliveryTime(fmt.format(dateCellValue));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
// 日期解析失败时不做处理,保持为null
|
|
|
|
}
|
|
|
|
|
|
|
|
// 设置需求单位,处理可能的空单元格
|
|
|
|
materialInfo.setDemandUnit(cellTypeToString(row.getCell(11)));
|
|
|
|
|
|
|
|
// 设置投标价格和差价
|
|
|
|
if (tblTradeBidSubInfo != null && tblTradeBidSubInfo.getTbjg() != null) {
|
|
|
|
try {
|
|
|
|
BigDecimal tbjg = new BigDecimal(tblTradeBidSubInfo.getTbjg());
|
|
|
|
materialInfo.setBidPrice(tbjg);
|
|
|
|
materialInfo.setDiffPrice(tbjg.subtract(zbjg));
|
|
|
|
} catch (Exception e) {
|
|
|
|
// 数字解析失败时不做处理
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 设置投标编号和日期
|
|
|
|
materialInfo.setBidNum(projectNumber);
|
|
|
|
materialInfo.setBidDate(bidDate);
|
|
|
|
|
|
|
|
tblTradeBidMaterialDetails.add(materialInfo);
|
|
|
|
} catch (Exception e) {
|
|
|
|
// 记录日志或处理异常
|
|
|
|
log.error("处理物料信息时发生错误", e);
|
|
|
|
// 可以根据需要决定是否添加部分处理成功的数据
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tblTradeBidSubService.update(
|
|
|
|
Wrappers.lambdaUpdate(TblTradeBidSub.class)
|
|
|
|
.eq(TblTradeBidSub::getWlbm, materialCode)
|
|
|
|
.eq(TblTradeBidSub::getXjbswjh,projectNumber)
|
|
|
|
.set(TblTradeBidSub::getSfzb,"1")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
// tblTradeBidMaterialDetailsService.saveBatch(tblTradeBidMaterialDetails);
|
|
|
|
tblTradeBidMaterialDetailsService.saveBatch(tblTradeBidMaterialDetails);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error(e.getMessage(), e);
|
...
|
...
|
|