Commit 48837a3f authored by lixiaolei's avatar lixiaolei

submit

parent e589da46
...@@ -39,8 +39,9 @@ public class BusinessInfoController extends BaseController ...@@ -39,8 +39,9 @@ public class BusinessInfoController extends BaseController
* 项目批量导入 * 项目批量导入
*/ */
@PostMapping("/upload") @PostMapping("/upload")
public AjaxResult batchUpload(@RequestParam(value="file",required = false) MultipartFile file, HttpServletRequest request, HttpServletResponse response){ // public AjaxResult batchUpload(@RequestPart("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response){
return businessInfoService.batchUpload(file,response); public AjaxResult batchUpload(@RequestPart("file") MultipartFile file){
return businessInfoService.batchUpload(file);
} }
/** /**
......
...@@ -118,6 +118,78 @@ public class BusinessInfo extends BaseEntity ...@@ -118,6 +118,78 @@ public class BusinessInfo extends BaseEntity
@Excel(name = "项目状态") @Excel(name = "项目状态")
private Integer status; 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() { public Integer getStatus() {
return status; return status;
} }
...@@ -359,7 +431,12 @@ public class BusinessInfo extends BaseEntity ...@@ -359,7 +431,12 @@ public class BusinessInfo extends BaseEntity
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("customerId", getCustomerId()) .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(); .toString();
} }
} }
...@@ -90,7 +90,13 @@ public interface BusinessInfoMapper extends BaseMapper<BusinessInfo> ...@@ -90,7 +90,13 @@ public interface BusinessInfoMapper extends BaseMapper<BusinessInfo>
*/ */
BusinessBrowseVo selectTotal(Integer business); 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); int selectCountByStatusAndCustomerId(@Param("status") Integer status,@Param("customerId") String customerId);
......
...@@ -61,7 +61,7 @@ public interface IBusinessInfoService ...@@ -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; ...@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dsk.common.constant.HttpStatus; import com.dsk.common.constant.HttpStatus;
import com.dsk.common.core.domain.AjaxResult; import com.dsk.common.core.domain.AjaxResult;
...@@ -13,6 +14,7 @@ import com.dsk.common.core.domain.entity.BusinessInfo; ...@@ -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.BusinessLabel;
import com.dsk.common.core.domain.entity.BusinessRelateCompany; import com.dsk.common.core.domain.entity.BusinessRelateCompany;
import com.dsk.common.core.domain.entity.BusinessUser; 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.DateUtils;
import com.dsk.common.utils.SecurityUtils; import com.dsk.common.utils.SecurityUtils;
import com.dsk.system.domain.BusinessExcelDto; import com.dsk.system.domain.BusinessExcelDto;
...@@ -28,6 +30,7 @@ import com.dsk.system.mapper.BusinessRelateCompanyMapper; ...@@ -28,6 +30,7 @@ import com.dsk.system.mapper.BusinessRelateCompanyMapper;
import com.dsk.system.mapper.BusinessUserMapper; import com.dsk.system.mapper.BusinessUserMapper;
import com.dsk.system.service.IBusinessInfoService; import com.dsk.system.service.IBusinessInfoService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -79,6 +82,11 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService { ...@@ -79,6 +82,11 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
*/ */
@Override @Override
public List<BusinessListVo> selectBusinessInfoList(BusinessListDto dto) { 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); return businessInfoMapper.selectBusinessInfoList(dto);
} }
...@@ -87,7 +95,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService { ...@@ -87,7 +95,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
BusinessBrowseVo businessBrowseVo = new BusinessBrowseVo(); BusinessBrowseVo businessBrowseVo = new BusinessBrowseVo();
//查询项目基本信息 //查询项目基本信息
BusinessInfo businessInfo = businessInfoMapper.selectBusinessInfoById(businessId); 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())); businessBrowseVo.setLabelList(businessLabelMapper.selectBusinessLabelList(new BusinessLabel(businessId)).stream().map(p -> p.getLabel()).collect(Collectors.toList()));
//查询关键企业 //查询关键企业
...@@ -106,34 +114,37 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService { ...@@ -106,34 +114,37 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
} }
@Override @Override
public AjaxResult batchUpload(MultipartFile file, HttpServletResponse response) { public AjaxResult batchUpload(MultipartFile file) {
int row=3;//起始行数 //获取当前登录用户id
int rowSuccess=0;//成功条数 Long userId = SecurityUtils.getLoginUser().getUserId();
Integer errorCount=0;//失败条数 // Long userId = 103L;
if (userId == null) return AjaxResult.error("请登录");
int row = 3;//起始行数
int rowSuccess = 0;//成功条数
Integer errorCount = 0;//失败条数
List<String> result = new LinkedList();//导入结果汇总 List<String> result = new LinkedList();//导入结果汇总
List<BusinessExcelDto> businessInfoList = readBusinessInfoExcel.getExcelInfo(file); List<BusinessExcelDto> businessInfoList = readBusinessInfoExcel.getExcelInfo(file);
for (BusinessExcelDto businessInfo : businessInfoList) { 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++; row++;
if(count > 0){ if (count > 0) {
//如果存在,跳过该项目,不保存 //如果存在,跳过该项目,不保存
result.add("第"+row+"行的"+businessInfo.getProjectName()+"的项目已存在,跳过该项目,保存下一条"); result.add("第" + row + "行的" + businessInfo.getProjectName() + "的项目已存在,跳过该项目,保存下一条");
errorCount++; errorCount++;
}else { } else {
//保存到数据库 //保存到数据库
BusinessAddDto businessAddDto = new BusinessAddDto(); BusinessAddDto businessAddDto = new BusinessAddDto();
BeanUtil.copyProperties(businessInfo,businessAddDto); BeanUtil.copyProperties(businessInfo, businessAddDto);
//获取当前登录用户id businessAddDto.setUserId(userId.intValue());
businessAddDto.setUserId(SecurityUtils.getLoginUser().getUserId().intValue());
businessAddDto.setCompanyId(0); businessAddDto.setCompanyId(0);
AjaxResult add = insertBusinessInfo(businessAddDto); 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("导入项目成功条数" + rowSuccess);
result.add("导入项目失败条件"+errorCount); result.add("导入项目失败条数" + errorCount);
return errorCount == businessInfoList.size() ? AjaxResult.error(String.join("\n",result),response) : AjaxResult.success(String.join("\n",result),response); return errorCount == businessInfoList.size() ? AjaxResult.error(String.join(",", result)) : AjaxResult.success(String.join(",", result));
} }
/** /**
...@@ -146,8 +157,8 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService { ...@@ -146,8 +157,8 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
@Transactional @Transactional
public AjaxResult insertBusinessInfo(BusinessAddDto dto) { public AjaxResult insertBusinessInfo(BusinessAddDto dto) {
//新增前查询是否已存在 //新增前查询是否已存在
BusinessInfo selectOne = businessInfoMapper.selectOne(Wrappers.<BusinessInfo>lambdaQuery().eq(BusinessInfo::getProjectName, dto.getProjectName())); int count = businessInfoMapper.isRepetitionProjectName(dto.getProjectName(), dto.getUserId());
if(ObjectUtil.isNotEmpty(selectOne)) return AjaxResult.error("项目名称已存在"); if (count > 0) return AjaxResult.error("项目名称已存在");
//新增项目主信息 //新增项目主信息
BusinessInfo businessInfo = new BusinessInfo(); BusinessInfo businessInfo = new BusinessInfo();
BeanUtil.copyProperties(dto, businessInfo); BeanUtil.copyProperties(dto, businessInfo);
...@@ -174,8 +185,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService { ...@@ -174,8 +185,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
*/ */
@Override @Override
@Transactional @Transactional
public int updateBusinessInfo(BusinessInfo businessInfo) public int updateBusinessInfo(BusinessInfo businessInfo) {
{
businessInfo.setUpdateTime(DateUtils.getNowDate()); businessInfo.setUpdateTime(DateUtils.getNowDate());
return businessInfoMapper.updateBusinessInfo(businessInfo); return businessInfoMapper.updateBusinessInfo(businessInfo);
} }
......
...@@ -108,7 +108,8 @@ public class ReadBusinessInfoExcel { ...@@ -108,7 +108,8 @@ public class ReadBusinessInfoExcel {
// List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); // List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
ArrayList<BusinessExcelDto> list = new ArrayList<>(); ArrayList<BusinessExcelDto> list = new ArrayList<>();
//循环Excel行数 //循环Excel行数
for (int r = 1; r < totalRows; r++) { //
for (int r = 3; r < totalRows; r++) {
Row row = sheet.getRow(r); Row row = sheet.getRow(r);
if (row == null) { if (row == null) {
continue; continue;
...@@ -116,7 +117,7 @@ public class ReadBusinessInfoExcel { ...@@ -116,7 +117,7 @@ public class ReadBusinessInfoExcel {
//循环Excel的列 //循环Excel的列
// Map<String, Object> map = new HashMap<String, Object>(); // Map<String, Object> map = new HashMap<String, Object>();
BusinessExcelDto businessExcelDto = new BusinessExcelDto(); 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); Cell cell = row.getCell(c);
if (null != cell) { if (null != cell) {
if (c == 0) { if (c == 0) {
...@@ -147,6 +148,7 @@ public class ReadBusinessInfoExcel { ...@@ -147,6 +148,7 @@ public class ReadBusinessInfoExcel {
//添加到list //添加到list
list.add(businessExcelDto); list.add(businessExcelDto);
} }
log.info("项目批量导入Excel数据,{}",list);
return list; return list;
} }
......
...@@ -29,7 +29,12 @@ ...@@ -29,7 +29,12 @@
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
<result property="status" column="status"/> <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> </resultMap>
<sql id="selectBusinessInfoVo"> <sql id="selectBusinessInfoVo">
...@@ -57,7 +62,13 @@ ...@@ -57,7 +62,13 @@
create_time, create_time,
update_time, update_time,
status, 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 from business_info
</sql> </sql>
...@@ -240,7 +251,12 @@ ...@@ -240,7 +251,12 @@
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="status != null">status,</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>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="projectName != null">#{projectName},</if> <if test="projectName != null">#{projectName},</if>
...@@ -267,6 +283,12 @@ ...@@ -267,6 +283,12 @@
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="customerId != null">#{customerId},</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> </trim>
</insert> </insert>
...@@ -297,6 +319,12 @@ ...@@ -297,6 +319,12 @@
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="customerId != null">customer_id = #{customerId},</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> </trim>
where id = #{id} where id = #{id}
</update> </update>
...@@ -340,8 +368,21 @@ ...@@ -340,8 +368,21 @@
plan_start_time, plan_start_time,
plan_complete_time, plan_complete_time,
build_property, 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 from business_info
where id = #{id} where id = #{id}
</select> </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> </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