|
|
|
package org.jeecg.modules.erp.trade.controller;
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.net.URLDecoder;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
...
|
...
|
@@ -15,7 +14,12 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
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.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
...
|
...
|
@@ -47,305 +51,351 @@ import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Description: 询价表
|
|
|
|
* @Author: jeecg-boot
|
|
|
|
* @Date: 2025-02-12
|
|
|
|
* @Date: 2025-02-12
|
|
|
|
* @Version: V1.0
|
|
|
|
*/
|
|
|
|
@Api(tags="询价表")
|
|
|
|
@Api(tags = "询价表")
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/trade/tblTradePriceInquiry")
|
|
|
|
@Slf4j
|
|
|
|
public class TblTradePriceInquiryController {
|
|
|
|
@Autowired
|
|
|
|
private ITblTradePriceInquiryService tblTradePriceInquiryService;
|
|
|
|
@Autowired
|
|
|
|
private ITblTradeTenderInfoService tblTradeTenderInfoService;
|
|
|
|
@Autowired
|
|
|
|
private ITblTradeBidSubService tblTradeBidSubService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页列表查询
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiry
|
|
|
|
* @param pageNo
|
|
|
|
* @param pageSize
|
|
|
|
* @param req
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "询价表-分页列表查询")
|
|
|
|
@ApiOperation(value="询价表-分页列表查询", notes="询价表-分页列表查询")
|
|
|
|
@GetMapping(value = "/list")
|
|
|
|
public Result<IPage<TblTradePriceInquiry>> queryPageList(TblTradePriceInquiry tblTradePriceInquiry,
|
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
|
HttpServletRequest req) {
|
|
|
|
QueryWrapper<TblTradePriceInquiry> queryWrapper = QueryGenerator.initQueryWrapper(tblTradePriceInquiry, req.getParameterMap());
|
|
|
|
Page<TblTradePriceInquiry> page = new Page<TblTradePriceInquiry>(pageNo, pageSize);
|
|
|
|
IPage<TblTradePriceInquiry> pageList = tblTradePriceInquiryService.page(page, queryWrapper);
|
|
|
|
return Result.OK(pageList);
|
|
|
|
}
|
|
|
|
@Autowired
|
|
|
|
private ITblTradePriceInquiryService tblTradePriceInquiryService;
|
|
|
|
@Autowired
|
|
|
|
private ITblTradeTenderInfoService tblTradeTenderInfoService;
|
|
|
|
@Autowired
|
|
|
|
private ITblTradeBidSubService tblTradeBidSubService;
|
|
|
|
@Autowired
|
|
|
|
private ITblTradeBidMaterialDetailsService tblTradeBidMaterialDetailsService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页列表查询
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiry
|
|
|
|
* @param pageNo
|
|
|
|
* @param pageSize
|
|
|
|
* @param req
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "询价表-分页列表查询")
|
|
|
|
@ApiOperation(value = "询价表-分页列表查询", notes = "询价表-分页列表查询")
|
|
|
|
@GetMapping(value = "/list")
|
|
|
|
public Result<IPage<TblTradePriceInquiry>> queryPageList(TblTradePriceInquiry tblTradePriceInquiry,
|
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
|
HttpServletRequest req) {
|
|
|
|
QueryWrapper<TblTradePriceInquiry> queryWrapper = QueryGenerator.initQueryWrapper(tblTradePriceInquiry, req.getParameterMap());
|
|
|
|
Page<TblTradePriceInquiry> page = new Page<TblTradePriceInquiry>(pageNo, pageSize);
|
|
|
|
IPage<TblTradePriceInquiry> pageList = tblTradePriceInquiryService.page(page, queryWrapper);
|
|
|
|
return Result.OK(pageList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页列表查询
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiry
|
|
|
|
* @param pageNo
|
|
|
|
* @param pageSize
|
|
|
|
* @param req
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "询价表-分页列表查询")
|
|
|
|
@ApiOperation(value="投标-分页列表查询", notes="投标-分页列表查询")
|
|
|
|
@GetMapping(value = "/bidList")
|
|
|
|
public Result<IPage<TblTradePriceInquiry>> queryPageList1(TblTradePriceInquiry tblTradePriceInquiry,
|
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
|
HttpServletRequest req) {
|
|
|
|
QueryWrapper<TblTradePriceInquiry> queryWrapper = QueryGenerator.initQueryWrapper(tblTradePriceInquiry, req.getParameterMap());
|
|
|
|
Page<TblTradePriceInquiry> page = new Page<TblTradePriceInquiry>(pageNo, pageSize);
|
|
|
|
IPage<TblTradePriceInquiry> pageList = tblTradePriceInquiryService.page(page, queryWrapper);
|
|
|
|
return Result.OK(pageList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页列表查询
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiry
|
|
|
|
* @param pageNo
|
|
|
|
* @param pageSize
|
|
|
|
* @param req
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "询价表-分页列表查询")
|
|
|
|
@ApiOperation(value = "投标-分页列表查询", notes = "投标-分页列表查询")
|
|
|
|
@GetMapping(value = "/bidList")
|
|
|
|
public Result<IPage<TblTradePriceInquiry>> queryPageList1(TblTradePriceInquiry tblTradePriceInquiry,
|
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
|
HttpServletRequest req) {
|
|
|
|
QueryWrapper<TblTradePriceInquiry> queryWrapper = QueryGenerator.initQueryWrapper(tblTradePriceInquiry, req.getParameterMap());
|
|
|
|
Page<TblTradePriceInquiry> page = new Page<TblTradePriceInquiry>(pageNo, pageSize);
|
|
|
|
IPage<TblTradePriceInquiry> pageList = tblTradePriceInquiryService.page(page, queryWrapper);
|
|
|
|
return Result.OK(pageList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页列表查询
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiry
|
|
|
|
* @param pageNo
|
|
|
|
* @param pageSize
|
|
|
|
* @param req
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "询价表-分页列表查询")
|
|
|
|
@ApiOperation(value="中标列表查询", notes="中标列表查询")
|
|
|
|
@GetMapping(value = "/winBidList")
|
|
|
|
public Result<IPage<Map<String,Object>>> queryWinBidList(TblTradePriceInquiry tblTradePriceInquiry,
|
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
|
HttpServletRequest req) {
|
|
|
|
QueryWrapper<TblTradePriceInquiry> queryWrapper = QueryGenerator.initQueryWrapper(tblTradePriceInquiry, req.getParameterMap());
|
|
|
|
Page<TblTradePriceInquiry> page = new Page<TblTradePriceInquiry>(pageNo, pageSize);
|
|
|
|
IPage<TblTradePriceInquiry> pageList = tblTradePriceInquiryService.page(page, queryWrapper);
|
|
|
|
|
|
|
|
IPage<Map<String,Object>> res = new Page<>();
|
|
|
|
List<Map<String,Object>> list = new ArrayList<>();
|
|
|
|
res.setTotal(pageList.getTotal());
|
|
|
|
res.setSize(pageList.getSize());
|
|
|
|
res.setPages(pageList.getPages());
|
|
|
|
res.setCurrent(pageList.getCurrent());
|
|
|
|
res.setRecords(list);
|
|
|
|
/**
|
|
|
|
* 分页列表查询
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiry
|
|
|
|
* @param pageNo
|
|
|
|
* @param pageSize
|
|
|
|
* @param req
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "询价表-分页列表查询")
|
|
|
|
@ApiOperation(value = "中标列表查询", notes = "中标列表查询")
|
|
|
|
@GetMapping(value = "/winBidList")
|
|
|
|
public Result<IPage<Map<String, Object>>> queryWinBidList(TblTradeBidMaterialDetails tblTradeBidMaterialDetails,
|
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
|
HttpServletRequest req) {
|
|
|
|
|
|
|
|
Page<TblTradeBidMaterialDetails> page = new Page<>(pageNo, pageSize);
|
|
|
|
IPage<Map<String, Object>> pageList = tblTradeBidMaterialDetailsService.pageList(page, tblTradeBidMaterialDetails);
|
|
|
|
return Result.OK(pageList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 添加
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiryPage
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "询价表-添加")
|
|
|
|
@ApiOperation(value = "询价表-添加", notes = "询价表-添加")
|
|
|
|
@PostMapping(value = "/add")
|
|
|
|
public Result<String> add(@RequestBody TblTradePriceInquiryPage tblTradePriceInquiryPage) {
|
|
|
|
TblTradePriceInquiry tblTradePriceInquiry = new TblTradePriceInquiry();
|
|
|
|
BeanUtils.copyProperties(tblTradePriceInquiryPage, tblTradePriceInquiry);
|
|
|
|
tblTradePriceInquiryService.saveMain(tblTradePriceInquiry, tblTradePriceInquiryPage.getTblTradeTenderInfoList());
|
|
|
|
return Result.OK("添加成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
pageList.getRecords().forEach(e->{
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
|
map.put("xjbswjh",e.getXjbswjh());
|
|
|
|
/**
|
|
|
|
* 编辑
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiryPage
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "询价表-编辑")
|
|
|
|
@ApiOperation(value = "询价表-编辑", notes = "询价表-编辑")
|
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
|
|
|
public Result<String> edit(@RequestBody TblTradePriceInquiryPage tblTradePriceInquiryPage) {
|
|
|
|
TblTradePriceInquiry tblTradePriceInquiry = new TblTradePriceInquiry();
|
|
|
|
BeanUtils.copyProperties(tblTradePriceInquiryPage, tblTradePriceInquiry);
|
|
|
|
TblTradePriceInquiry tblTradePriceInquiryEntity = tblTradePriceInquiryService.getById(tblTradePriceInquiry.getId());
|
|
|
|
if (tblTradePriceInquiryEntity == null) {
|
|
|
|
return Result.error("未找到对应数据");
|
|
|
|
}
|
|
|
|
tblTradePriceInquiryService.updateMain(tblTradePriceInquiry, tblTradePriceInquiryPage.getTblTradeTenderInfoList());
|
|
|
|
return Result.OK("编辑成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
List<TblTradeBidSub> bidSubList = tblTradeBidSubService.list(new QueryWrapper<TblTradeBidSub>().eq("xjbswjh", e.getXjbswjh()));
|
|
|
|
/**
|
|
|
|
* 通过id删除
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "询价表-通过id删除")
|
|
|
|
@ApiOperation(value = "询价表-通过id删除", notes = "询价表-通过id删除")
|
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
|
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
|
|
|
tblTradePriceInquiryService.delMain(id);
|
|
|
|
return Result.OK("删除成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
map.put("ljbs",bidSubList.size());
|
|
|
|
// 投标笔数
|
|
|
|
long tbbs = bidSubList.stream().filter(i -> StrUtil.isNotBlank(i.getTbjg())).count();
|
|
|
|
map.put("tbbs",tbbs);
|
|
|
|
// 中标笔数
|
|
|
|
long zbbs = bidSubList.stream().filter(i -> StrUtil.equals("是", i.getSfzb())).count();
|
|
|
|
map.put("zbbs",zbbs);
|
|
|
|
// 中标比率
|
|
|
|
if (tbbs == 0){
|
|
|
|
map.put("zbl","0%");
|
|
|
|
}else {
|
|
|
|
double div = NumberUtil.div(zbbs, tbbs, 4);
|
|
|
|
map.put("zbl",NumberUtil.formatPercent(div,2));
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 批量删除
|
|
|
|
*
|
|
|
|
* @param ids
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "询价表-批量删除")
|
|
|
|
@ApiOperation(value = "询价表-批量删除", notes = "询价表-批量删除")
|
|
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
|
|
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
|
this.tblTradePriceInquiryService.delBatchMain(Arrays.asList(ids.split(",")));
|
|
|
|
return Result.OK("批量删除成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
list.add(map);
|
|
|
|
});
|
|
|
|
/**
|
|
|
|
* 通过id查询
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "询价表-通过id查询")
|
|
|
|
@ApiOperation(value = "询价表-通过id查询", notes = "询价表-通过id查询")
|
|
|
|
@GetMapping(value = "/queryById")
|
|
|
|
public Result<TblTradePriceInquiry> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
|
TblTradePriceInquiry tblTradePriceInquiry = tblTradePriceInquiryService.getById(id);
|
|
|
|
if (tblTradePriceInquiry == null) {
|
|
|
|
return Result.error("未找到对应数据");
|
|
|
|
}
|
|
|
|
return Result.OK(tblTradePriceInquiry);
|
|
|
|
|
|
|
|
return Result.OK(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 添加
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiryPage
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "询价表-添加")
|
|
|
|
@ApiOperation(value="询价表-添加", notes="询价表-添加")
|
|
|
|
@PostMapping(value = "/add")
|
|
|
|
public Result<String> add(@RequestBody TblTradePriceInquiryPage tblTradePriceInquiryPage) {
|
|
|
|
TblTradePriceInquiry tblTradePriceInquiry = new TblTradePriceInquiry();
|
|
|
|
BeanUtils.copyProperties(tblTradePriceInquiryPage, tblTradePriceInquiry);
|
|
|
|
tblTradePriceInquiryService.saveMain(tblTradePriceInquiry, tblTradePriceInquiryPage.getTblTradeTenderInfoList());
|
|
|
|
return Result.OK("添加成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 编辑
|
|
|
|
*
|
|
|
|
* @param tblTradePriceInquiryPage
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "询价表-编辑")
|
|
|
|
@ApiOperation(value="询价表-编辑", notes="询价表-编辑")
|
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
|
public Result<String> edit(@RequestBody TblTradePriceInquiryPage tblTradePriceInquiryPage) {
|
|
|
|
TblTradePriceInquiry tblTradePriceInquiry = new TblTradePriceInquiry();
|
|
|
|
BeanUtils.copyProperties(tblTradePriceInquiryPage, tblTradePriceInquiry);
|
|
|
|
TblTradePriceInquiry tblTradePriceInquiryEntity = tblTradePriceInquiryService.getById(tblTradePriceInquiry.getId());
|
|
|
|
if(tblTradePriceInquiryEntity==null) {
|
|
|
|
return Result.error("未找到对应数据");
|
|
|
|
}
|
|
|
|
tblTradePriceInquiryService.updateMain(tblTradePriceInquiry, tblTradePriceInquiryPage.getTblTradeTenderInfoList());
|
|
|
|
return Result.OK("编辑成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过id删除
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "询价表-通过id删除")
|
|
|
|
@ApiOperation(value="询价表-通过id删除", notes="询价表-通过id删除")
|
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
|
tblTradePriceInquiryService.delMain(id);
|
|
|
|
return Result.OK("删除成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 批量删除
|
|
|
|
*
|
|
|
|
* @param ids
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "询价表-批量删除")
|
|
|
|
@ApiOperation(value="询价表-批量删除", notes="询价表-批量删除")
|
|
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
|
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
|
this.tblTradePriceInquiryService.delBatchMain(Arrays.asList(ids.split(",")));
|
|
|
|
return Result.OK("批量删除成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过id查询
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "询价表-通过id查询")
|
|
|
|
@ApiOperation(value="询价表-通过id查询", notes="询价表-通过id查询")
|
|
|
|
@GetMapping(value = "/queryById")
|
|
|
|
public Result<TblTradePriceInquiry> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
|
TblTradePriceInquiry tblTradePriceInquiry = tblTradePriceInquiryService.getById(id);
|
|
|
|
if(tblTradePriceInquiry==null) {
|
|
|
|
return Result.error("未找到对应数据");
|
|
|
|
}
|
|
|
|
return Result.OK(tblTradePriceInquiry);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过id查询
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "贸易招标信息-通过主表ID查询")
|
|
|
|
@ApiOperation(value="贸易招标信息-通过主表ID查询", notes="贸易招标信息-通过主表ID查询")
|
|
|
|
@GetMapping(value = "/queryTblTradeTenderInfoByMainId")
|
|
|
|
public Result<IPage<TblTradeTenderInfo>> queryTblTradeTenderInfoListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
|
|
List<TblTradeTenderInfo> tblTradeTenderInfoList = tblTradeTenderInfoService.selectByMainId(id);
|
|
|
|
IPage <TblTradeTenderInfo> page = new Page<>();
|
|
|
|
page.setRecords(tblTradeTenderInfoList);
|
|
|
|
page.setTotal(tblTradeTenderInfoList.size());
|
|
|
|
return Result.OK(page);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 通过id查询
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "贸易招标信息-通过主表ID查询")
|
|
|
|
@ApiOperation(value = "贸易招标信息-通过主表ID查询", notes = "贸易招标信息-通过主表ID查询")
|
|
|
|
@GetMapping(value = "/queryTblTradeTenderInfoByMainId")
|
|
|
|
public Result<IPage<TblTradeTenderInfo>> queryTblTradeTenderInfoListByMainId(@RequestParam(name = "id", required = true) String id) {
|
|
|
|
List<TblTradeTenderInfo> tblTradeTenderInfoList = tblTradeTenderInfoService.selectByMainId(id);
|
|
|
|
IPage<TblTradeTenderInfo> page = new Page<>();
|
|
|
|
page.setRecords(tblTradeTenderInfoList);
|
|
|
|
page.setTotal(tblTradeTenderInfoList.size());
|
|
|
|
return Result.OK(page);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出excel
|
|
|
|
*
|
|
|
|
* @param request
|
|
|
|
* @param tblTradePriceInquiry
|
|
|
|
*/
|
|
|
|
* 导出excel
|
|
|
|
*
|
|
|
|
* @param request
|
|
|
|
* @param tblTradePriceInquiry
|
|
|
|
*/
|
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
|
public ModelAndView exportXls(HttpServletRequest request, TblTradePriceInquiry tblTradePriceInquiry) {
|
|
|
|
// Step.1 组装查询条件查询数据
|
|
|
|
QueryWrapper<TblTradePriceInquiry> queryWrapper = QueryGenerator.initQueryWrapper(tblTradePriceInquiry, request.getParameterMap());
|
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
// Step.1 组装查询条件查询数据
|
|
|
|
QueryWrapper<TblTradePriceInquiry> queryWrapper = QueryGenerator.initQueryWrapper(tblTradePriceInquiry, request.getParameterMap());
|
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
|
|
|
|
//配置选中数据查询条件
|
|
|
|
String selections = request.getParameter("selections");
|
|
|
|
if(oConvertUtils.isNotEmpty(selections)) {
|
|
|
|
List<String> selectionList = Arrays.asList(selections.split(","));
|
|
|
|
queryWrapper.in("id",selectionList);
|
|
|
|
}
|
|
|
|
//Step.2 获取导出数据
|
|
|
|
List<TblTradePriceInquiry> tblTradePriceInquiryList = tblTradePriceInquiryService.list(queryWrapper);
|
|
|
|
//配置选中数据查询条件
|
|
|
|
String selections = request.getParameter("selections");
|
|
|
|
if (oConvertUtils.isNotEmpty(selections)) {
|
|
|
|
List<String> selectionList = Arrays.asList(selections.split(","));
|
|
|
|
queryWrapper.in("id", selectionList);
|
|
|
|
}
|
|
|
|
//Step.2 获取导出数据
|
|
|
|
List<TblTradePriceInquiry> tblTradePriceInquiryList = tblTradePriceInquiryService.list(queryWrapper);
|
|
|
|
|
|
|
|
// Step.3 组装pageList
|
|
|
|
List<TblTradePriceInquiryPage> pageList = new ArrayList<TblTradePriceInquiryPage>();
|
|
|
|
for (TblTradePriceInquiry main : tblTradePriceInquiryList) {
|
|
|
|
TblTradePriceInquiryPage vo = new TblTradePriceInquiryPage();
|
|
|
|
BeanUtils.copyProperties(main, vo);
|
|
|
|
List<TblTradeTenderInfo> tblTradeTenderInfoList = tblTradeTenderInfoService.selectByMainId(main.getId());
|
|
|
|
vo.setTblTradeTenderInfoList(tblTradeTenderInfoList);
|
|
|
|
pageList.add(vo);
|
|
|
|
}
|
|
|
|
// Step.3 组装pageList
|
|
|
|
List<TblTradePriceInquiryPage> pageList = new ArrayList<TblTradePriceInquiryPage>();
|
|
|
|
for (TblTradePriceInquiry main : tblTradePriceInquiryList) {
|
|
|
|
TblTradePriceInquiryPage vo = new TblTradePriceInquiryPage();
|
|
|
|
BeanUtils.copyProperties(main, vo);
|
|
|
|
List<TblTradeTenderInfo> tblTradeTenderInfoList = tblTradeTenderInfoService.selectByMainId(main.getId());
|
|
|
|
vo.setTblTradeTenderInfoList(tblTradeTenderInfoList);
|
|
|
|
pageList.add(vo);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Step.4 AutoPoi 导出Excel
|
|
|
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
|
mv.addObject(NormalExcelConstants.FILE_NAME, "询价表列表");
|
|
|
|
mv.addObject(NormalExcelConstants.CLASS, TblTradePriceInquiryPage.class);
|
|
|
|
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("询价表数据", "导出人:"+sysUser.getRealname(), "询价表"));
|
|
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
|
return mv;
|
|
|
|
// Step.4 AutoPoi 导出Excel
|
|
|
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
|
mv.addObject(NormalExcelConstants.FILE_NAME, "询价表列表");
|
|
|
|
mv.addObject(NormalExcelConstants.CLASS, TblTradePriceInquiryPage.class);
|
|
|
|
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("询价表数据", "导出人:" + sysUser.getRealname(), "询价表"));
|
|
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
|
return mv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过excel导入数据
|
|
|
|
*
|
|
|
|
* @param request
|
|
|
|
* @param response
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
* 通过excel导入数据
|
|
|
|
*
|
|
|
|
* @param request
|
|
|
|
* @param response
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
|
System.out.println(fileMap);
|
|
|
|
// for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
|
// // 获取上传文件对象
|
|
|
|
// MultipartFile file = entity.getValue();
|
|
|
|
// ImportParams params = new ImportParams();
|
|
|
|
// params.setTitleRows(2);
|
|
|
|
// params.setHeadRows(1);
|
|
|
|
// params.setNeedSave(true);
|
|
|
|
// try {
|
|
|
|
// List<TblTradePriceInquiryPage> list = ExcelImportUtil.importExcel(file.getInputStream(), TblTradePriceInquiryPage.class, params);
|
|
|
|
// for (TblTradePriceInquiryPage page : list) {
|
|
|
|
// TblTradePriceInquiry po = new TblTradePriceInquiry();
|
|
|
|
// BeanUtils.copyProperties(page, po);
|
|
|
|
// tblTradePriceInquiryService.saveMain(po, page.getTblTradeTenderInfoList());
|
|
|
|
// }
|
|
|
|
// return Result.OK("文件导入成功!数据行数:" + list.size());
|
|
|
|
// } catch (Exception e) {
|
|
|
|
// log.error(e.getMessage(),e);
|
|
|
|
// return Result.error("文件导入失败:"+e.getMessage());
|
|
|
|
// } finally {
|
|
|
|
// try {
|
|
|
|
// file.getInputStream().close();
|
|
|
|
// } catch (IOException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return Result.OK("文件导入失败!");
|
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
|
Iterator<String> fileNames = multipartRequest.getFileNames();
|
|
|
|
while (fileNames.hasNext()) {
|
|
|
|
String fileName = fileNames.next();
|
|
|
|
MultipartFile file = multipartRequest.getFile(fileName);
|
|
|
|
if (file != null && !file.isEmpty()) {
|
|
|
|
try (InputStream inputStream = file.getInputStream()) {
|
|
|
|
// 使用 POI 读取 Excel 文件
|
|
|
|
Workbook workbook = new XSSFWorkbook(inputStream);
|
|
|
|
Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表
|
|
|
|
|
|
|
|
// 提取采购项目编号
|
|
|
|
String projectNumber = sheet.getRow(1).getCell(2).getStringCellValue();
|
|
|
|
String bidDate = sheet.getRow(2).getCell(6).getStringCellValue();
|
|
|
|
QueryWrapper<TblTradeBidSub> queryWrapper = new QueryWrapper<>();
|
|
|
|
queryWrapper.eq("xjbswjh", projectNumber);
|
|
|
|
List<TblTradeBidSub> tblTradeBidSubs = tblTradeBidSubService.list(queryWrapper);
|
|
|
|
Map<String, TblTradeBidSub> subMap = tblTradeBidSubs
|
|
|
|
.stream()
|
|
|
|
.collect(Collectors.toMap(TblTradeBidSub::getWlbm, e -> e,(oldvalue, newvalue) -> newvalue));
|
|
|
|
|
|
|
|
//标段(包)名称 物料编码
|
|
|
|
//SRM编码 物料长描述 单位 品牌 数量 中标单价 税率(%) 总价(不含税,元) 需求单位 交货时间 合同编号 合同日期
|
|
|
|
ArrayList<TblTradeBidMaterialDetails> tblTradeBidMaterialDetails = new ArrayList<>();
|
|
|
|
for (int i = 10; i < sheet.getLastRowNum(); i++) {
|
|
|
|
Row row = sheet.getRow(i);
|
|
|
|
if (row == null) continue;
|
|
|
|
//物料编码
|
|
|
|
String materialCode = cellTypeToString(row.getCell(2));
|
|
|
|
materialCode = materialCode.split("\\.")[0];
|
|
|
|
TblTradeBidSub tblTradeBidSubInfo = subMap.get(materialCode);
|
|
|
|
|
|
|
|
TblTradeBidMaterialDetails materialInfo = new TblTradeBidMaterialDetails();
|
|
|
|
materialInfo.setPackageName(cellTypeToString(row.getCell(1))); //标段(包)名称
|
|
|
|
materialInfo.setMaterialCode(materialCode);//物料编码
|
|
|
|
materialInfo.setSrmCode(cellTypeToString(row.getCell(3))); //SRM编码
|
|
|
|
materialInfo.setMaterialDescription(cellTypeToString(row.getCell(4))); //物料长描述
|
|
|
|
materialInfo.setMeasurementUnit(cellTypeToString(row.getCell(5))); //单位
|
|
|
|
materialInfo.setBrand(cellTypeToString(row.getCell(6))); //品牌
|
|
|
|
String value = cellTypeToString(row.getCell(7)); // 假设值为 "20.000"
|
|
|
|
value = value.split("\\.")[0]; // 去除小数点及其后面的部分
|
|
|
|
int intValue = Integer.parseInt(value); // 解析为整数
|
|
|
|
materialInfo.setDemandQuantity(intValue); //数量
|
|
|
|
|
|
|
|
BigDecimal zbjg = new BigDecimal(cellTypeToString(row.getCell(8)));
|
|
|
|
materialInfo.setWinningBidPrice(zbjg); // 中标单价
|
|
|
|
//是否中标
|
|
|
|
if (StringUtils.isBlank(cellTypeToString(row.getCell(8)))){
|
|
|
|
materialInfo.setIsBid(2);
|
|
|
|
}else {
|
|
|
|
materialInfo.setIsBid(1);
|
|
|
|
}
|
|
|
|
materialInfo.setTaxRate(cellTypeToString(row.getCell(9))); // 税率
|
|
|
|
materialInfo.setBidTotalPrice(new BigDecimal(cellTypeToString(row.getCell(10)))); // 总价(不含税,元)
|
|
|
|
Cell cell = row.getCell(12);
|
|
|
|
Date dateCellValue = cell.getDateCellValue();
|
|
|
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
materialInfo.setRequiredDeliveryTime(fmt.format(dateCellValue)); // 交货时间
|
|
|
|
materialInfo.setDemandUnit(cellTypeToString(row.getCell(11))); // 需求单位
|
|
|
|
//投标价格
|
|
|
|
if (tblTradeBidSubInfo.getTbjg() != null){
|
|
|
|
BigDecimal tbjg = new BigDecimal(tblTradeBidSubInfo.getTbjg());
|
|
|
|
materialInfo.setBidPrice(tbjg);
|
|
|
|
materialInfo.setDiffPrice(tbjg.subtract(zbjg));
|
|
|
|
}
|
|
|
|
|
|
|
|
materialInfo.setBidNum(projectNumber);
|
|
|
|
materialInfo.setBidDate(bidDate);
|
|
|
|
tblTradeBidMaterialDetails.add(materialInfo);
|
|
|
|
}
|
|
|
|
tblTradeBidMaterialDetailsService.saveBatch(tblTradeBidMaterialDetails);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error(e.getMessage(), e);
|
|
|
|
return Result.error("文件导入失败!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Result.OK("文件导入成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
|
|
|
public String cellTypeToString(Cell cell) {
|
|
|
|
switch (cell.getCellType()) {
|
|
|
|
case STRING:
|
|
|
|
return cell.getStringCellValue();
|
|
|
|
case NUMERIC:
|
|
|
|
String str = "";
|
|
|
|
if (DateUtil.isCellDateFormatted(cell)) {
|
|
|
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
// 如果是日期类型
|
|
|
|
Date date = cell.getDateCellValue();
|
|
|
|
str = fmt.format(date);
|
|
|
|
} else {
|
|
|
|
// 如果是普通数字
|
|
|
|
double numericValue = cell.getNumericCellValue();
|
|
|
|
// String formattedValue =
|
|
|
|
str = new BigDecimal(numericValue).toPlainString();
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
case BOOLEAN:
|
|
|
|
return String.valueOf(cell.getBooleanCellValue());
|
|
|
|
case FORMULA:
|
|
|
|
return cell.getCellFormula();
|
|
|
|
case BLANK:
|
|
|
|
return "";
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|