mirror of https://github.com/jeecgboot/jeecg-boot
Merge pull request #132 from LQYBill/feat/ydhDeleteTracking
fix: sku weight export effective date formatpull/8040/head
commit
210a2de464
|
@ -5,6 +5,7 @@ import java.io.InputStream;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -17,6 +18,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;
|
||||||
|
@ -69,9 +71,12 @@ 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;
|
||||||
|
|
||||||
private final static Integer NUMBER_OF_SKU_EXCEL_COLUMNS = 3;
|
private final static Integer NUMBER_OF_SKU_EXCEL_COLUMNS = 3;
|
||||||
private final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
private final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
*
|
*
|
||||||
|
@ -159,22 +164,27 @@ public class SkuWeightController extends JeecgController<SkuWeight, ISkuWeightSe
|
||||||
/**
|
/**
|
||||||
* 导出excel
|
* 导出excel
|
||||||
*
|
*
|
||||||
* @param skuIds
|
* @param request
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/exportXls")
|
@RequestMapping(value = "/exportXls")
|
||||||
public ModelAndView exportXls(@RequestParam(value = "selections[]", required = false) List<String> skuIds) {
|
public ModelAndView exportXls(HttpServletRequest request) {
|
||||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
List<SkuWeightPage> skuWeightList;
|
|
||||||
if (skuIds == null || skuIds.isEmpty()) {
|
List<String> selections = new ArrayList<>();
|
||||||
skuWeightList = skuWeightService.listLatestWeights();
|
request.getParameterMap().forEach((k,v) -> {
|
||||||
} else {
|
if(k.equals("selections[]")) {
|
||||||
skuWeightList = skuWeightService.listLatestWeightForSkus(skuIds);
|
selections.addAll(Arrays.asList(v));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
List<SkuWeight> exportList = skuWeightService.exportToExcel(selections);
|
||||||
|
|
||||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||||
mv.addObject(NormalExcelConstants.FILE_NAME, "SKU重量列表");
|
mv.addObject(NormalExcelConstants.FILE_NAME, "SKU重量");
|
||||||
mv.addObject(NormalExcelConstants.CLASS, SkuWeightPage.class);
|
mv.addObject(NormalExcelConstants.CLASS, SkuWeight.class);
|
||||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("SKU重量数据", "导出人:" + sysUser.getRealname(), "SKU重量"));
|
ExportParams exportParams=new ExportParams("SKU重量报表", "导出人:" + sysUser.getRealname(), "SKU重量");
|
||||||
mv.addObject(NormalExcelConstants.DATA_LIST, skuWeightList);
|
exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload());
|
||||||
|
mv.addObject(NormalExcelConstants.PARAMS,exportParams);
|
||||||
|
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||||
return mv;
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,10 @@ public interface SkuWeightMapper extends BaseMapper<SkuWeight> {
|
||||||
|
|
||||||
String searchFirstEmptyWeightSku(@Param("skuIds") List<String> skuIds);
|
String searchFirstEmptyWeightSku(@Param("skuIds") List<String> skuIds);
|
||||||
|
|
||||||
|
List<SkuWeight> exportToExcel(@Param("skuIds") List<String> skuIds);
|
||||||
|
|
||||||
List<SkuWeightPage> listLatestWeights();
|
List<SkuWeightPage> listLatestWeights();
|
||||||
|
|
||||||
List<SkuWeightPage> listLatestWeightForSkus(@Param("skuIds") List<String> skuIds);
|
List<SkuWeightPage> listLatestWeightForSkus(@Param("skuIds") List<String> skuIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,4 +62,23 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
ORDER BY erp_code;
|
ORDER BY erp_code;
|
||||||
</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>
|
|
@ -17,6 +17,7 @@ public interface ISkuWeightService extends IService<SkuWeight> {
|
||||||
|
|
||||||
String searchFirstEmptyWeightSku(List<String> skuIds);
|
String searchFirstEmptyWeightSku(List<String> skuIds);
|
||||||
|
|
||||||
|
List<SkuWeight> exportToExcel(List<String> skuIds);
|
||||||
/**
|
/**
|
||||||
* used to export all latest weights for front, so instead of fetching skuId, we fetch erpCode
|
* used to export all latest weights for front, so instead of fetching skuId, we fetch erpCode
|
||||||
* @return
|
* @return
|
||||||
|
|
|
@ -34,6 +34,11 @@ public class SkuWeightServiceImpl extends ServiceImpl<SkuWeightMapper, SkuWeight
|
||||||
return skuWeightMapper.searchFirstEmptyWeightSku(skuIds);
|
return skuWeightMapper.searchFirstEmptyWeightSku(skuIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SkuWeight> exportToExcel(List<String> skuIds) {
|
||||||
|
return skuWeightMapper.exportToExcel(skuIds);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SkuWeightPage> listLatestWeights() {
|
public List<SkuWeightPage> listLatestWeights() {
|
||||||
return skuWeightMapper.listLatestWeights();
|
return skuWeightMapper.listLatestWeights();
|
||||||
|
|
Loading…
Reference in New Issue