diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/EduCustomFormApplication.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/EduCustomFormApplication.java new file mode 100644 index 0000000..f748300 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/EduCustomFormApplication.java @@ -0,0 +1,33 @@ +package com.yida.data.customForm; + +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; + +import cc.mrbird.febs.common.security.starter.annotation.EnableFebsCloudResourceServer; +import org.springframework.transaction.annotation.EnableTransactionManagement; + + +/** + * @author wjm + */ +@EnableAsync +@EnableScheduling +@EnableFebsCloudResourceServer +@EnableFeignClients(basePackages = "com.yida.data") +@MapperScan("com.yida.data.customForm.mapper") +@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class) +@EnableTransactionManagement +public class EduCustomFormApplication { + public static void main(String[] args) { + new SpringApplicationBuilder(EduCustomFormApplication.class) + .web(WebApplicationType.SERVLET) + .run(args); + } +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormAuthController.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormAuthController.java new file mode 100644 index 0000000..303bfee --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormAuthController.java @@ -0,0 +1,53 @@ +package com.yida.data.customForm.controller; + +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.customform.CoreCustomFormAuth; +import com.yida.data.customForm.service.CoreCustomFormAuthService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + + +/** + * 表单对应管理员权限表 Controller + * + * @author ccl + * @date 2021-11-05 15:41:13 + */ +@Api(tags = "后台--表单权限") +@Slf4j +@Validated +@RestController +@RequestMapping("coreCustomFormAuth") +@RequiredArgsConstructor +public class CoreCustomFormAuthController { + + private final CoreCustomFormAuthService coreCustomFormAuthService; + + @ApiOperation("新增或修改表单基本权限") + @PostMapping("saveOrUpdateFormAuth") + public ResultBean saveOrUpdateFormAuth (@RequestBody CoreCustomFormAuth formAuth){ + coreCustomFormAuthService.saveOrUpdate(formAuth); + return ResultBean.buildSuccess(); + } + + @ApiOperation("批量删除表单基本权限") + @PostMapping("delFormAuth") + public ResultBean delFormAuth (@RequestBody List authIds){ + coreCustomFormAuthService.removeByIds(authIds); + return ResultBean.buildSuccess(); + } + + @ApiOperation("查询权限列表") + @GetMapping("findFormAuthList") + public ResultBean> findFormAuthList (){ + + return ResultBean.buildSuccess(coreCustomFormAuthService.list()); + } + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormController.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormController.java new file mode 100644 index 0000000..1d5f5f2 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormController.java @@ -0,0 +1,123 @@ +package com.yida.data.customForm.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.customform.CoreCustomForm; +import com.yida.data.common.core.utils.FebsUtil; +import com.yida.data.customForm.service.CoreCustomFormItemChildrenService; +import com.yida.data.customForm.service.CoreCustomFormItemsService; +import com.yida.data.customForm.service.CoreCustomFormService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + + + +/** + * 自定义表单 Controller + * + * @author wjm + * @date 2021-08-11 20:55:19 + */ +@Slf4j +@Validated +@RestController +@RequestMapping("/coreCustomForm") +@RequiredArgsConstructor +@Api(tags = "后台--表单管理") +public class CoreCustomFormController { + + private final CoreCustomFormService coreCustomFormService; + private final CoreCustomFormItemsService coreCustomFormItemsService; + private final CoreCustomFormItemChildrenService coreCustomFormItemChildrenService; + + + /*** + * @Author jianMingWang + * @Description //查询所有表单 + * @Date 14:33 2021/8/9 + * @Param [schoolId] + * @return com.liuliu.data.custom.entity.ResultBean> + **/ + @ApiOperation("表单分页查询") + @GetMapping("/findList") + public ResultBean> fondType(@ApiParam(value = "学校ID", required = true, type = "Long") Long schoolId, + @ApiParam(value = "表单类型ID", required = true, type = "Long") Long formTypeId, + @ApiParam(value = "是否为模板:1=是,0=否", required = false, type = "String") @RequestParam(value = "model", required = false) String model, + @ApiParam(value = "当前页码", required = false, defaultValue = "1", type = "Integer") @RequestParam(defaultValue = "1") Integer pageNum, + @ApiParam(value = "页面大小", required = false, defaultValue = "10", type = "Integer") @RequestParam(defaultValue = "10") Integer pageSize) { + + IPage customFormPageList = coreCustomFormService.findCustomFormPageList(new Page(pageNum, pageSize), + schoolId, formTypeId, model, FebsUtil.getCurrentUser()); + return ResultBean.buildSuccess(customFormPageList); + + } + + + /*** + * @Author jianMingWang + * @Description //获取当前表单 + * @Date 11:22 2021/8/10 + * @Param [schoolId, formTypeId] + * @return com.liuliu.data.custom.entity.ResultBean + **/ + @ApiOperation("表单详情") + @GetMapping("/findById") + public ResultBean findById(@ApiParam(value = "主键ID", required = true, type = "Long") Long id) { + + return ResultBean.buildSuccess(coreCustomFormService.findById(id)); + + } + + + /*** + * @Author jianMingWang + * @Description //删除表单 + * @Date 14:29 2021/8/9 + * @Param [coreCustomForm] + * @return com.liuliu.data.custom.entity.ResultBean + **/ + @ApiOperation("删除表单") + @GetMapping("/delForm") + public ResultBean delForm(@ApiParam(value = "主键ID", required = true, type = "Long") Long formId) { + + coreCustomFormService.delForm(formId); + //删除表单对应附表 + return ResultBean.buildSuccess(); + } + + /*** + * @Author jianMingWang + * @Description 创建、编辑表单 + * @Date 14:29 2021/8/9 + * @Param [coreCustomForm] + * @return com.liuliu.data.custom.entity.ResultBean + **/ + @ApiOperation("创建表单") + @PostMapping("/createForm") + public ResultBean createForm(@RequestBody CoreCustomForm dto) throws Exception { + + Integer state = coreCustomFormService.saveForm(dto); + if (state==1){ + return ResultBean.buildError("已发布的表不能修改"); + } + return ResultBean.buildSuccess(); + } + + @ApiOperation("表单发布") + @GetMapping("/publishForm") + public ResultBean publishForm(@RequestParam Long formId,@ApiParam("1为发布,2为取消发布")@RequestParam Integer status) { + + CoreCustomForm byId = coreCustomFormService.getById(formId); + byId.setStatus(status); + coreCustomFormService.publishForm(byId); + return ResultBean.buildSuccess(); + } + + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormDataController.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormDataController.java new file mode 100644 index 0000000..7058711 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormDataController.java @@ -0,0 +1,155 @@ +package com.yida.data.customForm.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.customform.*; +import com.yida.data.customForm.dto.FormDataInput; +import com.yida.data.customForm.dto.RemindAgainDTO; +import com.yida.data.customForm.entity.FormDataReturn; +import com.yida.data.customForm.service.CoreCustomFormDataService; +import com.yida.data.customForm.service.CoreCustomFormItemChildrenService; +import com.yida.data.customForm.service.CoreCustomFormItemsService; +import com.yida.data.customForm.service.CoreCustomFormService; +import com.yida.data.customForm.vo.CommitUserVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * @ClassName CoreCustomFormDataController + * @Author jianMingWang + * @Date 2021/8/12 16:54 + * @Version 1.0 + **/ +@Slf4j +@Validated +@RestController +@RequestMapping("/coreCustomFormData") +@RequiredArgsConstructor +@Api(tags = "后台--表单数据相关") +public class CoreCustomFormDataController { + + @Autowired + private CoreCustomFormDataService coreCustomFormDataService; + @Autowired + private CoreCustomFormService coreCustomFormService; + @Autowired + private CoreCustomFormItemsService coreCustomFormItemsService; + @Autowired + private CoreCustomFormItemChildrenService coreCustomFormItemChildrenService; + + + /*** + * @Author jianMingWang + * @Description //列表分页查看当前表单数据 + * @Date 17:33 2021/9/16 + * @Param [] + * @return com.yida.data.common.core.common.ResultBean + **/ + @ApiOperation("列表分页查询当前表单数据") + @GetMapping("/findSubmitFromDataListByFormId") + public ResultBean findSubmitFromDataListByFormId(@ApiParam(required = true, value = "表单主键ID") @RequestParam Integer formId, + @ApiParam(required = true, value = "每页条数") @RequestParam(required = true, defaultValue = "10") Integer pageSize, + @ApiParam(required = true, value = "页码") @RequestParam(required = true, defaultValue = "1") Integer pageNo) { + + return ResultBean.buildSuccess(coreCustomFormDataService.findList(formId, pageSize, pageNo)); + + } + + /*** + * @Author jianMingWang + * @Description //导出excel数据 + * @Date 16:40 2021/9/17 + * @return com.yida.data.common.core.common.ResultBean + **/ + @GetMapping("/exportData") + @ApiOperation("导出表单数据") + public void exportData(@ApiParam(value = "表单主键ID", required = true) @RequestParam Integer formId, HttpServletResponse response) { + try { + coreCustomFormDataService.exportData(formId, response); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /*** + * @Author jianMingWang + * @Description //获取当前表单 + * @Date 11:22 2021/8/10 + * @Param [schoolId, formTypeId] + * @return com.liuliu.data.custom.entity.ResultBean + **/ + @ApiOperation("表单详情") + @GetMapping("/findById") + public ResultBean findById(@ApiParam(value = "主键ID", required = true, type = "Long") Long id) { + + CoreCustomForm coreCustomForm = coreCustomFormService.getById(id); + List coreCustomFormItemList = coreCustomFormItemsService.list(Wrappers.query().lambda().eq(CoreCustomFormItems::getFormId, id)); + coreCustomFormItemList.forEach(coreCustomFormItems -> { + List coreCustomFormItemChildrenlist = coreCustomFormItemChildrenService.list(Wrappers.query().lambda().eq(CoreCustomFormItemChildren::getFormItemId, coreCustomFormItems.getId())); + coreCustomFormItems.setCoreCustomFormItemChildrenList(coreCustomFormItemChildrenlist); + }); + coreCustomForm.setCoreCustomFormItemsList(coreCustomFormItemList); + return ResultBean.buildSuccess(coreCustomForm); + + + } + + @GetMapping("commitUser") + @ApiOperation("表单人员列表查询") + public ResultBean commitUser(@ApiParam("表单id") @RequestParam Long formId, + @ApiParam("未提交为0,已提交为1") @RequestParam Integer type, + @ApiParam("名字") @RequestParam(required = false) String name, + @RequestParam(defaultValue = "1") Long pageNum, + @RequestParam(defaultValue = "10") Long pageSize) { + + Page page = new Page<>(); + page.setCurrent(pageNum); + page.setSize(pageSize); + return ResultBean.buildSuccess(coreCustomFormService.commitUser(formId,type,name,page)); + } + + @GetMapping("findCommitUser") + @ApiOperation("已提交人员列表查询") + public ResultBean findCommitUser(@ApiParam("表单id") @RequestParam Long formId, + @ApiParam("0为未提交,1为已提交") @RequestParam(required = false) Integer fillType, + @RequestParam(defaultValue = "1") Long pageNum, + @RequestParam(defaultValue = "10") Long pageSize) { + + Page page = new Page<>(); + page.setCurrent(pageNum); + page.setSize(pageSize); + return ResultBean.buildSuccess(coreCustomFormService.findCommitUser(formId, fillType, page)); + } + + @GetMapping("findStatistic") + @ApiOperation("查询统计数据") + public ResultBean findStatistic(@ApiParam("表单id") @RequestParam Long formId) { + + return ResultBean.buildSuccess(coreCustomFormService.findStatistic(formId)); + } + + @PostMapping("remindAgain") + @ApiOperation("未提交人员再次提醒") + public ResultBean remindAgain(@RequestBody RemindAgainDTO dto) { + + coreCustomFormService.remindAgain(dto); + return ResultBean.buildSuccess(); + } + + @ApiOperation("导出已提交、未提交人员") + @GetMapping("/exportUserListInOut") + public void exportUserListInOut(@ApiParam("表单id") @RequestParam Long formId, @ApiParam("1为已提交,0为未提交") @RequestParam Integer status, HttpServletResponse response) { + coreCustomFormService.exportUserListInOut(formId, status, response); + } + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormGroupController.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormGroupController.java new file mode 100644 index 0000000..4ce242a --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormGroupController.java @@ -0,0 +1,73 @@ +package com.yida.data.customForm.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.customform.CoreCustomForm; +import com.yida.data.common.core.entity.customform.CoreCustomFormGroup; +import com.yida.data.customForm.dto.SaveFormRelationGroupDTO; +import com.yida.data.customForm.service.CoreCustomFormGroupService; +import com.yida.data.customForm.service.CoreCustomFormService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 表单组 Controller + * + * @author ccl + * @date 2021-11-05 15:41:03 + */ +@Slf4j +@Validated +@RestController +@RequestMapping("coreCustomFormGroup") +@RequiredArgsConstructor +@Api(tags = "后台--表单分组") +public class CoreCustomFormGroupController { + + private final CoreCustomFormGroupService formGroupService; + + private final CoreCustomFormService customFormService; + + @GetMapping("findGroupPageList") + @ApiOperation("分页查询表单组") + public ResultBean> findGroupPageList(@RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String groupName){ + + + return ResultBean.buildSuccess(formGroupService.findGroupPageList(pageNum,pageSize,groupName)); + } + + @PostMapping("saveOrUpdateGroup") + @ApiOperation("新增表单组") + public ResultBean saveOrUpdateGroup(@RequestBody CoreCustomFormGroup formGroup){ + formGroupService.saveOrUpdate(formGroup); + return ResultBean.buildSuccess(); + } + + @PostMapping("removeFormGroup") + @ApiOperation("批量删除表单组") + public ResultBean removeFormGroup(@RequestBody List ids){ + formGroupService.removeByIds(ids); + return ResultBean.buildSuccess(); + } + + @GetMapping("updateFormGroup") + @ApiOperation("将表单分到表单组") + public ResultBean updateFormGroup(@RequestParam @ApiParam("表单组id") Long id, + @RequestParam @ApiParam("组 id") Long groupId){ + CoreCustomForm coreCustomForm = new CoreCustomForm(); + coreCustomForm.setId(id); + coreCustomForm.setGroupId(groupId); + customFormService.updateById(coreCustomForm); + return ResultBean.buildSuccess(); + } +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormModelController.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormModelController.java new file mode 100644 index 0000000..e9e7461 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormModelController.java @@ -0,0 +1,43 @@ +package com.yida.data.customForm.controller; + +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.customForm.service.CoreCustomFormModelService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.xml.transform.Result; + +/** + * 自定义表单模板 Controller + * + * @author wjm + * @date 2021-08-30 15:22:15 + */ +@Slf4j +@Validated +@RestController +@RequestMapping("formModel") +@RequiredArgsConstructor +@Api(tags = "后台--表单模板管理") +public class CoreCustomFormModelController { + + private final CoreCustomFormModelService coreCustomFormModelService; + + @GetMapping("/selectFormModel") + @ApiOperation("查询表单模板") + public ResultBean selectFormModel(@RequestParam Long id){ + + return ResultBean.buildSuccess(coreCustomFormModelService.getById(id)); + } + + @GetMapping("/delFormModel") + @ApiOperation("删除表单模板") + public ResultBean delFormModel(@RequestParam Long id){ + coreCustomFormModelService.removeById(id); + return ResultBean.buildSuccess(); + } +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormTypeController.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormTypeController.java new file mode 100644 index 0000000..4bb616e --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/CoreCustomFormTypeController.java @@ -0,0 +1,54 @@ +package com.yida.data.customForm.controller; + +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.FebsResponse; +import com.yida.data.common.core.entity.QueryRequest; +import com.yida.data.common.core.entity.customform.CoreCustomFormType; +import com.yida.data.common.core.exception.FebsException; +import com.yida.data.common.core.utils.FebsUtil; +import com.yida.data.customForm.service.CoreCustomFormTypeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +/** + * 自定义表单类型表 Controller + * + * @author wjm + * @date 2021-08-12 10:56:57 + */ +@Slf4j +@Validated +@RestController +@RequestMapping("/coreCustomFormType") +@RequiredArgsConstructor +@Api(tags = "后台--表单类型") +public class CoreCustomFormTypeController { + + @Autowired + private final CoreCustomFormTypeService coreCustomFormTypeService; + + + @ApiOperation("查询自定义表单类型LIST") + @GetMapping("/findList") + public ResultBean> fondTypeList(){ + List type = coreCustomFormTypeService.list(); + return ResultBean.buildSuccess(type); + } + + @ApiOperation("新增表单类型") + @PostMapping("/insertFormType") + public ResultBean insertFormType(@RequestBody CoreCustomFormType coreCustomFormType){ + coreCustomFormTypeService.save(coreCustomFormType); + return ResultBean.buildSuccess(); + } +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/InCoreCustomFormController.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/InCoreCustomFormController.java new file mode 100644 index 0000000..074abb0 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/InCoreCustomFormController.java @@ -0,0 +1,47 @@ +package com.yida.data.customForm.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.customform.CoreCustomForm; +import com.yida.data.customForm.dto.RemindAgainDTO; +import com.yida.data.customForm.service.CoreCustomFormService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author ccl + */ +@Slf4j +@Validated +@RestController +@RequestMapping("in/coreCustomForm") +@RequiredArgsConstructor +@Api(tags = "不鉴权-表单管理") +public class InCoreCustomFormController { + + private final CoreCustomFormService coreCustomFormService; + + @GetMapping("updateById") + @ApiOperation("修改表单为发布") + public ResultBean updateById(@RequestParam Long id){ + coreCustomFormService.updateAndSendNotice(id); + return ResultBean.buildSuccess(); + } + + @GetMapping("remindLast") + @ApiOperation("距离结束通知") + public ResultBean remindLast(@RequestParam Long id){ + RemindAgainDTO dto = new RemindAgainDTO(); + dto.setFormId(id); + coreCustomFormService.remindAgain(dto); + return ResultBean.buildSuccess(); + } + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/app/AppCustomFormController.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/app/AppCustomFormController.java new file mode 100644 index 0000000..19c8539 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/controller/app/AppCustomFormController.java @@ -0,0 +1,150 @@ +package com.yida.data.customForm.controller.app; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.customform.CoreCustomForm; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUser; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUserParent; +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; +import com.yida.data.common.core.exception.FebsException; +import com.yida.data.customForm.dto.FormDataInput; +import com.yida.data.customForm.service.CoreCustomFormDataService; +import com.yida.data.customForm.service.CoreCustomFormRelationUserParentService; +import com.yida.data.customForm.service.CoreCustomFormRelationUserService; +import com.yida.data.customForm.service.CoreCustomFormService; +import com.yida.data.customForm.vo.FormStudentVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * @author ccl + */ +@Slf4j +@Validated +@RestController +@RequestMapping("/appCustomForm") +@RequiredArgsConstructor +@Api(tags = "app表单--表单管理") +public class AppCustomFormController { + + @Resource + private final CoreCustomFormService formService; + + @Resource + private final CoreCustomFormDataService coreCustomFormDataService; + + @Resource + private final CoreCustomFormRelationUserService userService; + + @Resource + private final CoreCustomFormRelationUserParentService parentService; + + @GetMapping("appFindFormList") + @ApiOperation("app查询填报列表") + public ResultBean> appFindFormList(@ApiParam("用户id") @RequestParam Long userId, + @ApiParam("0为职工,1为学生,2为家长") @RequestParam Integer type, + @ApiParam("学校id") @RequestParam Long schoolId, + @ApiParam("表单名称") @RequestParam(required = false) String tableName, + @ApiParam("表单状态,不传为全查") @RequestParam(required = false) Integer status, + @RequestParam(defaultValue = "10") Long pageSize, + @RequestParam(defaultValue = "1") Long pageNum){ + + return ResultBean.buildSuccess(formService.appFindFormList(new Page(pageNum,pageSize),userId,tableName,status,schoolId,type)); + } + + @GetMapping("appFindAdminFormList") + @ApiOperation("app查询管理列表列表") + public ResultBean> appFindAdminFormList(@ApiParam("用户id") @RequestParam Long userId, + @ApiParam("学校id") @RequestParam Long schoolId, + @ApiParam("表单名称") @RequestParam(required = false) String tableName, + @ApiParam("表单状态,不传为全查") @RequestParam(required = false) Integer status, + @RequestParam(defaultValue = "10") Long pageSize, + @RequestParam(defaultValue = "1") Long pageNum){ + return ResultBean.buildSuccess(formService.appFindAdminFormList(new Page(pageNum,pageSize),userId,tableName,status,schoolId)); + } + + @GetMapping("appHandOnCustomForm") + @ApiOperation("app用户查询用户是否是管理员") + public ResultBean appHandOnCustomForm(@ApiParam("用户id")@RequestParam Long userId, + @ApiParam("学校id")@RequestParam Long schoolId){ + + return ResultBean.buildSuccess(formService.appHandOnCustomForm(userId,schoolId)); + } + + /*** + * @Author jianMingWang + * @Description 提交表单数据 + * @Date 11:28 2021/8/11 + * @Param [formDataInput] + * @return com.liuliu.data.custom.entity.ResultBean + **/ + @ApiOperation("app提交保存表单数据") + @PostMapping("/saveFormData") + public ResultBean saveFormData(@RequestBody FormDataInput formDataInput) { + + CoreCustomForm form = formService.getOne(Wrappers.lambdaQuery(new CoreCustomForm()) + .eq(CoreCustomForm::getTableName, formDataInput.getTableName())); + + //验证用否是否能填报 + List userList = new ArrayList<>(); + List list = userService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, form.getId())); + if (form.getRecever()==2){ + List list1 = new ArrayList<>(); + List parentList = parentService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUserParent()) + .eq(CoreCustomFormRelationUserParent::getCustomFormId, form.getId())); + for (CoreCustomFormRelationUserParent userParent : parentList) { + list1.add(userParent.getParentId()); + } + if (!list1.contains(formDataInput.getUserId())){ + return ResultBean.buildError("您不能填报该表"); + } + }else { + for (CoreCustomFormRelationUser relationUser : list) { + userList.add(relationUser.getUserId()); + } + if (!userList.contains(formDataInput.getUserId())) { + return ResultBean.buildError("您不能填报该表"); + } + } + Map data = coreCustomFormDataService.findData(form.getId(), formDataInput.getUserId()); + if (ObjectUtil.isNotEmpty(data)&&form.getUpdateType()==0){ + return ResultBean.buildError("您已填报,请勿重复填写"); + } + coreCustomFormDataService.saveFormData(formDataInput,data); + return ResultBean.buildSuccess(); + + } + + @GetMapping("appFindFormAndData") + @ApiOperation("app查询表单填报详情") + public ResultBean appFindFormAndData(@ApiParam("用户id")@RequestParam Long userId, + @ApiParam("表单id")@RequestParam Long formId){ + + return ResultBean.buildSuccess(formService.appFindFormAndData(userId,formId)); + } + + @GetMapping("appFindStudentByForm") + @ApiOperation("app查询表单关联的学生列表") + public ResultBean> appFindStudentByForm(@ApiParam("家长id")@RequestParam Long userId, + @ApiParam("表单id")@RequestParam Long formId){ + + return ResultBean.buildSuccess(formService.appFindStudentByForm(userId,formId)); + } +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/entity/FormDataReturn.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/entity/FormDataReturn.java new file mode 100644 index 0000000..a785fdb --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/entity/FormDataReturn.java @@ -0,0 +1,26 @@ +package com.yida.data.customForm.entity; + +import com.yida.data.common.core.entity.customform.CoreCustomFormItems; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName FormDataReturn + * @Author jianMingWang + * @Date 2021/9/17 14:39 + * @Version 1.0 + **/ +@Data +public class FormDataReturn { + private List list; + private Integer total; + private List filedList; + + public FormDataReturn(List list, Integer total, List filedList) { + this.list = list; + this.total = total; + this.filedList = filedList; + } +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/entity/RedisKey.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/entity/RedisKey.java new file mode 100644 index 0000000..0b8db9e --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/entity/RedisKey.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.entity; + +/** + * @ClassName RedisKey + * @Author jianMingWang + * @Date 2021/9/17 13:47 + * @Version 1.0 + **/ +public interface RedisKey { + /** + * 表单主体信息缓存key + */ + String FORM_LOCAL = "form.local."; +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormAuthMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormAuthMapper.java new file mode 100644 index 0000000..709abe2 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormAuthMapper.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormAuth; + +/** + * 表单对应管理员权限表 Mapper + * + * @author ccl + * @date 2021-11-05 15:41:13 + */ +public interface CoreCustomFormAuthMapper extends BaseMapper { + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormAuthRelationFormMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormAuthRelationFormMapper.java new file mode 100644 index 0000000..cc60c03 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormAuthRelationFormMapper.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormAuthRelationForm; + +/** + * 权限对应管理员表 Mapper + * + * @author ccl + * @date 2021-11-05 15:41:15 + */ +public interface CoreCustomFormAuthRelationFormMapper extends BaseMapper { + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormDataMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormDataMapper.java new file mode 100644 index 0000000..f981f79 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormDataMapper.java @@ -0,0 +1,42 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.entity.customform.CoreCustomForm; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 自定义表单 Mapper + * + * @author wjm + * @date 2021-08-11 20:55:19 + */ +public interface CoreCustomFormDataMapper{ + + List findFormFiled(@Param("dbName") String dbName, @Param("tableName") String tableName); + + void initSqlWithParameterReturnVoid(@Param("sql") String sql, @Param("parameterMap") Map parameterMap); + + List initSqlWithNUllReturnListMap(@Param("sql") String sql); + + Integer initSqlWithNUllReturnInteger(@Param("sql") String sql); + + /** + * 查询对应表的数据 + * @param sql + * @return + */ + Map findData(@Param("sql") String sql); + + /** + * 清空数据表 + * @param sql + */ + void truncateTable(@Param("sql") String sql); + + void removeBySql(@Param("sql") String sql); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormGroupMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormGroupMapper.java new file mode 100644 index 0000000..79b4c7d --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormGroupMapper.java @@ -0,0 +1,23 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.entity.customform.CoreCustomFormGroup; +import org.apache.ibatis.annotations.Param; + +/** + * 表单组 Mapper + * + * @author ccl + * @date 2021-11-05 15:41:03 + */ +public interface CoreCustomFormGroupMapper extends BaseMapper { + + /** + * 分页查询组列表并返回组内表name; + * @param objectPage + * @param groupName + * @return + */ + Page findGroupPageList(@Param("objectPage") Page objectPage, @Param("groupName") String groupName); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormItemChildrenMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormItemChildrenMapper.java new file mode 100644 index 0000000..441bc43 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormItemChildrenMapper.java @@ -0,0 +1,17 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormItemChildren; + +import java.util.List; + +/** + * 自定义表单组件 Mapper + * + * @author wjm + * @date 2021-08-12 10:45:22 + */ +public interface CoreCustomFormItemChildrenMapper extends BaseMapper { + + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormItemsMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormItemsMapper.java new file mode 100644 index 0000000..71b8f8d --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormItemsMapper.java @@ -0,0 +1,16 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormItemChildren; +import com.yida.data.common.core.entity.customform.CoreCustomFormItems; + +import java.util.List; + +/** + * 自定义表单组件 Mapper + * + * @author wjm + * @date 2021-08-12 10:44:45 + */ +public interface CoreCustomFormItemsMapper extends BaseMapper { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormMapper.java new file mode 100644 index 0000000..66126a5 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormMapper.java @@ -0,0 +1,57 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.entity.customform.CoreCustomForm; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 自定义表单 Mapper + * + * @author wjm + * @date 2021-08-11 20:55:19 + */ +public interface CoreCustomFormMapper extends BaseMapper { + + IPage findPageList(@Param("page") Page page, @Param("coreCustomForm") CoreCustomForm coreCustomForm); + + Integer initSqlReturnInt(@Param("sql") String sql); + + void initSqlReturnVoid(@Param("sql") String sql); + + + /** + * 查询用户对应填写表单 + * @param page + * @param userId + * @param tableName + * @param status + * @param schoolId + * @return + */ + IPage appFindFormList(@Param("page") Page page, + @Param("userIdList") List userIdList, + @Param("tableName") String tableName, + @Param("status") Integer status, + @Param("schoolId") Long schoolId, + @Param("type") Integer type); + + + /** + * 查询用户对应管理表单 + * @param page + * @param userId + * @param tableName + * @param status + * @param schoolId + * @return + */ + IPage appFindAdminFormList(@Param("page") Page page, + @Param("userId") Long userId, + @Param("tableName") String tableName, + @Param("status") Integer status, + @Param("schoolId") Long schoolId); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormModelItemChildrenMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormModelItemChildrenMapper.java new file mode 100644 index 0000000..a4f40e3 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormModelItemChildrenMapper.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormModelItemChildren; + +/** + * 自定义表单模板组件 Mapper + * + * @author wjm + * @date 2021-08-30 15:22:32 + */ +public interface CoreCustomFormModelItemChildrenMapper extends BaseMapper { + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormModelItemsMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormModelItemsMapper.java new file mode 100644 index 0000000..2b8c4fc --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormModelItemsMapper.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormModelItems; + +/** + * 自定义表单模板组件 Mapper + * + * @author wjm + * @date 2021-08-30 15:22:49 + */ +public interface CoreCustomFormModelItemsMapper extends BaseMapper { + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormModelMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormModelMapper.java new file mode 100644 index 0000000..839ec8b --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormModelMapper.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormModel; + +/** + * 自定义表单模板 Mapper + * + * @author wjm + * @date 2021-08-30 15:22:15 + */ +public interface CoreCustomFormModelMapper extends BaseMapper { + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormRelationAdminMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormRelationAdminMapper.java new file mode 100644 index 0000000..8f5cfcb --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormRelationAdminMapper.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationAdmin; + +/** + * 表单对应管理员 Mapper + * + * @author ccl + * @date 2021-11-05 15:41:08 + */ +public interface CoreCustomFormRelationAdminMapper extends BaseMapper { + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormRelationUserMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormRelationUserMapper.java new file mode 100644 index 0000000..ffe376e --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormRelationUserMapper.java @@ -0,0 +1,31 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUser; +import org.apache.ibatis.annotations.Param; + +/** + * 表单对应可见人员表 Mapper + * + * @author ccl + * @date 2021-11-05 15:41:11 + */ +public interface CoreCustomFormRelationUserMapper extends BaseMapper { + + /** + * 查询所有的人数和所有已填的人 + * @param id + */ + Integer findUserNum(@Param("id") Long id); + + /** + * 为填报得人员 + * @param formId + * @return + */ + Integer findNotCommit(Long formId); + + Page findUserList(@Param("page") Page page, @Param("type") Integer type, + @Param("name") String name, @Param("formId") Long formId); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormRelationUserParentMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormRelationUserParentMapper.java new file mode 100644 index 0000000..b38812d --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormRelationUserParentMapper.java @@ -0,0 +1,25 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUserParent; +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; +import org.apache.ibatis.annotations.Param; + +/** + * @author ccl + */ +public interface CoreCustomFormRelationUserParentMapper extends BaseMapper { + /** + * 查询总数 + * @param formId + * @return + */ + Integer findTotal(@Param("formId") Long formId); + + /** + * 查询未提交数据 + * @param formId + * @return + */ + Integer findParentStatistic(Long formId); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormStatisticMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormStatisticMapper.java new file mode 100644 index 0000000..57b9120 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormStatisticMapper.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; + +/** + * 表单对应统计数据表 Mapper + * + * @author ccl + * @date 2021-11-05 15:58:43 + */ +public interface CoreCustomFormStatisticMapper extends BaseMapper { + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormTopicalMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormTopicalMapper.java new file mode 100644 index 0000000..1414bb1 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormTopicalMapper.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormTopical; + +/** + * 表单对应主题表 Mapper + * + * @author ccl + * @date 2021-11-05 15:41:09 + */ +public interface CoreCustomFormTopicalMapper extends BaseMapper { + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormTypeMapper.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormTypeMapper.java new file mode 100644 index 0000000..30bda7c --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/mapper/CoreCustomFormTypeMapper.java @@ -0,0 +1,14 @@ +package com.yida.data.customForm.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.yida.data.common.core.entity.customform.CoreCustomFormType; + +/** + * 自定义表单类型表 Mapper + * + * @author wjm + * @date 2021-08-12 10:56:57 + */ +public interface CoreCustomFormTypeMapper extends BaseMapper { + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormAuthRelationFormService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormAuthRelationFormService.java new file mode 100644 index 0000000..a6ff3e9 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormAuthRelationFormService.java @@ -0,0 +1,15 @@ +package com.yida.data.customForm.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormAuthRelationForm; + +import java.util.List; + +/** +* 权限对应管理员表 Service接口 +* +* @author ccl +* @date 2021-11-05 15:41:15 +*/ +public interface CoreCustomFormAuthRelationFormService extends IService { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormAuthService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormAuthService.java new file mode 100644 index 0000000..eeab9c8 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormAuthService.java @@ -0,0 +1,16 @@ +package com.yida.data.customForm.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormAuth; + +import java.util.List; + +/** +* 表单对应管理员权限表 Service接口 +* +* @author ccl +* @date 2021-11-05 15:41:13 +*/ +public interface CoreCustomFormAuthService extends IService { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormDataService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormDataService.java new file mode 100644 index 0000000..f7e1872 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormDataService.java @@ -0,0 +1,81 @@ +package com.yida.data.customForm.service; + + +import cn.hutool.http.HttpResponse; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.CurrentUser; +import com.yida.data.customForm.dto.CoreCustomFormData; +import com.yida.data.customForm.dto.FormDataInput; +import com.yida.data.customForm.entity.FormDataReturn; +import org.apache.ibatis.annotations.Param; + +import javax.servlet.http.HttpServletResponse; +import java.text.ParseException; +import java.util.List; +import java.util.Map; + +/** + * 自定义表单 Service接口 + * + * @author wjm + * @date 2021-08-11 20:55:19 + */ +public interface CoreCustomFormDataService { + + /*** + * @Author jianMingWang + * @Description 保存表单数据 + * @Date 9:39 2021/9/17 + * @Param formDataInput + * @return void + **/ + void saveFormData(FormDataInput formDataInput,Map data); + + /*** + * @Author jianMingWang + * @Description //分页列表查询表单数据 + * @Date 9:40 2021/9/17 + * @Param [formId, pageSize, pageNo] + * @return java.util.List + **/ + List findSubmitFormDataListByFormId(Integer formId, Integer pageSize, Integer pageNo); + + + /*** + * @Author jianMingWang + * @Description //查询提交总数 + * @Date 14:12 2021/9/17 + * @Param [formId] + * @return java.lang.Integer + **/ + Integer findSubmitFormDataTotalNumByFormId(Integer formId); + + + /*** + * @Author jianMingWang + * @Description //分页查询表单数据 + * @Date 14:34 2021/9/23 + * @Param [formId, pageSize, pageNo] + * @return com.yida.data.customForm.entity.FormDataReturn + **/ + FormDataReturn findList(Integer formId, Integer pageSize, Integer pageNo); + + /*** + * @Author jianMingWang + * @Description //导出表单数据 + * @Date 14:34 2021/9/23 + * @Param [formId, response] + * @return void + **/ + void exportData(Integer formId, HttpServletResponse response) throws ParseException; + + Map findData(Long formId, Long userId); + + /** + * 清空 + * @param sql + */ + void truncateTable(String sql); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormGroupService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormGroupService.java new file mode 100644 index 0000000..cde9148 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormGroupService.java @@ -0,0 +1,21 @@ +package com.yida.data.customForm.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormGroup; + + +/** +* 表单组 Service接口 +* +* @author ccl +* @date 2021-11-05 15:41:03 +*/ +public interface CoreCustomFormGroupService extends IService { + + /** + * 查询分组列表,同时返回组内表名和id + * @return + */ + Page findGroupPageList(Integer pageNum, Integer pageSize, String groupName); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormItemChildrenService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormItemChildrenService.java new file mode 100644 index 0000000..0fa0516 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormItemChildrenService.java @@ -0,0 +1,16 @@ +package com.yida.data.customForm.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormItemChildren; + +/** + * 自定义表单组件选项 Service接口 + * + * @author wjm + * @date 2021-08-11 20:55:19 + */ +public interface CoreCustomFormItemChildrenService extends IService { + + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormItemsService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormItemsService.java new file mode 100644 index 0000000..9253fe9 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormItemsService.java @@ -0,0 +1,20 @@ +package com.yida.data.customForm.service; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.CurrentUser; +import com.yida.data.common.core.entity.customform.CoreCustomForm; +import com.yida.data.common.core.entity.customform.CoreCustomFormItems; + +/** + * 自定义表单组件 Service接口 + * + * @author wjm + * @date 2021-08-11 20:55:19 + */ +public interface CoreCustomFormItemsService extends IService { + + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormModelItemChildrenService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormModelItemChildrenService.java new file mode 100644 index 0000000..4f1fd90 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormModelItemChildrenService.java @@ -0,0 +1,13 @@ +package com.yida.data.customForm.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormModelItemChildren; + +/** +* 自定义表单模板组件 Service接口 +* +* @author wjm +* @date 2021-08-30 15:22:32 +*/ +public interface CoreCustomFormModelItemChildrenService extends IService { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormModelItemsService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormModelItemsService.java new file mode 100644 index 0000000..6d9d84d --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormModelItemsService.java @@ -0,0 +1,13 @@ +package com.yida.data.customForm.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormModelItems; + +/** +* 自定义表单模板组件 Service接口 +* +* @author wjm +* @date 2021-08-30 15:22:49 +*/ +public interface CoreCustomFormModelItemsService extends IService { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormModelService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormModelService.java new file mode 100644 index 0000000..e55db20 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormModelService.java @@ -0,0 +1,13 @@ +package com.yida.data.customForm.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormModel; + +/** +* 自定义表单模板 Service接口 +* +* @author wjm +* @date 2021-08-30 15:22:15 +*/ +public interface CoreCustomFormModelService extends IService { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormRelationAdminService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormRelationAdminService.java new file mode 100644 index 0000000..36323a9 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormRelationAdminService.java @@ -0,0 +1,17 @@ +package com.yida.data.customForm.service; + +import com.yida.data.common.core.entity.QueryRequest; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationAdmin; + +import java.util.List; + +/** +* 表单对应管理员 Service接口 +* +* @author ccl +* @date 2021-11-05 15:41:08 +*/ +public interface CoreCustomFormRelationAdminService extends IService { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormRelationUserParentService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormRelationUserParentService.java new file mode 100644 index 0000000..a612863 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormRelationUserParentService.java @@ -0,0 +1,18 @@ +package com.yida.data.customForm.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUserParent; +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; + +/** + * @author ccl + */ +public interface CoreCustomFormRelationUserParentService extends IService { + /** + * 查询家长统计数据 + * + * @param formId + * @return + */ + CoreCustomFormStatistic findParentStatistic(Long formId); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormRelationUserService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormRelationUserService.java new file mode 100644 index 0000000..221727c --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormRelationUserService.java @@ -0,0 +1,41 @@ +package com.yida.data.customForm.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.entity.QueryRequest; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUser; +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; + +import java.util.List; + +/** +* 表单对应可见人员表 Service接口 +* +* @author ccl +* @date 2021-11-05 15:41:11 +*/ +public interface CoreCustomFormRelationUserService extends IService { + /** + * 查询对应表中所有应填人员,和已填人员 + * @param id + */ + Integer findUserNum(Long id); + + /** + * 查询统计数据 + * @param formId + * @return + */ + CoreCustomFormStatistic findStatistic(Long formId); + + /** + * 条件查询用户 + * @param page + * @param type + * @param name + * @param formId + * @return + */ + Page findUserList(Page page, Integer type, String name, Long formId); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormService.java new file mode 100644 index 0000000..e61cd31 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormService.java @@ -0,0 +1,144 @@ +package com.yida.data.customForm.service; + + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.CurrentUser; +import com.yida.data.common.core.entity.QueryRequest; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomForm; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUser; +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; +import com.yida.data.customForm.dto.RemindAgainDTO; +import com.yida.data.customForm.dto.SaveCustomFormDTO; +import com.yida.data.customForm.vo.CommitUserVO; +import com.yida.data.customForm.vo.FormStudentVO; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 自定义表单 Service接口 + * + * @author wjm + * @date 2021-08-11 20:55:19 + */ +public interface CoreCustomFormService extends IService { + + IPage findCustomFormPageList(Page page, Long schoolId, Long formTypeId, String model, CurrentUser currentUser); + + Integer saveForm(CoreCustomForm dto) throws Exception; + + + /** + * app查询用户对应填写表单 + * @param objectPage + * @param userId + * @param formName + * @param status + * @param schoolId + * @return + */ + IPage appFindFormList(Page objectPage, Long userId,String tableName,Integer status,Long schoolId,Integer type); + + + /** + * app查询用户管理对应表单 + * @param objectPage + * @param userId + * @param tableName + * @param status + * @param schoolId + * @return + */ + IPage appFindAdminFormList(Page objectPage, Long userId,String tableName,Integer status,Long schoolId); + + /** + * 查询用户对应是否是管理员 + * @param userId + * @param schoolId + * @return + */ + Boolean appHandOnCustomForm(Long userId,Long schoolId); + + /** + * 查询表单详情 + * @param id + * @return + */ + CoreCustomForm findById(Long id); + + /** + * 删除表单,及对应附表 + * @param id + */ + void delForm(Long id); + + void updateAndSendNotice(Long formId); + + /** + * 条件查询表单对应填报情况 + * @param formId + * @param fillType + * @param page + * @return + */ + Page findCommitUser(Long formId, Integer fillType, Page page); + + /** + * 查询表单对应统计数据 + * @param formId + * @return + */ + CoreCustomFormStatistic findStatistic(Long formId); + + /** + * 再次提醒 + * @param dto + */ + void remindAgain(RemindAgainDTO dto); + + /** + * 导出表单未提交和已提交的人员信息 + * @param formId + * @param status + * @param response + */ + void exportUserListInOut(Long formId, Integer status, HttpServletResponse response); + + + + /** + * 发布接口 + * @param byId + */ + void publishForm(CoreCustomForm byId); + + + + /** + * 查询表单和填报数据 + * @param userId + * @param formId + * @return + */ + Object appFindFormAndData(Long userId, Long formId); + + /** + * 条件查询 + * @param formId + * @param type + * @param page + * @return + */ + CommitUserVO commitUser(Long formId, Integer type, String name, Page page); + + /** + * 通过表单查询对应需要填报的学生 + * @param userId + * @param formId + * @return + */ + List appFindStudentByForm(Long userId, Long formId); +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormStatisticService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormStatisticService.java new file mode 100644 index 0000000..584760e --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormStatisticService.java @@ -0,0 +1,18 @@ +package com.yida.data.customForm.service; + + +import com.yida.data.common.core.entity.QueryRequest; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; + +import java.util.List; + +/** +* 表单对应统计数据表 Service接口 +* +* @author ccl +* @date 2021-11-05 15:58:43 +*/ +public interface CoreCustomFormStatisticService extends IService { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormTopicalService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormTopicalService.java new file mode 100644 index 0000000..006edc9 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormTopicalService.java @@ -0,0 +1,17 @@ +package com.yida.data.customForm.service; + +import com.yida.data.common.core.entity.QueryRequest; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormTopical; + +import java.util.List; + +/** +* 表单对应主题表 Service接口 +* +* @author ccl +* @date 2021-11-05 15:41:09 +*/ +public interface CoreCustomFormTopicalService extends IService { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormTypeService.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormTypeService.java new file mode 100644 index 0000000..37af35d --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/CoreCustomFormTypeService.java @@ -0,0 +1,18 @@ +package com.yida.data.customForm.service; + + +import com.yida.data.common.core.entity.QueryRequest; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.entity.customform.CoreCustomFormType; + +import java.util.List; + +/** +* 自定义表单类型表 Service接口 +* +* @author wjm +* @date 2021-08-12 10:56:57 +*/ +public interface CoreCustomFormTypeService extends IService { +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormAuthRelationFormServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormAuthRelationFormServiceImpl.java new file mode 100644 index 0000000..423ec17 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormAuthRelationFormServiceImpl.java @@ -0,0 +1,27 @@ +package com.yida.data.customForm.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.customform.CoreCustomFormAuthRelationForm; +import com.yida.data.customForm.mapper.CoreCustomFormAuthRelationFormMapper; +import com.yida.data.customForm.service.CoreCustomFormAuthRelationFormService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; + + +/** +* 权限对应管理员表 Service实现 +* +* @author ccl +* @date 2021-11-05 15:41:15 +*/ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormAuthRelationFormServiceImpl extends ServiceImpl + implements CoreCustomFormAuthRelationFormService { + +private final CoreCustomFormAuthRelationFormMapper coreCustomFormAuthAdminMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormAuthServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormAuthServiceImpl.java new file mode 100644 index 0000000..b419e81 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormAuthServiceImpl.java @@ -0,0 +1,32 @@ +package com.yida.data.customForm.service.impl; + +import com.yida.data.common.core.entity.customform.CoreCustomFormAuth; +import com.yida.data.customForm.mapper.CoreCustomFormAuthMapper; +import com.yida.data.customForm.service.CoreCustomFormAuthService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.QueryRequest; + +import java.util.List; + +/** +* 表单对应管理员权限表 Service实现 +* +* @author ccl +* @date 2021-11-05 15:41:13 +*/ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormAuthServiceImpl extends ServiceImpl + implements CoreCustomFormAuthService { + +private final CoreCustomFormAuthMapper coreCustomFormAuthMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormDataServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormDataServiceImpl.java new file mode 100644 index 0000000..6b0aea6 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormDataServiceImpl.java @@ -0,0 +1,440 @@ +package com.yida.data.customForm.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.yida.data.common.core.entity.constant.AppConstant; +import com.yida.data.common.core.entity.customform.*; +import com.yida.data.common.core.entity.notice.qywx.BaseStaffNotice; +import com.yida.data.common.core.entity.notice.qywx.inside.Text; +import com.yida.data.common.core.entity.system.EduApp; +import com.yida.data.common.core.entity.user.EduParent; +import com.yida.data.common.core.entity.user.EduStaff; +import com.yida.data.common.core.entity.user.EduStudent; +import com.yida.data.common.core.exception.FebsException; +import com.yida.data.common.core.utils.ExcelUtil; +import com.yida.data.common.core.utils.WxUtil; +import com.yida.data.common.service.CommonService; +import com.yida.data.customForm.dto.FormDataInput; +import com.yida.data.customForm.entity.FormDataReturn; +import com.yida.data.customForm.entity.RedisKey; +import com.yida.data.customForm.mapper.CoreCustomFormDataMapper; +import com.yida.data.customForm.service.*; + +import com.yida.data.customForm.vo.ParentCommit; +import com.yida.data.user.feign.RemoteStaffService; +import com.yida.data.user.feign.RemoteStudentService; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; + +import cc.mrbird.febs.common.redis.service.RedisService; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import lombok.RequiredArgsConstructor; + +import static com.yida.data.common.core.entity.constant.CachePrefixConstant.*; + +/** + * 自定义表单 Service实现 + * + * @author wjm + * @date 2021-08-11 20:55:19 + */ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormDataServiceImpl implements CoreCustomFormDataService { + + @Value("${edu.customform.dbname}") + private String dbName; + + @Value("${febs.teacherFormUrl}") + private String teacherFormUrl; + + @Resource + private CoreCustomFormDataMapper coreCustomFormDataMapper; + + @Resource + private CoreCustomFormService coreCustomFormService; + + @Resource + private CoreCustomFormItemsService coreCustomFormItemsService; + + @Resource + private CoreCustomFormRelationUserService userService; + + @Resource + private RedisService redisService; + + @Resource + private RemoteStaffService remoteStaffService; + + @Resource + private RemoteStudentService remoteStudentService; + + @Resource + private CoreCustomFormRelationUserParentService parentService; + + @Resource + private CoreCustomFormRelationAdminService adminService; + + @Resource + private WxUtil wxUtil; + @Resource + private CommonService commonService; + + @Override + public void saveFormData(FormDataInput formDataInput,Map data) { + CoreCustomForm form = coreCustomFormService.getOne(Wrappers.lambdaQuery(new CoreCustomForm()) + .eq(CoreCustomForm::getTableName, formDataInput.getTableName())); + if (ObjectUtil.isNotEmpty(data)){ + String sql = "DELETE FROM "+formDataInput.getTableName()+" WHERE user_id = "+formDataInput.getUserId(); + coreCustomFormDataMapper.removeBySql(sql); + } + + List filedList = coreCustomFormDataMapper.findFormFiled(dbName, formDataInput.getTableName()); + JSONObject jsonObject = JSONUtil.parseObj(formDataInput.getJsonDataString()); + List parameterList = new ArrayList<>(); + Map parameterMap = new HashMap(); + String baseSql = "insert into " + formDataInput.getTableName() + "("; + filedList.forEach(filed -> { + parameterList.add("#{parameterMap." + filed + "}"); + parameterMap.put(filed, jsonObject.get(filed)); + }); + parameterMap.put("create_date", new Date()); + parameterMap.put("user_id", formDataInput.getUserId()); + String finalSql = baseSql + String.join(",", filedList) + ")values(" + String.join(",", parameterList) + ")"; + coreCustomFormDataMapper.initSqlWithParameterReturnVoid(finalSql, parameterMap); + + + //修改填报人填报状态 + CoreCustomForm one = coreCustomFormService.getOne(Wrappers.lambdaQuery(new CoreCustomForm()) + .eq(CoreCustomForm::getTableName, formDataInput.getTableName())); + + if (one.getRecever() != 2) { + userService.update(Wrappers.lambdaUpdate(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, one.getId()) + .eq(CoreCustomFormRelationUser::getUserId, formDataInput.getUserId()) + .set(CoreCustomFormRelationUser::getFill, 1) + .set(CoreCustomFormRelationUser::getFillTime, LocalDateTime.now())); + } else if (one.getRecever() == 2) { + parentService.update(Wrappers.lambdaUpdate(new CoreCustomFormRelationUserParent()) + .eq(CoreCustomFormRelationUserParent::getCustomFormId, one.getId()) + .set(CoreCustomFormRelationUserParent::getFillType, 1) + .set(CoreCustomFormRelationUserParent::getFillTime,LocalDateTime.now())); + } + + //新增数据发送通知 + if (form.getRemindAdmin()==1){ + + //查询对应管理员 + List adminList = adminService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationAdmin()) + .eq(CoreCustomFormRelationAdmin::getCustomFormId, form.getId())); + for (CoreCustomFormRelationAdmin relationUser : adminList) { + EduStaff staff = remoteStaffService.getStaffNoPermission(relationUser.getAdminId()).getData(); + BaseStaffNotice textSchoolNotice = new BaseStaffNotice(); + EduApp appByCodeAndSchool = commonService.getAppByCodeAndSchool(AppConstant.CUSTOM_FORM_TEACHER, null, form.getOrgId()); + Text text = new Text(); + textSchoolNotice.setText(text); + textSchoolNotice.setAgentid(appByCodeAndSchool.getWxAgentId()); + String url = teacherFormUrl+appByCodeAndSchool.getWxCorpId()+"&loginType=0&userType=0&state="+AppConstant.CUSTOM_FORM_TEACHER+"&id="+form.getId();; + + text.setContent("" + form.getRemindAdminModel()+" "+staff.getName()+"已填报《"+form.getFormTitle()+"》"+ ""); + textSchoolNotice.setTouser(staff.getWxId()); + String accessToken = wxUtil.getAccessToken(appByCodeAndSchool.getWxCorpId(), appByCodeAndSchool.getWxSecret()); + wxUtil.pushStaffNotice(accessToken, textSchoolNotice); + } + } + + } + + + @Override + public List findSubmitFormDataListByFormId(Integer formId, Integer pageSize, Integer pageNo) { + //查询formID对应的数据表 + CoreCustomForm coreCustomForm = null; + if (redisService.hasKey(RedisKey.FORM_LOCAL + formId)) { + coreCustomForm = (CoreCustomForm) redisService.get(RedisKey.FORM_LOCAL + formId); + } else { + coreCustomForm = coreCustomFormService.getById(formId); + } + + if (ObjectUtil.isEmpty(pageNo) && ObjectUtil.isEmpty(pageSize)) { + String initSql = "select * from " + coreCustomForm.getTableName(); + return coreCustomFormDataMapper.initSqlWithNUllReturnListMap(initSql); + } + + Integer limitBeginNum = pageNo == 1 ? 0 : (pageSize * (pageNo - 1)); + Integer limitEndNum = pageNo * pageSize; + String initSql = "select * from " + coreCustomForm.getTableName() + + " limit " + limitBeginNum + "," + limitEndNum; + //查询出表单数据ListMap + //查询出表单数据 + List maps = coreCustomFormDataMapper.initSqlWithNUllReturnListMap(initSql); + for (Map map : maps) { + Long userId = (Long) map.get("user_id"); + //教职工 + if (coreCustomForm.getRecever() == 0) { + EduStaff staff = (EduStaff) redisService.hget(STAFF_DATA, userId.toString()); + if (ObjectUtil.isEmpty(staff)) { + staff = remoteStaffService.getStaff(userId).getData(); + redisService.hset(STAFF_DATA, userId.toString(), staff); + } + map.put("staff", staff); + } + //学生 + else if (coreCustomForm.getRecever() == 1) { + EduStudent student = (EduStudent) redisService.hget(STUDENT_DATA, userId.toString()); + if (ObjectUtil.isEmpty(student)) { + student = remoteStudentService.getStudentNoPermission(userId).getData(); + redisService.hset(STUDENT_DATA, userId.toString(), student); + } + map.put("student", student); + } + //家长 + else if (coreCustomForm.getRecever() == 2) { + Long customUserId = parentService.getOne(Wrappers.lambdaQuery(new CoreCustomFormRelationUserParent()) + .eq(CoreCustomFormRelationUserParent::getCustomFormId, formId) + .eq(CoreCustomFormRelationUserParent::getParentId, userId)).getCustomUserId(); + Long studentId = userService.getById(customUserId).getUserId(); + + EduStudent student = (EduStudent) redisService.hget(STUDENT_DATA, studentId.toString()); + if (ObjectUtil.isEmpty(student)) { + student = remoteStudentService.getStudentNoPermission(studentId).getData(); + redisService.hset(STUDENT_DATA, studentId.toString(), student); + } + EduParent parent = student.getParents().stream().filter(p -> p.getId().equals(userId)).collect(Collectors.toList()).get(0); + + ParentCommit parentCommit = new ParentCommit(); + parentCommit.setParentName(student.getStuName() + parent.getParentType()); + parentCommit.setPhone(parent.getMobile()); + parentCommit.setSchoolName(student.getSchoolName()); + parentCommit.setCampusName(student.getCampusName()); + parentCommit.setSectionName(student.getSectionName()); + parentCommit.setGradeName(student.getGradeName()); + parentCommit.setClassName(student.getClassName()); + map.put("parent", parentCommit); + } + } + return coreCustomFormDataMapper.initSqlWithNUllReturnListMap(initSql); + } + + + @Override + public Integer findSubmitFormDataTotalNumByFormId(Integer formId) { + CoreCustomForm coreCustomForm = null; + if (redisService.hasKey(RedisKey.FORM_LOCAL + formId)) { + coreCustomForm = (CoreCustomForm) redisService.get(RedisKey.FORM_LOCAL + formId); + } else { + coreCustomForm = coreCustomFormService.getById(formId); + } + String initSql = "select count(id) from " + coreCustomForm.getTableName(); + //查询出表单数据ListMap + //查询出表单数据 + return coreCustomFormDataMapper.initSqlWithNUllReturnInteger(initSql); + } + + @Override + public FormDataReturn findList(Integer formId, Integer pageSize, Integer pageNo) { + List submitFormDataListByFormId = this.findSubmitFormDataListByFormId(formId, pageSize, pageNo); + Integer submitFormDataTotalNumByFormId = this.findSubmitFormDataTotalNumByFormId(formId); + List coreCustomFormItemList = coreCustomFormItemsService.list(Wrappers.query().lambda().eq(CoreCustomFormItems::getFormId, formId)); + return new FormDataReturn(submitFormDataListByFormId, submitFormDataTotalNumByFormId, coreCustomFormItemList); + } + + + @Override + public void exportData(Integer formId, HttpServletResponse response) throws ParseException { + CoreCustomForm byId = coreCustomFormService.getById(formId); + if (byId.getRecever() == 0) { + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet(); + XSSFRow row = sheet.createRow(0); + List coreCustomFormItemList = coreCustomFormItemsService.list(Wrappers.query().lambda().eq(CoreCustomFormItems::getFormId, formId)); + row.createCell(0).setCellValue("序号"); + row.createCell(1).setCellValue("姓名"); + row.createCell(2).setCellValue("电话"); + row.createCell(coreCustomFormItemList.size() + 3).setCellValue("时间"); + for (int i = 0; i < coreCustomFormItemList.size(); i++) { + row.createCell(i + 4).setCellValue(coreCustomFormItemList.get(i).getItemTitle()); + } + + List submitFormDataListByFormId = this.findSubmitFormDataListByFormId(formId, null, null); + for (int j = 0; j < submitFormDataListByFormId.size(); j++) { + XSSFRow row1 = sheet.createRow(j + 1); + Map map = submitFormDataListByFormId.get(j); + Iterator iter = map.keySet().iterator(); + while (iter.hasNext()) { + //字段名称 + String key = iter.next(); + //填报值 + Object value = map.get(key); + + if ("id".equals(key)) { + row1.createCell(0).setCellValue(ObjectUtil.toString(value)); + continue; + } + if ("user_id".equals(key)) { + EduStaff hget = (EduStaff) redisService.hget(STAFF_DATA, value.toString()); + row1.createCell(1).setCellValue(ObjectUtil.toString(hget.getName())); + row1.createCell(2).setCellValue(ObjectUtil.toString(hget.getMobile())); + continue; + } + if ("create_date".equals(key)) { + SimpleDateFormat myFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + row1.createCell(coreCustomFormItemList.size() + 2).setCellValue(myFmt.format(myFmt.parse(ObjectUtil.toString(value)))); + continue; + } + for (int i = 0; i < coreCustomFormItemList.size(); i++) { + String itemFiledName = coreCustomFormItemList.get(i).getItemFiledName(); + if (key.equals(itemFiledName)) { + row1.createCell(i + 3).setCellValue(ObjectUtil.toString(value)); + } + } + } + } + ExcelUtil.export("表单数据", "xlsx", workbook, response); + } else if (byId.getRecever() == 1) { + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet(); + XSSFRow row = sheet.createRow(0); + List coreCustomFormItemList = coreCustomFormItemsService.list(Wrappers.query().lambda().eq(CoreCustomFormItems::getFormId, formId)); + row.createCell(0).setCellValue("序号"); + row.createCell(1).setCellValue("班级"); + row.createCell(2).setCellValue("姓名"); + row.createCell(3).setCellValue("学号"); + row.createCell(coreCustomFormItemList.size() + 3).setCellValue("填报时间"); + for (int i = 0; i < coreCustomFormItemList.size(); i++) { + row.createCell(i + 5).setCellValue(coreCustomFormItemList.get(i).getItemTitle()); + } + List submitFormDataListByFormId = this.findSubmitFormDataListByFormId(formId, null, null); + for (int j = 0; j < submitFormDataListByFormId.size(); j++) { + XSSFRow row1 = sheet.createRow(j + 1); + Map map = submitFormDataListByFormId.get(j); + Iterator iter = map.keySet().iterator(); + while (iter.hasNext()) { + //字段名称 + String key = iter.next(); + //填报值 + Object value = map.get(key); + + if ("id".equals(key)) { + row1.createCell(0).setCellValue(ObjectUtil.toString(value)); + continue; + } + if ("user_id".equals(key)) { + EduStudent hget = (EduStudent) redisService.hget(STUDENT_DATA, value.toString()); + String classAndGrade = hget.getGradeName() + hget.getClassName(); + row1.createCell(1).setCellValue(ObjectUtil.toString(classAndGrade)); + row1.createCell(2).setCellValue(ObjectUtil.toString(hget.getStuName())); + row1.createCell(3).setCellValue(ObjectUtil.toString(hget.getStuNumber())); + continue; + } + if ("create_date".equals(key)) { + SimpleDateFormat myFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + row1.createCell(coreCustomFormItemList.size() + 3).setCellValue(myFmt.format(myFmt.parse(ObjectUtil.toString(value)))); + continue; + } + for (int i = 0; i < coreCustomFormItemList.size(); i++) { + String itemFiledName = coreCustomFormItemList.get(i).getItemFiledName(); + if (key.equals(itemFiledName)) { + row1.createCell(i + 5).setCellValue(ObjectUtil.toString(value)); + } + } + } + } + ExcelUtil.export("表单数据", "xlsx", workbook, response); + } else if (byId.getRecever() == 2) { + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet(); + XSSFRow row = sheet.createRow(0); + List coreCustomFormItemList = coreCustomFormItemsService.list(Wrappers.query().lambda().eq(CoreCustomFormItems::getFormId, formId)); + row.createCell(0).setCellValue("序号"); + row.createCell(1).setCellValue("班级"); + row.createCell(2).setCellValue("家长"); + row.createCell(3).setCellValue("电话"); + row.createCell(coreCustomFormItemList.size() + 3).setCellValue("填报时间"); + for (int i = 0; i < coreCustomFormItemList.size(); i++) { + row.createCell(i + 5).setCellValue(coreCustomFormItemList.get(i).getItemTitle()); + } + + List submitFormDataListByFormId = this.findSubmitFormDataListByFormId(formId, null, null); + for (int j = 0; j < submitFormDataListByFormId.size(); j++) { + XSSFRow row1 = sheet.createRow(j + 1); + Map map = submitFormDataListByFormId.get(j); + Iterator iter = map.keySet().iterator(); + while (iter.hasNext()) { + //字段名称 + String key = iter.next(); + //填报值 + Object value = map.get(key); + + if ("id".equals(key)) { + row1.createCell(0).setCellValue(ObjectUtil.toString(value)); + continue; + } + if ("user_id".equals(key)) { + CoreCustomFormRelationUserParent one = parentService.getOne(Wrappers.lambdaQuery(new CoreCustomFormRelationUserParent()) + .eq(CoreCustomFormRelationUserParent::getCustomFormId, formId) + .eq(CoreCustomFormRelationUserParent::getParentId, key)); + CoreCustomFormRelationUser relationStudent = userService.getById(one.getCustomUserId()); + + EduStudent hget = (EduStudent) redisService.hget(STUDENT_DATA, relationStudent.getUserId().toString()); + List parents = hget.getParents(); + EduParent parent = parents.stream().filter(p -> p.getWxId().equals(key)).collect(Collectors.toList()).get(0); + + String classAndGrade = hget.getGradeName() + hget.getClassName(); + row1.createCell(1).setCellValue(ObjectUtil.toString(classAndGrade)); + row1.createCell(2).setCellValue(ObjectUtil.toString(parent.getParentType())); + row1.createCell(3).setCellValue(ObjectUtil.toString(parent.getMobile())); + continue; + } + if ("create_date".equals(key)) { + SimpleDateFormat myFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + row1.createCell(coreCustomFormItemList.size() + 3).setCellValue(myFmt.format(myFmt.parse(ObjectUtil.toString(value)))); + continue; + } + for (int i = 0; i < coreCustomFormItemList.size(); i++) { + String itemFiledName = coreCustomFormItemList.get(i).getItemFiledName(); + if (key.equals(itemFiledName)) { + row1.createCell(i + 4).setCellValue(ObjectUtil.toString(value)); + } + } + } + } + ExcelUtil.export("表单数据", "xlsx", workbook, response); + } + } + + @Override + public Map findData(Long formId, Long userId) { + CoreCustomForm form = coreCustomFormService.getById(formId); + String sql = "select * from " + form.getTableName() + " where user_id = " + userId; + + return coreCustomFormDataMapper.findData(sql); + } + + @Override + public void truncateTable(String sql) { + coreCustomFormDataMapper.truncateTable(sql); + } + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormGroupServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormGroupServiceImpl.java new file mode 100644 index 0000000..1cc5b62 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormGroupServiceImpl.java @@ -0,0 +1,40 @@ +package com.yida.data.customForm.service.impl; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.entity.customform.CoreCustomFormGroup; +import com.yida.data.customForm.mapper.CoreCustomFormGroupMapper; +import com.yida.data.customForm.service.CoreCustomFormGroupService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + + +/** + * 表单组 Service实现 + * + * @author ccl + * @date 2021-11-05 15:41:03 + */ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormGroupServiceImpl extends ServiceImpl + implements CoreCustomFormGroupService { + + private final CoreCustomFormGroupMapper coreCustomFormGroupMapper; + + + + @Override + public Page findGroupPageList(Integer pageNum,Integer pageSize,String groupName) { + + Page groupPage = page(new Page<>(pageNum, pageSize), Wrappers.lambdaQuery(new CoreCustomFormGroup()) + .like(CoreCustomFormGroup::getGroupName, groupName) + .orderByDesc(CoreCustomFormGroup::getCreateDate)); + + return groupPage; + } +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormItemChildrenServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormItemChildrenServiceImpl.java new file mode 100644 index 0000000..cdcee56 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormItemChildrenServiceImpl.java @@ -0,0 +1,30 @@ +package com.yida.data.customForm.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.customform.CoreCustomFormItemChildren; +import com.yida.data.common.core.entity.customform.CoreCustomFormItems; +import com.yida.data.customForm.mapper.CoreCustomFormItemChildrenMapper; +import com.yida.data.customForm.mapper.CoreCustomFormItemsMapper; +import com.yida.data.customForm.service.CoreCustomFormItemChildrenService; +import com.yida.data.customForm.service.CoreCustomFormItemsService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; + +/** + * 自定义表单类型表 Service实现 + * + * @author wjm + * @date 2021-08-12 10:56:57 + */ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormItemChildrenServiceImpl extends ServiceImpl implements CoreCustomFormItemChildrenService { + + @Resource + private final CoreCustomFormItemChildrenMapper coreCustomFormItemChildrenMapper; +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormItemsServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormItemsServiceImpl.java new file mode 100644 index 0000000..88ed88f --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormItemsServiceImpl.java @@ -0,0 +1,31 @@ +package com.yida.data.customForm.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.customform.CoreCustomFormItems; +import com.yida.data.common.core.entity.customform.CoreCustomFormType; +import com.yida.data.customForm.mapper.CoreCustomFormItemsMapper; +import com.yida.data.customForm.mapper.CoreCustomFormTypeMapper; +import com.yida.data.customForm.service.CoreCustomFormItemsService; +import com.yida.data.customForm.service.CoreCustomFormTypeService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; + +/** + * 自定义表单类型表 Service实现 + * + * @author wjm + * @date 2021-08-12 10:56:57 + */ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormItemsServiceImpl extends ServiceImpl implements CoreCustomFormItemsService { + + @Resource + private final CoreCustomFormItemsMapper coreCustomFormItemsMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormModelItemChildrenServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormModelItemChildrenServiceImpl.java new file mode 100644 index 0000000..a441260 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormModelItemChildrenServiceImpl.java @@ -0,0 +1,26 @@ +package com.yida.data.customForm.service.impl; + +import com.yida.data.common.core.entity.customform.CoreCustomFormModelItemChildren; +import com.yida.data.customForm.mapper.CoreCustomFormModelItemChildrenMapper; +import com.yida.data.customForm.service.CoreCustomFormModelItemChildrenService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** +* 自定义表单模板组件 Service实现 +* +* @author wjm +* @date 2021-08-30 15:22:32 +*/ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormModelItemChildrenServiceImpl extends ServiceImpl + implements CoreCustomFormModelItemChildrenService { + +private final CoreCustomFormModelItemChildrenMapper coreCustomFormModelItemChildrenMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormModelItemsServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormModelItemsServiceImpl.java new file mode 100644 index 0000000..01d2d98 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormModelItemsServiceImpl.java @@ -0,0 +1,26 @@ +package com.yida.data.customForm.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.customform.CoreCustomFormModelItems; +import com.yida.data.customForm.mapper.CoreCustomFormModelItemsMapper; +import com.yida.data.customForm.service.CoreCustomFormModelItemsService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; + +/** +* 自定义表单模板组件 Service实现 +* +* @author wjm +* @date 2021-08-30 15:22:49 +*/ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormModelItemsServiceImpl extends ServiceImpl + implements CoreCustomFormModelItemsService { + +private final CoreCustomFormModelItemsMapper coreCustomFormModelItemsMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormModelServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormModelServiceImpl.java new file mode 100644 index 0000000..97755d7 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormModelServiceImpl.java @@ -0,0 +1,26 @@ +package com.yida.data.customForm.service.impl; + +import com.yida.data.common.core.entity.customform.CoreCustomFormModel; +import com.yida.data.customForm.mapper.CoreCustomFormModelMapper; +import com.yida.data.customForm.service.CoreCustomFormModelService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +/** +* 自定义表单模板 Service实现 +* +* @author wjm +* @date 2021-08-30 15:22:15 +*/ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormModelServiceImpl extends ServiceImpl + implements CoreCustomFormModelService { + +private final CoreCustomFormModelMapper coreCustomFormModelMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormRelationAdminServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormRelationAdminServiceImpl.java new file mode 100644 index 0000000..48ba604 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormRelationAdminServiceImpl.java @@ -0,0 +1,32 @@ +package com.yida.data.customForm.service.impl; + +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationAdmin; +import com.yida.data.customForm.mapper.CoreCustomFormRelationAdminMapper; +import com.yida.data.customForm.service.CoreCustomFormRelationAdminService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.QueryRequest; + +import java.util.List; + +/** +* 表单对应管理员 Service实现 +* +* @author ccl +* @date 2021-11-05 15:41:08 +*/ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormRelationAdminServiceImpl extends ServiceImpl + implements CoreCustomFormRelationAdminService { + +private final CoreCustomFormRelationAdminMapper coreCustomFormRelationAdminMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormRelationUserParentServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormRelationUserParentServiceImpl.java new file mode 100644 index 0000000..933913e --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormRelationUserParentServiceImpl.java @@ -0,0 +1,32 @@ +package com.yida.data.customForm.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUserParent; +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; +import com.yida.data.customForm.mapper.CoreCustomFormRelationUserParentMapper; +import com.yida.data.customForm.service.CoreCustomFormRelationUserParentService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +/** + * @author ccl + */ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormRelationUserParentServiceImpl extends ServiceImpl + implements CoreCustomFormRelationUserParentService { + @Override + public CoreCustomFormStatistic findParentStatistic(Long formId) { + Integer total = baseMapper.findTotal(formId); + Integer notCommit =baseMapper.findParentStatistic(formId); + CoreCustomFormStatistic formStatistic = new CoreCustomFormStatistic(); + formStatistic.setCustomFormId(formId); + formStatistic.setNotSubmitNum(notCommit); + formStatistic.setTotalNum(total); + formStatistic.setSubmitNum(total-notCommit); + return formStatistic; + } +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormRelationUserServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormRelationUserServiceImpl.java new file mode 100644 index 0000000..4d38b8e --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormRelationUserServiceImpl.java @@ -0,0 +1,54 @@ +package com.yida.data.customForm.service.impl; + +import com.yida.data.common.core.entity.customform.CoreCustomFormRelationUser; +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; +import com.yida.data.customForm.mapper.CoreCustomFormRelationUserMapper; +import com.yida.data.customForm.service.CoreCustomFormRelationUserService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.QueryRequest; + +import java.util.List; + +/** + * 表单对应可见人员表 Service实现 + * + * @author ccl + * @date 2021-11-05 15:41:11 + */ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormRelationUserServiceImpl extends ServiceImpl + implements CoreCustomFormRelationUserService { + + private final CoreCustomFormRelationUserMapper coreCustomFormRelationUserMapper; + + @Override + public Integer findUserNum(Long id) { + return baseMapper.findUserNum(id); + } + + @Override + public CoreCustomFormStatistic findStatistic(Long formId) { + Integer num = baseMapper.findNotCommit(formId); + CoreCustomFormStatistic formStatistic = new CoreCustomFormStatistic(); + formStatistic.setTotalNum(findUserNum(formId)); + formStatistic.setNotSubmitNum(num); + formStatistic.setSubmitNum(findUserNum(formId)-num); + formStatistic.setCustomFormId(formId); + return formStatistic; + } + + @Override + public Page findUserList(Page page, Integer type, String name, Long formId) { + + return baseMapper.findUserList(page,type,name,formId); + } +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormServiceImpl.java new file mode 100644 index 0000000..ba137f8 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormServiceImpl.java @@ -0,0 +1,1071 @@ +package com.yida.data.customForm.service.impl; + +import cc.mrbird.febs.common.redis.service.RedisService; +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.yida.data.common.core.entity.CurrentUser; +import com.yida.data.common.core.entity.classschedule.EduClassScheduleTimeModelDetail; +import com.yida.data.common.core.entity.constant.AppConstant; +import com.yida.data.common.core.entity.customform.*; +import com.yida.data.common.core.entity.job.Job; +import com.yida.data.common.core.entity.letter.EduLetterBox; +import com.yida.data.common.core.entity.notice.qywx.BaseSchoolNotice; +import com.yida.data.common.core.entity.notice.qywx.BaseStaffNotice; +import com.yida.data.common.core.entity.notice.qywx.TextSchoolNotice; +import com.yida.data.common.core.entity.notice.qywx.inside.Text; +import com.yida.data.common.core.entity.system.Dept; +import com.yida.data.common.core.entity.system.EduApp; +import com.yida.data.common.core.entity.user.EduParent; +import com.yida.data.common.core.entity.user.EduStaff; +import com.yida.data.common.core.entity.user.EduStaffDept; +import com.yida.data.common.core.entity.user.EduStudent; +import com.yida.data.common.core.exception.FebsException; +import com.yida.data.common.core.utils.ExcelUtil; +import com.yida.data.common.core.utils.WxUtil; +import com.yida.data.common.service.CommonService; +import com.yida.data.customForm.dto.RemindAgainDTO; +import com.yida.data.customForm.dto.SaveCustomFormDTO; +import com.yida.data.customForm.mapper.CoreCustomFormItemChildrenMapper; +import com.yida.data.customForm.mapper.CoreCustomFormItemsMapper; +import com.yida.data.customForm.mapper.CoreCustomFormMapper; +import com.yida.data.customForm.mapper.CoreCustomFormRelationUserMapper; +import com.yida.data.customForm.service.*; +import com.yida.data.customForm.vo.*; +import com.yida.data.job.feign.RemoteJobService; +import com.yida.data.user.feign.RemoteStaffService; +import com.yida.data.user.feign.RemoteStudentService; +import io.swagger.models.auth.In; +import javafx.scene.Parent; +import org.apache.tomcat.jni.Error; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.convert.EntityWriter; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.QueryRequest; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +import static com.yida.data.common.core.entity.constant.CachePrefixConstant.STAFF_DATA; +import static com.yida.data.common.core.entity.constant.CachePrefixConstant.STUDENT_DATA; + +/** + * 自定义表单 Service实现 + * + * @author wjm + * @date 2021-08-11 20:55:19 + */ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormServiceImpl extends ServiceImpl implements CoreCustomFormService { + + private static final String JOB_BEAN_NAME = "formUpdateTask"; + private static final String JOB_METHOD_NAME = "formUpdate"; + private static final String JOB_METHOD_NAME1 = "formRemind"; + @Resource + private final CoreCustomFormAuthRelationFormService relationFormService; + @Resource + private final CoreCustomFormRelationAdminService adminService; + @Resource + private final CoreCustomFormMapper coreCustomFormMapper; + @Resource + private CoreCustomFormItemsService coreCustomFormItemsService; + @Resource + private CoreCustomFormItemChildrenService coreCustomFormItemChildrenService; + @Resource + private CoreCustomFormRelationUserService relationUserService; + @Resource + private CoreCustomFormTopicalService topicalService; + @Resource + private CoreCustomFormRelationUserParentService parentService; + @Resource + private RemoteStaffService remoteStaffService; + @Resource + private CoreCustomFormDataService coreCustomFormDataService; + + @Resource + private CommonService commonService; + @Resource + private WxUtil wxUtil; + @Resource + private RedisService redisService; + + @Resource + private RemoteJobService remoteJobService; + @Resource + private RemoteStudentService remoteStudentService; + + @Value("${edu.customform.basetablename}") + private String baseTableName; + + @Value("${febs.parentFormUrl}") + private String parentFormUrl; + + @Value("${febs.teacherFormUrl}") + private String teacherFormUrl; + + @Override + public IPage findCustomFormPageList(Page page, Long schoolId, Long formTypeId, String model, CurrentUser currentUser) { + CoreCustomForm coreCustomForm = new CoreCustomForm(); + if (0 == formTypeId) { + coreCustomForm.setCreateId(currentUser.getUserId()); + coreCustomForm.setFormTypeId(null); + } else { + coreCustomForm.setFormTypeId(formTypeId); + } + coreCustomForm.setOrgId(schoolId); + IPage pageList = coreCustomFormMapper.findPageList(page, coreCustomForm); + pageList.getRecords().forEach(customForm -> { + String tableName = customForm.getTableName(); + if (ObjectUtil.isNotEmpty(tableName)) { + String sql = "SELECT count(id) FROM " + tableName; + int i = coreCustomFormMapper.initSqlReturnInt(sql); + customForm.setSubmitNum(i); + } + }); + return pageList; + } + + /*** + * @Author jianMingWang + * @Description 保存表单信息 + * @Date 15:39 2021/8/12 + * @Param [coreCustomForm] + * @return void + **/ + @Override + public Integer saveForm(CoreCustomForm coreCustomForm) { + + + if (ObjectUtil.isNotEmpty(coreCustomForm.getId())) { + CoreCustomForm byId = getById(coreCustomForm.getId()); + //2.1编辑时判断是否已发布,发布后不能修改 + if (byId.getStatus() == 1) { + //已发布,不能修改 + return 1; + } + updateById(coreCustomForm); + //2.2删除之前的任务 + remoteJobService.delJobByMethod(JOB_BEAN_NAME, JOB_METHOD_NAME, coreCustomForm.getId().toString()); + //2.4删除附表 + coreCustomFormItemsService.remove(Wrappers.query().lambda().eq(CoreCustomFormItems::getFormId, coreCustomForm.getId())); + coreCustomFormItemChildrenService.remove(Wrappers.query().lambda().eq(CoreCustomFormItemChildren::getFormId, coreCustomForm.getId())); + relationUserService.remove(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, coreCustomForm.getId())); + adminService.remove(Wrappers.lambdaQuery(new CoreCustomFormRelationAdmin()) + .eq(CoreCustomFormRelationAdmin::getCustomFormId, coreCustomForm.getId())); + //2.4删除表对应的管理员的权限 + relationFormService.remove(Wrappers.lambdaQuery(new CoreCustomFormAuthRelationForm()) + .eq(CoreCustomFormAuthRelationForm::getCustomFormId, coreCustomForm.getId())); + parentService.remove(Wrappers.lambdaQuery(new CoreCustomFormRelationUserParent()) + .eq(CoreCustomFormRelationUserParent::getCustomFormId, coreCustomForm.getId())); + } else { + coreCustomForm.setTableName(baseTableName + System.currentTimeMillis()); + save(coreCustomForm); + } + String droptableSql = "DROP TABLE IF EXISTS `" + coreCustomForm.getTableName() + "`; \n"; + + StringBuffer stringBuffer = new StringBuffer(); + String createTableSql = "CREATE TABLE " + coreCustomForm.getTableName() + "( \n" + "`id` int(11) NOT NULL AUTO_INCREMENT,\n"; + stringBuffer.append(createTableSql); + + + //3.1添加组件 + coreCustomForm.getCoreCustomFormItemsList().forEach(coreCustomFormItems -> { + + String typeValue = ""; + if ("moreInput".equals(coreCustomFormItems.getItemType())) { + typeValue = "text"; + } else { + typeValue = "varchar(255)"; + } + String filedName = coreCustomFormItems.getItemType() + System.currentTimeMillis(); + String sql = "`" + filedName + "` " + typeValue + " DEFAULT NULL COMMENT '" + coreCustomFormItems.getItemTitle() + "'"; + stringBuffer.append(sql).append(","); + + + coreCustomFormItems.setId(null); + coreCustomFormItems.setFormId(coreCustomForm.getId()); + coreCustomFormItems.setDelFlag(0); + coreCustomFormItems.setItemFiledName(filedName); + coreCustomFormItemsService.save(coreCustomFormItems); + + coreCustomFormItems.getCoreCustomFormItemChildrenList().forEach(coreCustomFormItemChildren -> { + coreCustomFormItemChildren.setId(null); + coreCustomFormItemChildren.setFormItemId(coreCustomFormItems.getId()); + coreCustomFormItemChildren.setFormId(coreCustomForm.getId()); + coreCustomFormItemChildrenService.save(coreCustomFormItemChildren); + + }); + + }); + + + //3.2执行创建表sql + + coreCustomFormMapper.initSqlReturnVoid(droptableSql); + + String initsql = stringBuffer + + "`user_id` bigint DEFAULT NULL,\n" + + "`create_date` datetime DEFAULT NULL,\n" + + "PRIMARY KEY (`id`)\n" + + ") ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8"; + + coreCustomFormMapper.initSqlReturnVoid(initsql); + + //4.1保存表单对应管理员和管理员对应权限 + List adminList = new ArrayList<>(); + List adminAuthList = new ArrayList<>(); + List formRelationAdmins = coreCustomForm.getFormRelationAdmins(); + for (CoreCustomFormRelationAdmin formRelationAdmin : formRelationAdmins) { + formRelationAdmin.setCustomFormId(coreCustomForm.getId()); + adminList.add(formRelationAdmin); + List relationForms = formRelationAdmin.getRelationForms(); + for (CoreCustomFormAuthRelationForm relationForm : relationForms) { + relationForm.setUserId(formRelationAdmin.getAdminId()); + relationForm.setCustomFormId(coreCustomForm.getId()); + adminAuthList.add(relationForm); + } + } + adminService.saveBatch(adminList); + + relationFormService.saveBatch(adminAuthList); + + //4.1保存填写人员列表,如果每个家长必须填,则保存家长WxId,如果为每个学生必须填,则保存学生id + + List userList = new ArrayList<>(); + List formRelationUsers = coreCustomForm.getFormRelationUsers(); + for (CoreCustomFormRelationUser formRelationUser : formRelationUsers) { + formRelationUser.setCustomFormId(coreCustomForm.getId()); + userList.add(formRelationUser); + } + relationUserService.saveBatch(userList); + //4.1.1如果表单收集对象为家长则保存家长微信id和家长id + List userParentList = new ArrayList<>(); + if (coreCustomForm.getRecever() == 2) { + for (CoreCustomFormRelationUser formRelationUser : userList) { + EduStudent student = (EduStudent) redisService.hget(STUDENT_DATA, formRelationUser.getUserId().toString()); + if (ObjectUtil.isEmpty(student)) { + student = remoteStudentService.getStudentNoPermission(formRelationUser.getUserId()).getData(); + redisService.hset(STUDENT_DATA, formRelationUser.getUserId().toString(), student); + } + List parents = student.getParents(); + for (EduParent parent : parents) { + CoreCustomFormRelationUserParent userParent = new CoreCustomFormRelationUserParent(); + userParent.setParentId(parent.getId()); + userParent.setParentWxId(parent.getWxId()); + userParent.setCustomFormId(coreCustomForm.getId()); + userParent.setCustomUserId(formRelationUser.getId()); + userParentList.add(userParent); + } + + } + } + parentService.saveBatch(userParentList); + + if (ObjectUtil.isEmpty(coreCustomForm.getId())) { + //1.新增主体表 + //1.1直接发布看需不需要提醒 + if (coreCustomForm.getStatus() == 1) { + //1.1.1发布时需要提醒用户且为家长 + if (coreCustomForm.getRemindUser() == 1) { + remindUser(coreCustomForm); + } + + //1.2定时发布 + if (coreCustomForm.getPublishType() == 1) { + + LocalDateTime publishDate = coreCustomForm.getPublishDate(); + Job job = new Job(); + job.setBeanName(JOB_BEAN_NAME); + job.setMethodName(JOB_METHOD_NAME); + job.setParams(coreCustomForm.getId().toString()); + job.setStatus(Job.ScheduleStatus.NORMAL.getValue()); + + // 1.2.1cron表达式 + String cron = "0" + + " " + + publishDate.getMinute() + + " " + + publishDate.getHour() + + " " + + publishDate.getDayOfMonth() + + " " + + publishDate.getMonthValue() + + " " + + "?" + + " " + + publishDate.getYear(); + job.setCronExpression(cron); + remoteJobService.saveJob(job); + } + } + } else { + //2.编辑 + + //2.3定时发布 + if (coreCustomForm.getPublishType() == 1) { + + LocalDateTime publishDate = coreCustomForm.getPublishDate(); + Job job = new Job(); + job.setBeanName(JOB_BEAN_NAME); + job.setMethodName(JOB_METHOD_NAME); + job.setParams(coreCustomForm.getId().toString()); + job.setStatus(Job.ScheduleStatus.NORMAL.getValue()); + + //2.3.1cron表达式 + String cron = "0" + + " " + + publishDate.getMinute() + + " " + + publishDate.getHour() + + " " + + publishDate.getDayOfMonth() + + " " + + publishDate.getMonthValue() + + " " + + "?" + + " " + + publishDate.getYear(); + job.setCronExpression(cron); + remoteJobService.saveJob(job); + } + //修改为立即发布看需不需要通知家长; + if (coreCustomForm.getStatus() == 1) { + if (coreCustomForm.getRemindUser()==1) { + remindUser(coreCustomForm); + } + } + } + return 200; + } + + /** + * 通知表单对应人员 + * @param coreCustomForm + */ + private void remindUser(CoreCustomForm coreCustomForm) { + if (coreCustomForm.getRecever() == 1 || coreCustomForm.getRecever() == 2) { + + List userId = new ArrayList<>(); + for (CoreCustomFormRelationUser formRelationUser : coreCustomForm.getFormRelationUsers()) { + userId.add(formRelationUser.getUserId()); + } + List parentId = remoteStudentService.findParentWxId(userId).getData(); + //1.1.2发送通知 + TextSchoolNotice textSchoolNotice = new TextSchoolNotice(); + EduApp appByCodeAndSchool = commonService.getAppByCodeAndSchool(AppConstant.CUSTOM_FORM_PARENT, null, coreCustomForm.getOrgId()); + + Text text = new Text(); + textSchoolNotice.setText(text); + textSchoolNotice.setAgentid(appByCodeAndSchool.getWxAgentId()); + String url = parentFormUrl + appByCodeAndSchool.getWxCorpId() + "&loginType=0&userType=1&state=" + AppConstant.CUSTOM_FORM_PARENT + "&id=" + coreCustomForm.getId(); + String remindUserModel = coreCustomForm.getRemindUserModel(); + if (ObjectUtil.isEmpty(remindUserModel)){ + remindUserModel = ""; + } + text.setContent("" + "《" + coreCustomForm.getFormTitle() + "》" + remindUserModel + ""); + textSchoolNotice.setTo_parent_userid(parentId); + String accessToken = wxUtil.getAccessToken(appByCodeAndSchool.getWxCorpId(), appByCodeAndSchool.getWxSecret()); + wxUtil.pushSchoolNotice(accessToken, textSchoolNotice); + + } + //通知教职工 + if (coreCustomForm.getRecever()==0){ + for (CoreCustomFormRelationUser relationUser : coreCustomForm.getFormRelationUsers()) { + EduStaff staff = remoteStaffService.getStaffNoPermission(relationUser.getUserId()).getData(); + BaseStaffNotice textSchoolNotice = new BaseStaffNotice(); + EduApp appByCodeAndSchool = commonService.getAppByCodeAndSchool(AppConstant.CUSTOM_FORM_TEACHER, null, coreCustomForm.getOrgId()); + Text text = new Text(); + textSchoolNotice.setText(text); + textSchoolNotice.setAgentid(appByCodeAndSchool.getWxAgentId()); + String url = teacherFormUrl + appByCodeAndSchool.getWxCorpId() + "&loginType=0&userType=0&state=" + AppConstant.CUSTOM_FORM_TEACHER + "&id=" + coreCustomForm.getId(); + String remindUserModel = coreCustomForm. getRemindUserModel(); + if (ObjectUtil.isEmpty(remindUserModel)){ + remindUserModel = ""; + } + text.setContent("" + "《" + coreCustomForm.getFormTitle() + "》" + remindUserModel + ""); + textSchoolNotice.setTouser(staff.getWxId()); + String accessToken = wxUtil.getAccessToken(appByCodeAndSchool.getWxCorpId(), appByCodeAndSchool.getWxSecret()); + wxUtil.pushStaffNotice(accessToken, textSchoolNotice); + } + } + //1.2看需不需要快结束时提醒 + if (coreCustomForm.getRemind() == 1) { + //创建定时任务,快结束时提醒 + LocalDateTime publishDate = coreCustomForm.getEndDate().minusHours(coreCustomForm.getRemindHour()); + Job job = new Job(); + job.setBeanName(JOB_BEAN_NAME); + job.setMethodName(JOB_METHOD_NAME1); + job.setParams(coreCustomForm.getId().toString()); + job.setStatus(Job.ScheduleStatus.NORMAL.getValue()); + + + // 1.2.1cron表达式 + String cron = "0" + + " " + + publishDate.getMinute() + + " " + + publishDate.getHour() + + " " + + publishDate.getDayOfMonth() + + " " + + publishDate.getMonthValue() + + " " + + "?" + + " " + + publishDate.getYear(); + job.setCronExpression(cron); + remoteJobService.saveJob(job); + } + } + + @Override + public IPage appFindFormList(Page page, Long userId, String tableName, Integer status, Long schoolId, Integer type) { + + List userIdList = new ArrayList<>(); + + + //type = 1 的时候 userId = 家长id + if (type == 1) { + List data = remoteStudentService.listStudentByParent(userId).getData(); + //空的证明没有学生直接返回; + if (CollectionUtil.isEmpty(data)) { + return new Page<>(); + } + for (EduStudent datum : data) { + userIdList.add(datum.getId()); + } + + IPage coreCustomFormIPage = baseMapper.appFindFormList(page, userIdList, tableName, status, schoolId, type); + for (CoreCustomForm record : coreCustomFormIPage.getRecords()) { + + if (record.getRecever() == 1) { + //已填报数量 + int size = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, record.getId()) + .eq(CoreCustomFormRelationUser::getFill, 1) + .in(CoreCustomFormRelationUser::getUserId, userIdList)).size(); + record.setFillNum(size); + //已填报数量需要填报数量 + int needSize = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, record.getId()) + .in(CoreCustomFormRelationUser::getUserId, userIdList)).size(); + record.setNeedFillNum(needSize); + } else { + Integer fillType = parentService.getOne(Wrappers.lambdaQuery(new CoreCustomFormRelationUserParent()) + .eq(CoreCustomFormRelationUserParent::getCustomFormId, record.getId()) + .eq(CoreCustomFormRelationUserParent::getParentId, userId)).getFillType(); + record.setFill(fillType); + } + } + return coreCustomFormIPage; + } else { + userIdList.add(userId); + + return baseMapper.appFindFormList(page, userIdList, tableName, status, schoolId, type); + } + } + + @Override + public IPage appFindAdminFormList(Page page, Long userId, String tableName, Integer status, Long schoolId) { + + return baseMapper.appFindAdminFormList(page, userId, tableName, status, schoolId); + } + + @Override + public Boolean appHandOnCustomForm(Long userId, Long schoolId) { + List list = adminService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationAdmin()) + .eq(CoreCustomFormRelationAdmin::getAdminId, userId)); + return !CollectionUtil.isEmpty(list); + } + + @Override + public CoreCustomForm findById(Long id) { + CoreCustomForm coreCustomForm = getById(id); + List coreCustomFormItemList = coreCustomFormItemsService.list(Wrappers.query().lambda().eq(CoreCustomFormItems::getFormId, id)); + coreCustomFormItemList.forEach(coreCustomFormItems -> { + List coreCustomFormItemChildrenList = coreCustomFormItemChildrenService.list(Wrappers.query().lambda().eq(CoreCustomFormItemChildren::getFormItemId, coreCustomFormItems.getId())); + coreCustomFormItems.setCoreCustomFormItemChildrenList(coreCustomFormItemChildrenList); + }); + coreCustomForm.setCoreCustomFormItemsList(coreCustomFormItemList); + + //查询表对应主题 + coreCustomForm.setCoreCustomFormTopical(topicalService.getOne(Wrappers.lambdaQuery(new CoreCustomFormTopical()) + .eq(CoreCustomFormTopical::getCustomFormId, id))); + //查询对应关联填写用户 + List list = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, id)); + coreCustomForm.setFormRelationUsers(list); + //查询对应关联管理员 + List relationAdmins = adminService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationAdmin()) + .eq(CoreCustomFormRelationAdmin::getCustomFormId, id)); + for (CoreCustomFormRelationAdmin relationAdmin : relationAdmins) { + //查询对应关联权限 + relationAdmin.setRelationForms(relationFormService.list(Wrappers.lambdaQuery(new CoreCustomFormAuthRelationForm()) + .eq(CoreCustomFormAuthRelationForm::getCustomFormId, id) + .eq(CoreCustomFormAuthRelationForm::getUserId, relationAdmin.getAdminId()))); + } + coreCustomForm.setFormRelationAdmins(relationAdmins); + + return coreCustomForm; + } + + @Override + public void delForm(Long id) { + //删除主表 + baseMapper.deleteById(id); + //删除附表 + relationUserService.remove(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, id)); + adminService.remove(Wrappers.lambdaQuery(new CoreCustomFormRelationAdmin()) + .eq(CoreCustomFormRelationAdmin::getCustomFormId, id)); + coreCustomFormItemsService.remove(Wrappers.lambdaQuery(new CoreCustomFormItems()) + .eq(CoreCustomFormItems::getFormId, id)); + coreCustomFormItemChildrenService.remove(Wrappers.lambdaQuery(new CoreCustomFormItemChildren()) + .eq(CoreCustomFormItemChildren::getFormId, id)); + relationFormService.remove(Wrappers.lambdaQuery(new CoreCustomFormAuthRelationForm()) + .eq(CoreCustomFormAuthRelationForm::getCustomFormId, id)); + topicalService.remove(Wrappers.lambdaQuery(new CoreCustomFormTopical()) + .eq(CoreCustomFormTopical::getCustomFormId, id)); + } + + @Override + public void updateAndSendNotice(Long formId) { + + //修改为发布 + update(Wrappers.lambdaUpdate(new CoreCustomForm()) + .eq(CoreCustomForm::getId, formId) + .set(CoreCustomForm::getStatus, 1)); + + CoreCustomForm coreCustomForm = getById(formId); + List list = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, formId)); + + //发布时需要提醒用户且为家长 + if (coreCustomForm.getRemindUser() == 1 && coreCustomForm.getRecever() == 1) { + List userId = new ArrayList<>(); + for (CoreCustomFormRelationUser formRelationUser : list) { + userId.add(formRelationUser.getUserId()); + } + List parentId = remoteStudentService.findParentWxId(userId).getData(); + //发送通知 + TextSchoolNotice textSchoolNotice = new TextSchoolNotice(); + EduApp appByCodeAndSchool = commonService.getAppByCodeAndSchool(AppConstant.CUSTOM_FORM_PARENT, null, coreCustomForm.getOrgId()); + + Text text = new Text(); + textSchoolNotice.setText(text); + textSchoolNotice.setAgentid(appByCodeAndSchool.getWxAgentId()); + String url = parentFormUrl + appByCodeAndSchool.getWxCorpId() + "&loginType=0&userType=1&state=" + AppConstant.CUSTOM_FORM_PARENT + "&id=" + coreCustomForm.getId(); + String remindUserModel = coreCustomForm.getRemindUserModel(); + if (ObjectUtil.isEmpty(remindUserModel)){ + remindUserModel = ""; + } + text.setContent("" + "《" + coreCustomForm.getFormTitle()+"》" + remindUserModel + ""); + textSchoolNotice.setTo_parent_userid(parentId); + String accessToken = wxUtil.getAccessToken(appByCodeAndSchool.getWxCorpId(), appByCodeAndSchool.getWxSecret()); + wxUtil.pushSchoolNotice(accessToken, textSchoolNotice); + } + //发布同时开启了快到期提醒 + if (coreCustomForm.getRemind() == 1) { + //创建定时任务,快结束时提醒 + LocalDateTime publishDate = coreCustomForm.getEndDate().minusHours(coreCustomForm.getRemindHour()); + //发布时的 + if (publishDate.isAfter(LocalDateTime.now())) { + + } + Job job = new Job(); + job.setBeanName(JOB_BEAN_NAME); + job.setMethodName(JOB_METHOD_NAME1); + job.setParams(coreCustomForm.getId().toString()); + job.setStatus(Job.ScheduleStatus.NORMAL.getValue()); + + StringBuilder cron = new StringBuilder(); + // 1.2.1cron表达式 + cron.append("0") + .append(" ") + .append(publishDate.getMinute()) + .append(" ") + .append(publishDate.getHour()) + .append(" ") + .append(publishDate.getDayOfMonth()) + .append(" ") + .append(publishDate.getMonthValue()) + .append(" ") + .append("?") + .append(" ") + .append(publishDate.getYear()); + job.setCronExpression(cron.toString()); + remoteJobService.saveJob(job); + } + } + + @Override + public Page findCommitUser(Long formId, Integer fillType, Page page) { + CoreCustomForm form = getById(formId); + List submitFormDataListByFormId = coreCustomFormDataService.findSubmitFormDataListByFormId(formId.intValue(), null, null); + List formItems = coreCustomFormItemsService.list(Wrappers.lambdaQuery(new CoreCustomFormItems()) + .eq(CoreCustomFormItems::getFormId, formId)); + + //接收对象为家长 + List commitUser = new ArrayList<>(); + if (form.getRecever() == 2) { + Page parentPage = parentService.page(page, Wrappers.lambdaQuery(new CoreCustomFormRelationUserParent()) + .eq(CoreCustomFormRelationUserParent::getCustomFormId, formId) + .eq(CoreCustomFormRelationUserParent::getFillType, fillType)); + for (CoreCustomFormRelationUserParent record : parentPage.getRecords()) { + List collect = submitFormDataListByFormId.stream().filter(o -> o.get("user_id").toString().equals(record.getParentId().toString())).collect(Collectors.toList()); + for (Map datum : collect) { + if (form.getRecever() == 0) { + datum.put("type", 0); + } else if (form.getRecever() == 1) { + datum.put("type", 1); + } + CoreCustomFormRelationUser byId = relationUserService.getById(record.getCustomUserId()); + EduStudent student = (EduStudent) redisService.hget(STUDENT_DATA, byId.getUserId().toString()); + if (ObjectUtil.isEmpty(student)) { + student = remoteStudentService.getStudentNoPermission(byId.getUserId()).getData(); + redisService.hset(STUDENT_DATA, byId.getUserId().toString(), student); + } + EduParent parent = student.getParents().stream().filter(p -> p.getId().equals(record.getParentId())).collect(Collectors.toList()).get(0); + List eduParents = new ArrayList<>(); + eduParents.add(parent); + student.setParents(eduParents); + datum.put("parent", parent); + datum.put("filedList", formItems); + } + Map map = new HashMap<>(); + map.put("staffAndData", collect); + commitUser.add(map); + } + Page page1 = new Page<>(); + page1.setSize(parentPage.getSize()); + page1.setCurrent(parentPage.getCurrent()); + page1.setTotal(parentPage.getTotal()); + page1.setRecords(commitUser); + return page1; + } + + Page userPage = relationUserService.page(page, Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, formId) + .eq(CoreCustomFormRelationUser::getFill, fillType)); + for (CoreCustomFormRelationUser record : userPage.getRecords()) { + EduStaff staff = new EduStaff(); + EduStudent student = new EduStudent(); + if (form.getRecever() == 0) { + staff = (EduStaff) redisService.hget(STAFF_DATA, record.getUserId().toString()); + if (ObjectUtil.isEmpty(staff)) { + staff = remoteStaffService.getStaff(record.getUserId()).getData(); + redisService.hset(STAFF_DATA, record.getUserId().toString(), staff); + } + } + if (form.getRecever() == 1) { + student = (EduStudent) redisService.hget(STUDENT_DATA, record.getUserId().toString()); + if (ObjectUtil.isEmpty(student)) { + student = remoteStudentService.getStudentNoPermission(record.getUserId()).getData(); + redisService.hset(STUDENT_DATA, record.getUserId().toString(), student); + } + } + // + List data = submitFormDataListByFormId.stream().filter(o -> o.get("user_id").toString().equals(record.getUserId().toString())).collect(Collectors.toList()); + + for (Map datum : data) { + if (form.getRecever() == 0) { + datum.put("type", 0); + } else if (form.getRecever() == 1) { + datum.put("type", 1); + } + datum.put("student", student); + datum.put("staff", staff); + datum.put("filedList", formItems); + } + Map map = new HashMap<>(); + map.put("staffAndData", data); + commitUser.add(map); + } + Page page1 = new Page<>(); + page1.setSize(userPage.getSize()); + page1.setCurrent(userPage.getCurrent()); + page1.setTotal(userPage.getTotal()); + page1.setRecords(commitUser); + return page1; + } + + @Override + public CoreCustomFormStatistic findStatistic(Long formId) { + CoreCustomForm byId = getById(formId); + //教职工和学生统计 + if (byId.getRecever() == 0 || byId.getRecever() == 1) { + return relationUserService.findStatistic(formId); + } + //家长统计 + return parentService.findParentStatistic(formId); + } + + @Override + public void remindAgain(RemindAgainDTO dto) { + CoreCustomForm byId = getById(dto.getFormId()); + + //查询未填报人员id, + List userIdList = dto.getUserId(); + if (CollectionUtil.isEmpty(userIdList)) { + List staffList = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, dto.getFormId()) + .eq(CoreCustomFormRelationUser::getFill, 0)); + for (CoreCustomFormRelationUser relationUser : staffList) { + userIdList.add(relationUser.getUserId()); + } + } + + //1.教职工通知 + if (byId.getRecever() == 0) { + for (Long staffId : userIdList) { + // + EduStaff staff = remoteStaffService.getStaffNoPermission(staffId).getData(); + BaseStaffNotice textSchoolNotice = new BaseStaffNotice(); + EduApp appByCodeAndSchool = commonService.getAppByCodeAndSchool(AppConstant.CUSTOM_FORM_TEACHER, null, byId.getOrgId()); + Text text = new Text(); + textSchoolNotice.setText(text); + textSchoolNotice.setAgentid(appByCodeAndSchool.getWxAgentId()); + String url = teacherFormUrl + appByCodeAndSchool.getWxCorpId() + "&loginType=0&userType=0&state=" + AppConstant.CUSTOM_FORM_PARENT + "&id=" + byId.getId(); + + text.setContent("" + "《" + byId.getFormTitle() + "》" + byId.getRemindUserModel() + ""); + textSchoolNotice.setTouser(staff.getWxId()); + String accessToken = wxUtil.getAccessToken(appByCodeAndSchool.getWxCorpId(), appByCodeAndSchool.getWxSecret()); + wxUtil.pushStaffNotice(accessToken, textSchoolNotice); + } + }//2.学生对象通知 + List parentWxId = remoteStudentService.findParentWxId(userIdList).getData(); + TextSchoolNotice textSchoolNotice = new TextSchoolNotice(); + EduApp appByCodeAndSchool = commonService.getAppByCodeAndSchool(AppConstant.CUSTOM_FORM_PARENT, null, byId.getOrgId()); + Text text = new Text(); + textSchoolNotice.setText(text); + textSchoolNotice.setAgentid(appByCodeAndSchool.getWxAgentId()); + String url = parentFormUrl + appByCodeAndSchool.getWxCorpId() + "&loginType=0&userType=1&state=" + AppConstant.CUSTOM_FORM_PARENT + "&id=" + byId.getId(); + String remindUserModel = byId.getRemindUserModel(); + if(ObjectUtil.isEmpty(remindUserModel)){ + remindUserModel = ""; + } + text.setContent("" + "《" + byId.getFormTitle() + "》" + remindUserModel + ""); + textSchoolNotice.setTo_parent_userid(parentWxId); + String accessToken = wxUtil.getAccessToken(appByCodeAndSchool.getWxCorpId(), appByCodeAndSchool.getWxSecret()); + wxUtil.pushSchoolNotice(accessToken, textSchoolNotice); + + } + + @Override + public void exportUserListInOut(Long formId, Integer status, HttpServletResponse response) { + //导出已提交或未提交人员数据 + CoreCustomForm form = getById(formId); + //填写的主体为教职工 + if (form.getRecever() == 0) { + //职工信息列表 + List importStaffList = new ArrayList<>(); + List staffIdList = new ArrayList<>(); + List list = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, formId) + .eq(CoreCustomFormRelationUser::getFill, status)); + for (CoreCustomFormRelationUser relationUser : list) { + staffIdList.add(relationUser.getUserId()); + } + for (Long staffId : staffIdList) { + EduStaff staff = (EduStaff) redisService.hget(STAFF_DATA, staffId.toString()); + ImportStaffVO importStaffVO = new ImportStaffVO(); + importStaffVO.setName(staff.getName()); + importStaffVO.setPhone(staff.getMobile()); + importStaffVO.setPosition(staff.getPosition()); + importStaffVO.setSchoolName(staff.getSchoolName()); + importStaffVO.setSex(staff.getSex()); + importStaffList.add(importStaffVO); + } + String name = ""; + if (status == 0) { + name = "未提交职工.xlsx"; + } else { + name = "已提交职工.xlsx"; + } + ExcelUtil.export(name, ImportStaffVO.class, importStaffList, response); + + } + //填写主体为学生 + else if (form.getRecever() == 1) { + //学生信息列表 + List importStudent = new ArrayList<>(); + List studentList = new ArrayList<>(); + List list = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, formId) + .eq(CoreCustomFormRelationUser::getFill, status)); + for (CoreCustomFormRelationUser relationUser : list) { + studentList.add(relationUser.getUserId()); + } + for (Long studentId : studentList) { + EduStudent student = (EduStudent) redisService.hget(STUDENT_DATA, studentId.toString()); + if (ObjectUtil.isEmpty(student)) { + student = remoteStudentService.getStudentNoPermission(studentId).getData(); + } + ImportStudentVO importStudentVO = new ImportStudentVO(); + importStudentVO.setCampusName(student.getCampusName()); + importStudentVO.setClassName(student.getClassName()); + importStudentVO.setGradeName(student.getGradeName()); + importStudentVO.setSchoolName(student.getSchoolName()); + importStudentVO.setSectionName(student.getSectionName()); + importStudentVO.setStudentName(student.getStuName()); + importStudentVO.setStudentNum(student.getStuNumber()); + importStudent.add(importStudentVO); + } + String name = ""; + if (status == 0) { + name = "未提交学生.xlsx"; + } else { + name = "已提交学生.xlsx"; + } + ExcelUtil.export(name, ImportStudentVO.class, importStudent, response); + } + //填写主体为家长 + else if (form.getRecever() == 2) { + //学生信息加家长信息b + List importParentVOList = new ArrayList<>(); + List parentList = parentService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUserParent()) + .eq(CoreCustomFormRelationUserParent::getCustomFormId, formId) + .eq(CoreCustomFormRelationUserParent::getFillType, status)); + + for (CoreCustomFormRelationUserParent parent : parentList) { + CoreCustomFormRelationUser byId = relationUserService.getById(parent.getCustomUserId()); + + EduStudent student = (EduStudent) redisService.hget(STUDENT_DATA, byId.getUserId().toString()); + List collect = student.getParents().stream().filter(s -> s.getWxId().equals(parent.getParentId())).collect(Collectors.toList()); + + ImportParentVO importParentVO = new ImportParentVO(); + importParentVO.setCampusName(student.getCampusName()); + importParentVO.setClassName(student.getClassName()); + importParentVO.setGradeName(student.getGradeName()); + importParentVO.setSchoolName(student.getSchoolName()); + importParentVO.setSectionName(student.getSectionName()); + importParentVO.setStudentName(student.getStuName()); + importParentVO.setParentName(collect.get(0).getParentType()); + importParentVO.setPhone(collect.get(0).getMobile()); + importParentVOList.add(importParentVO); + + } + String name = ""; + if (status == 0) { + name = "未提交家长.xlsx"; + } else { + name = "已提交家长.xlsx"; + } + ExcelUtil.export(name, ImportParentVO.class, importParentVOList, response); + } + } + + + @Override + public void publishForm(CoreCustomForm byId) { + //修改表单发布,通知对应人员 + updateById(byId); + if (byId.getStatus() == 1) { + //通知教职工 + if (byId.getRecever() == 0) { + List staffList = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, byId.getId())); + for (CoreCustomFormRelationUser relationUser : staffList) { + EduStaff staff = remoteStaffService.getStaffNoPermission(relationUser.getUserId()).getData(); + BaseStaffNotice textSchoolNotice = new BaseStaffNotice(); + EduApp appByCodeAndSchool = commonService.getAppByCodeAndSchool(AppConstant.CUSTOM_FORM_TEACHER, null, byId.getOrgId()); + Text text = new Text(); + textSchoolNotice.setText(text); + textSchoolNotice.setAgentid(appByCodeAndSchool.getWxAgentId()); + String url = teacherFormUrl + appByCodeAndSchool.getWxCorpId() + "&loginType=0&userType=0&state=" + AppConstant.CUSTOM_FORM_TEACHER + "&id=" + byId.getId(); + String remindUserModel = byId.getRemindUserModel(); + if(ObjectUtil.isEmpty(remindUserModel)){ + remindUserModel = ""; + } + text.setContent("" + "《" + byId.getFormTitle() + "》" + remindUserModel + ""); + textSchoolNotice.setTouser(staff.getWxId()); + String accessToken = wxUtil.getAccessToken(appByCodeAndSchool.getWxCorpId(), appByCodeAndSchool.getWxSecret()); + wxUtil.pushStaffNotice(accessToken, textSchoolNotice); + } + } + //通知学生所有家长 + else { + List studentList = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, byId.getId())); + List studentIdList = new ArrayList<>(); + for (CoreCustomFormRelationUser student : studentList) { + studentIdList.add(student.getUserId()); + } + List parentWxId = remoteStudentService.findParentWxId(studentIdList).getData(); + TextSchoolNotice textSchoolNotice = new TextSchoolNotice(); + EduApp appByCodeAndSchool = commonService.getAppByCodeAndSchool(AppConstant.CUSTOM_FORM_PARENT, null, byId.getOrgId()); + Text text = new Text(); + textSchoolNotice.setText(text); + textSchoolNotice.setAgentid(appByCodeAndSchool.getWxAgentId()); + String url = parentFormUrl + appByCodeAndSchool.getWxCorpId() + "&loginType=0&userType=1&state=" + AppConstant.CUSTOM_FORM_PARENT + "&id=" + byId.getId(); + String remindUserModel = byId.getRemindUserModel(); + if (ObjectUtil.isEmpty(remindUserModel)){ + remindUserModel = ""; + } + text.setContent("" + "《" + byId.getFormTitle() + "》" + remindUserModel + ""); + textSchoolNotice.setTo_parent_userid(parentWxId); + String accessToken = wxUtil.getAccessToken(appByCodeAndSchool.getWxCorpId(), appByCodeAndSchool.getWxSecret()); + wxUtil.pushSchoolNotice(accessToken, textSchoolNotice); + } + } else { + //撤回时,修改所有关联用户表为未填报,填报时间为null,清空对应data表 + relationUserService.update(Wrappers.lambdaUpdate(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, byId.getId()) + .set(CoreCustomFormRelationUser::getFill, 0)); + + //清空对应data表 + String sql = "truncate table " + byId.getTableName(); + coreCustomFormDataService.truncateTable(sql); + } + } + + + @Override + public CoreCustomForm appFindFormAndData(Long userId, Long formId) { + CoreCustomForm form = getById(formId); + List itemList = coreCustomFormItemsService.list(Wrappers.lambdaQuery(new CoreCustomFormItems()) + .eq(CoreCustomFormItems::getFormId, formId)); + for (CoreCustomFormItems coreCustomFormItems : itemList) { + List itemChildrenList = coreCustomFormItemChildrenService.list(Wrappers.lambdaQuery(new CoreCustomFormItemChildren()) + .eq(CoreCustomFormItemChildren::getFormId, formId) + .eq(CoreCustomFormItemChildren::getFormItemId, coreCustomFormItems.getId())); + coreCustomFormItems.setCoreCustomFormItemChildrenList(itemChildrenList); + } + form.setCoreCustomFormItemsList(itemList); + CoreCustomFormTopical topical = topicalService.getOne(Wrappers.lambdaQuery(new CoreCustomFormTopical()) + .eq(CoreCustomFormTopical::getCustomFormId, formId)); + form.setCoreCustomFormTopical(topical); + Map userData = coreCustomFormDataService.findData(formId, userId); + form.setData(userData); + return form; + } + + @Override + public CommitUserVO commitUser(Long formId, Integer type, String name, Page page) { + CoreCustomForm form = getById(formId); + List userList = new ArrayList<>(); + + Page page1 = relationUserService.findUserList(page, type, name, formId); + List parentList = parentService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUserParent()) + .eq(CoreCustomFormRelationUserParent::getCustomFormId, formId) + .eq(CoreCustomFormRelationUserParent::getFillType, type)); + if (form.getRecever() == 2) { + for (CoreCustomFormRelationUserParent userParent : parentList) { + Long studentId = relationUserService.getById(userParent.getCustomUserId()).getUserId(); + EduStudent student = (EduStudent) redisService.hget(STUDENT_DATA, studentId.toString()); + List parents = student.getParents(); + EduParent parent = parents.stream().filter(p -> p.getId().equals(userParent.getParentId())).collect(Collectors.toList()).get(0); + + CommitVO commitVO = new CommitVO(); + commitVO.setId(parent.getId()); + String deptName = student.getGradeName() + student.getClassName(); + commitVO.setDeptName(deptName); + commitVO.setName(student.getStuName() + parent.getParentType()); + userList.add(commitVO); + } + } + for (CoreCustomFormRelationUser user : page1.getRecords()) { + if (form.getRecever() == 0) { + EduStaff staff = (EduStaff) redisService.hget(STAFF_DATA, user.getUserId().toString()); + if (ObjectUtil.isEmpty(staff)) { + staff = remoteStaffService.getStaff(user.getUserId()).getData(); + } + CommitVO commitVO = new CommitVO(); + commitVO.setId(staff.getId()); + + commitVO.setName(staff.getName()); + List staffDept = staff.getStaffDept(); + String staffDeptName = ""; + for (int i = 0; i < staffDept.size(); i++) { + Dept dept = commonService.getDept(staffDept.get(i).getDeptId()); + if (i == staffDept.size() - 1) { + staffDeptName += dept.getDeptName(); + } else { + staffDeptName += dept.getDeptName() + "/"; + } + ; + + } + commitVO.setDeptName(staffDeptName); + userList.add(commitVO); + } else if (form.getRecever() == 1) { + EduStudent student = (EduStudent) redisService.hget(STUDENT_DATA, user.getUserId().toString()); + if (ObjectUtil.isEmpty(student)) { + student = remoteStudentService.getStudentNoPermission(user.getUserId()).getData(); + + } + CommitVO commitVO = new CommitVO(); + commitVO.setId(student.getId()); + String deptName = student.getGradeName() + student.getClassName(); + commitVO.setDeptName(deptName); + commitVO.setName(student.getStuName()); + userList.add(commitVO); + + } + } + CommitUserVO commitUserVO = new CommitUserVO(); + commitUserVO.setType(form.getRecever()); + commitUserVO.setRecord(userList); + commitUserVO.setPageNum(page1.getCurrent()); + commitUserVO.setPageSize(page1.getSize()); + commitUserVO.setTotal(page1.getTotal()); + + return commitUserVO; + } + + @Override + public List appFindStudentByForm(Long userId, Long formId) { + List data = remoteStudentService.listStudentByParent(userId).getData(); + List list = relationUserService.list(Wrappers.lambdaQuery(new CoreCustomFormRelationUser()) + .eq(CoreCustomFormRelationUser::getCustomFormId, formId)); + List studentList = new ArrayList<>(); + for (CoreCustomFormRelationUser relationUser : list) { + for (EduStudent datum : data) { + if (relationUser.getUserId().equals(datum.getId())) { + FormStudentVO formStudentVO = new FormStudentVO(); + formStudentVO.setFill(relationUser.getFill()); + formStudentVO.setStudentId(datum.getId()); + formStudentVO.setStudentName(datum.getStuName()); + studentList.add(formStudentVO); + } + } + } + return studentList; + } + + /*** + * @Author jianMingWang + * @Description 组装执行sql + * @Date 20:00 2021/8/10 + * @Param [] + * @return java.lang.String + **/ + public String createSql(CoreCustomFormItems coreCustomFormItem) { + String typeValue = ""; + if ("moreInput".equals(coreCustomFormItem.getItemType())) { + typeValue = "text"; + } else { + typeValue = "varchar(255)"; + } + String filedname = coreCustomFormItem.getItemType() + System.currentTimeMillis(); + return "`" + filedname + "` " + typeValue + " DEFAULT NULL COMMENT '" + coreCustomFormItem.getItemTitle() + "'"; + } + + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormStatisticServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormStatisticServiceImpl.java new file mode 100644 index 0000000..725cc33 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormStatisticServiceImpl.java @@ -0,0 +1,32 @@ +package com.yida.data.customForm.service.impl; + +import com.yida.data.common.core.entity.customform.CoreCustomFormStatistic; +import com.yida.data.customForm.mapper.CoreCustomFormStatisticMapper; +import com.yida.data.customForm.service.CoreCustomFormStatisticService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.QueryRequest; + +import java.util.List; + +/** +* 表单对应统计数据表 Service实现 +* +* @author ccl +* @date 2021-11-05 15:58:43 +*/ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormStatisticServiceImpl extends ServiceImpl + implements CoreCustomFormStatisticService { + +private final CoreCustomFormStatisticMapper coreCustomFormStatisticMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormTopicalServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormTopicalServiceImpl.java new file mode 100644 index 0000000..5247cfc --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormTopicalServiceImpl.java @@ -0,0 +1,32 @@ +package com.yida.data.customForm.service.impl; + +import com.yida.data.common.core.entity.customform.CoreCustomFormTopical; +import com.yida.data.customForm.mapper.CoreCustomFormTopicalMapper; +import com.yida.data.customForm.service.CoreCustomFormTopicalService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.QueryRequest; + +import java.util.List; + +/** +* 表单对应主题表 Service实现 +* +* @author ccl +* @date 2021-11-05 15:41:09 +*/ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormTopicalServiceImpl extends ServiceImpl + implements CoreCustomFormTopicalService { + +private final CoreCustomFormTopicalMapper coreCustomFormTopicalMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormTypeServiceImpl.java b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormTypeServiceImpl.java new file mode 100644 index 0000000..dd649c0 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/java/com/yida/data/customForm/service/impl/CoreCustomFormTypeServiceImpl.java @@ -0,0 +1,35 @@ +package com.yida.data.customForm.service.impl; + +import cn.hutool.core.util.ObjectUtil; +import com.yida.data.common.core.entity.CurrentUser; +import com.yida.data.common.core.entity.customform.CoreCustomForm; +import com.yida.data.common.core.entity.customform.CoreCustomFormType; +import com.yida.data.customForm.mapper.CoreCustomFormTypeMapper; +import com.yida.data.customForm.service.CoreCustomFormTypeService; +import org.checkerframework.checker.units.qual.C; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.annotation.Propagation; +import lombok.RequiredArgsConstructor; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.entity.QueryRequest; + +import java.util.List; + +/** + * 自定义表单类型表 Service实现 + * + * @author wjm + * @date 2021-08-12 10:56:57 + */ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true) +public class CoreCustomFormTypeServiceImpl extends ServiceImpl implements CoreCustomFormTypeService { + + private final CoreCustomFormTypeMapper coreCustomFormTypeMapper; + +} diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormAuthAdminMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormAuthAdminMapper.xml new file mode 100644 index 0000000..6891338 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormAuthAdminMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormAuthMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormAuthMapper.xml new file mode 100644 index 0000000..3294fcb --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormAuthMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormDataMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormDataMapper.xml new file mode 100644 index 0000000..02d9ea3 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormDataMapper.xml @@ -0,0 +1,36 @@ + + + + + ${sql} + + + ${sql} + + + + + + + + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormGroupMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormGroupMapper.xml new file mode 100644 index 0000000..145063f --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormGroupMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormGroupRelationFormMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormGroupRelationFormMapper.xml new file mode 100644 index 0000000..92d7cae --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormGroupRelationFormMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormItemChildrenMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormItemChildrenMapper.xml new file mode 100644 index 0000000..d9c80dd --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormItemChildrenMapper.xml @@ -0,0 +1,4 @@ + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormItemsMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormItemsMapper.xml new file mode 100644 index 0000000..6ec66f2 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormItemsMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormMapper.xml new file mode 100644 index 0000000..2cc4c19 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormMapper.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormModelItemChildrenMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormModelItemChildrenMapper.xml new file mode 100644 index 0000000..0b9e8df --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormModelItemChildrenMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormModelItemsMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormModelItemsMapper.xml new file mode 100644 index 0000000..a885383 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormModelItemsMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormModelMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormModelMapper.xml new file mode 100644 index 0000000..627c567 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormModelMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormRelationAdminMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormRelationAdminMapper.xml new file mode 100644 index 0000000..fd4c8d2 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormRelationAdminMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormRelationUserMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormRelationUserMapper.xml new file mode 100644 index 0000000..e85f226 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormRelationUserMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormRelationUserParentMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormRelationUserParentMapper.xml new file mode 100644 index 0000000..b8f110c --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormRelationUserParentMapper.xml @@ -0,0 +1,22 @@ + + + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormStatisticMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormStatisticMapper.xml new file mode 100644 index 0000000..45f94ee --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormStatisticMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormTopicalMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormTopicalMapper.xml new file mode 100644 index 0000000..b93c9c1 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormTopicalMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormTypeMapper.xml b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormTypeMapper.xml new file mode 100644 index 0000000..ad8c268 --- /dev/null +++ b/febs-server/edu-custom-form/edu-custom-form-biz/src/main/resources/mapper/CoreCustomFormTypeMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/fallback/transaction/RemoteStudentApplyServiceFallback.java b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/fallback/transaction/RemoteStudentApplyServiceFallback.java new file mode 100644 index 0000000..33b99ac --- /dev/null +++ b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/fallback/transaction/RemoteStudentApplyServiceFallback.java @@ -0,0 +1,38 @@ +package com.yida.data.school.fallback.transaction; + +import com.yida.data.common.core.annotation.Fallback; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.school.feign.transaction.RemoteStudentApplyService; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; +import java.util.Map; + +/** + * RemoteStudentApplyService fallback处理类 + * + * @author ZYJ + * @date 2022/8/26 + */ +@Slf4j +@Fallback +public class RemoteStudentApplyServiceFallback implements FallbackFactory { + + @Override + public RemoteStudentApplyService create(Throwable throwable) { + log.error("RemoteStudentApplyService fallback reason:{}", throwable.getMessage()); + + return new RemoteStudentApplyService() { + @Override + public ResultBean>> listApplyCode(Long[] studentIds) { + return null; + } + + @Override + public ResultBean hasApply(Long studentId, String applyCode) { + return null; + } + }; + } +} diff --git a/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/feign/transaction/RemoteStudentApplyService.java b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/feign/transaction/RemoteStudentApplyService.java new file mode 100644 index 0000000..61f0490 --- /dev/null +++ b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/feign/transaction/RemoteStudentApplyService.java @@ -0,0 +1,24 @@ +package com.yida.data.school.feign.transaction; + +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.constant.FebsServerConstant; + +import com.yida.data.school.fallback.transaction.RemoteStudentApplyServiceFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; +import java.util.Map; + +@FeignClient(value = FebsServerConstant.EDU_SCHOOL, contextId = "studentApplyServiceClient", + fallbackFactory = RemoteStudentApplyServiceFallback.class) +public interface RemoteStudentApplyService { + + @GetMapping("/in/transaction/studentApply/listApply") + ResultBean>> listApplyCode(@RequestParam("studentIds") Long[] studentIds); + + @GetMapping("/transaction/studentApply/hasApply") + ResultBean hasApply(@RequestParam("studentId") Long studentId, + @RequestParam("applyCode") String applyCode); +} diff --git a/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/news/ManuscriptPublishPathVO.java b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/news/ManuscriptPublishPathVO.java new file mode 100644 index 0000000..57d3fd5 --- /dev/null +++ b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/news/ManuscriptPublishPathVO.java @@ -0,0 +1,25 @@ +package com.yida.data.school.vo.news; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 发布稿件进度 - 实体 + */ +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Data +public class ManuscriptPublishPathVO { + + @ApiModelProperty("名称") + private String label; + + @ApiModelProperty("") + private Integer value; + + private static Integer wxPath = 0; +} diff --git a/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyImportErrorVO.java b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyImportErrorVO.java new file mode 100644 index 0000000..deff76b --- /dev/null +++ b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyImportErrorVO.java @@ -0,0 +1,14 @@ +package com.yida.data.school.vo.transcation; + +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +import lombok.Data; + +@Data +public class StudentApplyImportErrorVO { + + @ExcelProperty(index = 1, value = "有效结束时间") + @ApiModelProperty("错误信息") + private String errorMsg; +} diff --git a/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyImportProgressVO.java b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyImportProgressVO.java new file mode 100644 index 0000000..6b92e22 --- /dev/null +++ b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyImportProgressVO.java @@ -0,0 +1,13 @@ +package com.yida.data.school.vo.transcation; + +import lombok.Data; + +@Data +public class StudentApplyImportProgressVO { + + private Integer totalNum; + private Integer currentNum; + private String errorPageUrl; + private Integer finish; + private String redisKey; +} diff --git a/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyImportVO.java b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyImportVO.java new file mode 100644 index 0000000..8d1cd04 --- /dev/null +++ b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyImportVO.java @@ -0,0 +1,57 @@ +package com.yida.data.school.vo.transcation; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.yida.data.common.core.converter.LocalDateTimeConverter; +import io.swagger.annotations.ApiModelProperty; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Date; +import lombok.Data; + +@Data +public class StudentApplyImportVO { + + @ExcelProperty(index = 0, value = "序号") + @ApiModelProperty(value = "序号") + private Long indexNo; + + @ExcelProperty(index = 1, value = "学校名称") + @ApiModelProperty("学校名称") + private String schoolName; + + @ExcelProperty(index = 2, value = "校区名称") + @ApiModelProperty("校区名称") + private String campusName; + + @ExcelProperty(index = 3, value = "学段名称") + @ApiModelProperty("学段名称") + private String sectionName; + + @ExcelProperty(index = 4, value = "年级名称") + @ApiModelProperty("年级名称") + private String gradeName; + + @ExcelProperty(index = 5, value = "班级名称") + @ApiModelProperty("班级名称") + private String className; + + @ExcelProperty(index = 6, value = "学生姓名") + @ApiModelProperty("学生姓名") + private String studentName; + + @ExcelProperty(index = 7, value = "学生学号") + @ApiModelProperty("学生学号") + private String studentNumber; + + @ExcelProperty(index = 8, value = "开通应用") + @ApiModelProperty("开通应用") + private String applyCode; + + @ExcelProperty(index = 9, value = "有效开始时间") + @ApiModelProperty("有效开始时间") + private String startTime; + + @ExcelProperty(index = 10, value = "有效结束时间") + @ApiModelProperty("有效结束时间") + private String endTime; +} diff --git a/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyStatusVO.java b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyStatusVO.java new file mode 100644 index 0000000..d351555 --- /dev/null +++ b/febs-server/edu-school/edu-school-api/src/main/java/com/yida/data/school/vo/transcation/StudentApplyStatusVO.java @@ -0,0 +1,16 @@ +package com.yida.data.school.vo.transcation; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDate; + +@Data +public class StudentApplyStatusVO { + + @ApiModelProperty("应用状态,0-未开通,1-使用中,2-已过期") + private Integer status; + + @ApiModelProperty("过期时间") + private LocalDate deadLine; +} diff --git a/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/controller/EduStudentApplyController.java b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/controller/EduStudentApplyController.java new file mode 100644 index 0000000..45435de --- /dev/null +++ b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/controller/EduStudentApplyController.java @@ -0,0 +1,147 @@ +package com.yida.data.school.transaction.controller; + +import cc.mrbird.febs.common.redis.service.RedisService; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.annotation.ControllerLog; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.apply.EduApply; +import com.yida.data.common.core.entity.apply.EduStudentApply; +import com.yida.data.common.core.entity.constant.CachePrefixConstant; +import com.yida.data.common.core.entity.constant.FebsConstant; +import com.yida.data.common.core.utils.FebsUtil; +import com.yida.data.school.transaction.service.EduStudentApplyService; +import com.yida.data.school.vo.transcation.EduApplyVO; +import com.yida.data.school.vo.transcation.StudentApplyImportProgressVO; +import com.yida.data.school.vo.transcation.StudentApplyStatusVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import java.util.UUID; +import javax.servlet.http.HttpServletResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.time.LocalDateTime; +import org.springframework.web.multipart.MultipartFile; + +@Api(tags = "交易-学生应用关系") +@RequiredArgsConstructor +@RequestMapping("/transaction/studentApply") +@RestController +public class EduStudentApplyController { + + private final EduStudentApplyService eduStudentApplyService; + + private final RedisService redisService; + + + @ApiOperation("分页查询学生开通应用") + @GetMapping("/listStudentApply") + @ControllerLog(operation = "分页查询学生开通应用") + public ResultBean> listApply( + @ApiParam("学生名字") @RequestParam(required = false) String studentName, + @ApiParam("学号") @RequestParam(required = false) String studentNumber, + @ApiParam("学校ID") @RequestParam(required = false) Long schoolId, + @ApiParam("校区ID") @RequestParam(required = false) Long campusId, + @ApiParam("学段ID") @RequestParam(required = false) Long sectionId, + @ApiParam("年级ID") @RequestParam(required = false) Long gradeId, + @ApiParam("班级ID") @RequestParam(required = false) Long classId, + @ApiParam("当前页码") @RequestParam(defaultValue = "1") Integer pageNum, + @ApiParam("页面大小") @RequestParam(defaultValue = "10") Integer pageSize) { + Page page = new Page<>(); + page.setCurrent(pageNum); + page.setSize(pageSize); + + return ResultBean.buildSuccess( + eduStudentApplyService + .listStudentApply(studentName, studentNumber, schoolId, sectionId, campusId, gradeId, classId, page)); + } + + @ApiOperation("获取开通应用详情") + @GetMapping("/getStudentApply") + @ControllerLog(operation = "获取开通应用详情") + public ResultBean getStudentApply(@ApiParam("主键ID") Long id) { + return ResultBean.buildSuccess(eduStudentApplyService.getById(id)); + } + + @ApiOperation("删除开通应用") + @GetMapping("/deleteStudentApply") + @ControllerLog(operation = "删除学生开通应用") + public ResultBean deleteStudentApply(@ApiParam("主键ID") Long id) { + eduStudentApplyService.update(Wrappers.lambdaUpdate(new EduStudentApply()) + .eq(EduStudentApply::getId, id) + .set(EduStudentApply::getDelFlag, 1)); + return ResultBean.buildSuccess(); + } + + @ApiOperation("保存学生开通应用") + @PostMapping("/saveStudentApply") + @ControllerLog(operation = "保存学生开通应用") + public ResultBean insertApply(@ApiParam("开通应用") @RequestBody EduStudentApply eduStudentApply) { + eduStudentApplyService.save(eduStudentApply); + return ResultBean.buildSuccess(); + } + + + @ApiOperation("查询学生是否拥有该应用权限") + @GetMapping("/hasApply") + public ResultBean listApplyCode(@ApiParam("学生id") Long studentId, + @ApiParam("应用编码") String applyCode) { + return ResultBean.buildSuccess(eduStudentApplyService.count(Wrappers.lambdaQuery(new EduStudentApply()) + .eq(EduStudentApply::getStudentId, studentId) + .eq(EduStudentApply::getApplyCode, applyCode) + .ge(EduStudentApply::getEndTime, LocalDateTime.now()) + .le(EduStudentApply::getStartTime, LocalDateTime.now())) > 0); + } + + @ApiOperation("查询学生的应用状态") + @GetMapping("/getApplyStatus") + public ResultBean getApplyStatus(@ApiParam("学生id") Long studentId, + @ApiParam("应用编码") String applyCode) { + return ResultBean.buildSuccess(eduStudentApplyService.getStudentApplyStatus(studentId, applyCode)); + } + + + @ApiOperation("下载学生开通应用导入模板") + @PostMapping("/downloadTemplate") + public void downloadTemplate(HttpServletResponse response) throws Exception { + eduStudentApplyService.downloadTemplate(response); + } + + + @ApiOperation("导入学生开通应用信息") + @PostMapping("/importStudentApplyInfo") + public ResultBean importStudentApplyInfo(@RequestParam(value = "file") MultipartFile file) + throws Exception { + String redisKey = UUID.randomUUID().toString(); + StudentApplyImportProgressVO progressVO = new StudentApplyImportProgressVO(); + progressVO.setRedisKey(redisKey); + progressVO.setFinish(0); + progressVO.setTotalNum(0); + progressVO.setCurrentNum(0); + redisService.hset(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey, progressVO); + eduStudentApplyService.importStudentApplyInfo(file, redisKey); + return ResultBean.buildSuccess(progressVO); + } + + @ApiOperation("获取导入学生开通应用信息进度") + @GetMapping("/getImportStudentApplyInfoProgress") + public ResultBean getImportStudentApplyInfoProgress(@RequestParam("redisKey") String redisKey) { + return ResultBean.buildSuccess(eduStudentApplyService.getImportStudentApplyInfoProgress(redisKey)); + } + + @ApiOperation("删除缓存导入进度") + @GetMapping("/deleteRedisStudentApplyImportProgress") + public ResultBean deleteRedisStudentApplyImportProgress(@RequestParam("redisKey") String redisKey) { + redisService.hdel(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey); + return ResultBean.buildSuccess(); + } + +} diff --git a/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/controller/InEduStudentApplyController.java b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/controller/InEduStudentApplyController.java new file mode 100644 index 0000000..49a2cd2 --- /dev/null +++ b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/controller/InEduStudentApplyController.java @@ -0,0 +1,52 @@ +package com.yida.data.school.transaction.controller; + +import cc.mrbird.febs.common.redis.service.RedisService; +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.apply.EduStudentApply; +import com.yida.data.common.core.entity.constant.CachePrefixConstant; +import com.yida.data.school.transaction.service.EduStudentApplyService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Api(tags = "交易-学生应用关系(不鉴权)") +@RequiredArgsConstructor +@RequestMapping("/in/transaction/studentApply") +@RestController +public class InEduStudentApplyController { + + private final EduStudentApplyService eduStudentApplyService; + private final RedisService redisService; + + @ApiOperation("查询学生的应用编码列表") + @GetMapping("/listApply") + public ResultBean>> listApplyCode(@RequestParam("studentIds") Long[] studentIds) { + List applyCodeList = eduStudentApplyService.list(Wrappers.lambdaQuery(new EduStudentApply()) + .in(EduStudentApply::getStudentId, studentIds) + .ge(EduStudentApply::getEndTime, LocalDateTime.now()) + .le(EduStudentApply::getStartTime, LocalDateTime.now())); + Map> res = new HashMap<>(); + if (CollUtil.isNotEmpty(applyCodeList)) { + Map> collect = applyCodeList.stream().collect(Collectors.groupingBy(EduStudentApply::getStudentId)); + for (Map.Entry> entry : collect.entrySet()) { + List applyCode = entry.getValue().stream().map(x -> x.getApplyCode()).distinct().collect(Collectors.toList()); + res.put(entry.getKey(), applyCode); + redisService.hset(CachePrefixConstant.STUDENT_APPLY, entry.getKey().toString(), applyCode); + } + } + return ResultBean.buildSuccess(res); + } + +} diff --git a/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/listener/importStudentApplyListener.java b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/listener/importStudentApplyListener.java new file mode 100644 index 0000000..af6151f --- /dev/null +++ b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/listener/importStudentApplyListener.java @@ -0,0 +1,53 @@ +package com.yida.data.school.transaction.listener; + +import cc.mrbird.febs.common.redis.service.RedisService; +import cn.hutool.core.collection.CollUtil; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.yida.data.common.core.entity.apply.EduStudentApply; +import com.yida.data.common.service.CommonService; +import com.yida.data.school.transaction.service.EduStudentApplyService; +import com.yida.data.school.vo.transcation.StudentApplyImportVO; +import com.yida.data.user.dto.ImportStudentDormDTO; +import java.util.ArrayList; +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@RequiredArgsConstructor +public class importStudentApplyListener extends AnalysisEventListener { + + + private EduStudentApplyService eduStudentApplyService; + + + private List list = new ArrayList<>(); + + private String key; + + + public importStudentApplyListener(EduStudentApplyService eduStudentApplyService, String key) { + this.eduStudentApplyService = eduStudentApplyService; + this.key = key; + } + + @Override + public void invoke(StudentApplyImportVO data, AnalysisContext context) { + if (null == data) { + log.info("excel导入失败:{}", data.toString()); + } + list.add(data); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + saveData(); + } + + public void saveData() { + eduStudentApplyService.insertStudentApplyData(list, key); + } + +} diff --git a/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/mapper/EduStudentApplyMapper.java b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/mapper/EduStudentApplyMapper.java new file mode 100644 index 0000000..ba26394 --- /dev/null +++ b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/mapper/EduStudentApplyMapper.java @@ -0,0 +1,21 @@ +package com.yida.data.school.transaction.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.yida.data.common.core.entity.apply.EduStudentApply; + +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface EduStudentApplyMapper extends BaseMapper { + + List getStudentApplyStatus(@Param("studentId") Long studentId, + @Param("applyCode") String applyCode); + + IPage listStudentApply(@Param("studentName") String studentName, + @Param("studentNumber") String studentNumber, + @Param("schoolId") Long schoolId, @Param("sectionId") Long sectionId,@Param("campusId") Long campusId, + @Param("gradeId") Long gradeId, @Param("classId") Long classId, Page page); +} diff --git a/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/service/EduStudentApplyService.java b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/service/EduStudentApplyService.java new file mode 100644 index 0000000..ba07d56 --- /dev/null +++ b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/service/EduStudentApplyService.java @@ -0,0 +1,48 @@ +package com.yida.data.school.transaction.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.entity.apply.EduStudentApply; +import com.yida.data.school.vo.transcation.StudentApplyImportErrorVO; +import com.yida.data.school.vo.transcation.StudentApplyImportProgressVO; +import com.yida.data.school.vo.transcation.StudentApplyImportVO; +import com.yida.data.school.vo.transcation.StudentApplyStatusVO; +import io.swagger.annotations.ApiParam; +import java.io.IOException; +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.scheduling.annotation.Async; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; + +public interface EduStudentApplyService extends IService { + + StudentApplyStatusVO getStudentApplyStatus(Long studentId, String applyCode); + + IPage listStudentApply(String studentName, + String studentNumber, + Long schoolId, + Long sectionId, + Long campusId, + Long gradeId, + Long classId, + Page page); + + /** + * 下载学生开通应用模板 + * + * @param response + * @throws Exception + */ + void downloadTemplate(HttpServletResponse response) throws Exception; + + @Async + void importStudentApplyInfo(MultipartFile file, String redisKey) throws IOException; + + void insertStudentApplyData(List studentApplyImportVOList, String redisKey); + + StudentApplyImportProgressVO getImportStudentApplyInfoProgress( String redisKey); + +} diff --git a/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/service/impl/EduStudentApplyServiceImpl.java b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/service/impl/EduStudentApplyServiceImpl.java new file mode 100644 index 0000000..5922728 --- /dev/null +++ b/febs-server/edu-school/edu-school-biz/src/main/java/com/yida/data/school/transaction/service/impl/EduStudentApplyServiceImpl.java @@ -0,0 +1,245 @@ +package com.yida.data.school.transaction.service.impl; + +import cc.mrbird.febs.common.redis.service.RedisService; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.excel.EasyExcel; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.yida.data.common.core.common.ResultBean; +import com.yida.data.common.core.common.ResultMsgType; +import com.yida.data.common.core.entity.CurrentUser; +import com.yida.data.common.core.entity.apply.EduStudentApply; +import com.yida.data.common.core.entity.constant.CachePrefixConstant; +import com.yida.data.common.core.entity.system.Dept; +import com.yida.data.common.core.entity.user.EduStudent; +import com.yida.data.common.core.enums.ImportTemplateTypeEnum; +import com.yida.data.common.core.utils.FebsUtil; +import com.yida.data.common.core.utils.FileUtil; +import com.yida.data.common.service.CommonService; +import com.yida.data.school.transaction.listener.importStudentApplyListener; +import com.yida.data.school.transaction.mapper.EduStudentApplyMapper; +import com.yida.data.school.transaction.service.EduStudentApplyService; +import com.yida.data.school.vo.transcation.StudentApplyImportErrorVO; +import com.yida.data.school.vo.transcation.StudentApplyImportProgressVO; +import com.yida.data.school.vo.transcation.StudentApplyImportVO; +import com.yida.data.school.vo.transcation.StudentApplyStatusVO; +import com.yida.data.user.dto.ListStudentDTO; +import com.yida.data.user.dto.StudentErrorExportDTO; +import com.yida.data.user.dto.WelcomeInviteImportDTO; +import com.yida.data.user.feign.RemoteStudentService; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Objects; +import java.util.UUID; +import javax.servlet.http.HttpServletResponse; +import lombok.AllArgsConstructor; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.checkerframework.checker.units.qual.A; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.ClassPathResource; +import org.springframework.stereotype.Service; + +import java.time.LocalDateTime; +import java.util.List; +import org.springframework.util.StopWatch; +import org.springframework.web.multipart.MultipartFile; + +@Slf4j +@Service +@RequiredArgsConstructor +public class EduStudentApplyServiceImpl extends ServiceImpl implements + EduStudentApplyService { + + private final CommonService commonService; + + private final RedisService redisService; + + private final RemoteStudentService remoteStudentService; + + @Value("${febs.uploadUrl}") + private String uploadUrl; + + @Override + public StudentApplyStatusVO getStudentApplyStatus(Long studentId, String applyCode) { + StudentApplyStatusVO applyStatus = new StudentApplyStatusVO(); + List list = list(Wrappers.lambdaQuery(new EduStudentApply()).eq(EduStudentApply::getStudentId, + studentId) + .eq(EduStudentApply::getApplyCode, applyCode) + .ge(EduStudentApply::getEndTime, LocalDateTime.now()) + .le(EduStudentApply::getStartTime, LocalDateTime.now())); + if (CollUtil.isEmpty(list)) { + List applyList = baseMapper.getStudentApplyStatus(studentId, applyCode); + if (CollUtil.isNotEmpty(applyList)) { + applyStatus.setStatus(2); + applyStatus.setDeadLine(applyList.get(0).getEndTime().toLocalDate().plusDays(1L)); + } else { + applyStatus.setStatus(0); + } + } else { + applyStatus.setStatus(1); + } + return applyStatus; + } + + @Override + public IPage listStudentApply(String studentName, String studentNumber, Long schoolId, Long sectionId, + Long campusId, + Long gradeId, Long classId, Page page) { + IPage eduStudentApplyIPage = this.baseMapper + .listStudentApply(studentName, studentNumber, schoolId, sectionId, campusId, gradeId, classId, page); + return eduStudentApplyIPage; + } + + @Override + public void downloadTemplate(HttpServletResponse response) throws Exception { + + String fileName = "学生开通应用导入模板.xls"; + // 获取导入文件模板 + ClassPathResource classPathResource = new ClassPathResource("template/" + fileName); + InputStream inputStream = classPathResource.getInputStream(); + FileUtil.download(FileUtil.inputStreamToFile(inputStream), fileName, false, response); + } + + @Override + public void importStudentApplyInfo(MultipartFile file, String redisKey) throws IOException { + log.info("开始导入学生开通应用数据"); + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + EasyExcel.read(file.getInputStream(), StudentApplyImportVO.class, + new importStudentApplyListener(this, redisKey)) + .sheet(0).headRowNumber(1).doRead(); + stopWatch.stop(); + log.info("导入学生开通应用数据总共耗时: {}", stopWatch.getTotalTimeSeconds() + "秒"); + } + + @Override + public void insertStudentApplyData(List studentApplyImportVOList, String redisKey) { + StudentApplyImportProgressVO progressVO = new StudentApplyImportProgressVO(); + progressVO.setFinish(0); + progressVO.setTotalNum(studentApplyImportVOList.size()); + progressVO.setCurrentNum(0); + progressVO.setRedisKey(redisKey); + redisService.hset(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey, progressVO); + + List errorVOList = new ArrayList<>(); + List saveData = new ArrayList<>(); + Integer index = 1; + + for (StudentApplyImportVO studentApplyImportVO : studentApplyImportVOList) { + index++; + String baseMag = "第" + index + "行,"; + StudentApplyImportErrorVO studentApplyImportErrorVO = checkImportDataIsNull(index, studentApplyImportVO); + if (studentApplyImportErrorVO != null) { + errorVOList.add(studentApplyImportErrorVO); + continue; + } + Dept dept = commonService.getSchoolByName(studentApplyImportVO.getSchoolName()); + if (ObjectUtil.isNull(dept)) { + StudentApplyImportErrorVO errorVO = new StudentApplyImportErrorVO(); + errorVO.setErrorMsg(baseMag + "学校名称不匹配"); + errorVOList.add(errorVO); + continue; + } + // 根据学校ID、学号查询学生信息 检测学号与学生姓名是否匹配 + EduStudent student = new EduStudent(); + student.setSchoolId(dept.getDeptId()); + student.setStuNumber(studentApplyImportVO.getStudentNumber()); + List currentStudentList = remoteStudentService.listBaseStudentNoJoin(student).getData(); + if (CollUtil.isEmpty(currentStudentList)) { + StudentApplyImportErrorVO errorVO = new StudentApplyImportErrorVO(); + errorVO.setErrorMsg(baseMag + "学生学号有误"); + errorVOList.add(errorVO); + continue; + } + if (!ObjectUtil.equal(studentApplyImportVO.getStudentName(), currentStudentList.get(0).getStuName())) { + StudentApplyImportErrorVO errorVO = new StudentApplyImportErrorVO(); + errorVO.setErrorMsg(baseMag + "学生姓名与学号不匹配"); + errorVOList.add(errorVO); + continue; + } + EduStudentApply eduStudentApply = new EduStudentApply(); + eduStudentApply.setStudentId(currentStudentList.get(0).getId()); + eduStudentApply.setApplyCode(studentApplyImportVO.getApplyCode()); + eduStudentApply + .setStartTime(LocalDateTimeUtil + .parse(studentApplyImportVO.getStartTime() + " 00:00:00", "yyyy-MM-dd HH:mm:ss")); + eduStudentApply + .setEndTime(LocalDateTimeUtil + .parse(studentApplyImportVO.getEndTime() + " 00:00:00", "yyyy-MM-dd HH:mm:ss")); + saveData.add(eduStudentApply); + + progressVO.setCurrentNum(index - 1); + redisService.hset(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey, progressVO); + } + if (CollUtil.isNotEmpty(saveData)) { + super.saveBatch(saveData); + } + + productErrorExcel(errorVOList, progressVO); + } + + @Override + public StudentApplyImportProgressVO getImportStudentApplyInfoProgress(String redisKey) { + return (StudentApplyImportProgressVO) redisService + .hget(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, redisKey); + } + + + public void productErrorExcel(List errorVOList, StudentApplyImportProgressVO progressVO) { + // 错误信息文件名称 + if (CollUtil.isNotEmpty(errorVOList)) { + String fileName = FileUtil.getLocalUploadAddress() + UUID.randomUUID().toString() + ".xlsx"; + EasyExcel.write(fileName, StudentApplyImportErrorVO.class) + .sheet("错误信息") + .doWrite(errorVOList); + // 上传到媒资 + String url = FileUtil.uploadFileToMediaServer(uploadUrl, new File(fileName)); + progressVO.setErrorPageUrl(url); + } + progressVO.setFinish(1); + redisService.hset(CachePrefixConstant.IMPORT_STUDENT_APPLY_PROGRESS, progressVO.getRedisKey(), progressVO); + } + + /** + * 检测插入数据是否为空 + * + * @return + */ + public StudentApplyImportErrorVO checkImportDataIsNull(Integer index, StudentApplyImportVO studentApplyImportVO) { + StudentApplyImportErrorVO studentApplyImportErrorVO = null; + String baseMag = "第" + index + "行,"; + if (ObjectUtil.isNull(studentApplyImportVO.getSchoolName())) { + studentApplyImportErrorVO = new StudentApplyImportErrorVO(); + studentApplyImportErrorVO.setErrorMsg(baseMag + "学校名称为空"); + } + if (ObjectUtil.isNull(studentApplyImportVO.getStudentName())) { + studentApplyImportErrorVO = new StudentApplyImportErrorVO(); + studentApplyImportErrorVO.setErrorMsg(baseMag + "学生姓名为空"); + } + if (ObjectUtil.isNull(studentApplyImportVO.getStudentNumber())) { + studentApplyImportErrorVO = new StudentApplyImportErrorVO(); + studentApplyImportErrorVO.setErrorMsg(baseMag + "学生学号为空"); + } + if (ObjectUtil.isNull(studentApplyImportVO.getApplyCode())) { + studentApplyImportErrorVO = new StudentApplyImportErrorVO(); + studentApplyImportErrorVO.setErrorMsg(baseMag + "开通应用为空"); + } + if (ObjectUtil.isNull(studentApplyImportVO.getStartTime())) { + studentApplyImportErrorVO = new StudentApplyImportErrorVO(); + studentApplyImportErrorVO.setErrorMsg(baseMag + "有效开始时间为空"); + } + if (ObjectUtil.isNull(studentApplyImportVO.getStartTime())) { + studentApplyImportErrorVO = new StudentApplyImportErrorVO(); + studentApplyImportErrorVO.setErrorMsg(baseMag + "有效结束时间为空"); + } + return studentApplyImportErrorVO; + } +} diff --git a/febs-server/edu-school/edu-school-biz/src/main/resources/mapper/transaction/EduStudentApplyMapper.xml b/febs-server/edu-school/edu-school-biz/src/main/resources/mapper/transaction/EduStudentApplyMapper.xml new file mode 100644 index 0000000..71cd483 --- /dev/null +++ b/febs-server/edu-school/edu-school-biz/src/main/resources/mapper/transaction/EduStudentApplyMapper.xml @@ -0,0 +1,56 @@ + + + + + + \ No newline at end of file diff --git a/febs-server/edu-user/edu-user-biz/src/main/resources/template/一键邀请导入模板.xls b/febs-server/edu-user/edu-user-biz/src/main/resources/template/一键邀请导入模板.xls new file mode 100644 index 0000000..17f573a Binary files /dev/null and b/febs-server/edu-user/edu-user-biz/src/main/resources/template/一键邀请导入模板.xls differ