From 92bc6dca274eb45dc330f63b5a3f90a01458e157 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期二, 27 五月 2025 14:48:55 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/ToolsStocktakingBoundController.java |  286 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 286 insertions(+), 0 deletions(-)

diff --git a/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/ToolsStocktakingBoundController.java b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/ToolsStocktakingBoundController.java
new file mode 100644
index 0000000..ffef65a
--- /dev/null
+++ b/lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/ToolsStocktakingBoundController.java
@@ -0,0 +1,286 @@
+package org.jeecg.modules.tms.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.modules.system.service.ISysBusinessCodeRuleService;
+import org.jeecg.modules.tms.entity.BaseTools;
+import org.jeecg.modules.tms.entity.ToolsStocktakingBound;
+import org.jeecg.modules.tms.entity.ToolsStocktakingBoundDetail;
+import org.jeecg.modules.tms.entity.dto.LossBoundFlowDto;
+import org.jeecg.modules.tms.entity.dto.StocktakingBoundFlowDto;
+import org.jeecg.modules.tms.entity.vo.ToolsStocktakingVo;
+import org.jeecg.modules.tms.enums.OutBillStatus;
+import org.jeecg.modules.tms.mapper.ToolsStocktakingBoundMapper;
+import org.jeecg.modules.tms.service.IToolsStocktakingBoundDetailService;
+import org.jeecg.modules.tms.service.IToolsStocktakingBoundService;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 鐩樼偣鍗曡〃
+ * @Author: houjie
+ * @Date: 2025-05-16
+ * @Version: V1.0
+ */
+@Api(tags = "鐩樼偣鍗曡〃")
+@RestController
+@RequestMapping("/tms/toolsStocktakingBound")
+@Slf4j
+public class ToolsStocktakingBoundController {
+    @Autowired
+    private IToolsStocktakingBoundService toolsStocktakingBoundService;
+    @Autowired
+    private IToolsStocktakingBoundDetailService toolsStocktakingBoundDetailService;
+    @Autowired
+    private ToolsStocktakingBoundMapper toolsStocktakingBoundMapper;
+
+    @Autowired
+    private ISysBusinessCodeRuleService businessCodeRuleService;
+
+    /**
+     * 鍒嗛〉鍒楄〃鏌ヨ
+     *
+     * @param toolsStocktakingBound
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    //@AutoLog(value = "鐩樼偣鍗曡〃-鍒嗛〉鍒楄〃鏌ヨ")
+    @ApiOperation(value = "鐩樼偣鍗曡〃-鍒嗛〉鍒楄〃鏌ヨ", notes = "鐩樼偣鍗曡〃-鍒嗛〉鍒楄〃鏌ヨ")
+    @GetMapping(value = "/list")
+    public Result<IPage<ToolsStocktakingBound>> queryPageList(ToolsStocktakingBound toolsStocktakingBound,
+                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                              HttpServletRequest req) {
+        QueryWrapper<ToolsStocktakingBound> queryWrapper = QueryGenerator.initQueryWrapper(toolsStocktakingBound, req.getParameterMap());
+        Page<ToolsStocktakingBound> page = new Page<ToolsStocktakingBound>(pageNo, pageSize);
+        IPage<ToolsStocktakingBound> pageList = toolsStocktakingBoundService.page(page, queryWrapper);
+        return Result.OK(pageList);
+    }
+
+
+    /**
+     * 娣诲姞
+     *
+     * @param toolsStocktakingBound
+     * @return
+     */
+    @AutoLog(value = "tms_stocktaking_bound-娣诲姞")
+    @ApiOperation(value = "tms_stocktaking_bound-娣诲姞", notes = "tms_stocktaking_bound-娣诲姞")
+    @PostMapping(value = "/add")
+    @Transactional(rollbackFor = {Exception.class})
+    public Result<String> add(@RequestBody ToolsStocktakingBound toolsStocktakingBound) {
+        toolsStocktakingBound.setApprovalStatus(OutBillStatus.DRAFT.getValue());
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (sysUser != null) {
+            toolsStocktakingBound.setHandler(sysUser.getId());
+        }
+        toolsStocktakingBound.setOrderCode(businessCodeRuleService.generateBusinessCodeSeq("stocktakingBound"));
+        //鏍¢獙鐗╂枡鍦ㄥ師鏉愭枡鍛ㄨ浆搴撳瓨涓嶅瓨鍦�
+        List<ToolsStocktakingBoundDetail> toolsStocktakingBoundDetailList = toolsStocktakingBound.getToolsStocktakingBoundDetailList();
+
+        toolsStocktakingBoundService.save(toolsStocktakingBound);
+        for (int i = 0; i < toolsStocktakingBoundDetailList.size(); i++) {
+            ToolsStocktakingBoundDetail toolsStocktakingBoundDetail = toolsStocktakingBoundDetailList.get(i);
+            toolsStocktakingBoundDetail.setAvailableQuantity(toolsStocktakingBoundDetail.getBookQuantity());
+            toolsStocktakingBoundDetail.setPracticalQuantity(toolsStocktakingBoundDetail.getPracticalQuantity());
+            toolsStocktakingBoundDetail.setSurplusDeficit(toolsStocktakingBoundDetail.getSurplusDeficit());
+            toolsStocktakingBoundDetail.setStocktakingDate(toolsStocktakingBoundDetail.getStocktakingDate());
+            toolsStocktakingBoundDetail.setRemark(toolsStocktakingBoundDetail.getRemark());
+            toolsStocktakingBoundDetail.setToolId(toolsStocktakingBoundDetail.getToolId());
+            toolsStocktakingBoundDetail.setToolCode(toolsStocktakingBoundDetail.getToolCode());
+            toolsStocktakingBoundDetail.setStocktakingBoundId(toolsStocktakingBound.getId());
+            toolsStocktakingBoundDetailService.save(toolsStocktakingBoundDetail);
+        }
+        return Result.OK();
+
+
+    }
+
+
+    @ApiOperation(value = "宸ュ叿鐩樼偣鏄庣粏-閫氳繃涓昏〃ID鏌ヨ", notes = "宸ュ叿鐩樼偣鏄庣粏-閫氳繃涓昏〃ID鏌ヨ")
+    @GetMapping(value = "/listToolsStocktakingBoundControllerDetailsByMainId")
+    public Result<IPage<ToolsStocktakingBoundDetail>> listToolsStocktakingBoundControllerDetailsByMainId(BaseTools baseTools,
+                                                                                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                                                         HttpServletRequest req) {
+        Map<String, String[]> parameterMap = req.getParameterMap();
+        Page<ToolsStocktakingBoundDetail> page = new Page<ToolsStocktakingBoundDetail>(pageNo, pageSize);
+        IPage<ToolsStocktakingBoundDetail> pageList = toolsStocktakingBoundDetailService.selectByMainId(page, parameterMap);
+
+        return Result.OK(pageList);
+    }
+
+
+    @AutoLog(value = "tms_stocktaking_bound-鎻愪氦鐩樼偣鍗�")
+    @ApiOperation(value = "tms_stocktaking_bound-鎻愪氦鐩樼偣鍗�", notes = "tms_stocktaking_bound-鎻愪氦鐩樼偣鍗�")
+    @GetMapping(value = "/submit")
+    public Result<String> submit(@RequestParam(name = "id") String id) {
+
+
+        toolsStocktakingBoundService.submintOrder(id);
+        return Result.OK("鎻愪氦鎴愬姛");
+    }
+
+    /**
+     * 瀹℃壒娴佺▼
+     * @param stocktakingBoundFlowDto
+     * @return
+     */
+    @AutoLog(value = "瀹℃壒娴佺▼")
+    @ApiOperation(value = "鎶ユ崯鍗�-瀹℃壒娴佺▼", notes = "鎶ユ崯鍗�-瀹℃壒娴佺▼")
+    @PostMapping("/approval")
+    public Result<?> approval(@RequestBody StocktakingBoundFlowDto stocktakingBoundFlowDto) {
+        toolsStocktakingBoundService.approvalProcess(stocktakingBoundFlowDto);
+        return Result.OK("鎿嶄綔鎴愬姛");
+    }
+    /**
+     * 缂栬緫
+     *
+     * @param toolsStocktakingBound
+     * @return
+     */
+    @AutoLog(value = "鐩樼偣鍗曡〃-缂栬緫")
+    @ApiOperation(value = "鐩樼偣鍗曡〃-缂栬緫", notes = "鐩樼偣鍗曡〃-缂栬緫")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    @Transactional(rollbackFor = {Exception.class})
+    public Result<String> edit(@RequestBody ToolsStocktakingBound toolsStocktakingBound) {
+        if (toolsStocktakingBound == null || StringUtils.isBlank(toolsStocktakingBound.getId())) {
+            return Result.error("鍙傛暟閿欒");
+        }
+
+        toolsStocktakingBoundDetailService.remove(new LambdaQueryWrapper<ToolsStocktakingBoundDetail>()
+                .eq(ToolsStocktakingBoundDetail::getStocktakingBoundId, toolsStocktakingBound.getId()));
+
+        ToolsStocktakingBound stocktakingBound = new ToolsStocktakingBound();
+        BeanUtils.copyProperties(stocktakingBound, toolsStocktakingBound);
+        toolsStocktakingBoundMapper.updateById(stocktakingBound);
+
+
+        List<ToolsStocktakingBoundDetail> detailList = toolsStocktakingBound.getToolsStocktakingBoundDetailList();
+        if (CollectionUtils.isEmpty(detailList)) {
+            return Result.error("鏄庣粏涓嶈兘涓虹┖");
+        }
+
+        detailList.forEach(item -> item.setStocktakingBoundId(stocktakingBound.getId()));
+        toolsStocktakingBoundDetailService.saveBatch(detailList);
+
+        return Result.OK("缂栬緫鎴愬姛");
+    }
+
+
+    /**
+     * 閫氳繃id鍒犻櫎
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "鐩樼偣鍗曡〃-閫氳繃id鍒犻櫎")
+    @ApiOperation(value = "鐩樼偣鍗曡〃-閫氳繃id鍒犻櫎", notes = "鐩樼偣鍗曡〃-閫氳繃id鍒犻櫎")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        toolsStocktakingBoundService.delMain(id);
+        return Result.OK("鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "鐩樼偣鍗曡〃-鎵归噺鍒犻櫎")
+    @ApiOperation(value = "鐩樼偣鍗曡〃-鎵归噺鍒犻櫎", notes = "鐩樼偣鍗曡〃-鎵归噺鍒犻櫎")
+
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.toolsStocktakingBoundService.delBatchMain(Arrays.asList(ids.split(",")));
+        return Result.OK("鎵归噺鍒犻櫎鎴愬姛锛�");
+    }
+
+    /**
+     * 閫氳繃id鏌ヨ
+     *
+     * @param id
+     * @return
+     */
+    //@AutoLog(value = "鐩樼偣鍗曡〃-閫氳繃id鏌ヨ")
+    @ApiOperation(value = "鐩樼偣鍗曡〃-閫氳繃id鏌ヨ", notes = "鐩樼偣鍗曡〃-閫氳繃id鏌ヨ")
+    @GetMapping(value = "/queryById")
+    public Result<ToolsStocktakingBound> queryById(@RequestParam(name = "id", required = true) String id) {
+        ToolsStocktakingBound toolsStocktakingBound = toolsStocktakingBoundService.getById(id);
+        if (toolsStocktakingBound == null) {
+            return Result.error("鏈壘鍒板搴旀暟鎹�");
+        }
+        return Result.OK(toolsStocktakingBound);
+
+    }
+
+
+    /**
+     * 閫氳繃excel瀵煎叆鏁版嵁
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            // 鑾峰彇涓婁紶鏂囦欢瀵硅薄
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<ToolsStocktakingVo> list = ExcelImportUtil.importExcel(file.getInputStream(), ToolsStocktakingVo.class, params);
+                for (ToolsStocktakingVo page : list) {
+                    ToolsStocktakingBound po = new ToolsStocktakingBound();
+                    BeanUtils.copyProperties(page, po);
+                    toolsStocktakingBoundService.saveMain(po, page.getToolsStocktakingBoundDetailList());
+                }
+                return Result.OK("鏂囦欢瀵煎叆鎴愬姛锛佹暟鎹鏁�:" + list.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("鏂囦欢瀵煎叆澶辫触:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.OK("鏂囦欢瀵煎叆澶辫触锛�");
+    }
+
+}

--
Gitblit v1.9.3