Houjie
2025-06-15 b48c1c7c0fa1cd9f6a1234b4b616dee6be6a12fa
lxzn-module-tms/src/main/java/org/jeecg/modules/tms/controller/ToolsStocktakingBoundController.java
@@ -1,5 +1,6 @@
package org.jeecg.modules.tms.controller;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -15,10 +16,7 @@
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.ToolSharpening;
import org.jeecg.modules.tms.entity.ToolsStocktakingBound;
import org.jeecg.modules.tms.entity.ToolsStocktakingBoundDetail;
import org.jeecg.modules.tms.entity.*;
import org.jeecg.modules.tms.entity.dto.LossBoundFlowDto;
import org.jeecg.modules.tms.entity.dto.StocktakingBoundFlowDto;
import org.jeecg.modules.tms.entity.vo.ToolsStocktakingVo;
@@ -38,6 +36,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -172,27 +171,42 @@
    @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>()
        toolsStocktakingBoundService.updateById(toolsStocktakingBound);
        // 删除申请单明细数据
                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("明细不能为空");
        }
        for (ToolsStocktakingBoundDetail item : detailList) {
            item.setStocktakingBoundId(toolsStocktakingBound.getId());
            item.setToolId(item.getToolId());
            item.setToolCode(item.getToolCode());
            item.setRemark(item.getRemark());
            item.setStocktakingDate(item.getStocktakingDate());
            item.setBookQuantity(item.getBookQuantity());
            item.setAvailableQuantity(item.getAvailableQuantity());
            item.setPracticalQuantity(item.getPracticalQuantity());
            item.setSurplusDeficit(item.getSurplusDeficit());
            item.setDifferenceValue(item.getDifferenceValue());
            item.setParamaTableName(item.getParamaTableName());
            item.setForeignLanguageName(item.getForeignLanguageName());
            item.setChineseName(item.getChineseName());
            item.setSupplierId(item.getSupplierId());
            item.setStorageLocation(item.getStorageLocation());
            item.setToolMaterial(item.getToolMaterial());
            item.setToolModel(item.getToolModel());
            item.setPositionCode(item.getPositionCode());
            item.setClassifyId(item.getClassifyId());
            item.setApplicationType(item.getApplicationType());
            toolsStocktakingBoundDetailService.saveOrUpdate(item);
        }
        toolsStocktakingBoundDetailService.saveOrUpdateBatch(detailList);
        return Result.OK("操作成功!");
        detailList.forEach(item -> item.setStocktakingBoundId(stocktakingBound.getId()));
        toolsStocktakingBoundDetailService.saveBatch(detailList);
        return Result.OK("编辑成功");
    }