master:库存明细导出;

pull/1121/head
liujiang 2025-06-12 00:16:16 +08:00
parent 0023a833bc
commit bf3e408059
8 changed files with 235 additions and 150 deletions

View File

@ -6,7 +6,12 @@ import com.ruoyi.common.core.controller.XktBaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.Page;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.controller.xkt.vo.storeProdStock.*;
import com.ruoyi.web.controller.xkt.vo.storeProdStorage.StoreStorageExportVO;
import com.ruoyi.xkt.dto.storeProdStorage.StoreStorageDetailDownloadDTO;
import com.ruoyi.xkt.dto.storeProdStorage.StoreStorageExportDTO;
import com.ruoyi.xkt.dto.storeProductStock.*;
import com.ruoyi.xkt.service.IStoreProductStockService;
import io.swagger.annotations.Api;
@ -15,6 +20,9 @@ import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.List;
@ -78,6 +86,18 @@ public class StoreProductStockController extends XktBaseController {
.toBean(stockAndDiscountVO, StoreProdStockAndDiscountDTO.class)), StoreProdStockAndDiscountResVO.class));
}
@ApiOperation(value = "导出库存", httpMethod = "POST", response = R.class)
@Log(title = "导出库存", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, @Validated @RequestBody StoreProdStockExportVO exportVO) throws UnsupportedEncodingException {
List<StoreProdStockDownloadDTO> downloadList = storeProdStockService.export(BeanUtil.toBean(exportVO, StoreProdStockExportDTO.class));
ExcelUtil<StoreProdStockDownloadDTO> util = new ExcelUtil<>(StoreProdStockDownloadDTO.class);
// 设置下载excel名
String encodedFileName = URLEncoder.encode("库存明细" + DateUtils.getDate(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename=" + encodedFileName + ".xlsx");
util.exportExcel(response, downloadList, "库存明细");
}
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.web.controller.xkt.vo.storeProdStock;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("档口库存导出数据")
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StoreProdStockExportVO {
@NotNull(message = "storeId不能为空!")
@ApiModelProperty(value = "storeId")
private Long storeId;
@ApiModelProperty(value = "storeProdStockIdList")
private List<Long> storeProdStockIdList;
@ApiModelProperty(value = "是否全量导出")
private Boolean fullExport;
}

View File

@ -0,0 +1,55 @@
package com.ruoyi.xkt.dto.storeProductStock;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import lombok.Data;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("库存明细导出")
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StoreProdStockDownloadDTO {
@Excel(name = "序号", cellType = Excel.ColumnType.NUMERIC, needMerge = true)
private Integer orderNum;
@Excel(name = "货号", needMerge = true)
private String prodArtNum;
@Excel(name = "颜色", needMerge = true)
private String colorName;
@Excel(name = "30")
private Integer size30Quantity;
@Excel(name = "31")
private Integer size31Quantity;
@Excel(name = "32")
private Integer size32Quantity;
@Excel(name = "33")
private Integer size33Quantity;
@Excel(name = "34")
private Integer size34Quantity;
@Excel(name = "35")
private Integer size35Quantity;
@Excel(name = "36")
private Integer size36Quantity;
@Excel(name = "37")
private Integer size37Quantity;
@Excel(name = "38")
private Integer size38Quantity;
@Excel(name = "39")
private Integer size39Quantity;
@Excel(name = "40")
private Integer size40Quantity;
@Excel(name = "41")
private Integer size41Quantity;
@Excel(name = "42")
private Integer size42Quantity;
@Excel(name = "43")
private Integer size43Quantity;
@Excel(name = "总库存")
private Integer totalQuantity;
}

View File

@ -0,0 +1,28 @@
package com.ruoyi.xkt.dto.storeProductStock;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel("档口库存导出数据")
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class StoreProdStockExportDTO {
@ApiModelProperty(value = "storeId")
private Long storeId;
@ApiModelProperty(value = "storeProdStockIdList")
private List<Long> storeProdStockIdList;
@ApiModelProperty(value = "是否全量导出")
private Boolean fullExport;
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.xkt.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.xkt.domain.StoreProductStock;
import com.ruoyi.xkt.dto.dailyStoreTag.DailyStoreTagDTO;
import com.ruoyi.xkt.dto.storeProductStock.StoreProdStockDownloadDTO;
import com.ruoyi.xkt.dto.storeProductStock.StoreProdStockPageDTO;
import com.ruoyi.xkt.dto.storeProductStock.StoreProdStockPageResDTO;
import org.apache.ibatis.annotations.Param;
@ -33,4 +34,19 @@ public interface StoreProductStockMapper extends BaseMapper<StoreProductStock> {
* @return List<DailyStoreTagDTO>
*/
List<DailyStoreTagDTO> selectTop10List(@Param("yesterday") Date yesterday, @Param("oneMonthAgo") Date oneMonthAgo);
/**
*
*
* @param storeProdStockIdList ID
* @return List<StoreProdStockDownloadDTO>
*/
List<StoreProdStockDownloadDTO> selectExportList(@Param("storeProdStockIdList") List<Long> storeProdStockIdList);
/**
*
*
* @return List<StoreProdStockDownloadDTO>
*/
List<StoreProdStockDownloadDTO> selectAllStockList();
}

View File

@ -91,4 +91,11 @@ public interface IStoreProductStockService {
*/
Integer checkAndUpdateStock(Long storeId, StoreProdCheckStockDTO checkStockDTO);
/**
*
*
* @param exportDTO
* @return List<StoreProdStockDownloadDTO>
*/
List<StoreProdStockDownloadDTO> export(StoreProdStockExportDTO exportDTO);
}

View File

@ -193,6 +193,26 @@ public class StoreProductStockServiceImpl implements IStoreProductStockService {
return this.storeProdStockMapper.updateById(stockList).size();
}
/**
*
*
* @param exportDTO
* @return List<StoreProdStockDownloadDTO>
*/
@Override
@Transactional(readOnly = true)
public List<StoreProdStockDownloadDTO> export(StoreProdStockExportDTO exportDTO) {
// 导出勾选
if (CollectionUtils.isNotEmpty(exportDTO.getStoreProdStockIdList())) {
return this.storeProdStockMapper.selectExportList(exportDTO.getStoreProdStockIdList());
// 导出所有库存明细
} else {
Optional.ofNullable(exportDTO.getFullExport())
.orElseThrow(() -> new ServiceException("全量导出fullExport不能为空!", HttpStatus.ERROR));
return this.storeProdStockMapper.selectAllStockList();
}
}
/**
*

View File

@ -3,156 +3,6 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.xkt.mapper.StoreProductStockMapper">
<resultMap type="StoreProductStock" id="StoreProductStockResult">
<result property="id" column="id" />
<result property="storeProdId" column="store_prod_id" />
<result property="storeProdColorId" column="store_prod_color_id" />
<result property="size30" column="size_30" />
<result property="size31" column="size_31" />
<result property="size32" column="size_32" />
<result property="size33" column="size_33" />
<result property="size34" column="size_34" />
<result property="size35" column="size_35" />
<result property="size36" column="size_36" />
<result property="size37" column="size_37" />
<result property="size38" column="size_38" />
<result property="size39" column="size_39" />
<result property="size40" column="size_40" />
<result property="size41" column="size_41" />
<result property="size42" column="size_42" />
<result property="size43" column="size_43" />
<result property="version" column="version" />
<result property="delFlag" column="del_flag" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectStoreProductStockVo">
select id, store_prod_id, store_prod_color_id, size_30, size_31, size_32, size_33, size_34, size_35, size_36, size_37, size_38, size_39, size_40, size_41, size_42, size_43, version, del_flag, create_by, create_time, update_by, update_time from store_product_stock
</sql>
<select id="selectStoreProductStockList" parameterType="StoreProductStock" resultMap="StoreProductStockResult">
<include refid="selectStoreProductStockVo"/>
<where>
<if test="storeProdId != null "> and store_prod_id = #{storeProdId}</if>
<if test="storeProdColorId != null "> and store_prod_color_id = #{storeProdColorId}</if>
<if test="size30 != null "> and size_30 = #{size30}</if>
<if test="size31 != null "> and size_31 = #{size31}</if>
<if test="size32 != null "> and size_32 = #{size32}</if>
<if test="size33 != null "> and size_33 = #{size33}</if>
<if test="size34 != null "> and size_34 = #{size34}</if>
<if test="size35 != null "> and size_35 = #{size35}</if>
<if test="size36 != null "> and size_36 = #{size36}</if>
<if test="size37 != null "> and size_37 = #{size37}</if>
<if test="size38 != null "> and size_38 = #{size38}</if>
<if test="size39 != null "> and size_39 = #{size39}</if>
<if test="size40 != null "> and size_40 = #{size40}</if>
<if test="size41 != null "> and size_41 = #{size41}</if>
<if test="size42 != null "> and size_42 = #{size42}</if>
<if test="size43 != null "> and size_43 = #{size43}</if>
<if test="version != null "> and version = #{version}</if>
</where>
</select>
<select id="selectStoreProductStockByStoreProdStockId" parameterType="Long" resultMap="StoreProductStockResult">
<include refid="selectStoreProductStockVo"/>
where id = #{id}
</select>
<insert id="insertStoreProductStock" parameterType="StoreProductStock" useGeneratedKeys="true" keyProperty="storeProdStockId">
insert into store_product_stock
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="storeProdId != null">store_prod_id,</if>
<if test="storeProdColorId != null">store_prod_color_id,</if>
<if test="size30 != null">size_30,</if>
<if test="size31 != null">size_31,</if>
<if test="size32 != null">size_32,</if>
<if test="size33 != null">size_33,</if>
<if test="size34 != null">size_34,</if>
<if test="size35 != null">size_35,</if>
<if test="size36 != null">size_36,</if>
<if test="size37 != null">size_37,</if>
<if test="size38 != null">size_38,</if>
<if test="size39 != null">size_39,</if>
<if test="size40 != null">size_40,</if>
<if test="size41 != null">size_41,</if>
<if test="size42 != null">size_42,</if>
<if test="size43 != null">size_43,</if>
<if test="version != null">version,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="storeProdId != null">#{storeProdId},</if>
<if test="storeProdColorId != null">#{storeProdColorId},</if>
<if test="size30 != null">#{size30},</if>
<if test="size31 != null">#{size31},</if>
<if test="size32 != null">#{size32},</if>
<if test="size33 != null">#{size33},</if>
<if test="size34 != null">#{size34},</if>
<if test="size35 != null">#{size35},</if>
<if test="size36 != null">#{size36},</if>
<if test="size37 != null">#{size37},</if>
<if test="size38 != null">#{size38},</if>
<if test="size39 != null">#{size39},</if>
<if test="size40 != null">#{size40},</if>
<if test="size41 != null">#{size41},</if>
<if test="size42 != null">#{size42},</if>
<if test="size43 != null">#{size43},</if>
<if test="version != null">#{version},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateStoreProductStock" parameterType="StoreProductStock">
update store_product_stock
<trim prefix="SET" suffixOverrides=",">
<if test="storeProdId != null">store_prod_id = #{storeProdId},</if>
<if test="storeProdColorId != null">store_prod_color_id = #{storeProdColorId},</if>
<if test="size30 != null">size_30 = #{size30},</if>
<if test="size31 != null">size_31 = #{size31},</if>
<if test="size32 != null">size_32 = #{size32},</if>
<if test="size33 != null">size_33 = #{size33},</if>
<if test="size34 != null">size_34 = #{size34},</if>
<if test="size35 != null">size_35 = #{size35},</if>
<if test="size36 != null">size_36 = #{size36},</if>
<if test="size37 != null">size_37 = #{size37},</if>
<if test="size38 != null">size_38 = #{size38},</if>
<if test="size39 != null">size_39 = #{size39},</if>
<if test="size40 != null">size_40 = #{size40},</if>
<if test="size41 != null">size_41 = #{size41},</if>
<if test="size42 != null">size_42 = #{size42},</if>
<if test="size43 != null">size_43 = #{size43},</if>
<if test="version != null">version = #{version},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteStoreProductStockByStoreProdStockId" parameterType="Long">
delete from store_product_stock where id = #{id}
</delete>
<delete id="deleteStoreProductStockByStoreProdStockIds" parameterType="String">
delete from store_product_stock where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectStockPage" parameterType="com.ruoyi.xkt.dto.storeProductStock.StoreProdStockPageDTO" resultType="com.ruoyi.xkt.dto.storeProductStock.StoreProdStockPageResDTO">
SELECT
@ -205,5 +55,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LIMIT 10
</select>
<select id="selectExportList" resultType="com.ruoyi.xkt.dto.storeProductStock.StoreProdStockDownloadDTO">
SELECT
DENSE_RANK() OVER ( ORDER BY sps.create_time DESC ) AS orderNum,
sps.prod_art_num,
sps.color_name,
sps.size_30 AS size30Quantity,
sps.size_31 AS size31Quantity,
sps.size_32 AS size32Quantity,
sps.size_33 AS size33Quantity,
sps.size_34 AS size34Quantity,
sps.size_35 AS size35Quantity,
sps.size_36 AS size36Quantity,
sps.size_37 AS size37Quantity,
sps.size_38 AS size38Quantity,
sps.size_39 AS size39Quantity,
sps.size_40 AS size40Quantity,
sps.size_41 AS size41Quantity,
sps.size_42 AS size42Quantity,
sps.size_43 AS size43Quantity,
COALESCE ( sps.size_30, 0 ) + COALESCE ( sps.size_31, 0 ) + COALESCE ( sps.size_32, 0 ) + COALESCE ( sps.size_33, 0 ) + COALESCE ( sps.size_34, 0 ) +
COALESCE ( sps.size_35, 0 ) + COALESCE ( sps.size_36, 0 ) + COALESCE ( sps.size_37, 0 ) + COALESCE ( sps.size_38, 0 ) + COALESCE ( sps.size_39, 0 ) +
COALESCE ( sps.size_40, 0 ) + COALESCE ( sps.size_41, 0 ) + COALESCE ( sps.size_42, 0 ) + COALESCE ( sps.size_43, 0 ) AS totalQuantity
FROM
store_product_stock sps
WHERE
sps.del_flag = 0
AND sps.id IN
<foreach collection="storeProdStockIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectAllStockList" resultType="com.ruoyi.xkt.dto.storeProductStock.StoreProdStockDownloadDTO">
SELECT
DENSE_RANK() OVER ( ORDER BY sps.create_time DESC ) AS orderNum,
sps.prod_art_num,
sps.color_name,
sps.size_30 AS size30Quantity,
sps.size_31 AS size31Quantity,
sps.size_32 AS size32Quantity,
sps.size_33 AS size33Quantity,
sps.size_34 AS size34Quantity,
sps.size_35 AS size35Quantity,
sps.size_36 AS size36Quantity,
sps.size_37 AS size37Quantity,
sps.size_38 AS size38Quantity,
sps.size_39 AS size39Quantity,
sps.size_40 AS size40Quantity,
sps.size_41 AS size41Quantity,
sps.size_42 AS size42Quantity,
sps.size_43 AS size43Quantity,
COALESCE ( sps.size_30, 0 ) + COALESCE ( sps.size_31, 0 ) + COALESCE ( sps.size_32, 0 ) + COALESCE ( sps.size_33, 0 ) + COALESCE ( sps.size_34, 0 ) +
COALESCE ( sps.size_35, 0 ) + COALESCE ( sps.size_36, 0 ) + COALESCE ( sps.size_37, 0 ) + COALESCE ( sps.size_38, 0 ) + COALESCE ( sps.size_39, 0 ) +
COALESCE ( sps.size_40, 0 ) + COALESCE ( sps.size_41, 0 ) + COALESCE ( sps.size_42, 0 ) + COALESCE ( sps.size_43, 0 ) AS totalQuantity
FROM
store_product_stock sps
WHERE
sps.del_flag = 0
</select>
</mapper>