anderx 5 роки тому
батько
коміт
bf2e4018e5

+ 81 - 44
src/main/java/com/goafanti/achievement/service/impl/AchievementServiceImpl.java

@@ -888,6 +888,8 @@ public class AchievementServiceImpl extends BaseMybatisDao<AchievementMapper> im
 	public void batchSaveAchievement(MultipartFile file) {
 		//创建一个对象,用来存储数据
 	    List<Achievement> list=new ArrayList<>();
+	    List<AchievementKeyword> keyword = new ArrayList<>();
+	    List<AchievementPublish> publish = new ArrayList<>();
 		Sheet sheet=FileUtils.pushReadFile(file);
 		//获得当前sheet的开始行
 		int firstRowNum = sheet.getFirstRowNum();
@@ -895,6 +897,8 @@ public class AchievementServiceImpl extends BaseMybatisDao<AchievementMapper> im
 		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);
@@ -912,74 +916,107 @@ public class AchievementServiceImpl extends BaseMybatisDao<AchievementMapper> im
 			    	try {
 			        switch (cellNum) {
 					case 0:
-						in.setName(getCellValue(cell));
+						in.setName(FileUtils.getCellValue(cell));
 						break;
 					case 1:
-						in.setIntroduction(getCellValue(cell));
+						in.setDataCategory(Integer.valueOf(FileUtils.getCellValue(cell)));
 						break;
 					case 2:
-						in.setKeyword(getCellValue(cell));
+						in.setCategory(Integer.valueOf(FileUtils.getCellValue(cell)));
 						break;
 					case 3:
-						in.setPatentCase(getCellValue(cell));
+						in.setIntroduction(FileUtils.getCellValue(cell));
 						break;
 					case 4:
-						in.setTeamDes(getCellValue(cell));
+						in.setKeyword(FileUtils.getCellValue(cell));
 						break;
 					case 5:
-						in.setParameter(getCellValue(cell));
+						in.setPatentCase(FileUtils.getCellValue(cell));
+						break;
+					case 6:
+						in.setTeamDes(FileUtils.getCellValue(cell));
+						break;
+					case 7:
+						in.setParameter(FileUtils.getCellValue(cell));
+						break;
+					case 8:
+						in.setBoutique(Integer.valueOf(FileUtils.getCellValue(cell)));
+						break;
+					case 9:
+						in.setIsHot(Integer.valueOf(FileUtils.getCellValue(cell)));
 						break;
 					}
 			    	} catch (Exception e) {
 			    		throw new BusinessException(new Error("表格第"+(rowNum+1)+"行输入内容不正确。"));
 					}
 		        }
-		        in.setTechBrokerId(TokenManager.getAdminId());
+		        in.setDeletedSign(DeleteStatus.UNDELETE.getCode());
+		        in.setOrgId(TokenManager.getAdminId());
+		        in.setOwnerId(TokenManager.getAdminId());
 		        in.setCreateTime(date);
 		        in.setStatus(0);
-		        in.setReleaseStatus(0);
+		        in.setReleaseStatus(AchievementAuditStatus.CREATE.getCode());
 		        in.setAuditStatus(0);
 		        in.setId(UUID.randomUUID().toString());
-		        System.out.println(in.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++) {
+		        	AchievementKeyword ak = new AchievementKeyword();
+					ak.setId(UUID.randomUUID().toString());
+					ak.setAchievementId(in.getId());
+					ak.setKeyword(keywords[j].trim());
+					keyword.add(ak);
+					}
+				}
+				
+				AchievementPublish ap = null;
+				List<String> webpages = new ArrayList<>();
+				webpages.add("web_achievement_main");
+				webpages.add("web_index");
+				webpages.add("web_achievement_list");
+				for(String page: webpages){
+						ap = new AchievementPublish();
+						ap.setId(UUID.randomUUID().toString());
+						ap.setAchievementId((in.getId()));
+						ap.setPublisher(TokenManager.getUserId());
+						ap.setPublisher("1");
+						ap.setPublishTime(date);
+						ap.setPublishClient(PageConstants.WEB_PLATFORM);
+						ap.setPublishPage(page);
+						ap.setPublishPlatform(defaultPlatformId);
+						ap.setIfTop(AFTConstants.NO);
+						ap.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
+						ap.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
+						publish.add(ap);
+				}
+				AchievementPublish ap2 = new AchievementPublish();
+				ap2.setId(UUID.randomUUID().toString());
+				ap2.setAchievementId(in.getId());
+				ap2.setPublisher(TokenManager.getUserId());
+				ap2.setPublishTime(date);
+				ap2.setPublishClient(PageConstants.APP_PLATFORM);
+				ap2.setPublishPage("ap2p_achievement_list");
+				ap2.setPublishPlatform(defaultPlatformId);
+				ap2.setIfTop(AFTConstants.NO);
+				ap2.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
+				ap2.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
+				publish.add(ap2);
+		        
    		}
+   		achievementMapper.insertBatch(list);
+   		achievementKeywordMapper.insertBatch(keyword);
+		achievementPublishMapper.insertBatch(publish);
        }
 	 
-		public static String getCellValue(Cell cell){
-     	String cellValue = "";
-     	if(cell == null){
-     		return cellValue;
-     	}
-     	        //把数字当成String来读,避免出现1读成1.0的情况
-     	        if(cell.getCellTypeEnum() == CellType.NUMERIC){
-     	        cell.setCellType(CellType.STRING);
-     	        }
-     	        //判断数据的类型
-     	        switch (cell.getCellTypeEnum()){
-     	        case NUMERIC: //数字
-     	        cellValue = String.valueOf(cell.getNumericCellValue());
-     	        break;
-     	        case STRING: //字符串
-     	        cellValue = String.valueOf(cell.getStringCellValue());
-     	        break;
-     	        case BOOLEAN: //Boolean
-     	        cellValue = String.valueOf(cell.getBooleanCellValue());
-     	        break;
-     	        case FORMULA: //公式
-     	        cellValue = String.valueOf(cell.getCellFormula());
-     	        break;
-     	        case BLANK: //空值
-     	        cellValue = "";
-     	        break;
-     	        case ERROR: //故障
-     	        cellValue = "非法字符";
-     	        break;
-     	        default:
-     	        cellValue = "未知类型";
-     	        break;
-     	        }
-     	        return cellValue;
-	}
+		
 	 
 
 }

+ 12 - 0
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -440,6 +440,18 @@ public class AdminApiController extends CertifyApiController {
 		return res;
 	}
 	
+	//管理员修改用户图片
+		@RequestMapping(value="/updatePictureUrl", method = RequestMethod.GET)
+		public Result updatePictureUrl(String uid,String url){
+			Result res = new Result();
+			if (StringUtils.isBlank(uid)||StringUtils.isBlank(url)) {
+				res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"",""));
+				return res;
+			}
+			res.setData(userService.updatePictureUrl(uid, url));
+			return res;
+		}
+	
 	
 	
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/AchievementPublishMapper.java

@@ -101,4 +101,6 @@ public interface AchievementPublishMapper {
 	List<String>getPublishPagesById(String id);
 
 	int deleteByAchievementId(String id);
+
+	void insertBatch(List<AchievementPublish> publish);
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/DemandPublishMapper.java

@@ -81,4 +81,6 @@ public interface DemandPublishMapper {
 	int batchDeleteByDemandIds(List<String> id);
 
 	int deleteByDemandId(String id);
+
+	void insertBatch(List<DemandPublish> publish);
 }

+ 4 - 3
src/main/java/com/goafanti/common/mapper/AchievementMapper.xml

@@ -820,8 +820,8 @@
   
    <insert id="insertBatch" parameterType="com.goafanti.common.model.Achievement">
     insert into achievement
-    	(id, deleted_sign, audit_status, 
-    	 create_time, release_status, data_category,
+    	(id, deleted_sign, audit_status, patent_case,parameter,owner_id,
+    	 create_time, release_status, data_category,info_sources,
     	 name, keyword, category,
     	 owner_name, owner_type, owner_id_number,
     	 owner_mobile, owner_email, owner_postal_address,
@@ -831,8 +831,9 @@
     <foreach item="item" index="index" collection="list" separator=",">
       (
       	#{item.id,jdbcType=VARCHAR}, #{item.deletedSign,jdbcType=INTEGER}, #{item.auditStatus,jdbcType=INTEGER}, 
+      	#{item.patentCase,jdbcType=LONGVARCHAR}, #{item.parameter,jdbcType=LONGVARCHAR},#{item.ownerId,jdbcType=VARCHAR},
       	#{item.createTime,jdbcType=TIMESTAMP}, #{item.releaseStatus,jdbcType=INTEGER}, #{item.dataCategory,jdbcType=INTEGER},
-      	#{item.name,jdbcType=VARCHAR}, #{item.keyword,jdbcType=VARCHAR}, #{item.category,jdbcType=INTEGER},
+      	#{item.infoSources,jdbcType=INTEGER},#{item.name,jdbcType=VARCHAR}, #{item.keyword,jdbcType=VARCHAR}, #{item.category,jdbcType=INTEGER},
       	#{item.ownerName,jdbcType=VARCHAR}, #{item.ownerType,jdbcType=VARCHAR}, #{item.ownerIdNumber,jdbcType=VARCHAR},
       	#{item.ownerMobile,jdbcType=VARCHAR}, #{item.ownerEmail,jdbcType=VARCHAR}, #{item.ownerPostalAddress,jdbcType=VARCHAR},
       	#{item.cooperationMode,jdbcType=INTEGER}, #{item.introduction,jdbcType=LONGVARCHAR},#{item.techBrokerId,jdbcType=VARCHAR},

+ 14 - 0
src/main/java/com/goafanti/common/mapper/AchievementPublishMapper.xml

@@ -451,4 +451,18 @@ where 1=1
 	 select publish_page from achievement_publish ap
 	 where ap.achievement_id = #{id}
 	 </select>
+	 
+	 <insert id="insertBatch" parameterType="com.goafanti.common.model.AchievementPublish">
+	  insert into achievement_publish (id, achievement_id, publish_platform, 
+      publish_client, publish_page, if_top, 
+      top_number, show_number, publisher, 
+      publish_time)
+    	values
+      <foreach item="item" index="index" collection="list" separator=",">
+    	 (#{item.id,jdbcType=VARCHAR}, #{item.achievementId,jdbcType=VARCHAR}, #{item.publishPlatform,jdbcType=INTEGER}, 
+      #{item.publishClient,jdbcType=INTEGER}, #{item.publishPage,jdbcType=VARCHAR}, #{item.ifTop,jdbcType=INTEGER}, 
+      #{item.topNumber,jdbcType=INTEGER}, #{item.showNumber,jdbcType=INTEGER}, #{item.publisher,jdbcType=VARCHAR}, 
+      #{item.publishTime,jdbcType=TIMESTAMP})
+      </foreach>
+	 </insert>
 </mapper>

+ 6 - 4
src/main/java/com/goafanti/common/mapper/DemandMapper.xml

@@ -671,18 +671,20 @@
     insert into demand 
     	(id, deleted_sign, audit_status, 
     	status, release_status, create_time, 
-    	keyword, data_category, name,
+    	keyword, data_category, name,employer_id,
     	demand_type, problem_des, employer_name,
-    	employer_contacts, employer_contacts_mobile, employer_contacts_mailbox, info_sources,tech_broker_id,remark,urgent_days ,urgent_money,is_hot)
+    	employer_contacts, employer_contacts_mobile, 
+    	employer_contacts_mailbox, info_sources,tech_broker_id,remark,urgent_days ,urgent_money,is_hot)
     values 
     <foreach item="item" index="index" collection="list" separator=",">
       (
       	#{item.id,jdbcType=VARCHAR}, #{item.deletedSign,jdbcType=INTEGER}, #{item.auditStatus,jdbcType=INTEGER},
       	#{item.status,jdbcType=INTEGER}, #{item.releaseStatus,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP},
-      	#{item.keyword,jdbcType=VARCHAR}, #{item.dataCategory,jdbcType=INTEGER}, #{item.name,jdbcType=VARCHAR},
+      	#{item.keyword,jdbcType=VARCHAR}, #{item.dataCategory,jdbcType=INTEGER}, #{item.name,jdbcType=VARCHAR},#{item.employerId,jdbcType=VARCHAR},
       	#{item.demandType,jdbcType=INTEGER}, #{item.problemDes,jdbcType=VARCHAR}, #{item.employerName,jdbcType=VARCHAR},
       	#{item.employerContacts,jdbcType=VARCHAR}, #{item.employerContactsMobile,jdbcType=VARCHAR}, #{item.employerContactsMailbox,jdbcType=VARCHAR},
-      	#{item.infoSources,jdbcType=INTEGER},#{item.techBrokerId,jdbcType=VARCHAR},#{item.remark,jdbcType=VARCHAR},,#{item.urgentDays,jdbcType=VARCHAR},#{item.urgentMoney,jdbcType=VARCHAR},#{isHot,jdbcType=INTEGER}
+      	#{item.infoSources,jdbcType=INTEGER},#{item.techBrokerId,jdbcType=VARCHAR},#{item.remark,jdbcType=VARCHAR},#{item.urgentDays,jdbcType=VARCHAR},
+      	#{item.urgentMoney,jdbcType=VARCHAR},#{item.isHot,jdbcType=INTEGER}
       )
     </foreach>
   </insert>

+ 14 - 0
src/main/java/com/goafanti/common/mapper/DemandPublishMapper.xml

@@ -452,4 +452,18 @@ where 1=1
 	  <delete id="deleteByDemandId" parameterType="java.lang.String">
 	 	delete from demand_publish where demand_id = #{demandId,jdbcType=VARCHAR}
 	 </delete>
+	 
+	<insert id="insertBatch" parameterType="com.goafanti.common.model.DemandPublish">
+    insert into demand_publish (id, demand_id, publish_platform, 
+      publish_client, publish_page, if_top, 
+      top_number, show_number, publisher, 
+      publish_time)
+    values
+    <foreach item="item" index="index" collection="list" separator=",">
+     (#{item.id,jdbcType=VARCHAR}, #{item.demandId,jdbcType=VARCHAR}, #{item.publishPlatform,jdbcType=VARCHAR}, 
+      #{item.publishClient,jdbcType=INTEGER}, #{item.publishPage,jdbcType=VARCHAR}, #{item.ifTop,jdbcType=INTEGER}, 
+      #{item.topNumber,jdbcType=INTEGER}, #{item.showNumber,jdbcType=INTEGER}, #{item.publisher,jdbcType=VARCHAR}, 
+      #{item.publishTime,jdbcType=TIMESTAMP})
+      </foreach>
+  </insert>
 </mapper>

+ 36 - 0
src/main/java/com/goafanti/common/utils/FileUtils.java

@@ -303,5 +303,41 @@ public class FileUtils {
 	       }
 	       return sheet;
 	}
+	
+	public static String getCellValue(Cell cell){
+     	String cellValue = "";
+     	if(cell == null){
+     		return cellValue;
+     	}
+     	        //把数字当成String来读,避免出现1读成1.0的情况
+     	        if(cell.getCellTypeEnum() == CellType.NUMERIC){
+     	        cell.setCellType(CellType.STRING);
+     	        }
+     	        //判断数据的类型
+     	        switch (cell.getCellTypeEnum()){
+     	        case NUMERIC: //数字
+     	        cellValue = String.valueOf(cell.getNumericCellValue());
+     	        break;
+     	        case STRING: //字符串
+     	        cellValue = String.valueOf(cell.getStringCellValue());
+     	        break;
+     	        case BOOLEAN: //Boolean
+     	        cellValue = String.valueOf(cell.getBooleanCellValue());
+     	        break;
+     	        case FORMULA: //公式
+     	        cellValue = String.valueOf(cell.getCellFormula());
+     	        break;
+     	        case BLANK: //空值
+     	        cellValue = "";
+     	        break;
+     	        case ERROR: //故障
+     	        cellValue = "非法字符";
+     	        break;
+     	        default:
+     	        cellValue = "未知类型";
+     	        break;
+     	        }
+     	        return cellValue;
+	}
 
 }

+ 43 - 10
src/main/java/com/goafanti/demand/controller/UserDemandApiController.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.AFTConstants;
@@ -300,9 +301,6 @@ public class UserDemandApiController extends CertifyApiController {
 	@RequestMapping(value = "/uploadTextFile", method = RequestMethod.POST)
 	public Result uploadTextFile(HttpServletRequest req, String sign) {
 		Result res = new Result();
-
-		AttachmentType attachmentType = AttachmentType.getField(sign);
-
 		/*if (attachmentType == AttachmentType.DEMAND_TEXT_FILE) {
 			res.setData(handleFiles(res, "/demand/", false, req, sign, TokenManager.getUserId()));
 		} else {
@@ -338,13 +336,6 @@ public class UserDemandApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求名称", "需求名称"));
 			return res;
 		}
-
-		/*if (!DemandDataCategory.USERDEMAND.getCode().equals(demand.getDataCategory())
-				&& !DemandDataCategory.ORGDEMAND.getCode().equals(demand.getDataCategory())) {
-			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "数据类型"));
-			return res;
-		}*/
-
 		if (StringUtils.isBlank(demand.getKeyword())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到关键词", "关键词"));
 			return res;
@@ -379,4 +370,46 @@ public class UserDemandApiController extends CertifyApiController {
 
 		return res;
 	}
+    /**
+     * 下载技术需求批量导入Excel模板
+     * 
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
+    public Result downloadTemplateFile(HttpServletResponse response, String sign) {
+        Result res = new Result();
+        AttachmentType attachmentType = AttachmentType.getField(sign);
+        if (attachmentType == AttachmentType.DEMAND_TEMPLATE) {
+                String path = "/tmp/demand_template.xls";
+                String suffix = path.substring(path.lastIndexOf("."));
+                String fileName = AttachmentType.DEMAND_TEMPLATE.getDesc() + suffix;
+                downloadFile(response, fileName, path);
+        } else {
+            res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
+        }
+        return res;
+    }
+    
+    
+    /**
+     * 批量导入科技成果
+     */
+    @RequestMapping(value = "/importDemand", method = RequestMethod.POST)
+    public Result importTemplate(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request) {
+    	Result res=new Result();
+    	//判断文件是否存在
+        if(null == file){
+      	  res.getError().add(buildError("文件不存在!","文件不存在!"));
+      	  return res;
+        }
+    	String fileName = file.getOriginalFilename();
+    	if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) {
+        	  res.getError().add(buildError("格式不正确","格式不正确"));
+        	  return res;
+          }
+    	demandService.batchSaveDemand(file);
+         res.data(1); 
+    	return res;
+    }
 }

+ 4 - 0
src/main/java/com/goafanti/demand/service/DemandService.java

@@ -2,6 +2,8 @@ package com.goafanti.demand.service;
 
 import java.util.List;
 
+import org.springframework.web.multipart.MultipartFile;
+
 import com.goafanti.common.bo.MyCollection;
 import com.goafanti.common.model.Demand;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -89,5 +91,7 @@ public interface DemandService {
 	Pagination<MyCollection> myCollectionDemand(Integer pageNo, Integer pageSize);
 
 	int addJtCollectSearch(Demand d);
+
+	void batchSaveDemand(MultipartFile file);
 	
 }

+ 132 - 12
src/main/java/com/goafanti/demand/service/impl/DemandServiceImpl.java

@@ -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);
+       }
 	
 	
 	}

+ 2 - 0
src/main/java/com/goafanti/user/service/UserService.java

@@ -77,5 +77,7 @@ public interface UserService {
 	boolean checkeToInviteCode(String beInviteCode);
 
 	Pagination<User> selectOrganizationList(User user, Integer pageNo, Integer pageSize);
+
+	int updatePictureUrl(String uid, String url);
 	
 }

+ 8 - 0
src/main/java/com/goafanti/user/service/impl/UserServiceImpl.java

@@ -327,4 +327,12 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 		
 		return  (Pagination<User>) findPage("selectOrganizationList", "selectOrganizationCount", params, pageNo, pageSize);
 	}
+
+	@Override
+	public int updatePictureUrl(String uid, String url) {
+		User u=new User();
+		u.setId(uid);
+		u.setHeadPortraitUrl(url);
+		return userMapper.updateByPrimaryKeySelective(u);
+	}
 }