Antiloveg 8 years ago
parent
commit
7cbaee462f

+ 0 - 15
src/main/java/com/goafanti/admin/controller/AdminAuditApiController.java

@@ -33,21 +33,6 @@ public class AdminAuditApiController extends CertifyApiController {
 		return res;
 	}
 
-	/**
-	 * 审核员--需求详情技术经纪人
-	 */
-	@RequestMapping(value = "/techBroder", method = RequestMethod.GET)
-	public Result demandDetail(String id) {
-		Result res = new Result();
-
-		if (StringUtils.isBlank(id)) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
-			return res;
-		}
-
-		res.setData(demandService.selectByPrimaryKey(id).getTechBrokerId());
-		return res;
-	}
 
 	/**
 	 * 审核员--审核科技需求

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

@@ -612,7 +612,8 @@
 	  oi.unit_name as username, d.demand_type as demandType, d.validity_period as validityPeriod, 
 	  d.employer_name as employerName, oi.licence_province as province, d.status, 
 	  d.release_status as releaseStatus, d.release_date as releaseDate, a.name as techBrokerId,
-	  d.employer_id as employerId, d.audit_status as auditStatus
+	  d.employer_id as employerId, d.audit_status as auditStatus,
+	  d.tech_broker_id as techBrokerId
 	from  demand d 
 	LEFT JOIN organization_identity oi on d.employer_id = oi.uid
 	LEFT JOIN admin a on a.id = d.tech_broker_id
@@ -771,7 +772,8 @@
   		d.picture_url as pictureUrl, d.text_file_url as textFileUrl, d.video_url as videoUrl,
   		d.budget_cost as budgetCost, d.fixed_cycle as fixedCycle, d.people_number as peopleNumber,
   		d.fixed_scheme as fixedScheme, d.cost_escrow as costEscrow, d.employer_id as employerId,
-  		oi.postal_address as address, u.email as mailbox,  d.contacts, d.audit_status as auditStatus
+  		oi.postal_address as address, u.email as mailbox,  d.contacts, d.audit_status as auditStatus,
+  		d.tech_broker_id as techBrokerId
   	from demand d 
   	left join organization_identity oi on oi.uid = d.employer_id
   	left join user u on u.id = d.employer_id

+ 23 - 5
src/main/java/com/goafanti/demand/controller/DemandApiController.java

@@ -76,7 +76,7 @@ public class DemandApiController extends CertifyApiController{
 		Demand d = new Demand();
 		BeanUtils.copyProperties(demand, d);
 		d.setEmployerId(TokenManager.getUserId());
-		demandService.saveUserDemand(d, validityPeriodFormattedDate);
+		demandService.saveDemand(d, validityPeriodFormattedDate);
 		return res;
 	}
 	
@@ -143,6 +143,28 @@ public class DemandApiController extends CertifyApiController{
 	}
 	
 	/**
+	 * 需求撤消发布(下架)
+	 */
+	@RequestMapping(value = "/offShelf", method = RequestMethod.POST)
+	public Result offShelf(String id){
+		Result res = new Result();
+		if (StringUtils.isBlank(id)){
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
+			return res;
+		}
+		
+		Demand d = demandService.selectByPrimaryKey(id);
+		
+		if (null == d){
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
+			return res;
+		}
+		
+		res.setData(demandService.updateReleaseStatus(d));
+		return res;
+	}
+	
+	/**
 	 * 删除需求(个人&团体)
 	 */
 	@RequestMapping(value = "/delete", method = RequestMethod.POST)
@@ -247,10 +269,6 @@ public class DemandApiController extends CertifyApiController{
 			return res;
 		}
 
-		if (null == demand.getReleaseStatus()) {
-			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到是否发布", "是否发布"));
-			return res;
-		}
 
 		return res;
 	}

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

@@ -41,4 +41,6 @@ public interface DemandService {
 
 	int updateAuditDemand(Demand d, String techBroderId, Integer auditStatus);
 
+	void saveDemand(Demand d, String validityPeriodFormattedDate);
+
 }

+ 70 - 39
src/main/java/com/goafanti/demand/service/impl/DemandServiceImpl.java

@@ -49,10 +49,10 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<DemandManageListBo> selectUserDemandManageList(Integer auditStatus, String province, Integer serialNumber, String name,
-			String keyword, Integer infoSources, Integer demandType, String validityPeriodStartDate,
-			String validityPeriodEndDate, String username, Integer status, Integer releaseStatus,
-			String releaseDateStartDate, String releaseDateEndDate, Integer pNo, Integer pSize) {
+	public Pagination<DemandManageListBo> selectUserDemandManageList(Integer auditStatus, String province,
+			Integer serialNumber, String name, String keyword, Integer infoSources, Integer demandType,
+			String validityPeriodStartDate, String validityPeriodEndDate, String username, Integer status,
+			Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate, Integer pNo, Integer pSize) {
 		Map<String, Object> params = new HashMap<>();
 		Date vStart = null;
 		Date vEnd = null;
@@ -102,8 +102,8 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 		if (null != rEnd) {
 			params.put("rEnd", rEnd);
 		}
-		
-		if (null != auditStatus){
+
+		if (null != auditStatus) {
 			params.put("auditStatus", auditStatus);
 		}
 
@@ -158,8 +158,8 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 		if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
 			params.put("mid", TokenManager.getAdminId());
 		}
-		
-		if (TokenManager.hasRole(AFTConstants.TECHBROKER)){
+
+		if (TokenManager.hasRole(AFTConstants.TECHBROKER)) {
 			params.put("techBroker", TokenManager.getAdminId());
 		}
 
@@ -170,10 +170,10 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<DemandManageListBo> selectOrgDemandManageList(Integer auditStatus, String province, Integer serialNumber, String name,
-			String keyword, Integer infoSources, Integer demandType, String validityPeriodStartDate,
-			String validityPeriodEndDate, String username, Integer status, Integer releaseStatus,
-			String releaseDateStartDate, String releaseDateEndDate, Integer pNo, Integer pSize) {
+	public Pagination<DemandManageListBo> selectOrgDemandManageList(Integer auditStatus, String province,
+			Integer serialNumber, String name, String keyword, Integer infoSources, Integer demandType,
+			String validityPeriodStartDate, String validityPeriodEndDate, String username, Integer status,
+			Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate, Integer pNo, Integer pSize) {
 		Map<String, Object> params = new HashMap<>();
 		Date vStart = null;
 		Date vEnd = null;
@@ -223,8 +223,8 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 		if (null != rEnd) {
 			params.put("rEnd", rEnd);
 		}
-		
-		if (null != auditStatus){
+
+		if (null != auditStatus) {
 			params.put("auditStatus", auditStatus);
 		}
 
@@ -279,8 +279,8 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 		if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
 			params.put("mid", TokenManager.getAdminId());
 		}
-		
-		if (TokenManager.hasRole(AFTConstants.TECHBROKER)){
+
+		if (TokenManager.hasRole(AFTConstants.TECHBROKER)) {
 			params.put("techBroker", TokenManager.getAdminId());
 		}
 
@@ -331,7 +331,6 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 		}
 		d.setValidityPeriod(validityPeriod);
 
-		
 		if (DemandAuditStatus.SUBMIT.getCode().equals(d.getAuditStatus())) {
 			d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
 			d.setReleaseStatus(DemandReleaseStatus.RELEASED.getCode());
@@ -452,6 +451,60 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 		return (Pagination<DemandListBo>) findPage("findDemandListByPage", "findDemandCount", params, pNo, pSize);
 	}
 
+	@Override
+	public int updateReleaseStatus(Demand d) {
+		d.setAuditStatus(DemandAuditStatus.CREATE.getCode());
+		d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
+		d.setStatus(DemandStatus.UNRESOLVED.getCode());
+		demandMapper.updateReleaseDate(d.getId());
+		return demandMapper.updateByPrimaryKeySelective(d);
+	}
+
+	@Override
+	public int updateAuditDemand(Demand d, String techBroderId, Integer auditStatus) {
+		d.setAuditStatus(auditStatus);
+		if (DemandAuditStatus.AUDITED.getCode().equals(auditStatus)) {
+			Calendar now = Calendar.getInstance();
+			now.set(Calendar.MILLISECOND, 0);
+			d.setReleaseDate(now.getTime());
+		} else {
+			d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
+		}
+		return demandMapper.updateByPrimaryKeySelective(d);
+	}
+
+	@Override
+	public void saveDemand(Demand d, String validityPeriodFormattedDate) {
+		Date validityPeriod = null;
+		if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
+			try {
+				validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
+			} catch (ParseException e) {
+			}
+		}
+
+		d.setValidityPeriod(validityPeriod);
+		d.setId(UUID.randomUUID().toString());
+
+		d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
+
+		Calendar now = Calendar.getInstance();
+		now.set(Calendar.MILLISECOND, 0);
+		d.setStatus(DemandStatus.UNRESOLVED.getCode());
+		d.setAuditStatus(DemandAuditStatus.CREATE.getCode());
+		d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
+
+		if (DemandAuditStatus.SUBMIT.getCode().equals(d.getAuditStatus())) {
+			d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
+			d.setReleaseStatus(DemandReleaseStatus.RELEASED.getCode());
+			createAuditorNotice(d);
+		}
+
+		d.setCreateTime(now.getTime());
+		demandMapper.insert(d);
+
+	}
+
 	// 给所有审核员发送审核通知
 	private void createAuditorNotice(Demand d) {
 		List<String> ids = userRoleMapper.listAuditor();
@@ -481,26 +534,4 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 			}
 		}
 	}
-
-	@Override
-	public int updateReleaseStatus(Demand d) {
-		d.setAuditStatus(DemandAuditStatus.CREATE.getCode());
-		d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
-		d.setStatus(DemandStatus.UNRESOLVED.getCode());
-		demandMapper.updateReleaseDate(d.getId());
-		return demandMapper.updateByPrimaryKeySelective(d);
-	}
-
-	@Override
-	public int updateAuditDemand(Demand d, String techBroderId, Integer auditStatus) {
-		d.setAuditStatus(auditStatus);
-		if (DemandAuditStatus.AUDITED.getCode().equals(auditStatus)){
-			Calendar now = Calendar.getInstance();
-			now.set(Calendar.MILLISECOND, 0);
-			d.setReleaseDate(now.getTime());
-		} else {
-			d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
-		}
-		return demandMapper.updateByPrimaryKeySelective(d);
-	}
 }