package com.ltkj.web.controller.system;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletResponse;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.ltkj.common.core.domain.entity.SysDept;
|
import com.ltkj.common.core.redis.RedisCache;
|
import com.ltkj.framework.config.MatchUtils;
|
import com.ltkj.hosp.domain.*;
|
import com.ltkj.hosp.service.*;
|
import com.ltkj.system.service.ISysConfigService;
|
import com.ltkj.system.service.ISysDeptService;
|
import com.ltkj.system.service.ISysUserService;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.web.bind.annotation.*;
|
import com.ltkj.common.annotation.Log;
|
import com.ltkj.common.core.controller.BaseController;
|
import com.ltkj.common.core.domain.AjaxResult;
|
import com.ltkj.common.enums.BusinessType;
|
import com.ltkj.common.utils.poi.ExcelUtil;
|
import com.ltkj.common.core.page.TableDataInfo;
|
|
/**
|
* 问卷记录Controller
|
*
|
* @author ltkj_赵佳豪&李格
|
* @date 2023-04-07
|
*/
|
@RestController
|
@RequestMapping("/hosp/surveyRecord")
|
public class TjSurveyRecordController extends BaseController {
|
@Resource
|
private ITjSurveyRecordService tjSurveyRecordService;
|
@Resource
|
private TjSurveyRecordDetailService tjSurveyRecordDetailService;
|
@Resource
|
private ITjCustomerService tjCustomerService;
|
@Resource
|
private ITjOrderService tjOrderService;
|
|
|
/**
|
* 查询问卷记录列表
|
*/
|
@GetMapping("/list")
|
public TableDataInfo list(TjSurveyRecord tjSurveyRecord) {
|
startPage();
|
List<TjSurveyRecord> list = tjSurveyRecordService.selectTjSurveyRecordList(tjSurveyRecord);
|
if(null !=list && list.size()>0){
|
for (TjSurveyRecord record : list) {
|
record.setUserName(MatchUtils.hideCusName(record.getUserName()));
|
record.setPhone(MatchUtils.hidePhoneNum(record.getPhone()));
|
}
|
}
|
return getDataTable(list);
|
}
|
//
|
// /**
|
// * 导出问卷记录列表
|
// */
|
// @Log(title = "问卷记录", businessType = BusinessType.EXPORT)
|
// @PostMapping("/export")
|
// public void export(HttpServletResponse response, TjSurveyRecord tjSurveyRecord) {
|
// List<TjSurveyRecord> list = tjSurveyRecordService.selectTjSurveyRecordList(tjSurveyRecord);
|
// ExcelUtil<TjSurveyRecord> util = new ExcelUtil<TjSurveyRecord>(TjSurveyRecord.class);
|
// util.exportExcel(response, list, "问卷记录数据");
|
// }
|
|
/**
|
* 获取问卷记录详细信息
|
*/
|
@GetMapping(value = "/{rid}")
|
public AjaxResult getInfo(@PathVariable("rid") Long rid) {
|
return success(tjSurveyRecordService.selectTjSurveyRecordByRid(rid));
|
}
|
|
|
/**
|
* 小程序判断是否填写过问卷(0未填1已填)
|
*/
|
@GetMapping("/appSurveyByIdCard")
|
@ApiOperation(value = "小程序判断是否填写过问卷(0未填1已填)")
|
public AjaxResult appSurveyByIdCard(@RequestParam @ApiParam(value = "tjNumber") String tjNumber) {
|
LambdaQueryWrapper<TjSurveyRecord> wqqq = new LambdaQueryWrapper<>();
|
wqqq.eq(TjSurveyRecord::getTjnumber, tjNumber);
|
List<TjSurveyRecord> byId = tjSurveyRecordService.list(wqqq);
|
if (byId != null) {
|
if (byId.size() > 0) {
|
return AjaxResult.success(1);
|
} else {
|
return AjaxResult.success(0);
|
}
|
}
|
return AjaxResult.success(0);
|
|
}
|
|
/**
|
* 小程序端问卷查询记录
|
*/
|
@GetMapping("/appGetTiJian")
|
@ApiOperation(value = "小程序端问卷查询记录")
|
public AjaxResult appGetTiJian(@RequestParam @ApiParam(value = "cusIdCard") String cusIdCard) {
|
Map<String, Object> res = new HashMap<>();
|
LambdaQueryWrapper<TjCustomer> wqqq = new LambdaQueryWrapper<>();
|
wqqq.eq(TjCustomer::getCusIdcard, cusIdCard);
|
TjCustomer one1 = tjCustomerService.getOne(wqqq);
|
if (one1 == null) {
|
return AjaxResult.error("查无此人");
|
}
|
LambdaQueryWrapper<TjOrder> wq0 = new LambdaQueryWrapper<>();
|
wq0.eq(TjOrder::getUserId, one1.getCusId());
|
List<TjOrder> tjOrders = tjOrderService.list(wq0);
|
|
if (tjOrders != null && tjOrders.size() > 0) {
|
for (TjOrder tjOrder : tjOrders) {
|
if (tjOrder.getFinishTime() != null) {
|
tjOrder.setTjFinishStatus("已完成");
|
} else {
|
tjOrder.setTjFinishStatus("未完成");
|
}
|
}
|
}
|
res.put("tjOrders", tjOrders);
|
res.put("customer", one1);
|
return AjaxResult.success(res);
|
}
|
|
/**
|
* 新增问卷记录
|
*/
|
@ApiOperation(value = "新增问卷记录")
|
@Log(title = "问卷记录", businessType = BusinessType.INSERT)
|
@PostMapping
|
public AjaxResult add(@RequestBody List<TjSurveyRecord> tjSurveyRecord) {
|
if (tjSurveyRecord != null && tjSurveyRecord.size() > 0) {
|
List<TjSurveyRecord> a = new ArrayList<>();
|
//先放第一个
|
a.add(tjSurveyRecord.get(0));
|
//对集合进行遍历 如果集合的问题id和第一个id一样
|
for (int i = 1; i < tjSurveyRecord.size(); i++) {
|
if (a.size()<=1){
|
continue;
|
}
|
if ((tjSurveyRecord.get(i)).getQid().equals((a.get(i - 1)).getQid())) {
|
a.get(i - 1).getTjSurveyRecordDetailList().add((tjSurveyRecord.get(i).getTjSurveyRecordDetailList()).get(0));
|
} else {
|
a.add(tjSurveyRecord.get(i));
|
}
|
}
|
for (TjSurveyRecord surveyRecord : a) {
|
tjSurveyRecordService.save(surveyRecord);
|
List<TjSurveyRecordDetail> recordDetailList = surveyRecord.getTjSurveyRecordDetailList();
|
if (null != recordDetailList && recordDetailList.size() > 0) {
|
tjSurveyRecordDetailService.saveBatch(recordDetailList);
|
}
|
}
|
}
|
return AjaxResult.success();
|
}
|
//
|
// /**
|
// * 修改问卷记录
|
// */
|
// @Log(title = "问卷记录", businessType = BusinessType.UPDATE)
|
// @PutMapping
|
// public AjaxResult edit(@RequestBody TjSurveyRecord tjSurveyRecord) {
|
// return toAjax(tjSurveyRecordService.updateTjSurveyRecord(tjSurveyRecord));
|
// }
|
//
|
// /**
|
// * 删除问卷记录
|
// */
|
// @Log(title = "问卷记录", businessType = BusinessType.DELETE)
|
// @DeleteMapping("/{rids}")
|
// public AjaxResult remove(@PathVariable Long[] rids) {
|
// return toAjax(tjSurveyRecordService.deleteTjSurveyRecordByRids(rids));
|
// }
|
}
|