Search in sources :

Example 1 with PanoramicRealTimeConsumptionGatherDto

use of com.monitor.dto.realtimeconsumptiongather.PanoramicRealTimeConsumptionGatherDto in project new-cloud by xie-summer.

the class PanoramicRealTimeConsumptionGatherServiceImpl method queryStatisticsForDay.

private PanoramicRealTimeConsumptionGatherDto queryStatisticsForDay(String date, String code) {
    PanoramicRealTimeConsumptionGatherDto gather = new PanoramicRealTimeConsumptionGatherDto();
    gather.setCode(code);
    gather.setValue(0.0);
    gather.setRecordValues(0.0);
    gather.setCtime(DateUtil.parseTimestamp(date, "yyyy-MM-dd"));
    gather.setGatherTime(date);
    gather.setName(StringUtils.equalsIgnoreCase(code, HG_01_XY_7505) ? "磷钙" : "普钙");
    gather.setDeleteFlag(1);
    gather.setDtime(null);
    gather.setfId("2");
    gather.setId(null);
    Condition condition = new Condition(PanoramicProductMaterials.class, false);
    condition.createCriteria().andCondition("code ='" + code + "' and in_or_out =1 and delete_flag =1 " + " AND date_format(utime,'%Y%m%d') = date_format('" + date + "','%Y%m%d')");
    List<PanoramicProductMaterials> productMaterials = productMaterialsService.findByCondition(condition);
    if (null != productMaterials && productMaterials.size() > 0) {
        productMaterials.forEach(e -> {
            gather.setValue(Double.parseDouble(e.getValue()) + gather.getValue());
            gather.setDeleteFlag(e.getDeleteFlag());
            gather.setfId(e.getfId());
            gather.setId(null);
            gather.setName(e.getName());
            gather.setOperator(e.getOperator());
            gather.setUnit(e.getUnit());
            gather.setDtime(null);
            gather.setUtime(e.getUtime());
        });
    }
    Condition cond = new Condition(PanoramicInventoryEntry.class, false);
    cond.createCriteria().andCondition(" code ='" + code + "' and in_or_out =1 and delete_flag =1  " + " AND date_format(utime,'%Y%m%d') = date_format('" + date + "','%Y%m%d')");
    List<PanoramicInventoryEntry> inventoryEntries = inventoryEntryService.findByCondition(cond);
    if (null != inventoryEntries && inventoryEntries.size() > 0) {
        inventoryEntries.forEach(e -> {
            gather.setRecordValues(Double.parseDouble(e.getValue()) + gather.getRecordValues());
        });
    }
    return gather;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicProductMaterials(com.monitor.model.productmaterials.PanoramicProductMaterials) PanoramicRealTimeConsumptionGatherDto(com.monitor.dto.realtimeconsumptiongather.PanoramicRealTimeConsumptionGatherDto) PanoramicInventoryEntry(com.monitor.model.inventoryentry.PanoramicInventoryEntry)

Example 2 with PanoramicRealTimeConsumptionGatherDto

use of com.monitor.dto.realtimeconsumptiongather.PanoramicRealTimeConsumptionGatherDto in project new-cloud by xie-summer.

the class PanoramicRealTimeConsumptionGatherServiceImpl method queryDayStatisticsByDate.

/**
 * 取得指定时间的消耗值
 */
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public PanoramicRealTimeConsumptionGatherDto queryDayStatisticsByDate(String date, String code) {
    if (StringUtils.equalsIgnoreCase(code, HG_01_XY_7505) || StringUtils.equalsIgnoreCase(code, HG_01_XY_7504) || StringUtils.equalsIgnoreCase(code, HG_01_XY_7500)) {
        return this.queryStatisticsForDay(date, code);
    }
    Condition condition = new Condition(PanoramicRealTimeConsumptionGather.class, false);
    condition.createCriteria().andCondition(" code ='" + code + "' AND f_id=2 AND delete_flag=1 " + " AND date_format(gather_time,'%Y%m%d') = date_format('" + date + "','%Y%m%d')");
    condition.setOrderByClause(" gather_time asc ");
    List<PanoramicRealTimeConsumptionGather> recordList = realTimeConsumptionGatherMapper.selectByCondition(condition);
    PanoramicRealTimeConsumptionGatherDto gather = new PanoramicRealTimeConsumptionGatherDto();
    gather.setCode(code);
    gather.setValue(0.0);
    gather.setRecordValues(0.0);
    gather.setCtime(DateUtil.parseTimestamp(date, "yyyy-MM-dd"));
    gather.setGatherTime(date);
    if (null != recordList && recordList.size() > 0) {
        recordList.forEach(e -> {
            gather.setValue(e.getValue() + gather.getValue());
            gather.setDeleteFlag(e.getDeleteFlag());
            gather.setfId(e.getfId());
            gather.setId(null);
            gather.setName(e.getName());
            gather.setOperator(e.getOperator());
            gather.setUnit(e.getUnit());
            gather.setDtime(null);
            gather.setUtime(e.getUtime());
        });
    }
    return gather;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicRealTimeConsumptionGather(com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather) PanoramicRealTimeConsumptionGatherDto(com.monitor.dto.realtimeconsumptiongather.PanoramicRealTimeConsumptionGatherDto) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PanoramicRealTimeConsumptionGatherDto (com.monitor.dto.realtimeconsumptiongather.PanoramicRealTimeConsumptionGatherDto)2 Condition (tk.mybatis.mapper.entity.Condition)2 PanoramicInventoryEntry (com.monitor.model.inventoryentry.PanoramicInventoryEntry)1 PanoramicProductMaterials (com.monitor.model.productmaterials.PanoramicProductMaterials)1 PanoramicRealTimeConsumptionGather (com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather)1 Transactional (org.springframework.transaction.annotation.Transactional)1