mirror of https://github.com/jeecgboot/jeecg-boot
fix: sku weight export effective date format
parent
c9aac600c0
commit
15f220e1cc
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.business.controller.admin;
|
package org.jeecg.modules.business.controller.admin;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.api.vo.Result;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
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.Sku;
|
||||||
import org.jeecg.modules.business.entity.SkuWeight;
|
import org.jeecg.modules.business.entity.SkuWeight;
|
||||||
import org.jeecg.modules.business.mongoService.SkuMongoService;
|
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.common.system.base.controller.JeecgController;
|
||||||
import org.jeecg.modules.business.vo.Responses;
|
import org.jeecg.modules.business.vo.Responses;
|
||||||
import org.jeecg.modules.business.vo.SkuWeightParam;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -54,6 +59,8 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
||||||
private ISecurityService securityService;
|
private ISecurityService securityService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SkuMongoService skuMongoService;
|
private SkuMongoService skuMongoService;
|
||||||
|
@Resource
|
||||||
|
private JeecgBaseConfig jeecgBaseConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
|
@ -143,12 +150,27 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
||||||
* 导出excel
|
* 导出excel
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param skuWeight
|
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("business:sku_weight:exportXls")
|
|
||||||
@RequestMapping(value = "/exportXls")
|
@RequestMapping(value = "/exportXls")
|
||||||
public ModelAndView exportXls(HttpServletRequest request, SkuWeight skuWeight) {
|
public ModelAndView exportXls(HttpServletRequest request) {
|
||||||
return super.exportXls(request, skuWeight, SkuWeight.class, "sku_weight");
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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 = "生效日期")
|
@ApiModelProperty(value = "生效日期")
|
||||||
private java.util.Date effectiveDate;
|
private java.util.Date effectiveDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,6 @@ public interface SkuWeightMapper extends BaseMapper<SkuWeight> {
|
||||||
SkuWeight getBySkuId(@Param("skuId") String skuId);
|
SkuWeight getBySkuId(@Param("skuId") String skuId);
|
||||||
|
|
||||||
String searchFirstEmptyWeightSku(@Param("skuIds") List<String> skuIds);
|
String searchFirstEmptyWeightSku(@Param("skuIds") List<String> skuIds);
|
||||||
|
|
||||||
|
List<SkuWeight> exportToExcel(@Param("skuIds") List<String> skuIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,4 +24,22 @@
|
||||||
)
|
)
|
||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
</select>
|
</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>
|
</mapper>
|
|
@ -15,4 +15,6 @@ public interface ISkuWeightService extends IService<SkuWeight> {
|
||||||
SkuWeight getBySkuId(String skuId);
|
SkuWeight getBySkuId(String skuId);
|
||||||
|
|
||||||
String searchFirstEmptyWeightSku(List<String> skuIds);
|
String searchFirstEmptyWeightSku(List<String> skuIds);
|
||||||
|
|
||||||
|
List<SkuWeight> exportToExcel(List<String> skuIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,4 +32,9 @@ public class SkuWeightServiceImpl extends ServiceImpl<SkuWeightMapper, SkuWeight
|
||||||
public String searchFirstEmptyWeightSku(List<String> skuIds) {
|
public String searchFirstEmptyWeightSku(List<String> skuIds) {
|
||||||
return skuWeightMapper.searchFirstEmptyWeightSku(skuIds);
|
return skuWeightMapper.searchFirstEmptyWeightSku(skuIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SkuWeight> exportToExcel(List<String> skuIds) {
|
||||||
|
return skuWeightMapper.exportToExcel(skuIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue