浏览代码

add 乐器置换支付接口

周箭河 4 年之前
父节点
当前提交
971c468d1d

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ReplacementInstrumentActivityDao.java

@@ -40,4 +40,19 @@ public interface ReplacementInstrumentActivityDao extends BaseDAO<Integer, Repla
      * @return
      */
     ReplacementInstrumentActivityStatDto getInfo(@Param("id") Integer id);
+
+
+    /**
+     * 获取问卷分页数据
+     * @param params
+     * @return
+     */
+    List<ReplacementInstrumentActivityStatDto> getPageList(Map<String, Object> params);
+
+    /**
+     * 获取问卷总条数
+     * @param params
+     * @return
+     */
+    Integer getCount(Map<String, Object> params);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ReplacementInstrumentActivityQueryInfo.java

@@ -15,6 +15,8 @@ public class ReplacementInstrumentActivityQueryInfo extends QueryInfo {
 
     private String specification;
 
+    private Boolean hasInstruments;
+
     public Integer getCooperationOrganId() {
         return cooperationOrganId;
     }
@@ -54,4 +56,12 @@ public class ReplacementInstrumentActivityQueryInfo extends QueryInfo {
     public void setSpecification(String specification) {
         this.specification = specification;
     }
+
+    public Boolean getHasInstruments() {
+        return hasInstruments;
+    }
+
+    public void setHasInstruments(Boolean hasInstruments) {
+        this.hasInstruments = hasInstruments;
+    }
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ReplacementInstrumentActivityService.java

@@ -20,6 +20,7 @@ public interface ReplacementInstrumentActivityService extends BaseService<Intege
 
     /**
      * 乐器置换的支付
+     *
      * @param replacementPayDto
      * @return
      * @throws Exception
@@ -28,6 +29,7 @@ public interface ReplacementInstrumentActivityService extends BaseService<Intege
 
     /**
      * 支付回调处理
+     *
      * @param studentPaymentOrder
      * @return
      */
@@ -35,9 +37,18 @@ public interface ReplacementInstrumentActivityService extends BaseService<Intege
 
     /**
      * 获取置换的详情
+     *
      * @param id
      * @return
      */
     ReplacementInstrumentActivityStatDto getInfo(Integer id);
 
+
+    /**
+     * 获取问卷列表
+     * @param queryInfo
+     * @return
+     */
+    PageInfo<ReplacementInstrumentActivityStatDto> getPageList(ReplacementInstrumentActivityQueryInfo queryInfo);
+
 }

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentActivityServiceImpl.java

@@ -338,4 +338,22 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
     public ReplacementInstrumentActivityStatDto getInfo(Integer id) {
         return replacementInstrumentActivityDao.getInfo(id);
     }
+
+    @Override
+    public PageInfo<ReplacementInstrumentActivityStatDto> getPageList(ReplacementInstrumentActivityQueryInfo queryInfo) {
+        PageInfo<ReplacementInstrumentActivityStatDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<String, Object>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<ReplacementInstrumentActivityStatDto> dataList = new ArrayList<>();
+        int count = replacementInstrumentActivityDao.getCount(params);
+
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = replacementInstrumentActivityDao.getPageList(params);
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
 }

+ 30 - 5
mec-biz/src/main/resources/config/mybatis/ReplacementInstrumentActivityMapper.xml

@@ -114,11 +114,7 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="ReplacementInstrumentActivityStatDto" parameterType="map">
-        SELECT ria.*,ri.brand_,ri.specification_,ri.param_,ri.market_price_,ri.discount_price_,ri.depreciation_price_,
-        ri.sale_price_,s.name_ subject_name_ FROM replacement_instrument_activity ria
-        LEFT JOIN replacement_instrument ri ON ri.id_ = ria.instruments_id_
-        LEFT JOIN subject s on s.id_ = ri.subject_id_
-        LEFT JOIN cooperation_organ co on co.id_ = ria.cooperation_organ_id_
+        SELECT * FROM replacement_instrument_activity
         <include refid="global.limit"/>
     </select>
 
@@ -142,12 +138,18 @@
             <if test="subjectId!=null">
                 AND ria.subject_id_ = #{subjectId}
             </if>
+            <if test="hasInstruments!=null">
+                AND ria.instruments_id_ >=1
+            </if>
             <if test="brand!=null and brand!=''">
                 AND ri.brand_ = #{brand}
             </if>
             <if test="specification!=null and specification!=''">
                 AND ri.specification_ = #{specification}
             </if>
+            <if test="organId != null">
+                AND FIND_IN_SET(o.organ_id_ , #{organId})
+            </if>
             <if test="search!=null and search!=''">
                 AND (ria.mobile_no_ LIKE CONCAT('%', #{search}, '%') OR ria.user_name_ LIKE CONCAT('%', #{search}, '%'))
             </if>
@@ -220,4 +222,27 @@
         LEFT JOIN subject s on s.id_ = ri.subject_id_
         WHERE ria.id_ = #{id}
     </select>
+
+    <!-- 获取问卷分页数据 -->
+    <select id="getPageList" resultMap="ReplacementInstrumentActivityStatDto" parameterType="map">
+        SELECT ria.*,ri.brand_,ri.specification_,ri.param_,ri.market_price_,ri.discount_price_,ri.depreciation_price_,
+        ri.sale_price_,s.name_ subject_name_,co.name_ cooperationOrganName FROM replacement_instrument_activity ria
+        LEFT JOIN replacement_instrument ri ON ri.id_ = ria.instruments_id_
+        LEFT JOIN subject s on s.id_ = ri.subject_id_
+        LEFT JOIN cooperation_organ co on co.id_ = ria.cooperation_organ_id_
+        LEFT JOIN organization o on o.id_ = co.organ_id_
+        <include refid="queryReplacementsCondition"/>
+        ORDER BY ria.id_ DESC
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 获取问卷总条数 -->
+    <select id="getCount" resultType="int">
+        SELECT COUNT(*)
+        FROM replacement_instrument_activity ria
+        LEFT JOIN replacement_instrument ri ON ri.id_ = ria.instruments_id_
+        LEFT JOIN cooperation_organ co on co.id_ = ria.cooperation_organ_id_
+        LEFT JOIN organization o on o.id_ = co.organ_id_
+        <include refid="queryReplacementsCondition"/>
+    </select>
 </mapper>

+ 66 - 2
mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentActivityController.java

@@ -5,22 +5,31 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
 import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
+import com.ym.mec.biz.dal.dto.StudentInstrumentExportDto;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.page.ReplacementInstrumentActivityQueryInfo;
 import com.ym.mec.biz.service.ReplacementInstrumentActivityService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.util.date.DateUtil;
+import com.ym.mec.util.excel.POIUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -42,7 +51,7 @@ public class ReplacementInstrumentActivityController extends BaseController {
     @ApiOperation(value = "分页查询列表")
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/queryPage')")
-    public Object queryPage(ReplacementInstrumentActivityQueryInfo queryInfo) {
+    public HttpResponseResult<PageInfo<ReplacementInstrumentActivityStatDto>> queryPage(ReplacementInstrumentActivityQueryInfo queryInfo) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             return failed("用户信息获取失败");
@@ -58,7 +67,8 @@ public class ReplacementInstrumentActivityController extends BaseController {
                 return failed("非法请求");
             }
         }
-        return succeed(replacementInstrumentActivityService.queryPage(queryInfo));
+        queryInfo.setHasInstruments(true);
+        return succeed(replacementInstrumentActivityService.getPageList(queryInfo));
     }
 
     @ApiOperation(value = "统计信息查询")
@@ -80,4 +90,58 @@ public class ReplacementInstrumentActivityController extends BaseController {
         replacementInstrumentActivityService.update(replacementInstrumentActivity);
         return succeed(replacementInstrumentActivity);
     }
+
+    @ApiOperation(value = "导出")
+    @GetMapping("/export")
+    @PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/export')")
+    public void export(ReplacementInstrumentActivityQueryInfo queryInfo, HttpServletResponse response) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败");
+        }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+            throw new BizException("用户所在分部异常");
+        } else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
+                throw new BizException("非法请求");
+            }
+        }
+        queryInfo.setHasInstruments(true);
+        queryInfo.setRows(99999);
+        PageInfo<ReplacementInstrumentActivityStatDto> pageList = replacementInstrumentActivityService.getPageList(queryInfo);
+
+        if (pageList.getTotal() <=0) {
+            throw new BizException("没有可导出的记录");
+        }
+
+        OutputStream outputStream = response.getOutputStream();
+        HSSFWorkbook workbook = null;
+        try {
+            String[] header = {"合作单位编号", "合作单位", "学员编号", "学员姓名", "联系电话", "声部", "品牌", "型号"};
+            String[] body = {"cooperationOrganId", "cooperationOrganName","userId", "userName", "mobileNo", "subjectName", "brand", "specification"};
+            workbook = POIUtil.exportExcel(header, body, pageList.getRows());
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attachment;filename=replacement-" + DateUtil.getDate(new Date()) + ".xls");
+            response.flushBuffer();
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+            outputStream.flush();
+            workbook.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (outputStream != null) {
+                try {
+                    workbook.close();
+                    outputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }