|
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
|
|
import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
|
|
import com.ruoyi.ams.asn.dto.TotalInfoDTO;
|
|
import com.ruoyi.ams.asn.dto.TotalInfoDTO;
|
|
|
|
+import com.ruoyi.ams.asn.dto.WmsAllGranularityTotalDTO;
|
|
import com.ruoyi.ams.asn.dto.WmsDetailsReqDTO;
|
|
import com.ruoyi.ams.asn.dto.WmsDetailsReqDTO;
|
|
import com.ruoyi.ams.asn.dto.WmsDetailsTotalDTO;
|
|
import com.ruoyi.ams.asn.dto.WmsDetailsTotalDTO;
|
|
import com.ruoyi.ams.asn.mapper.WmsDocAsnDetailsMapper;
|
|
import com.ruoyi.ams.asn.mapper.WmsDocAsnDetailsMapper;
|
|
@@ -15,6 +16,7 @@ import com.ruoyi.common.constant.Constants;
|
|
import com.ruoyi.common.enums.Granularity;
|
|
import com.ruoyi.common.enums.Granularity;
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
import com.ruoyi.common.exception.base.BaseException;
|
|
import com.ruoyi.common.exception.base.BaseException;
|
|
|
|
+import com.ruoyi.common.utils.ConvertUtils;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.common.utils.TimeUtils;
|
|
import com.ruoyi.common.utils.TimeUtils;
|
|
import com.ruoyi.common.utils.params.SplitedTimeParam;
|
|
import com.ruoyi.common.utils.params.SplitedTimeParam;
|
|
@@ -160,15 +162,16 @@ public class WmsDocAsnDetailsServiceImpl implements IWmsDocAsnDetailsService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据status获取字段状态率
|
|
* 根据status获取字段状态率
|
|
- * @param field 字段名
|
|
|
|
- * @param beginTime 起始时间
|
|
|
|
- * @param endTime 结束时间
|
|
|
|
- * @param status 默认总量 HG: 合格 BHG:不合格 DJ:待检
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param field 字段名
|
|
|
|
+ * @param beginTime 起始时间
|
|
|
|
+ * @param endTime 结束时间
|
|
|
|
+ * @param status 默认总量 HG: 合格 BHG:不合格 DJ:待检
|
|
* @param granularity 时间粒度
|
|
* @param granularity 时间粒度
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public List<WmsDetailsTotalDTO> getPassRate(String field, String beginTime, String endTime, String status, Granularity granularity){
|
|
|
|
|
|
+ public List<WmsDetailsTotalDTO> getPassRate(String field, String beginTime, String endTime, String status, Granularity granularity) {
|
|
List<WmsDetailsTotalDTO> result = new ArrayList<>();
|
|
List<WmsDetailsTotalDTO> result = new ArrayList<>();
|
|
if (ObjectUtil.isNull(granularity)) {
|
|
if (ObjectUtil.isNull(granularity)) {
|
|
granularity = Granularity.DAY;
|
|
granularity = Granularity.DAY;
|
|
@@ -197,32 +200,35 @@ public class WmsDocAsnDetailsServiceImpl implements IWmsDocAsnDetailsService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 根据字段名获取时间段内年/月/日总量
|
|
|
|
- * @param field 字段名
|
|
|
|
- * @param beginTime 起始时间
|
|
|
|
- * @param endTime 结束时间
|
|
|
|
|
|
+ * 根据字段名获取时间段内传入时间当年/当月/当日总量
|
|
|
|
+ *
|
|
|
|
+ * @param field 字段名
|
|
|
|
+ * @param currentTime 目标时间
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public Map<String, List<WmsDetailsTotalDTO>> queryAllGranularityTotal(String field, String beginTime, String endTime){
|
|
|
|
- List<WmsDetailsTotalDTO> result = new ArrayList<>();
|
|
|
|
|
|
+ public Map<String, List<WmsAllGranularityTotalDTO>> queryAllGranularityTotal(String field, String currentTime) {
|
|
|
|
+ List<WmsAllGranularityTotalDTO> result = new ArrayList<>();
|
|
for (Granularity granularity : Granularity.values()) {
|
|
for (Granularity granularity : Granularity.values()) {
|
|
if (granularity.equals(Granularity.HOUR)) continue;
|
|
if (granularity.equals(Granularity.HOUR)) continue;
|
|
- List<WmsDetailsTotalDTO> wmsDetailsTotalDTOByDayList = queryFieldTotalList(field, beginTime, endTime, granularity);
|
|
|
|
- result.addAll(wmsDetailsTotalDTOByDayList);
|
|
|
|
|
|
+ SplitedTimeParam splitTimeByGranularity = TimeUtils.getSplitTimeByGranularity(currentTime, granularity);
|
|
|
|
+ List<WmsDetailsTotalDTO> wmsDetailsTotalDTOByDayList = queryFieldTotalList(field, splitTimeByGranularity.getBeginTime(), splitTimeByGranularity.getEndTime(), granularity);
|
|
|
|
+ List<WmsAllGranularityTotalDTO> wmsAllGranularityTotalDTOList = ConvertUtils.sourceToTarget(wmsDetailsTotalDTOByDayList, WmsAllGranularityTotalDTO.class);
|
|
|
|
+ wmsAllGranularityTotalDTOList.forEach(item -> item.setGranularity(granularity));
|
|
|
|
+ result.addAll(wmsAllGranularityTotalDTOList);
|
|
}
|
|
}
|
|
- Map<String, List<WmsDetailsTotalDTO>> wmsDetailsTotalDTOMap = result.stream().collect(Collectors.groupingBy(WmsDetailsTotalDTO::getName));
|
|
|
|
|
|
+ Map<String, List<WmsAllGranularityTotalDTO>> wmsDetailsTotalDTOMap = result.stream().collect(Collectors.groupingBy(WmsAllGranularityTotalDTO::getName));
|
|
return wmsDetailsTotalDTOMap;
|
|
return wmsDetailsTotalDTOMap;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据字段field获取时间段按天切割后产量 data不传即获取总量
|
|
* 根据字段field获取时间段按天切割后产量 data不传即获取总量
|
|
*
|
|
*
|
|
- * @param data 字段具体值
|
|
|
|
- * @param field 字段名称
|
|
|
|
- * @param beginTime 起始时间
|
|
|
|
- * @param endTime 结束时间
|
|
|
|
- * @param status 默认总量 HG: 合格 BHG:不合格 DJ:待检
|
|
|
|
|
|
+ * @param data 字段具体值
|
|
|
|
+ * @param field 字段名称
|
|
|
|
+ * @param beginTime 起始时间
|
|
|
|
+ * @param endTime 结束时间
|
|
|
|
+ * @param status 默认总量 HG: 合格 BHG:不合格 DJ:待检
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public List<WmsDetailsTotalDTO> queryFieldTotalList(String data, String field, String beginTime, String endTime, String status) {
|
|
public List<WmsDetailsTotalDTO> queryFieldTotalList(String data, String field, String beginTime, String endTime, String status) {
|
|
@@ -231,6 +237,7 @@ public class WmsDocAsnDetailsServiceImpl implements IWmsDocAsnDetailsService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 根据字段field获取时间段根据时间粒度切割后产量 data不传即获取总量
|
|
* 根据字段field获取时间段根据时间粒度切割后产量 data不传即获取总量
|
|
|
|
+ *
|
|
* @param wmsDetailsReqDTO
|
|
* @param wmsDetailsReqDTO
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -261,6 +268,9 @@ public class WmsDocAsnDetailsServiceImpl implements IWmsDocAsnDetailsService {
|
|
*/
|
|
*/
|
|
public List<WmsDetailsTotalDTO> queryFieldTotalList(String data, String field, String beginTime, String endTime, String status, Granularity granularity) {
|
|
public List<WmsDetailsTotalDTO> queryFieldTotalList(String data, String field, String beginTime, String endTime, String status, Granularity granularity) {
|
|
List<WmsDetailsTotalDTO> result = new ArrayList<>();
|
|
List<WmsDetailsTotalDTO> result = new ArrayList<>();
|
|
|
|
+ if (ObjectUtil.isNull(granularity)) {
|
|
|
|
+ granularity = Granularity.DAY;
|
|
|
|
+ }
|
|
Map<String, SplitedTimeParam> splitTimeMap = TimeUtils.getSplitedTimeGroupByTime(beginTime, endTime, granularity);
|
|
Map<String, SplitedTimeParam> splitTimeMap = TimeUtils.getSplitedTimeGroupByTime(beginTime, endTime, granularity);
|
|
if (StringUtils.isNotBlank(data)) {
|
|
if (StringUtils.isNotBlank(data)) {
|
|
List<WmsDocAsnDetails> wmsDocAsnDetailsList = queryWmsDocAsnDetailsList(data, field, beginTime, endTime, status);
|
|
List<WmsDocAsnDetails> wmsDocAsnDetailsList = queryWmsDocAsnDetailsList(data, field, beginTime, endTime, status);
|
|
@@ -283,12 +293,11 @@ public class WmsDocAsnDetailsServiceImpl implements IWmsDocAsnDetailsService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
- * @param data 字段具体值
|
|
|
|
- * @param wmsDocAsnDetailsList 根据某一字段分类的入库单集合
|
|
|
|
- * @param beginTime 起始时间
|
|
|
|
- * @param endTime 结束时间
|
|
|
|
- * @param granularity 时间粒度
|
|
|
|
|
|
+ * @param data 字段具体值
|
|
|
|
+ * @param wmsDocAsnDetailsList 根据某一字段分类的入库单集合
|
|
|
|
+ * @param beginTime 起始时间
|
|
|
|
+ * @param endTime 结束时间
|
|
|
|
+ * @param granularity 时间粒度
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
private WmsDetailsTotalDTO buildWmsDetailsTotalDTOList(String data, List<WmsDocAsnDetails> wmsDocAsnDetailsList, String beginTime, String endTime, Granularity granularity) {
|
|
private WmsDetailsTotalDTO buildWmsDetailsTotalDTOList(String data, List<WmsDocAsnDetails> wmsDocAsnDetailsList, String beginTime, String endTime, Granularity granularity) {
|
|
@@ -300,9 +309,9 @@ public class WmsDocAsnDetailsServiceImpl implements IWmsDocAsnDetailsService {
|
|
/**
|
|
/**
|
|
* 构建传入时间段根据时间粒度切割某一字段分类后的产量
|
|
* 构建传入时间段根据时间粒度切割某一字段分类后的产量
|
|
*
|
|
*
|
|
- * @param data 字段具体值
|
|
|
|
- * @param wmsDocAsnDetailsList 根据某一字段分类的入库单集合
|
|
|
|
- * @param splitTimeMap 根据时间粒度对时间段切割集合
|
|
|
|
|
|
+ * @param data 字段具体值
|
|
|
|
+ * @param wmsDocAsnDetailsList 根据某一字段分类的入库单集合
|
|
|
|
+ * @param splitTimeMap 根据时间粒度对时间段切割集合
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
private WmsDetailsTotalDTO buildWmsDetailsTotalDTOList(String data, List<WmsDocAsnDetails> wmsDocAsnDetailsList, Map<String, SplitedTimeParam> splitTimeMap) {
|
|
private WmsDetailsTotalDTO buildWmsDetailsTotalDTOList(String data, List<WmsDocAsnDetails> wmsDocAsnDetailsList, Map<String, SplitedTimeParam> splitTimeMap) {
|
|
@@ -315,7 +324,8 @@ public class WmsDocAsnDetailsServiceImpl implements IWmsDocAsnDetailsService {
|
|
List<WmsDocAsnDetails> wmsDocAsnDetailsBetweenTimeList = wmsDocAsnDetailsList.stream().filter(item -> TimeUtils.dateToTimestamp(item.getLotatt03(), TimeUtils.DATE_TIME_PATTERN) >= TimeUtils.dateToTimestamp(splitedTimeParam.getBeginTime(), TimeUtils.DATE_TIME_PATTERN)
|
|
List<WmsDocAsnDetails> wmsDocAsnDetailsBetweenTimeList = wmsDocAsnDetailsList.stream().filter(item -> TimeUtils.dateToTimestamp(item.getLotatt03(), TimeUtils.DATE_TIME_PATTERN) >= TimeUtils.dateToTimestamp(splitedTimeParam.getBeginTime(), TimeUtils.DATE_TIME_PATTERN)
|
|
&& TimeUtils.dateToTimestamp(item.getLotatt03(), TimeUtils.DATE_TIME_PATTERN) <= TimeUtils.dateToTimestamp(splitedTimeParam.getEndTime(), TimeUtils.DATE_TIME_PATTERN)).collect(Collectors.toList());
|
|
&& TimeUtils.dateToTimestamp(item.getLotatt03(), TimeUtils.DATE_TIME_PATTERN) <= TimeUtils.dateToTimestamp(splitedTimeParam.getEndTime(), TimeUtils.DATE_TIME_PATTERN)).collect(Collectors.toList());
|
|
//总数
|
|
//总数
|
|
- BigDecimal total = wmsDocAsnDetailsBetweenTimeList.stream().filter(item -> ObjectUtil.isNotEmpty(item.getExpectedQtyEach())).map(WmsDocAsnDetails::getExpectedQtyEach).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
+ BigDecimal total = wmsDocAsnDetailsBetweenTimeList.stream().filter(item -> ObjectUtil.isNotEmpty(item.getExpectedQtyEach()))
|
|
|
|
+ .map(WmsDocAsnDetails::getExpectedQtyEach).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
totalInfoDTO.setTotal(total);
|
|
totalInfoDTO.setTotal(total);
|
|
totalInfoDTO.setTime(splitTimeParamEntry.getKey());
|
|
totalInfoDTO.setTime(splitTimeParamEntry.getKey());
|
|
totalInfoDTOList.add(totalInfoDTO);
|
|
totalInfoDTOList.add(totalInfoDTO);
|