yumeng 2 rokov pred
rodič
commit
919f6998ef

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/MaterialInfoMapper.java

@@ -2,6 +2,7 @@ package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.MaterialInfo;
 import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -41,5 +42,7 @@ public interface MaterialInfoMapper extends BaseMapper<MaterialInfo> {
 
     void materialSync(@Param("projectId") Long projectId, @Param("toProjectId") Long toProjectId, @Param("productId") Long productId);
 
+    List<JSONObject> excelByIds(@Param("ids") JSONArray ids);
+
     // List<MaterialInfo> getListByParams(String tagCode, String type, Integer status, String materialName, String code, String startDate, String endDate, List<Long> projectIds, String ascription, String clipId, String shotId, String planId, Integer offlineFlag);
 }

+ 13 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml

@@ -263,5 +263,18 @@
         where product_id = #{productId}
         and status = 1
     </select>
+    <select id="excelByIds" resultType="com.alibaba.fastjson.JSONObject"
+            parameterType="com.alibaba.fastjson.JSONArray">
+        select material_name as 'name',url as 'url' from
+        ctop_material_info
+        where 1 = 1
+        <if test='ids != null and ids.size() > 0'>
+            AND id in
+            <foreach collection="ids" item="id" separator=","
+                     open="(" close=")">
+                #{id}
+            </foreach>
+        </if>
+    </select>
 
 </mapper>

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java

@@ -92,4 +92,6 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
     void materialSync(Long projectId, JSONArray toProjectIds);
 
     List<MaterialInfo> getExcelListByParams(String tagCode, String type, Integer status, String materialName, List<Long> projectIds, String code, String startDate, String endDate, String userId, String clipId, String shotId, String planId, String leaderName, Integer offlineFlag, Integer syncKuaishou, Integer syncBytedance, Integer materialInnovate);
+
+    List<JSONObject> excelByIds(JSONArray ids);
 }

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -1043,6 +1043,11 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         return materialInfoMapper.getListByParams(tagCode, type, status, materialName, code, startDate, endDate, userId, projectIds, ascription, clipId, shotId, planId, leaderName, offlineFlag, syncKuaishou, syncBytedance, materialInnovate);
     }
 
+    @Override
+    public List<JSONObject> excelByIds(JSONArray ids) {
+        return materialInfoMapper.excelByIds(ids);
+    }
+
 
     @Override
     public JSONArray getIdListByProject(Long projectId) {

+ 34 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -691,6 +691,40 @@ public class MaterialInfoController {
         }
     }
 
+    @RequestMapping("/excelByIds")
+    public void getExcelReport(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject requestJson) {
+        JSONArray ids = requestJson.getJSONArray("ids");
+        if (Check.isNull(ids)) {
+            return;
+        }
+        List<JSONObject> list = materialInfoService.excelByIds(ids);
+        if (!Check.isNull(list)) {
+            try {
+                List<List<Object>> excelList = new ArrayList<>();
+                for (int i = 0; i < list.size(); i++) {
+                    JSONObject jsonObject = list.get(i);
+                    List<Object> temp = new ArrayList<>();
+                    temp.add(jsonObject.getString("name"));
+                    temp.add(jsonObject.getString("url"));
+
+                    excelList.add(temp);
+
+                }
+                OutputStream os = response.getOutputStream();
+                ExportExcelUtils eeu = new ExportExcelUtils();
+                XSSFWorkbook workbook = new XSSFWorkbook();
+                String[] titles = {"素材名称", "素材链接"};
+                eeu.exportExcelForAttendance(workbook, 0, "素材信息", titles, excelList);
+                HttpUtils.setResponseHeader(response, "clockIn.xlsx");
+                workbook.write(os);
+                os.flush();
+                os.close();
+            } catch (IOException e) {
+                log.error(e.getMessage());
+            }
+        }
+    }
+
 
     @ApiOperation(value = "素材信息-分页列表查询", notes = "素材信息-分页列表查询")
     @GetMapping(value = "/supplierList")