|
|
@@ -1,5 +1,6 @@
|
|
|
package com.goafanti.demand.service.impl;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Calendar;
|
|
|
@@ -11,11 +12,16 @@ import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import com.goafanti.common.bo.Error;
|
|
|
import com.goafanti.common.bo.MyCollection;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.constant.PageConstants;
|
|
|
@@ -39,6 +45,7 @@ import com.goafanti.common.dao.UserIdentityMapper;
|
|
|
import com.goafanti.common.dao.UserInterestMapper;
|
|
|
import com.goafanti.common.dao.UserMapper;
|
|
|
import com.goafanti.common.dao.UserRoleMapper;
|
|
|
+import com.goafanti.common.enums.AchievementAuditStatus;
|
|
|
import com.goafanti.common.enums.DeleteStatus;
|
|
|
import com.goafanti.common.enums.DemandAuditStatus;
|
|
|
import com.goafanti.common.enums.DemandInfoSourceStatus;
|
|
|
@@ -49,8 +56,12 @@ import com.goafanti.common.enums.NoticeReadStatus;
|
|
|
import com.goafanti.common.enums.NoticeStatus;
|
|
|
import com.goafanti.common.enums.UserType;
|
|
|
import com.goafanti.common.enums.collectType;
|
|
|
+import com.goafanti.common.error.BusinessException;
|
|
|
+import com.goafanti.common.model.Achievement;
|
|
|
import com.goafanti.common.model.AchievementDemand;
|
|
|
import com.goafanti.common.model.AchievementDemandCount;
|
|
|
+import com.goafanti.common.model.AchievementKeyword;
|
|
|
+import com.goafanti.common.model.AchievementPublish;
|
|
|
import com.goafanti.common.model.Demand;
|
|
|
import com.goafanti.common.model.DemandKeyword;
|
|
|
import com.goafanti.common.model.DemandPublish;
|
|
|
@@ -60,6 +71,7 @@ import com.goafanti.common.model.OrganizationIdentity;
|
|
|
import com.goafanti.common.model.User;
|
|
|
import com.goafanti.common.model.UserIdentity;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
+import com.goafanti.common.utils.FileUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
@@ -762,50 +774,42 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
|
|
|
|
|
|
@Override
|
|
|
public List<DemandListBo> recentDemand(int size,String pattern,String showLocation) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.selectRecentDemand(size,pattern,showLocation);
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public List<DemandListBo> companyDemand(int size,String pattern,String showLocation) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.selectCompanyDemand(size,pattern,showLocation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DemandListBo> getUrgentDemand(int size,String pattern,String showLocation) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.getUrgentDemand(size,pattern,showLocation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DemandListBo> getHotDemand(int size,String pattern,String showLocation, int deletedSign) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.getHotDemand(size,pattern,showLocation,deletedSign);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DemandListBo> areaDemand(int size,String pattern,String showLocation) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.getAreaDemand(size,pattern,showLocation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DemandListBo> proLearnStudyDemand(int size,String pattern,String showLocation) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.getProLearnStudyDemand(size,pattern,showLocation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DemandListBo> getFundCrowdDemand(int size,String pattern,String showLocation) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.getFundCrowdDemand(size,pattern,showLocation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DemandListBo> getPersonnelDemand(int size,String pattern,String showLocation) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.getPersonnelDemand(size,pattern,showLocation);
|
|
|
}
|
|
|
|
|
|
@@ -839,19 +843,16 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
|
|
|
|
|
|
@Override
|
|
|
public DemandListBo getDemandDetail(String id, Integer type) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.getDemandDetail(id, type);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int getInterestCount(String id) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.countInterest(id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<DemandListBo> getBoutiqueDemandList(int i,String pattern,String showLocation) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
return demandMapper.getBoutiqueDemandList(i,pattern,showLocation);
|
|
|
}
|
|
|
|
|
|
@@ -893,7 +894,6 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Override
|
|
|
public Pagination<DemandListBo> getDemandObjects(DemandListBo demandListBo, Integer pageNo, Integer pageSize) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
if(pageNo==null || pageNo<1) {
|
|
|
pageNo=1;
|
|
|
}
|
|
|
@@ -974,6 +974,126 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
|
|
|
}
|
|
|
return i;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void batchSaveDemand(MultipartFile file) {
|
|
|
+ //创建一个对象,用来存储数据
|
|
|
+ List<Demand> list=new ArrayList<>();
|
|
|
+ List<DemandKeyword> keyword = new ArrayList<>();
|
|
|
+ List<DemandPublish> publish = new ArrayList<>();
|
|
|
+ Sheet sheet=FileUtils.pushReadFile(file);
|
|
|
+ //获得当前sheet的开始行
|
|
|
+ int firstRowNum = sheet.getFirstRowNum();
|
|
|
+ //获得当前sheet最后一行
|
|
|
+ int lastRowNum=sheet.getLastRowNum();
|
|
|
+ //循环除了第2行的所有行
|
|
|
+ Date date=new Date();
|
|
|
+ //获取技淘网的id
|
|
|
+ String defaultPlatformId = branchInformationMapper.selectByDomain(PageConstants.DEFAULT_DOMAIN).getId();
|
|
|
+ for(int rowNum = firstRowNum+2;rowNum <= lastRowNum;rowNum++){
|
|
|
+ //获得当前行
|
|
|
+ Row row = sheet.getRow(rowNum);
|
|
|
+ if(row == null){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //获得当前行的开始列
|
|
|
+ int firstCellNum = row.getFirstCellNum();
|
|
|
+ //获得当前行的列数
|
|
|
+ int lastCellNum = row.getLastCellNum();
|
|
|
+ //循环当前行 cellNum = (firstCellNum+1) 则是除开第一例
|
|
|
+ Demand in=new Demand();
|
|
|
+ for(int cellNum = (firstCellNum); cellNum < lastCellNum;cellNum++){
|
|
|
+ Cell cell = row.getCell(cellNum);
|
|
|
+ try {
|
|
|
+ switch (cellNum) {
|
|
|
+ case 0:
|
|
|
+ in.setName(FileUtils.getCellValue(cell));
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ in.setDemandType(Integer.valueOf(FileUtils.getCellValue(cell)));
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ in.setDataCategory(Integer.valueOf(FileUtils.getCellValue(cell)));
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ in.setProblemDes(FileUtils.getCellValue(cell));
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ in.setKeyword(FileUtils.getCellValue(cell));
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ in.setIsHot(Integer.valueOf(FileUtils.getCellValue(cell)));
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ in.setIsUrgent(Integer.valueOf(FileUtils.getCellValue(cell)));
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ in.setUrgentDays(Integer.valueOf(FileUtils.getCellValue(cell)));
|
|
|
+ break;
|
|
|
+ case 8:
|
|
|
+ in.setUrgentMoney(new BigDecimal(FileUtils.getCellValue(cell)));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BusinessException(new Error("表格第"+(rowNum+1)+"行输入内容不正确。"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ in.setDeletedSign(DeleteStatus.UNDELETE.getCode());
|
|
|
+ in.setEmployerId(TokenManager.getAdminId());
|
|
|
+ in.setCreateTime(date);
|
|
|
+ in.setStatus(0);
|
|
|
+ in.setReleaseStatus(AchievementAuditStatus.CREATE.getCode());
|
|
|
+ in.setAuditStatus(0);
|
|
|
+ in.setId(UUID.randomUUID().toString());
|
|
|
+ in.setInfoSources(1);
|
|
|
+ list.add(in);
|
|
|
+ //关键字处理
|
|
|
+ String [] keywords=null;
|
|
|
+ if(in.getKeyword()!=null) {
|
|
|
+ if (in.getKeyword().contains(",")) {
|
|
|
+ keywords=in.getKeyword().split(",");
|
|
|
+ }else if (in.getKeyword().contains(",")) {
|
|
|
+ keywords=in.getKeyword().split(",");
|
|
|
+ }
|
|
|
+ for (int j = 0; j < keywords.length; j++) {
|
|
|
+ DemandKeyword ak = new DemandKeyword();
|
|
|
+ ak.setId(UUID.randomUUID().toString());
|
|
|
+ ak.setDemandId(in.getId());
|
|
|
+ ak.setKeyword(keywords[j].trim());
|
|
|
+ keyword.add(ak);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DemandPublish ap = new DemandPublish();
|
|
|
+ ap.setId(UUID.randomUUID().toString());
|
|
|
+ ap.setDemandId((in.getId()));
|
|
|
+ ap.setPublisher(TokenManager.getUserId());
|
|
|
+ ap.setPublishTime(date);
|
|
|
+ ap.setPublishClient(PageConstants.WEB_PLATFORM);
|
|
|
+ ap.setPublishPage("wep_demand_list");
|
|
|
+ ap.setPublishPlatform(defaultPlatformId);
|
|
|
+ ap.setIfTop(AFTConstants.NO);
|
|
|
+ ap.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
|
|
|
+ ap.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
|
|
|
+ publish.add(ap);
|
|
|
+ DemandPublish ap2 = new DemandPublish();
|
|
|
+ ap2.setId(UUID.randomUUID().toString());
|
|
|
+ ap2.setDemandId(in.getId());
|
|
|
+ ap2.setPublisher(TokenManager.getUserId());
|
|
|
+ ap2.setPublishTime(date);
|
|
|
+ ap2.setPublishClient(PageConstants.APP_PLATFORM);
|
|
|
+ ap2.setPublishPage("app_demand_list");
|
|
|
+ ap2.setPublishPlatform(defaultPlatformId);
|
|
|
+ ap2.setIfTop(AFTConstants.NO);
|
|
|
+ ap2.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
|
|
|
+ ap2.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
|
|
|
+ publish.add(ap2);
|
|
|
+
|
|
|
+ }
|
|
|
+ demandMapper.insertBatch(list);
|
|
|
+ demandKeywordMapper.insertBatch(keyword);
|
|
|
+ demandPublishMapper.insertBatch(publish);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|