Explorar o código

Accept Merge Request #163 merge : (master -> test)

Merge Request: merge
Created By: @Antiloveg
Accepted By: @Antiloveg
URL: https://coding.net/t/aft/p/AFT/git/merge/163
Antiloveg %!s(int64=8) %!d(string=hai) anos
pai
achega
ef19a31534

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

@@ -18,4 +18,6 @@ public interface PatentCostMapper {
     int updateByPrimaryKey(PatentCost record);
 
 	void batchInsert(List<PatentCost> pc);
+
+	int batchUpdateByPrimaryKey(List<PatentCost> list);
 }

+ 10 - 1
src/main/java/com/goafanti/common/mapper/PatentCostMapper.xml

@@ -222,7 +222,7 @@
 		</if>
 	</select>
 	
-	<insert id="batchInsert" parameterType="com.goafanti.common.model.PatentCost">
+ <insert id="batchInsert" parameterType="com.goafanti.common.model.PatentCost">
    insert into patent_cost (id, pid, annual_fee,
 		annual_fee_state, application_fee, trial_fee,
 		printing_fee, funds, reimbursement,
@@ -243,4 +243,13 @@
 	  )
     </foreach>
   </insert>
+  
+  <update id="batchUpdateByPrimaryKey" parameterType="java.util.List">
+		update patent_cost set annual_fee_state = 0
+		where id in
+		<foreach item="item" index="index" collection="list" open="("
+			separator="," close=")">
+			#{item}
+		</foreach>
+	</update>
 </mapper>

+ 48 - 27
src/main/java/com/goafanti/common/task/PatentTask.java

@@ -1,6 +1,7 @@
 package com.goafanti.common.task;
 
 import java.text.ParseException;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
@@ -9,21 +10,33 @@ import javax.annotation.Resource;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
-import org.junit.Test;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import com.aliyuncs.DefaultAcsClient;
+import com.aliyuncs.IAcsClient;
+import com.aliyuncs.exceptions.ClientException;
+import com.aliyuncs.exceptions.ServerException;
+import com.aliyuncs.profile.DefaultProfile;
+import com.aliyuncs.profile.IClientProfile;
+import com.aliyuncs.sms.model.v20160927.SingleSendSmsRequest;
+import com.aliyuncs.sms.model.v20160927.SingleSendSmsResponse;
 import com.goafanti.common.constant.AFTConstants;
+import com.goafanti.common.model.PatentCost;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.common.utils.LoggerUtils;
+import com.goafanti.patent.bo.PatentAnnualFeeTaskBo;
 import com.goafanti.patent.bo.PatentExpireBo;
+import com.goafanti.patent.service.PatentCostService;
 import com.goafanti.patent.service.PatentInfoService;
 
 @Component
 public class PatentTask {
 	@Resource
 	private PatentInfoService	patentInfoService;
+	@Resource
+	private PatentCostService	patentCostService;
 
 	@Value(value = "${accessKey}")
 	private String				accessKey		= null;
@@ -36,57 +49,43 @@ public class PatentTask {
 	private static final String	LEAP_DAY_ADD	= "03-01";
 
 	/**
-	 * "0 0 6 * * ?" 每天上午6点触发一次
+	 * "0 0 0 * * ?" 每天0点触发一次
 	 */
 
 	@Scheduled(cron = "0 0 0 * * ?")
 	public void exprireRun() {
 		LoggerUtils.debug(getClass(), "开始检查专利到期");
+		Calendar now = Calendar.getInstance();
+		disposeExprireRecord(now);// 短信
+		disposeAnnualFee(now);// 年费状态
+	}
+
+	private void disposeExprireRecord(Calendar now) {
 		List<PatentExpireBo> peb = patentInfoService.selectExpireRecord();
 		if (null != peb && peb.size() > 0) {
-			//List<PatentCost> list = new ArrayList<PatentCost>();
 			for (PatentExpireBo p : peb) {
 				String mobile = p.getMobile();
-				Date patentApplicationDate = p.getPatentApplicationDate();
 				if (StringUtils.isNotBlank(mobile) && StringUtils.isNumeric(mobile)
-						&& null != patentApplicationDate) {
-					Calendar now = Calendar.getInstance();
+						&& null != p.getPatentApplicationDate()) {
 					try {
 						if (disposeExprire(p, now)) {
 							//sendMessage(p);
-							return;
 						}
-						
 					} catch (ParseException e) {
 					}
 				}
 			}
-		} 
-		/*List<PatentAnnualFeeTaskBo> af = patentInfoService.findAnnualFeeTaskBo();
-		PatentCost cost = null;*/
-		/*if (disposeExprireDate(patentApplicationDate, now.getTime())){
-			cost = new PatentCost();
-			cost.setId(p.getCostId());
-			cost.setAnnualFeeState(PatentAnnualFeeStatus.);
-		}*/
+		}
 	}
 
-
 	private Boolean disposeExprire(PatentExpireBo peb, Calendar now) throws ParseException {
 		Date addYear = disposeAddYear(peb.getPatentApplicationDate());// 申请日5年后
 		if (addYear.getTime() - now.getTime().getTime() >= 0) {
-			now.add(Calendar.MONTH, +3);//提前三个月
+			now.add(Calendar.MONTH, +3);// 提前三个月
 			return disposeExprireDate(peb.getPatentApplicationDate(), now.getTime());
 		}
 		return Boolean.FALSE;
 	}
-	
-	@Test
-	public void test(){
-		Calendar now = Calendar.getInstance();
-		now.add(Calendar.MONTH, -3);
-		System.out.println(DateFormatUtils.format(now.getTime(), AFTConstants.MMDD));
-	}
 
 	private Boolean disposeExprireDate(Date apd, Date now) {
 		String sApd = DateFormatUtils.format(apd, AFTConstants.MMDD);
@@ -108,7 +107,29 @@ public class PatentTask {
 				+ DateFormatUtils.format(s, AFTConstants.MMDD), AFTConstants.YYYYMMDD);
 	}
 
-	/*private void sendMessage(PatentExpireBo p) {
+	private void disposeAnnualFee(Calendar now) {
+		List<PatentAnnualFeeTaskBo> af = patentInfoService.findAnnualFeeTaskBo();
+		if (af.isEmpty()) {
+			return;
+		}
+		List<PatentCost> list = new ArrayList<>();
+		for (PatentAnnualFeeTaskBo bo : af) {
+			PatentCost cost = null;
+			if (disposeExprireDate(bo.getPatentApplicationDate(), now.getTime())) {
+				cost = new PatentCost();
+				cost.setId(bo.getId());
+				list.add(cost);
+			}
+		}
+		if (list.isEmpty()) {
+			return;
+		}
+		patentCostService.batchUpdateByPrimaryKey(list);
+
+	}
+
+	@SuppressWarnings("unused")
+	private void sendMessage(PatentExpireBo p) {
 		IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKey, accessSecret);
 		try {
 			DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", "Sms", "sms.aliyuncs.com");
@@ -128,6 +149,6 @@ public class PatentTask {
 		} catch (ClientException e) {
 			LoggerUtils.fmtError(getClass(), e, "客户端手机短信异常:%s", e.getMessage());
 		}
-	}*/
+	}
 
 }

+ 50 - 0
src/main/java/com/goafanti/evaluation/bo/ForecastIncome.java

@@ -0,0 +1,50 @@
+package com.goafanti.evaluation.bo;
+
+public class ForecastIncome {
+	private Long	marketScale	= 0l;
+	private Integer	marketRate	= 0;
+	private Long	unitPrice	= 0l;
+	private Long	saleCount	= 0l;
+	private Long	income		= 0l;
+
+	public Long getMarketScale() {
+		return marketScale;
+	}
+
+	public void setMarketScale(Long marketScale) {
+		this.marketScale = marketScale;
+	}
+
+	public Integer getMarketRate() {
+		return marketRate;
+	}
+
+	public void setMarketRate(Integer marketRate) {
+		this.marketRate = marketRate;
+	}
+
+	public Long getUnitPrice() {
+		return unitPrice;
+	}
+
+	public void setUnitPrice(Long unitPrice) {
+		this.unitPrice = unitPrice;
+	}
+
+	public Long getSaleCount() {
+		return saleCount;
+	}
+
+	public void setSaleCount(Long saleCount) {
+		this.saleCount = saleCount;
+	}
+
+	public Long getIncome() {
+		return income;
+	}
+
+	public void setIncome(Long income) {
+		this.income = income;
+	}
+
+}

+ 25 - 0
src/main/java/com/goafanti/evaluation/bo/Step5.java

@@ -0,0 +1,25 @@
+package com.goafanti.evaluation.bo;
+
+import java.util.List;
+
+public class Step5 {
+	private Integer					type;
+	private List<ForecastIncome>	forecastIncomes;
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public List<ForecastIncome> getForecastIncomes() {
+		return forecastIncomes;
+	}
+
+	public void setForecastIncomes(List<ForecastIncome> forecastIncomes) {
+		this.forecastIncomes = forecastIncomes;
+	}
+
+}

+ 17 - 0
src/main/java/com/goafanti/evaluation/bo/Step6.java

@@ -0,0 +1,17 @@
+package com.goafanti.evaluation.bo;
+
+import javax.validation.constraints.NotNull;
+
+public class Step6 {
+	@NotNull
+	private Integer	taxRate;
+
+	public Integer getTaxRate() {
+		return taxRate;
+	}
+
+	public void setTaxRate(Integer taxRate) {
+		this.taxRate = taxRate;
+	}
+	
+}

+ 67 - 0
src/main/java/com/goafanti/evaluation/bo/Step7.java

@@ -0,0 +1,67 @@
+package com.goafanti.evaluation.bo;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.NotNull;
+
+public class Step7 {
+	@NotNull
+	@Max(value = 7)
+	private Integer	political;
+
+	@NotNull
+	@Max(value = 7)
+	private Integer	technical;
+
+	@NotNull
+	@Max(value = 7)
+	private Integer	market;
+
+	@NotNull
+	@Max(value = 7)
+	private Integer	capital;
+
+	@NotNull
+	@Max(value = 7)
+	private Integer	management;
+
+	public Integer getPolitical() {
+		return political;
+	}
+
+	public void setPolitical(Integer political) {
+		this.political = political;
+	}
+
+	public Integer getTechnical() {
+		return technical;
+	}
+
+	public void setTechnical(Integer technical) {
+		this.technical = technical;
+	}
+
+	public Integer getMarket() {
+		return market;
+	}
+
+	public void setMarket(Integer market) {
+		this.market = market;
+	}
+
+	public Integer getCapital() {
+		return capital;
+	}
+
+	public void setCapital(Integer capital) {
+		this.capital = capital;
+	}
+
+	public Integer getManagement() {
+		return management;
+	}
+
+	public void setManagement(Integer management) {
+		this.management = management;
+	}
+	
+}

+ 49 - 0
src/main/java/com/goafanti/evaluation/controller/EvaluationController.java

@@ -29,10 +29,14 @@ import com.goafanti.common.model.ValueEvaluation;
 import com.goafanti.common.service.IndustryCategoryService;
 import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.evaluation.bo.ForecastIncome;
 import com.goafanti.evaluation.bo.Step1;
 import com.goafanti.evaluation.bo.Step2;
 import com.goafanti.evaluation.bo.Step3;
 import com.goafanti.evaluation.bo.Step4;
+import com.goafanti.evaluation.bo.Step5;
+import com.goafanti.evaluation.bo.Step6;
+import com.goafanti.evaluation.bo.Step7;
 import com.goafanti.evaluation.bo.YearIncome;
 import com.goafanti.evaluation.service.ValueEvaluationService;
 
@@ -147,6 +151,29 @@ public class EvaluationController extends BaseApiController {
 		return res;
 	}
 
+	@RequestMapping(value = "/step5", method = RequestMethod.POST)
+	public Result step5(String id, String type, String forecastIncomes) {
+		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
+		Result res = new Result();
+		Step5 step = new Step5();
+		try {
+			step.setType(Integer.valueOf(type));
+			List<ForecastIncome> ja = JSON.parseArray(forecastIncomes, ForecastIncome.class);
+			if (ja.size() != 3) {
+				res.error(buildError(ErrorConstants.EVALUATE_PARAM));
+			} else {
+				step.setForecastIncomes(ja);
+			}
+
+		} catch (Exception e) {
+			res.error(buildError(ErrorConstants.EVALUATE_PARAM));
+		}
+		if (res.getError().isEmpty()) {
+			updateSteps(step, 5, "4", res, id);
+		}
+		return res;
+	}
+
 	@RequestMapping(value = "/step5/{id}", method = RequestMethod.GET)
 	public Result step5Info(@PathVariable String id) {
 		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
@@ -164,6 +191,28 @@ public class EvaluationController extends BaseApiController {
 		}
 		return res;
 	}
+	
+	@RequestMapping(value = "/step6", method = RequestMethod.POST)
+	public Result step6(String id, @Valid Step6 data, BindingResult bindingResult) {
+		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
+		Result res = new Result();
+		if (handleBindingError(res, bindingResult)) {
+			return res;
+		}
+		updateSteps(data, 6, "5", res, id);
+		return res;
+	}
+	
+	@RequestMapping(value = "/step7", method = RequestMethod.POST)
+	public Result step7(String id, @Valid Step7 data, BindingResult bindingResult) {
+		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
+		Result res = new Result();
+		if (handleBindingError(res, bindingResult)) {
+			return res;
+		}
+		updateSteps(data, 7, "6", res, id);
+		return res;
+	}
 
 	private void updateSteps(Object step, Integer nextStep, String key, Result res, String id) {
 		ValueEvaluation ve = valueEvaluationService.getEvaluation(Long.valueOf(id));

+ 4 - 1
src/main/java/com/goafanti/evaluation/service/ValueEvaluationService.java

@@ -34,7 +34,10 @@ public class ValueEvaluationService extends BaseMybatisDao<ValueEvaluationMapper
 	}
 
 	public ValueEvaluation getEvaluation(Long id) {
-		return valueEvaluationMapper.selectByPrimaryKey(id);
+		Map<String, Object> params = new HashMap<>();
+		params.put("uid", TokenManager.getUserId());
+		params.put("id", id);
+		return valueEvaluationMapper.selectByPrimaryKeyAndUser(params);
 	}
 
 	public String getMyEvaluationSteps(Long id) {

+ 3 - 0
src/main/java/com/goafanti/patent/service/PatentCostService.java

@@ -1,6 +1,7 @@
 package com.goafanti.patent.service;
 
 import java.text.ParseException;
+import java.util.List;
 
 import com.goafanti.common.model.PatentCost;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -17,5 +18,7 @@ public interface PatentCostService {
 
 	PatentCost selectByPrimaryKey(String cid);
 
+	int batchUpdateByPrimaryKey(List<PatentCost> list);
+
 
 }

+ 1 - 0
src/main/java/com/goafanti/patent/service/PatentInfoService.java

@@ -58,4 +58,5 @@ public interface PatentInfoService {
 
 	List<PatentAnnualFeeTaskBo> findAnnualFeeTaskBo();
 
+
 }

+ 6 - 0
src/main/java/com/goafanti/patent/service/impl/PatentCostServiceImpl.java

@@ -3,6 +3,7 @@ package com.goafanti.patent.service.impl;
 import java.text.ParseException;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -81,4 +82,9 @@ public class PatentCostServiceImpl extends BaseMybatisDao<PatentCostMapper> impl
 		return patentCostMapper.selectByPrimaryKey(id);
 	}
 
+	@Override
+	public int batchUpdateByPrimaryKey(List<PatentCost> list) {
+		return patentCostMapper.batchUpdateByPrimaryKey(list);
+	}
+
 }

+ 7 - 4
src/main/java/com/goafanti/patent/service/impl/PatentInfoServiceImpl.java

@@ -610,6 +610,11 @@ public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> impl
 		patentCostMapper.batchInsert(pc);
 		patentLogMapper.batchInsert(pl);
 	}
+	
+	@Override
+	public List<PatentAnnualFeeTaskBo> findAnnualFeeTaskBo() {
+		return patentInfoMapper.findAnnualFeeTaskBo();
+	}
 
 	private void createNotice(PatentInfo p, PatentLog l) {
 		PatentInfo info = patentInfoMapper.selectByPrimaryKey(p.getId());
@@ -635,9 +640,7 @@ public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> impl
 		noticeMapper.insert(n);
 	}
 
-	@Override
-	public List<PatentAnnualFeeTaskBo> findAnnualFeeTaskBo() {
-		return patentInfoMapper.findAnnualFeeTaskBo();
-	}
+	
+
 
 }