From 3f69b4dfc585c4dfbc3c07a6acf5cdd838033636 Mon Sep 17 00:00:00 2001
From: liuguocan <527956374@qq.com>
Date: 星期二, 28 十一月 2023 14:45:49 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java |  191 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 179 insertions(+), 12 deletions(-)

diff --git a/consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java b/consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java
index 2747e39..6d2c4d5 100644
--- a/consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java
+++ b/consum-base/src/main/java/com/consum/base/controller/LWhFormScrappedController.java
@@ -1,23 +1,48 @@
 package com.consum.base.controller;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
 import com.consum.base.BaseController;
-import com.consum.base.pojo.LWhFormInventoryParam;
+import com.consum.base.core.utils.CommonUtil;
+import com.consum.base.core.utils.MapUtils;
+import com.consum.base.core.utils.MapperUtil;
+import com.consum.base.core.utils.PageUtil;
 import com.consum.base.pojo.LWhFormScrappedParam;
+import com.consum.base.pojo.excel.ScrappedInfoExport;
+import com.consum.base.pojo.query.LWhFormScrappedQry;
+import com.consum.base.pojo.response.FromTransferTemplateInfoVO;
+import com.consum.base.pojo.response.LWhFormScrappedExtendVO;
+import com.consum.base.pojo.response.LWhFormScrappedVO;
 import com.consum.base.service.LWhFormScrappedServiceImpl;
 import com.consum.model.po.FinSysTenantUser;
-import com.iplatform.model.po.S_user_core;
+import com.consum.model.po.LWhFormScrapped;
+import com.walker.infrastructure.utils.CollectionUtils;
 import com.walker.web.ResponseValue;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.compress.utils.Lists;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-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.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description 鎶ュ簾鍗�
  * @Author 鍗㈠簡闃�
  * @Date 2023/11/1
  */
+@Api(value = "鎶ュ簾鍗�", tags = "鎶ュ簾鍗�")
 @RestController
 @RequestMapping("/pc/l/wh/form/scrapped")
 public class LWhFormScrappedController extends BaseController {
@@ -25,22 +50,164 @@
     @Autowired
     private LWhFormScrappedServiceImpl lWhFormScrappedService;
 
+
     /**
-     * @Description  鏂板鎶ュ簾鍗�
+     * @Description 鏂板鎶ュ簾鍗�
      * @Author 鍗㈠簡闃�
      * @Date 2023/11/1
      */
+    @ApiOperation(value = "鏂板鎶ュ簾鍗�", notes = "鏂板鎶ュ簾鍗�")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "param")
+    })
     @PostMapping("/add")
-    public ResponseValue add(@RequestBody LWhFormScrappedParam param) {
-        //鏍规嵁鐩樼偣浜篿d鏌ヨ鐩樼偣浜�
-        S_user_core operatorUser = this.getUser(param.getOperatorId());
+    public ResponseValue add() {
+        LWhFormScrappedParam param = CommonUtil.getObjFromReqBody(LWhFormScrappedParam.class);
+        LWhFormScrappedParam query = new LWhFormScrappedParam();
+        CommonUtil.copyProperties(param, query);
+        param = query;
         FinSysTenantUser sysInfo = this.getSysInfo();
-        int result = this.lWhFormScrappedService.add(param, sysInfo,operatorUser);
-        if (result > 0) return ResponseValue.success(1);
+        int result = this.lWhFormScrappedService.add(param,0, this.getCurrentUser(), sysInfo);
+        if (result > 0) {
+            return ResponseValue.success(1);
+        }
         return ResponseValue.error("鏂板澶辫触锛�");
     }
 
+    @ApiOperation(value = "鏂板鎶ュ簾鍗�", notes = "鏂板鎶ュ簾鍗�")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "param")
+    })
+    @PostMapping("/deprAdd")
+    public ResponseValue deprAdd() {
+        LWhFormScrappedParam param = CommonUtil.getObjFromReqBody(LWhFormScrappedParam.class);
+        LWhFormScrappedParam query = new LWhFormScrappedParam();
+        CommonUtil.copyProperties(param, query);
+        param = query;
 
+        FinSysTenantUser sysInfo = this.getSysInfo();
+        int result = this.lWhFormScrappedService.add(param,1, this.getCurrentUser(), sysInfo);
+        if (result > 0) {
+            return ResponseValue.success(1);
+        }
+        return ResponseValue.error("鏂板澶辫触锛�");
+    }
+
+    /**
+     * @Description 鍒楄〃鏌ヨ
+     * @Author 鍗㈠簡闃�
+     * @Date 2023/11/02 1.鏌ヨ鎶ュ簾鍗� 2.鏌ヨ鎶ュ簾鍗曠墿鍝�
+     */
+    @ApiOperation(value = "鍒楄〃鏌ヨ", notes = "鍒楄〃鏌ヨ")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "param", value = "鏌ヨ鏉′欢", dataType = "LWhFormScrappedQry", paramType = "query")
+    })
+    @GetMapping("/list")
+    public ResponseValue queryList() {
+        LWhFormScrappedQry param = CommonUtil.getObjFromReq(LWhFormScrappedQry.class);
+        LWhFormScrappedQry query = new LWhFormScrappedQry();
+        CommonUtil.copyProperties(param, query);
+        param = query;
+
+        FinSysTenantUser sysInfo = getSysInfo();
+        if (sysInfo == null) {
+            return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
+        }
+        PageUtil genericPager = lWhFormScrappedService.queryList(param, sysInfo);
+        List<LWhFormScrapped> data = genericPager.getDatas();
+        List<LWhFormScrappedVO> result = Lists.newArrayList();
+        if (!CollectionUtils.isEmpty(data)) {
+            data.forEach(item -> {
+                LWhFormScrappedVO lWhFormScrappedVO = new LWhFormScrappedVO();
+                BeanUtils.copyProperties(item, lWhFormScrappedVO);
+                List<FromTransferTemplateInfoVO> list = Lists.newArrayList();
+                // 鏌ヨ鍨嬪彿鏁伴噺
+                String sql =
+                        "SELECT fsg.id,fsg.BASE_GOODS_TEMPLATE_ID goodsTemplatesId,fsg.GOODS_TEMPLATE_NAME goodsName,sum(counts) count FROM l_wh_form_scrapped fs left join l_wh_form_scrapped_goods fsg on fs.id = fsg.FORM_SCRAPPED_ID "
+                                + "where fsg.FORM_SCRAPPED_ID =:id group by fsg.BASE_GOODS_TEMPLATE_ID";
+                Map<String, Object> paramMap = new HashMap<>();
+                paramMap.put("id", item.getId());
+                List<Map<String, Object>> procureModelList = lWhFormScrappedService.select(sql, paramMap, new MapperUtil());
+                for (Map<String, Object> map : procureModelList) {
+                    FromTransferTemplateInfoVO fromTransferTemplateInfoVO = MapUtils.convertMapToObj(map, FromTransferTemplateInfoVO.class);
+                    list.add(fromTransferTemplateInfoVO);
+                }
+                lWhFormScrappedVO.setGoodTemplateInfo(list);
+                result.add(lWhFormScrappedVO);
+            });
+        }
+        genericPager.setDatas(result);
+        return ResponseValue.success(genericPager);
+    }
+
+    /**
+     * @Description 鏍规嵁id鏌ヨ璇︽儏
+     * @Author 鍗㈠簡闃�
+     * @Date 2023/11/2
+     */
+    @ApiOperation(value = "鏍规嵁id鏌ヨ璇︽儏", notes = "鏍规嵁id鏌ヨ璇︽儏")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "鎶ュ簾鍗昳d", dataType = "Long", paramType = "query")
+    })
+    @GetMapping("/detail")
+    public ResponseValue getById(Long id) {
+        if (id == null) {
+            return ResponseValue.error("鎶ュ簾鍗昳d涓虹┖");
+        }
+        LWhFormScrappedExtendVO scrappedExtend = this.lWhFormScrappedService.getById(id);
+        return ResponseValue.success(scrappedExtend);
+    }
+
+    /**
+     * 鎶ュ簾鏄庣粏
+     *
+     * @param
+     * @return
+     */
+    @ApiOperation(value = "鎶ュ簾鏄庣粏", notes = "鎶ュ簾鏄庣粏")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "param", value = "鏌ヨ鏉′欢", dataType = "LWhFormScrappedQry", paramType = "query")
+    })
+    @GetMapping("/list/detailList")
+    public ResponseValue queryDetailList( ) {
+        LWhFormScrappedQry param = CommonUtil.getObjFromReq(LWhFormScrappedQry.class);
+        LWhFormScrappedQry query = new LWhFormScrappedQry();
+        CommonUtil.copyProperties(param, query);
+        param = query;
+
+        FinSysTenantUser sysInfo = this.getSysInfo();
+        if (sysInfo == null) {
+            return ResponseValue.error("鐧诲綍鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
+        }
+        PageUtil pageUtil = lWhFormScrappedService.queryDetailList(param, sysInfo);
+        return ResponseValue.success(pageUtil);
+    }
+
+    /**
+     * @Description 瀵煎嚭鎶ュ簾鐧昏鍗�
+     * @Author 鍗㈠簡闃�
+     * @Date 2023/11/2
+     */
+    @GetMapping("/export")
+    public ResponseValue export(Long id, HttpServletRequest request, HttpServletResponse response) {
+        if (id == null) {
+            return ResponseValue.error("鎶ュ簾鍗昳d涓虹┖");
+        }
+        try {
+            OutputStream outputStream = response.getOutputStream();
+            List<Map<String, Object>> export = lWhFormScrappedService.export(id);
+            ExportParams exportParams = new ExportParams("鎶ュ簾鍗曠櫥璁�", "鎶ュ簾鍗曠櫥璁�");
+            Workbook sheets = ExcelExportUtil.exportExcel(exportParams, ScrappedInfoExport.class, export);
+            // 璁剧疆鍝嶅簲澶�
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
+            response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("鎶ュ簾鍗曠櫥璁�.xlsx", "utf-8"));
+            sheets.write(outputStream);
+            sheets.close();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        return ResponseValue.success();
+    }
 
 
 }

--
Gitblit v1.9.1