소스 검색

fix 考试导出模板

he2802 3 년 전
부모
커밋
b98bb8e421

+ 17 - 6
zhongzheng-admin/src/main/java/com/zhongzheng/controller/user/UserSubscribeController.java

@@ -12,6 +12,9 @@ import com.zhongzheng.common.core.domain.model.LoginUser;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.bank.vo.QuestionImport;
 import com.zhongzheng.modules.base.vo.UserProfileExportGaiVo;
+import com.zhongzheng.modules.exam.bo.ExamApplyGoodsQueryBo;
+import com.zhongzheng.modules.exam.service.IExamApplyGoodsService;
+import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
 import com.zhongzheng.modules.exam.vo.ExamApplyVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
 import com.zhongzheng.modules.grade.vo.ClassPeriodStudentExportVo;
@@ -56,6 +59,8 @@ public class UserSubscribeController extends BaseController {
 
     private final IUserExamGoodsService iUserExamGoodsService;
 
+    private final IExamApplyGoodsService iExamApplyGoodsService;
+
     /**
      * 查询用户预约考试列表
      */
@@ -177,7 +182,15 @@ public class UserSubscribeController extends BaseController {
     @PreAuthorize("@ss.hasPermi('system:profile:export')")
     @Log(title = "导出新增预约模板", businessType = BusinessType.EXPORT)
     @GetMapping("/exportNew")
-    public AjaxResult<Object> exportNew(UserSubscribeExportBo bo) {
+    public AjaxResult<Map<String,Object>> exportNew(UserSubscribeExportBo bo) {
+        Map<String,Object> map = new HashMap<>();
+        ExamApplyGoodsQueryBo examApplyGoodsQueryBo = new ExamApplyGoodsQueryBo();
+        examApplyGoodsQueryBo.setApplyId(bo.getApplyId());
+        List<ExamApplyGoodsVo> goodsList = iExamApplyGoodsService.listGoods(examApplyGoodsQueryBo);
+        ExcelUtil<ExamApplyGoodsVo> goodsUtil = new ExcelUtil<ExamApplyGoodsVo>(ExamApplyGoodsVo.class);
+        String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        map.put("goodsExcel",goodsUtil.exportEasyExcel(goodsUtil.exportEasyData(goodsList), bo.getApplyName()+"商品列表"+timeStr));
+
         if(Validator.isEmpty(bo.getApplySiteAddressTrain())){
             UserSubscribeExport export = new UserSubscribeExport();
             export.setRemark("导入时,请把示例删除");
@@ -193,8 +206,7 @@ public class UserSubscribeController extends BaseController {
             List<UserSubscribeExport> list = new ArrayList<>();
             list.add(export);
             ExcelUtil<UserSubscribeExport> util = new ExcelUtil<UserSubscribeExport>(UserSubscribeExport.class);
-            String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-            return util.exportEasyExcel(util.exportEasyData(list), "新增预约模板"+timeStr);
+            map.put("demoExcel",util.exportEasyExcel(util.exportEasyData(list), "新增预约模板"+timeStr));
         }else{
             //有考培地点
             UserSubscribeTrainExport export = new UserSubscribeTrainExport();
@@ -215,10 +227,9 @@ public class UserSubscribeController extends BaseController {
             List<UserSubscribeTrainExport> list = new ArrayList<>();
             list.add(export);
             ExcelUtil<UserSubscribeTrainExport> util = new ExcelUtil<UserSubscribeTrainExport>(UserSubscribeTrainExport.class);
-            String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-            return util.exportEasyExcel(util.exportEasyData(list), "新增预约模板"+timeStr);
+            map.put("demoExcel",util.exportEasyExcel(util.exportEasyData(list), "新增预约模板"+timeStr));
         }
-
+        return AjaxResult.success(map);
 
     }
 }

+ 7 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/mapper/ExamApplyGoodsMapper.java

@@ -1,7 +1,13 @@
 package com.zhongzheng.modules.exam.mapper;
 
+import com.zhongzheng.modules.exam.bo.ExamApplyGoodsQueryBo;
+import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
 import com.zhongzheng.modules.exam.domain.ExamApplyGoods;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
+import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
+
+import java.util.List;
 
 /**
  * 考试安排绑定商品Mapper接口
@@ -10,5 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @date 2021-12-07
  */
 public interface ExamApplyGoodsMapper extends BaseMapper<ExamApplyGoods> {
-
+    List<ExamApplyGoodsVo> listGoods(ExamApplyGoodsQueryBo bo);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/IExamApplyGoodsService.java

@@ -17,6 +17,8 @@ import java.util.List;
  * @date 2021-12-07
  */
 public interface IExamApplyGoodsService extends IService<ExamApplyGoods> {
+
+	List<ExamApplyGoodsVo> listGoods(ExamApplyGoodsQueryBo bo);
 	/**
 	 * 查询单个
 	 * @return

+ 5 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyGoodsServiceImpl.java

@@ -36,6 +36,11 @@ public class ExamApplyGoodsServiceImpl extends ServiceImpl<ExamApplyGoodsMapper,
     @Autowired
     private IExamApplyService examApplyService;
 
+    @Override
+    public List<ExamApplyGoodsVo> listGoods(ExamApplyGoodsQueryBo bo) {
+        return this.baseMapper.listGoods(bo);
+    }
+
     @Override
     public ExamApplyGoodsVo queryById(Long id){
         ExamApplyGoods db = this.baseMapper.selectById(id);

+ 9 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/vo/ExamApplyGoodsVo.java

@@ -1,6 +1,6 @@
 package com.zhongzheng.modules.exam.vo;
 
-import com.zhongzheng.common.annotation.Excel;
+import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -25,11 +25,17 @@ public class ExamApplyGoodsVo {
 	private Long id;
 
 	/** 绑定考试安排ID */
-	@Excel(name = "绑定考试安排ID")
 	@ApiModelProperty("绑定考试安排ID")
 	private Long applyId;
 	/** $column.columnComment */
-	@Excel(name = "绑定考试安排ID")
 	@ApiModelProperty("$column.columnComment")
 	private Long goodsId;
+
+	/** 考试开始时间段 */
+	@Excel(name = "商品编码",width = 30)
+	private String code;
+
+	/** 考试开始时间段 */
+	@Excel(name = "商品标题",width = 30)
+	private String goodsName;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserSubscribeExportBo.java

@@ -20,6 +20,10 @@ import java.util.List;
 @ApiModel("用户预约考试导出模板对象")
 public class UserSubscribeExportBo extends BaseEntity {
 
+	@Excel(name = "考试计划ID")
+	@ApiModelProperty("考试计划ID")
+	private Long applyId;
+
 	/** 考试标题 */
 	@Excel(name = "考试标题")
 	@ApiModelProperty("考试标题")

+ 20 - 0
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamApplyGoodsMapper.xml

@@ -12,5 +12,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="goodsId" column="goods_id"/>
     </resultMap>
 
+    <resultMap type="com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo" id="ExamApplyGoodsVoResult">
+        <result property="goodsName" column="goods_name"/>
+        <result property="code" column="code"/>
+        <result property="goodsId" column="goods_id"/>
+    </resultMap>
+
+    <select id="listGoods" parameterType="com.zhongzheng.modules.exam.bo.ExamApplyGoodsQueryBo" resultMap="ExamApplyGoodsVoResult">
+        SELECT
+        g.goods_name,
+        g.`code`
+        FROM
+        exam_apply_goods eg
+        LEFT JOIN goods g ON eg.goods_id = g.goods_id
+        WHERE
+        1=1
+        AND g.STATUS IN ( 1 )
+        <if test="applyId != null and applyId != ''">
+            and  eg.apply_id = #{applyId}
+        </if>
 
+    </select>
 </mapper>