fix: sku weight export effective date format

pull/8040/head
Gauthier LO 2025-02-17 15:21:19 +01:00
parent c9aac600c0
commit 15f220e1cc
6 changed files with 56 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package org.jeecg.modules.business.controller.admin;
import java.util.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -8,6 +9,7 @@ import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.config.JeecgBaseConfig;
import org.jeecg.modules.business.entity.Sku;
import org.jeecg.modules.business.entity.SkuWeight;
import org.jeecg.modules.business.mongoService.SkuMongoService;
@ -24,6 +26,9 @@ import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.business.vo.Responses;
import org.jeecg.modules.business.vo.SkuWeightParam;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@ -54,6 +59,8 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
private ISecurityService securityService;
@Autowired
private SkuMongoService skuMongoService;
@Resource
private JeecgBaseConfig jeecgBaseConfig;
/**
*
@ -143,12 +150,27 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
* excel
*
* @param request
* @param skuWeight
*/
@RequiresPermissions("business:sku_weight:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, SkuWeight skuWeight) {
return super.exportXls(request, skuWeight, SkuWeight.class, "sku_weight");
public ModelAndView exportXls(HttpServletRequest request) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<String> selections = new ArrayList<>();
request.getParameterMap().forEach((k,v) -> {
if(k.equals("selections[]")) {
selections.addAll(Arrays.asList(v));
}
});
List<SkuWeight> exportList = skuWeightService.exportToExcel(selections);
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "SKU重量");
mv.addObject(NormalExcelConstants.CLASS, SkuWeight.class);
ExportParams exportParams=new ExportParams("SKU重量报表", "导出人:" + sysUser.getRealname(), "SKU重量");
exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload());
mv.addObject(NormalExcelConstants.PARAMS,exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv;
}
/**

View File

@ -69,7 +69,9 @@ public class SkuWeight implements Serializable {
/**
*
*/
@Excel(name = "生效日期", width = 15)
@JsonFormat(timezone = "GMT+2", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "生效日期", width = 15, format = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "生效日期")
private java.util.Date effectiveDate;
}

View File

@ -18,4 +18,6 @@ public interface SkuWeightMapper extends BaseMapper<SkuWeight> {
SkuWeight getBySkuId(@Param("skuId") String skuId);
String searchFirstEmptyWeightSku(@Param("skuIds") List<String> skuIds);
List<SkuWeight> exportToExcel(@Param("skuIds") List<String> skuIds);
}

View File

@ -24,4 +24,22 @@
)
LIMIT 1;
</select>
<select id="exportToExcel" resultType="org.jeecg.modules.business.entity.SkuWeight">
WITH latestSkuWeights AS (
SELECT
sku_id,
weight,
effective_date,
ROW_NUMBER() OVER (PARTITION BY sku_id ORDER BY effective_date DESC) AS rn
FROM sku_weight sw
)
SELECT s.erp_code as sku_id, lsw.weight, lsw.effective_date
FROM latestSkuWeights lsw
JOIN sku s ON s.id = lsw.sku_id
WHERE lsw.sku_id IN
<foreach collection="skuIds" separator="," open="(" close=")" index="index" item="id">
#{id}
</foreach>
AND lsw.rn = 1;
</select>
</mapper>

View File

@ -15,4 +15,6 @@ public interface ISkuWeightService extends IService<SkuWeight> {
SkuWeight getBySkuId(String skuId);
String searchFirstEmptyWeightSku(List<String> skuIds);
List<SkuWeight> exportToExcel(List<String> skuIds);
}

View File

@ -32,4 +32,9 @@ public class SkuWeightServiceImpl extends ServiceImpl<SkuWeightMapper, SkuWeight
public String searchFirstEmptyWeightSku(List<String> skuIds) {
return skuWeightMapper.searchFirstEmptyWeightSku(skuIds);
}
@Override
public List<SkuWeight> exportToExcel(List<String> skuIds) {
return skuWeightMapper.exportToExcel(skuIds);
}
}