Commit 48837a3f authored by lixiaolei's avatar lixiaolei

submit

parent e589da46
......@@ -39,8 +39,9 @@ public class BusinessInfoController extends BaseController
* 项目批量导入
*/
@PostMapping("/upload")
public AjaxResult batchUpload(@RequestParam(value="file",required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response){
return businessInfoService.batchUpload(file,response);
// public AjaxResult batchUpload(@RequestPart("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response){
public AjaxResult batchUpload(@RequestPart("file") MultipartFile file){
return businessInfoService.batchUpload(file);
}
/**
......
......@@ -118,6 +118,78 @@ public class BusinessInfo extends BaseEntity
@Excel(name = "项目状态")
private Integer status;
/** 评标办法 */
@Excel(name = "评标办法")
private String evaluationBidWay;
/** 开标时间 */
@Excel(name = "开标时间")
private String bidOpenTime;
/** 开标地点 */
@Excel(name = "开标地点")
private String bidOpenPlace;
/** 保证金缴纳 */
@Excel(name = "保证金缴纳")
private String earnestMoneyPay;
/** 保证金金额 */
@Excel(name = "保证金金额")
private String earnestMoney;
/** 评标委员会 */
@Excel(name = "评标委员会")
private String evaluationBidCouncil;
public String getEvaluationBidWay() {
return evaluationBidWay;
}
public void setEvaluationBidWay(String evaluationBidWay) {
this.evaluationBidWay = evaluationBidWay;
}
public String getBidOpenTime() {
return bidOpenTime;
}
public void setBidOpenTime(String bidOpenTime) {
this.bidOpenTime = bidOpenTime;
}
public String getBidOpenPlace() {
return bidOpenPlace;
}
public void setBidOpenPlace(String bidOpenPlace) {
this.bidOpenPlace = bidOpenPlace;
}
public String getEarnestMoneyPay() {
return earnestMoneyPay;
}
public void setEarnestMoneyPay(String earnestMoneyPay) {
this.earnestMoneyPay = earnestMoneyPay;
}
public String getEarnestMoney() {
return earnestMoney;
}
public void setEarnestMoney(String earnestMoney) {
this.earnestMoney = earnestMoney;
}
public String getEvaluationBidCouncil() {
return evaluationBidCouncil;
}
public void setEvaluationBidCouncil(String evaluationBidCouncil) {
this.evaluationBidCouncil = evaluationBidCouncil;
}
public Integer getStatus() {
return status;
}
......@@ -359,7 +431,12 @@ public class BusinessInfo extends BaseEntity
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("customerId", getCustomerId())
.append("status", getStatus())
.append("evaluationBidWay", getEvaluationBidWay())
.append("bidOpenTime", getBidOpenTime())
.append("bidOpenPlace", getBidOpenPlace())
.append("earnestMoneyPay", getEarnestMoneyPay())
.append("earnestMoney", getEarnestMoney())
.append("evaluationBidCouncil", getEvaluationBidCouncil())
.toString();
}
}
......@@ -90,7 +90,13 @@ public interface BusinessInfoMapper extends BaseMapper<BusinessInfo>
*/
BusinessBrowseVo selectTotal(Integer business);
/**
* 查询项目名称是否存在
* @param projectName
* @param userId
* @return
*/
int isRepetitionProjectName(@Param("projectName") String projectName,@Param("userId") Integer userId);
int selectCountByStatusAndCustomerId(@Param("status") Integer status,@Param("customerId") String customerId);
......
......@@ -61,7 +61,7 @@ public interface IBusinessInfoService
/**
* 项目批量导入
*/
AjaxResult batchUpload(MultipartFile file, HttpServletResponse response);
AjaxResult batchUpload(MultipartFile file);
/**
* 新增项目详情
......
......@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.constant.HttpStatus;
import com.dsk.common.core.domain.AjaxResult;
......@@ -13,6 +14,7 @@ import com.dsk.common.core.domain.entity.BusinessInfo;
import com.dsk.common.core.domain.entity.BusinessLabel;
import com.dsk.common.core.domain.entity.BusinessRelateCompany;
import com.dsk.common.core.domain.entity.BusinessUser;
import com.dsk.common.exception.base.BaseException;
import com.dsk.common.utils.DateUtils;
import com.dsk.common.utils.SecurityUtils;
import com.dsk.system.domain.BusinessExcelDto;
......@@ -28,6 +30,7 @@ import com.dsk.system.mapper.BusinessRelateCompanyMapper;
import com.dsk.system.mapper.BusinessUserMapper;
import com.dsk.system.service.IBusinessInfoService;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
......@@ -79,6 +82,11 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
*/
@Override
public List<BusinessListVo> selectBusinessInfoList(BusinessListDto dto) {
if (dto.getUserId() == null) {
Long deptId = SecurityUtils.getLoginUser().getDeptId();
if (deptId == null) throw new BaseException("请登录");
dto.setDeptId(deptId.intValue());
}
return businessInfoMapper.selectBusinessInfoList(dto);
}
......@@ -87,7 +95,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
BusinessBrowseVo businessBrowseVo = new BusinessBrowseVo();
//查询项目基本信息
BusinessInfo businessInfo = businessInfoMapper.selectBusinessInfoById(businessId);
BeanUtil.copyProperties(businessInfo,businessBrowseVo);
BeanUtil.copyProperties(businessInfo, businessBrowseVo);
//查询项目标签
businessBrowseVo.setLabelList(businessLabelMapper.selectBusinessLabelList(new BusinessLabel(businessId)).stream().map(p -> p.getLabel()).collect(Collectors.toList()));
//查询关键企业
......@@ -106,34 +114,37 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
}
@Override
public AjaxResult batchUpload(MultipartFile file, HttpServletResponse response) {
int row=3;//起始行数
int rowSuccess=0;//成功条数
Integer errorCount=0;//失败条数
public AjaxResult batchUpload(MultipartFile file) {
//获取当前登录用户id
Long userId = SecurityUtils.getLoginUser().getUserId();
// Long userId = 103L;
if (userId == null) return AjaxResult.error("请登录");
int row = 3;//起始行数
int rowSuccess = 0;//成功条数
Integer errorCount = 0;//失败条数
List<String> result = new LinkedList();//导入结果汇总
List<BusinessExcelDto> businessInfoList = readBusinessInfoExcel.getExcelInfo(file);
for (BusinessExcelDto businessInfo : businessInfoList) {
//查询已有的项目名称
Integer count = businessInfoMapper.selectCount(Wrappers.<BusinessInfo>lambdaQuery().eq(BusinessInfo::getProjectName, businessInfo.getProjectName()));
Integer count = businessInfoMapper.isRepetitionProjectName(businessInfo.getProjectName(), userId.intValue());
row++;
if(count > 0){
if (count > 0) {
//如果存在,跳过该项目,不保存
result.add("第"+row+"行的"+businessInfo.getProjectName()+"的项目已存在,跳过该项目,保存下一条");
result.add("第" + row + "行的" + businessInfo.getProjectName() + "的项目已存在,跳过该项目,保存下一条");
errorCount++;
}else {
} else {
//保存到数据库
BusinessAddDto businessAddDto = new BusinessAddDto();
BeanUtil.copyProperties(businessInfo,businessAddDto);
//获取当前登录用户id
businessAddDto.setUserId(SecurityUtils.getLoginUser().getUserId().intValue());
BeanUtil.copyProperties(businessInfo, businessAddDto);
businessAddDto.setUserId(userId.intValue());
businessAddDto.setCompanyId(0);
AjaxResult add = insertBusinessInfo(businessAddDto);
if(add.get("code").equals(HttpStatus.SUCCESS))rowSuccess++;
if (add.get("code").equals(HttpStatus.SUCCESS)) rowSuccess++;
}
}
result.add("导入项目成功条数"+rowSuccess);
result.add("导入项目失败条件"+errorCount);
return errorCount == businessInfoList.size() ? AjaxResult.error(String.join("\n",result),response) : AjaxResult.success(String.join("\n",result),response);
result.add("导入项目成功条数" + rowSuccess);
result.add("导入项目失败条数" + errorCount);
return errorCount == businessInfoList.size() ? AjaxResult.error(String.join(",", result)) : AjaxResult.success(String.join(",", result));
}
/**
......@@ -146,8 +157,8 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
@Transactional
public AjaxResult insertBusinessInfo(BusinessAddDto dto) {
//新增前查询是否已存在
BusinessInfo selectOne = businessInfoMapper.selectOne(Wrappers.<BusinessInfo>lambdaQuery().eq(BusinessInfo::getProjectName, dto.getProjectName()));
if(ObjectUtil.isNotEmpty(selectOne)) return AjaxResult.error("项目名称已存在");
int count = businessInfoMapper.isRepetitionProjectName(dto.getProjectName(), dto.getUserId());
if (count > 0) return AjaxResult.error("项目名称已存在");
//新增项目主信息
BusinessInfo businessInfo = new BusinessInfo();
BeanUtil.copyProperties(dto, businessInfo);
......@@ -174,8 +185,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
*/
@Override
@Transactional
public int updateBusinessInfo(BusinessInfo businessInfo)
{
public int updateBusinessInfo(BusinessInfo businessInfo) {
businessInfo.setUpdateTime(DateUtils.getNowDate());
return businessInfoMapper.updateBusinessInfo(businessInfo);
}
......
......@@ -108,7 +108,8 @@ public class ReadBusinessInfoExcel {
// List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
ArrayList<BusinessExcelDto> list = new ArrayList<>();
//循环Excel行数
for (int r = 1; r < totalRows; r++) {
//
for (int r = 3; r < totalRows; r++) {
Row row = sheet.getRow(r);
if (row == null) {
continue;
......@@ -116,7 +117,7 @@ public class ReadBusinessInfoExcel {
//循环Excel的列
// Map<String, Object> map = new HashMap<String, Object>();
BusinessExcelDto businessExcelDto = new BusinessExcelDto();
for (int c = 3; c < this.totalCells; c++) {
for (int c = 0; c < this.totalCells; c++) {
Cell cell = row.getCell(c);
if (null != cell) {
if (c == 0) {
......@@ -147,6 +148,7 @@ public class ReadBusinessInfoExcel {
//添加到list
list.add(businessExcelDto);
}
log.info("项目批量导入Excel数据,{}",list);
return list;
}
......
......@@ -29,7 +29,12 @@
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="status" column="status"/>
<result property="customerId" column="customer_id"/>
<result property="evaluationBidWay" column="evaluation_bid_way"/>
<result property="bidOpenTime" column="bid_open_time"/>
<result property="bidOpenPlace" column="bid_open_place"/>
<result property="earnestMoneyPay" column="earnest_money_pay"/>
<result property="earnestMoney" column="earnest_money"/>
<result property="evaluationBidCouncil" column="evaluation_bid_council"/>
</resultMap>
<sql id="selectBusinessInfoVo">
......@@ -57,7 +62,13 @@
create_time,
update_time,
status,
customer_id
customer_id,
evaluation_bid_way,
bid_open_time,
bid_open_place,
earnest_money_pay,
earnest_money,
evaluation_bid_council
from business_info
</sql>
......@@ -240,7 +251,12 @@
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="status != null">status,</if>
<if test="customerId != null">customer_id,</if>
<if test="evaluationBidWay != null">evaluation_bid_way,</if>
<if test="bidOpenTime != null">bid_open_time,</if>
<if test="bidOpenPlace != null">bid_open_place,</if>
<if test="earnestMoneyPay != null">earnest_money_pay,</if>
<if test="earnestMoney != null">earnest_money,</if>
<if test="evaluationBidCouncil != null">evaluation_bid_council,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="projectName != null">#{projectName},</if>
......@@ -267,6 +283,12 @@
<if test="updateTime != null">#{updateTime},</if>
<if test="status != null">#{status},</if>
<if test="customerId != null">#{customerId},</if>
<if test="evaluationBidWay != null">#{evaluationBidWay},</if>
<if test="bidOpenTime != null">#{bidOpenTime},</if>
<if test="bidOpenPlace != null">#{bidOpenPlace},</if>
<if test="earnestMoneyPay != null">#{earnestMoneyPay},</if>
<if test="earnestMoney != null">#{earnestMoney},</if>
<if test="evaluationBidCouncil != null">#{evaluationBidCouncil},</if>
</trim>
</insert>
......@@ -297,6 +319,12 @@
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="status != null">status = #{status},</if>
<if test="customerId != null">customer_id = #{customerId},</if>
<if test="evaluationBidWay != null">evaluation_bid_way = #{evaluationBidWay},</if>
<if test="bidOpenTime != null">bid_open_time = #{bidOpenTime},</if>
<if test="bidOpenPlace != null">bid_open_place = #{bidOpenPlace},</if>
<if test="earnestMoneyPay != null">earnest_money_pay = #{earnestMoneyPay},</if>
<if test="earnestMoney != null">earnest_money = #{earnestMoney},</if>
<if test="evaluationBidCouncil != null">evaluation_bid_council = #{evaluationBidCouncil},</if>
</trim>
where id = #{id}
</update>
......@@ -340,8 +368,21 @@
plan_start_time,
plan_complete_time,
build_property,
project_details
project_details,
evaluation_bid_way,
bid_open_time,
bid_open_place,
earnest_money_pay,
earnest_money,
evaluation_bid_council
from business_info
where id = #{id}
</select>
<select id="isRepetitionProjectName" resultType="java.lang.Integer">
select count(i.id)
from business_info i
inner join business_user u on u.business_id = i.id
where i.project_name = #{projectName}
and u.user_id = #{userId}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment