albertshaw лет назад: 8
Родитель
Сommit
ecec550349

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

@@ -18,4 +18,6 @@ public interface ValueEvaluationMapper {
     int updateByPrimaryKey(ValueEvaluation record);
 
 	ValueEvaluation selectByPrimaryKeyAndUser(Map<String, Object> params);
+	
+	int deleteRecords(Map<String, Object> params);
 }

+ 11 - 0
src/main/java/com/goafanti/common/mapper/ValueEvaluationMapper.xml

@@ -150,4 +150,15 @@
     </if>
   </select>
   
+  <delete id="deleteRecords" parameterType="java.lang.Long">
+    delete from value_evaluation
+    where
+    id in 
+    <foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
+		#{item,jdbcType=BIGINT}
+	</foreach>
+    <if test="uid != null">
+    	and uid = #{uid,jdbcType=VARCHAR}
+    </if>
+  </delete>
 </mapper>

+ 13 - 0
src/main/java/com/goafanti/evaluation/bo/Step1.java

@@ -1,6 +1,7 @@
 package com.goafanti.evaluation.bo;
 
 import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
 import javax.validation.constraints.Size;
 
 public class Step1 {
@@ -30,6 +31,10 @@ public class Step1 {
 	@Size(max = 36)
 	private String	currencyType;
 
+	@NotNull
+	@Pattern(regexp = "\\d{4}-\\d{2}-\\d{2}")
+	private String	benchmarkDate;
+
 	public String getName() {
 		return name;
 	}
@@ -86,4 +91,12 @@ public class Step1 {
 		this.currencyType = currencyType;
 	}
 
+	public String getBenchmarkDate() {
+		return benchmarkDate;
+	}
+
+	public void setBenchmarkDate(String benchmarkDate) {
+		this.benchmarkDate = benchmarkDate;
+	}
+
 }

+ 128 - 0
src/main/java/com/goafanti/evaluation/bo/Step3.java

@@ -0,0 +1,128 @@
+package com.goafanti.evaluation.bo;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.NotNull;
+
+public class Step3 {
+	@NotNull
+	@Max(value = 7)
+	private Integer	progressiveness;
+	
+	@NotNull
+	@Max(value = 7)
+	private Integer	innovativeness;
+	
+	@NotNull
+	@Max(value = 7)
+	private Integer	ripeness;
+	
+	@NotNull
+	@Max(value = 7)
+	private Integer	alternatives;
+	
+	@NotNull
+	@Max(value = 7)
+	private Integer	defensive;
+	
+	@NotNull
+	@Max(value = 7)
+	private Integer	prospect;
+	
+	@NotNull
+	@Max(value = 7)
+	private Integer	supplyAndDemand;
+	
+	@NotNull
+	@Max(value = 7)
+	private Integer	rangeOfApplication;
+	
+	@NotNull
+	@Max(value = 7)
+	private Integer	imitable;
+	
+	@NotNull
+	@Max(value = 7)
+	private Integer	profitability;
+
+	public Integer getProgressiveness() {
+		return progressiveness;
+	}
+
+	public void setProgressiveness(Integer progressiveness) {
+		this.progressiveness = progressiveness;
+	}
+
+	public Integer getInnovativeness() {
+		return innovativeness;
+	}
+
+	public void setInnovativeness(Integer innovativeness) {
+		this.innovativeness = innovativeness;
+	}
+
+	public Integer getRipeness() {
+		return ripeness;
+	}
+
+	public void setRipeness(Integer ripeness) {
+		this.ripeness = ripeness;
+	}
+
+	public Integer getAlternatives() {
+		return alternatives;
+	}
+
+	public void setAlternatives(Integer alternatives) {
+		this.alternatives = alternatives;
+	}
+
+	public Integer getDefensive() {
+		return defensive;
+	}
+
+	public void setDefensive(Integer defensive) {
+		this.defensive = defensive;
+	}
+
+	public Integer getProspect() {
+		return prospect;
+	}
+
+	public void setProspect(Integer prospect) {
+		this.prospect = prospect;
+	}
+
+	public Integer getSupplyAndDemand() {
+		return supplyAndDemand;
+	}
+
+	public void setSupplyAndDemand(Integer supplyAndDemand) {
+		this.supplyAndDemand = supplyAndDemand;
+	}
+
+	public Integer getRangeOfApplication() {
+		return rangeOfApplication;
+	}
+
+	public void setRangeOfApplication(Integer rangeOfApplication) {
+		this.rangeOfApplication = rangeOfApplication;
+	}
+
+	public Integer getImitable() {
+		return imitable;
+	}
+
+	public void setImitable(Integer imitable) {
+		this.imitable = imitable;
+	}
+
+	public Integer getProfitability() {
+		return profitability;
+	}
+
+	public void setProfitability(Integer profitability) {
+		this.profitability = profitability;
+	}
+	
+	
+}

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

@@ -0,0 +1,25 @@
+package com.goafanti.evaluation.bo;
+
+import java.util.List;
+
+public class Step4 {
+	private Integer				hasIncome;
+	private List<YearIncome>	incomes;
+
+	public Integer getHasIncome() {
+		return hasIncome;
+	}
+
+	public void setHasIncome(Integer hasIncome) {
+		this.hasIncome = hasIncome;
+	}
+
+	public List<YearIncome> getIncomes() {
+		return incomes;
+	}
+
+	public void setIncomes(List<YearIncome> incomes) {
+		this.incomes = incomes;
+	}
+
+}

+ 32 - 0
src/main/java/com/goafanti/evaluation/bo/YearIncome.java

@@ -0,0 +1,32 @@
+package com.goafanti.evaluation.bo;
+
+public class YearIncome {
+	private Integer	year;
+	private Long	income;
+	private Integer	profit;
+
+	public Integer getYear() {
+		return year;
+	}
+
+	public void setYear(Integer year) {
+		this.year = year;
+	}
+
+	public Long getIncome() {
+		return income;
+	}
+
+	public void setIncome(Long income) {
+		this.income = income;
+	}
+
+	public Integer getProfit() {
+		return profit;
+	}
+
+	public void setProfit(Integer profit) {
+		this.profit = profit;
+	}
+
+}

+ 63 - 4
src/main/java/com/goafanti/evaluation/controller/EvaluationController.java

@@ -1,5 +1,8 @@
 package com.goafanti.evaluation.controller;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import javax.validation.Valid;
 
 import org.apache.commons.lang3.StringUtils;
@@ -23,6 +26,9 @@ import com.goafanti.common.utils.LoggerUtils;
 import com.goafanti.core.shiro.token.TokenManager;
 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.YearIncome;
 import com.goafanti.evaluation.service.ValueEvaluationService;
 
 @RestController
@@ -55,6 +61,20 @@ public class EvaluationController extends BaseApiController {
 		return valueEvaluationService.getMyEvaluationSteps(Long.valueOf(id));
 	}
 
+	@RequestMapping(value = "/remove", method = RequestMethod.POST)
+	public Result remove(String ids) {
+		Assert.isTrue(StringUtils.isNotBlank(ids), ErrorConstants.EVALUATE_PARAM);
+		Result res = new Result();
+		List<Long> idList = new ArrayList<>();
+		String[] idArr = ids.split(",");
+		for (String id : idArr) {
+			Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_PARAM);
+			idList.add(Long.valueOf(id));
+		}
+		res.data(valueEvaluationService.deleteMySteps(idList));
+		return res;
+	}
+
 	@RequestMapping(value = "/step1", method = RequestMethod.POST)
 	public Result step1(String id, @Valid Step1 data, BindingResult bindingResult) {
 		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
@@ -72,7 +92,7 @@ public class EvaluationController extends BaseApiController {
 		res.data(valueEvaluationService.update(ve));
 		return res;
 	}
-	
+
 	@RequestMapping(value = "/step2", method = RequestMethod.POST)
 	public Result step2(String id, @Valid Step2 data, BindingResult bindingResult) {
 		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
@@ -80,14 +100,53 @@ public class EvaluationController extends BaseApiController {
 		if (handleBindingError(res, bindingResult)) {
 			return res;
 		}
+		updateSteps(data, 2, "1", res, id);
+		return res;
+	}
+
+	@RequestMapping(value = "/step3", method = RequestMethod.POST)
+	public Result step3(String id, @Valid Step3 data, BindingResult bindingResult) {
+		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
+		Result res = new Result();
+		if (handleBindingError(res, bindingResult)) {
+			return res;
+		}
+		updateSteps(data, 3, "2", res, id);
+		return res;
+	}
+
+	@RequestMapping(value = "/step4", method = RequestMethod.POST)
+	public Result step4(String id, String hasIncome, String incomes) {
+		Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
+		Result res = new Result();
+		Step4 step = new Step4();
+		try {
+			step.setHasIncome(Integer.valueOf(hasIncome));
+			if (step.getHasIncome().equals(2)) {
+				List<YearIncome> ja = JSON.parseArray(incomes, YearIncome.class);
+				if (ja.size() != 3) {
+					res.error(buildError(ErrorConstants.EVALUATE_PARAM));
+				} else {
+					step.setIncomes(ja);
+				}
+			}
+		} catch (Exception e) {
+			res.error(buildError(ErrorConstants.EVALUATE_PARAM));
+		}
+		if (res.getError().isEmpty()) {
+			updateSteps(step, 4, "3", res, id);
+		}
+		return res;
+	}
+
+	private void updateSteps(Object step, Integer nextStep, String key, Result res, String id) {
 		ValueEvaluation ve = valueEvaluationService.getEvaluation(Long.valueOf(id));
 		Assert.notNull(ve, ErrorConstants.EVALUATE_ID);
-		ve.setStep(2);
+		ve.setStep(Math.max(nextStep, ve.getStep()));
 		JSONObject jo = JSON.parseObject(ve.getLog());
-		jo.put("1", data);
+		jo.put(key, step);
 		ve.setLog(jo.toJSONString());
 		res.data(valueEvaluationService.update(ve));
-		return res;
 	}
 
 	private boolean handleBindingError(Result res, BindingResult bindingResult) {

+ 8 - 0
src/main/java/com/goafanti/evaluation/service/ValueEvaluationService.java

@@ -1,6 +1,7 @@
 package com.goafanti.evaluation.service;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +45,13 @@ public class ValueEvaluationService extends BaseMybatisDao<ValueEvaluationMapper
 		return ve == null ? "{}" : ve.getLog();
 	}
 
+	public int deleteMySteps(List<Long> ids) {
+		Map<String, Object> params = new HashMap<>();
+		params.put("uid", TokenManager.getUserId());
+		params.put("ids", ids);
+		return valueEvaluationMapper.deleteRecords(params);
+	}
+
 	@SuppressWarnings("unchecked")
 	public Pagination<ValueEvaluation> list(Integer pageNo, Integer pageSize) {
 		Map<String, Object> params = new HashMap<>();