|
@@ -1,5 +1,8 @@
|
|
|
package com.goafanti.evaluation.controller;
|
|
package com.goafanti.evaluation.controller;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
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.core.shiro.token.TokenManager;
|
|
|
import com.goafanti.evaluation.bo.Step1;
|
|
import com.goafanti.evaluation.bo.Step1;
|
|
|
import com.goafanti.evaluation.bo.Step2;
|
|
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;
|
|
import com.goafanti.evaluation.service.ValueEvaluationService;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@@ -55,6 +61,20 @@ public class EvaluationController extends BaseApiController {
|
|
|
return valueEvaluationService.getMyEvaluationSteps(Long.valueOf(id));
|
|
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)
|
|
@RequestMapping(value = "/step1", method = RequestMethod.POST)
|
|
|
public Result step1(String id, @Valid Step1 data, BindingResult bindingResult) {
|
|
public Result step1(String id, @Valid Step1 data, BindingResult bindingResult) {
|
|
|
Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
|
|
Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
|
|
@@ -72,7 +92,7 @@ public class EvaluationController extends BaseApiController {
|
|
|
res.data(valueEvaluationService.update(ve));
|
|
res.data(valueEvaluationService.update(ve));
|
|
|
return res;
|
|
return res;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@RequestMapping(value = "/step2", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/step2", method = RequestMethod.POST)
|
|
|
public Result step2(String id, @Valid Step2 data, BindingResult bindingResult) {
|
|
public Result step2(String id, @Valid Step2 data, BindingResult bindingResult) {
|
|
|
Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
|
|
Assert.isTrue(StringUtils.isNumeric(id), ErrorConstants.EVALUATE_ID);
|
|
@@ -80,14 +100,53 @@ public class EvaluationController extends BaseApiController {
|
|
|
if (handleBindingError(res, bindingResult)) {
|
|
if (handleBindingError(res, bindingResult)) {
|
|
|
return res;
|
|
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));
|
|
ValueEvaluation ve = valueEvaluationService.getEvaluation(Long.valueOf(id));
|
|
|
Assert.notNull(ve, ErrorConstants.EVALUATE_ID);
|
|
Assert.notNull(ve, ErrorConstants.EVALUATE_ID);
|
|
|
- ve.setStep(2);
|
|
|
|
|
|
|
+ ve.setStep(Math.max(nextStep, ve.getStep()));
|
|
|
JSONObject jo = JSON.parseObject(ve.getLog());
|
|
JSONObject jo = JSON.parseObject(ve.getLog());
|
|
|
- jo.put("1", data);
|
|
|
|
|
|
|
+ jo.put(key, step);
|
|
|
ve.setLog(jo.toJSONString());
|
|
ve.setLog(jo.toJSONString());
|
|
|
res.data(valueEvaluationService.update(ve));
|
|
res.data(valueEvaluationService.update(ve));
|
|
|
- return res;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean handleBindingError(Result res, BindingResult bindingResult) {
|
|
private boolean handleBindingError(Result res, BindingResult bindingResult) {
|