|
|
@@ -20,13 +20,13 @@ import com.cyksj.service.mange.form.FormService;
|
|
|
import com.cyksj.service.mange.form.QuestionnairePromotionService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
+import com.ejlchina.searcher.util.MapBuilder;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/*
|
|
|
@@ -131,7 +131,21 @@ public class FormController {
|
|
|
* 用户问卷回答列表
|
|
|
*/
|
|
|
@GetMapping("/get/question/resp/data")
|
|
|
- public Result<SearchResult<FormFieldsDataView>> getData(Long promotionId, Long fieldsId) {
|
|
|
+ public Result<SearchResult<FormFieldsDataView>> getData(Long promotionId, Long fieldsId, Long startTime, Long endTime) {
|
|
|
+ DateTime startDate = null;
|
|
|
+ DateTime endDate = null;
|
|
|
+ if (startTime != null) {
|
|
|
+ startDate = DateUtil.date(startTime);
|
|
|
+ }
|
|
|
+ if (endTime != null) {
|
|
|
+ endDate = DateUtil.date(endTime);
|
|
|
+ }
|
|
|
+ if (startDate == null) {
|
|
|
+ startDate = DateUtil.beginOfDay(DateTime.now());
|
|
|
+ }
|
|
|
+ if (endDate == null) {
|
|
|
+ endDate = DateUtil.offsetDay(startDate, 1);
|
|
|
+ }
|
|
|
if (promotionId != null) {
|
|
|
QuestionnairePromotion byId = promotionService.getById(promotionId);
|
|
|
if (byId == null) throw BusinessRuntimeException.getInstance("问卷不存在");
|
|
|
@@ -143,9 +157,19 @@ public class FormController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- SearchResult<FormFieldsDataView> search = beanSearcher.search(FormFieldsDataView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
- .field(FormFieldsDataView::getFieldsId, fieldsId)
|
|
|
- .build());
|
|
|
+ String timeSql = StrUtil.EMPTY;
|
|
|
+ if (startDate != null) {
|
|
|
+ timeSql += String.format(" and fa.created_time >= '%s'", startDate);
|
|
|
+ }
|
|
|
+ if (endDate != null) {
|
|
|
+ timeSql += String.format(" and fa.created_time < '%s'", endDate);
|
|
|
+ }
|
|
|
+ MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap())
|
|
|
+ .field(FormFieldsDataView::getFieldsId, fieldsId);
|
|
|
+ if (StrUtil.isNotBlank(timeSql)) {
|
|
|
+ builder.put("time_sql", timeSql);
|
|
|
+ }
|
|
|
+ SearchResult<FormFieldsDataView> search = beanSearcher.search(FormFieldsDataView.class, builder.build());
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
}
|
|
|
|
|
|
@@ -153,19 +177,21 @@ public class FormController {
|
|
|
* @param promotionId
|
|
|
*/
|
|
|
@GetMapping("/export/question/resp/data")
|
|
|
- public void exportQuestionInfo(@RequestParam(required = false, defaultValue = "1") Long promotionId, String start, String end, String charset, HttpServletResponse response) throws Exception {
|
|
|
- if (StrUtil.isNotBlank(start)) {
|
|
|
- start = DateUtil.formatDate(new Date(Long.parseLong(start))) + " 00:00:00";
|
|
|
+ public void exportQuestionInfo(@RequestParam(required = false, defaultValue = "1") Long promotionId, Long startTime, Long endTime, String charset, HttpServletResponse response) throws Exception {
|
|
|
+ DateTime startDate = null;
|
|
|
+ DateTime endDate = null;
|
|
|
+ if (startTime != null) {
|
|
|
+ startDate = DateUtil.date(startTime);
|
|
|
}
|
|
|
- if (StrUtil.isNotBlank(end)) {
|
|
|
- end = DateUtil.formatDate(new Date(Long.parseLong(end))) + " 23:59:59";
|
|
|
+ if (endTime != null) {
|
|
|
+ endDate = DateUtil.date(endTime);
|
|
|
}
|
|
|
- if (StrUtil.isBlank(start)) {
|
|
|
- start = DateUtil.beginOfDay(DateTime.now()).toString();
|
|
|
+ if (startDate == null) {
|
|
|
+ startDate = DateUtil.beginOfDay(DateTime.now());
|
|
|
}
|
|
|
- if (StrUtil.isBlank(end)) {
|
|
|
- start = DateUtil.endOfDay(DateTime.now()).toString();
|
|
|
+ if (endDate == null) {
|
|
|
+ endDate = DateUtil.offsetDay(startDate, 1);
|
|
|
}
|
|
|
- formService.exportQuestionInfo(promotionId, start, end, response);
|
|
|
+ formService.exportQuestionInfo(promotionId, startDate, endDate, response);
|
|
|
}
|
|
|
}
|