Search in sources :

Example 1 with PanoramicDailyInventorySummary

use of com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary in project new-cloud by xie-summer.

the class PanoramicDailyInventorySummaryServiceImpl method countUsable.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public Integer countUsable(String code, String date) {
    // 最近7天历史消耗量数据值获取
    List<PanoramicRealTimeConsumptionGather> sum = realTimeConsumptionGatherService.findNumberdayData(code, 7, date);
    double sumSingle = 0.0;
    if (null != sum && sum.size() != 0) {
        // 当前仓库存量值获取
        PanoramicDailyInventorySummary summary = queryByDateAndCode(code, date);
        if (Optional.ofNullable(summary).isPresent()) {
            for (int i = 0; i < sum.size(); i++) {
                sumSingle = MathUtil.add(sumSingle, sum.get(i).getValue());
            }
            return Integer.parseInt(new java.text.DecimalFormat("0").format(summary.getValue() / sumSingle * sum.size()));
        }
        return null;
    } else {
        return null;
    }
}
Also used : PanoramicRealTimeConsumptionGather(com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather) PanoramicDailyInventorySummary(com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with PanoramicDailyInventorySummary

use of com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary in project new-cloud by xie-summer.

the class PanoramicDailyInventorySummaryServiceImpl method check.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public Map<String, String> check(List<String> codeList, String date) {
    Map<String, String> result = Maps.newHashMap();
    codeList.forEach((String e) -> {
        PanoramicDailyInventorySummary dailyInventorySummary = this.queryByDateAndCode(e, date);
        PanoramicMaterialThresholdConfiguration configuration = materialThresholdConfigurationService.findByCode(ThresholdConfigConstant.STOCK, e);
        result.put(e, ExceptionRecordStatusEnum.normal.getCode());
        if (!Optional.ofNullable(configuration).isPresent()) {
            // 3 库存配置异常
            result.put(e, ExceptionRecordStatusEnum.configuration.getCode());
        } else if ((!Optional.ofNullable(dailyInventorySummary).isPresent()) || dailyInventorySummary.getValue() < configuration.getLowerLimit()) {
            // 1:库存偏低
            result.put(e, ExceptionRecordStatusEnum.low.getCode());
        } else if (dailyInventorySummary.getValue() > configuration.getUpperLimit()) {
            result.put(e, ExceptionRecordStatusEnum.high.getCode());
        }
    });
    return result;
}
Also used : PanoramicMaterialThresholdConfiguration(com.monitor.model.materialthresholdconfiguration.PanoramicMaterialThresholdConfiguration) PanoramicDailyInventorySummary(com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with PanoramicDailyInventorySummary

use of com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary in project new-cloud by xie-summer.

the class PanoramicDailyInventorySummaryServiceImpl method queryByDateAndCode.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public PanoramicDailyInventorySummary queryByDateAndCode(String code, String date) {
    Condition condition = new Condition(PanoramicDailyInventorySummary.class, false);
    condition.createCriteria().andCondition(" code ='" + code + "' and f_id=2 and delete_flag=1 and utime >= '" + DateUtil.parseTimestamp(date, "yyyy-MM-dd") + "' and  utime < '" + DateUtil.parseTimestamp(DateUtil.getSpecifiedDayBefor(date, -1), "yyyy-MM-dd") + "'");
    condition.setOrderByClause(" utime desc ");
    List<PanoramicDailyInventorySummary> recordList = dailyInventorySummaryMapper.selectByCondition(condition);
    return (null == recordList || recordList.size() == 0) ? null : recordList.get(0);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicDailyInventorySummary(com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with PanoramicDailyInventorySummary

use of com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary in project new-cloud by xie-summer.

the class PanoramicDailyInventorySummaryServiceImpl method listByDateAndCode.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public List<PanoramicDailyInventorySummary> listByDateAndCode(String date) {
    Condition condition = new Condition(PanoramicDailyInventorySummary.class, false);
    condition.createCriteria().andCondition(" f_id=2 and delete_flag=1 and utime >= '" + DateUtil.parseTimestamp(date, "yyyy-MM-dd") + "' and  utime < '" + DateUtil.parseTimestamp(DateUtil.getSpecifiedDayBefor(date, -1), "yyyy-MM-dd") + "'");
    condition.setOrderByClause(" utime desc ");
    List<PanoramicDailyInventorySummary> recordList = dailyInventorySummaryMapper.selectByCondition(condition);
    return recordList;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicDailyInventorySummary(com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with PanoramicDailyInventorySummary

use of com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary in project new-cloud by xie-summer.

the class PanoramicDailyInventorySummaryServiceImpl method getPanoramicDailyInventorySummary.

private PanoramicDailyInventorySummary getPanoramicDailyInventorySummary(Double value, Integer category) {
    PanoramicDailyInventorySummary record = new PanoramicDailyInventorySummary();
    record.setValue(value);
    record.setCategory(category);
    record.setUnit("吨");
    record.setCtime(DateUtil.getCurFullTimestamp());
    record.setUtime(record.getCtime());
    record.setDeleteFlag(1);
    record.setDtime(null);
    record.setfId("2");
    record.setId(null);
    record.setOperator("auto_task");
    return record;
}
Also used : PanoramicDailyInventorySummary(com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary)

Aggregations

PanoramicDailyInventorySummary (com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary)7 Transactional (org.springframework.transaction.annotation.Transactional)4 Condition (tk.mybatis.mapper.entity.Condition)2 PanoramicMaterialThresholdConfiguration (com.monitor.model.materialthresholdconfiguration.PanoramicMaterialThresholdConfiguration)1 PanoramicProductMaterials (com.monitor.model.productmaterials.PanoramicProductMaterials)1 PanoramicRawMaterials (com.monitor.model.rawmaterials.PanoramicRawMaterials)1 PanoramicRealTimeConsumptionGather (com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather)1