| | |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.date.DateTime; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ltkj.common.core.domain.TreeSelect; |
| | | import com.ltkj.common.core.domain.entity.SysDept; |
| | | import com.ltkj.hosp.domain.TjSurveyOptions; |
| | | import com.ltkj.hosp.domain.TjSurveyQuestion; |
| | | import com.ltkj.hosp.domain.TjSurveyTempQues; |
| | | import com.ltkj.hosp.service.ITjSurveyQuestionService; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.system.service.ISysDeptService; |
| | | import com.ltkj.tduck.domain.UserFormEntity; |
| | | import com.ltkj.tduck.enums.FormSourceTypeEnum; |
| | | import com.ltkj.tduck.enums.FormStatusEnum; |
| | | import com.ltkj.tduck.service.UserFormService; |
| | | import com.ltkj.tduck.utils.ShortIdUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | |
| | | @Autowired |
| | | private ITjSurveyQuestionService tjSurveyQuestionService; |
| | | @Autowired |
| | | private ISysConfigService configService; |
| | | |
| | | @Autowired |
| | | private UserFormService formService; |
| | | |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | |
| | | /** |
| | | * 判断是否开启填鸭表单设计 |
| | | */ |
| | | @ApiOperation(value = "判断是否开启填鸭表单设计") |
| | | @GetMapping(value = "/needDesign") |
| | | public AjaxResult needDesign() { |
| | | final String call = configService.selectConfigByKey("need_design"); |
| | | return AjaxResult.success(call); |
| | | } |
| | | |
| | | /** |
| | | * 判断该模板是否可删除 |
| | | */ |
| | | @ApiOperation(value = "判断该模板是否可删除") |
| | | @GetMapping(value = "/canDelete") |
| | | public AjaxResult canDelete(Long id) { |
| | | // List<FwdPlanInfoVo> fwdPlanInfoVos = fwdSqlMapper.canDelete(id); |
| | | // if (fwdPlanInfoVos!=null && fwdPlanInfoVos.size()>0){ |
| | | // return AjaxResult.success(false); |
| | | // } |
| | | return AjaxResult.success(false); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询问卷模板列表 |
| | |
| | | return success(tjSurveyTemplateService.selectTjSurveyTemplateByMid(mid)); |
| | | } |
| | | |
| | | /** |
| | | * 获取问卷模板 |
| | | */ |
| | | // /** |
| | | // * 获取问卷模板 |
| | | // */ |
| | | // @GetMapping("/getQuesByMid") |
| | | // @ApiOperation(value = "获取问卷模板信息") |
| | | // public AjaxResult getQuesByMid(@RequestParam Long mid) { |
| | | // List<TjSurveyQuestion> l1=new ArrayList<>(); |
| | | // TjSurveyTemplate byId = tjSurveyTemplateService.selectTjSurveyTemplateByMid(mid); |
| | | // List<TjSurveyTempQues> tjSurveyTempQuesList = byId.getTjSurveyTempQuesList(); |
| | | // if (tjSurveyTempQuesList!=null){ |
| | | // for (TjSurveyTempQues tjSurveyTempQues : tjSurveyTempQuesList) { |
| | | // TjSurveyQuestion byId1 = tjSurveyQuestionService.selectTjSurveyQuestionByQid(tjSurveyTempQues.getQid()); |
| | | // if (byId1!=null){ |
| | | // l1.add(byId1); |
| | | // } |
| | | // } |
| | | // return AjaxResult.success(l1); |
| | | // } |
| | | // return AjaxResult.success("暂无信息"); |
| | | // } |
| | | |
| | | @GetMapping("/getQuesByMid") |
| | | @ApiOperation(value = "获取问卷模板信息") |
| | | public AjaxResult getQuesByMid(@RequestParam Long mid) { |
| | | List<TjSurveyQuestion> l1=new ArrayList<>(); |
| | | TjSurveyTemplate byId = tjSurveyTemplateService.selectTjSurveyTemplateByMid(mid); |
| | | List<TjSurveyTempQues> tjSurveyTempQuesList = byId.getTjSurveyTempQuesList(); |
| | | if (tjSurveyTempQuesList!=null){ |
| | | for (TjSurveyTempQues tjSurveyTempQues : tjSurveyTempQuesList) { |
| | | TjSurveyQuestion byId1 = tjSurveyQuestionService.selectTjSurveyQuestionByQid(tjSurveyTempQues.getQid()); |
| | | if (byId1!=null){ |
| | | l1.add(byId1); |
| | | } |
| | | TjSurveyTemplate byId = tjSurveyTemplateService.selectTemplateByMid1(Long.valueOf(mid)); |
| | | if(null !=byId){ |
| | | if ("1".equals(byId.getQybz())){ |
| | | return AjaxResult.success("该问卷模板不存在或已停用"); |
| | | } |
| | | return AjaxResult.success(l1); |
| | | //判断是否有问题 |
| | | if(byId.getDesignId()!=null){ |
| | | return AjaxResult.success(byId.getDesignId()); |
| | | } |
| | | LambdaQueryWrapper<TjSurveyQuestion> wq1=new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjSurveyQuestion::getMid,byId.getMid()); |
| | | final List<TjSurveyQuestion> list1 = tjSurveyQuestionService.list(wq1); |
| | | for (TjSurveyQuestion tjSurveyQuestion : list1) { |
| | | final List<TjSurveyOptions> tjSurveyOptions = tjSurveyQuestionService.selectOptionsByQid(tjSurveyQuestion.getQid()); |
| | | tjSurveyQuestion.setTjSurveyOptionsList(tjSurveyOptions); |
| | | } |
| | | return AjaxResult.success(list1); |
| | | |
| | | } |
| | | return AjaxResult.success("暂无信息"); |
| | | |
| | | |
| | | // List<TjSurveyQuestion> l11=new ArrayList<>(); |
| | | // TjSurveyTemplate byId1 = tjSurveyTemplateService.selectTjSurveyTemplateByMid(mid); |
| | | // List<TjSurveyTempQues> tjSurveyTempQuesList = byId1.getTjSurveyTempQuesList(); |
| | | // if (tjSurveyTempQuesList!=null){ |
| | | // for (TjSurveyTempQues tjSurveyTempQues : tjSurveyTempQuesList) { |
| | | // TjSurveyQuestion byId11 = tjSurveyQuestionService.selectTjSurveyQuestionByQid(tjSurveyTempQues.getQid()); |
| | | // if (byId11!=null){ |
| | | // l11.add(byId11); |
| | | // } |
| | | // } |
| | | // return AjaxResult.success(l11); |
| | | // } |
| | | // return AjaxResult.success("暂无信息"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增问卷模板 |
| | |
| | | @Log(title = "问卷模板", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody TjSurveyTemplate tjSurveyTemplate) { |
| | | return toAjax(tjSurveyTemplateService.insertTjSurveyTemplate(tjSurveyTemplate)); |
| | | // return toAjax(tjSurveyTemplateService.insertTjSurveyTemplate(tjSurveyTemplate)); |
| | | final String call = configService.selectConfigByKey("need_design"); |
| | | //判断是否开启填鸭表单设计 |
| | | if ("true".equals(call)){ |
| | | UserFormEntity form=new UserFormEntity(); |
| | | form.setFormKey(ShortIdUtils.genId()); |
| | | form.setName("<h2 style=\"text-align: center;\">"+tjSurveyTemplate.getTempName()+"</h2>"); |
| | | form.setStatus(1); |
| | | form.setSourceType(1); |
| | | form.setCreateTime(new DateTime()); |
| | | form.setType("1"); |
| | | form.setDeleted(false); |
| | | final boolean save = formService.save(form); |
| | | if (save){ |
| | | tjSurveyTemplate.setDesignId(form.getFormKey()); |
| | | final int i = tjSurveyTemplateService.insertTjSurveyTemplate(tjSurveyTemplate); |
| | | if (i==1) { |
| | | return AjaxResult.success(form); |
| | | } |
| | | } |
| | | }else{ |
| | | final int i = tjSurveyTemplateService.insertTjSurveyTemplate(tjSurveyTemplate); |
| | | if (i==1) { |
| | | return AjaxResult.success(false); |
| | | } |
| | | } |
| | | return AjaxResult.success(false); |
| | | } |
| | | |
| | | @GetMapping("/getQuestionsByMid") |
| | | public Map<String, Object> getQuestionsByMid(@RequestParam("mid") Long mid, |
| | | @RequestParam(required = false) String question, |
| | | @RequestParam("pageNum") int pageNum, |
| | | @RequestParam("pageSize") int pageSize) { |
| | | Map<String, Object> res = new HashMap<>(); |
| | | System.out.println(); |
| | | // List<TjSurveyQuestion> list = tjSurveyTemplateService.getQuestionsByMid(mid); |
| | | LambdaQueryWrapper<TjSurveyQuestion> wq1=new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjSurveyQuestion::getMid,mid); |
| | | if(null !=question && !question.equals("")){ |
| | | wq1.like(TjSurveyQuestion::getQuestion,question); |
| | | } |
| | | final List<TjSurveyQuestion> list = tjSurveyQuestionService.list(wq1); |
| | | |
| | | int start = 0, end = 0; |
| | | start = (pageNum - 1) * pageSize; |
| | | end = start + pageSize; |
| | | end = Math.min(list.size(), end); |
| | | List<TjSurveyQuestion> result = new ArrayList<>(); |
| | | for (int i = start; i < end; i++) { |
| | | result.add(list.get(i)); |
| | | } |
| | | final TjSurveyTemplate byId = tjSurveyTemplateService.selectTemplateByMid1(mid); |
| | | for (TjSurveyQuestion tjSurveyQuestion : result) { |
| | | tjSurveyQuestion.setTemplate(byId); |
| | | final List<TjSurveyOptions> tjSurveyOptions = tjSurveyQuestionService.selectOptionsByQid(tjSurveyQuestion.getQid()); |
| | | tjSurveyQuestion.setTjSurveyOptionsList(tjSurveyOptions); |
| | | } |
| | | res.put("data", result); |
| | | // res.put("temp", tjSurveyTemplateService.selectTjSurveyTemplateByMid(mid)); |
| | | res.put("total", list.size()); |
| | | return res; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询问卷模板列表 |
| | | */ |
| | | @GetMapping("/listByDeptId") |
| | | public AjaxResult listByDeptId(SysDept dept) { |
| | | List<TreeSelect> treeSelects =deptService.selectDeptList1(dept); |
| | | return AjaxResult.success(treeSelects); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改问卷模板 |
| | |
| | | public AjaxResult remove(@PathVariable Long[] mids) { |
| | | return toAjax(tjSurveyTemplateService.deleteTjSurveyTemplateByMids(mids)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 问卷启用禁用 |
| | | */ |
| | | @GetMapping("/updateQybz") |
| | | @ApiOperation(value = "问卷启用禁用") |
| | | public AjaxResult updateQybz(@RequestParam Long mid,@RequestParam String qybz) { |
| | | final TjSurveyTemplate byId = tjSurveyTemplateService.selectTemplateByMid1(mid); |
| | | byId.setQybz(qybz); |
| | | if ("0".equals(qybz) && tjSurveyTemplateService.qybzTjSurveyTemplateByQy(byId.getMid())==1){ |
| | | return AjaxResult.success("启用成功!"); |
| | | }else if ("1".equals(qybz) && tjSurveyTemplateService.qybzTjSurveyTemplateByJy(byId.getMid())==1){ |
| | | return AjaxResult.success("禁用成功!"); |
| | | }else { |
| | | return AjaxResult.error("出错了,请联系工作人员!"); |
| | | } |
| | | |
| | | } |
| | | } |