Search in sources :

Example 21 with Condition

use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.

the class PanoramicIntoTheFactoryRecordsServiceImpl method listByDate.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public List<PanoramicIntoTheFactoryRecords> listByDate(String date) {
    Condition condition = new Condition(PanoramicIntoTheFactoryRecords.class, false);
    condition.createCriteria().andCondition(" delete_flag=1  and status=1 and date_format(snapshot_time,'%Y%m%d') = date_format('" + date + "','%Y%m%d')");
    condition.setOrderByClause(" snapshot_time desc ");
    List<PanoramicIntoTheFactoryRecords> factoryRecords = intoTheFactoryRecordsMapper.selectByCondition(condition);
    return factoryRecords;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicIntoTheFactoryRecords(com.monitor.model.intothefactoryrecords.PanoramicIntoTheFactoryRecords) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with Condition

use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.

the class PanoramicProductOfflineMeasurementServiceImpl method productOfflineSummaryTask.

/**
 * 产品消耗数据实时汇总
 * @param name
 * @param code
 * @param date
 */
private void productOfflineSummaryTask(String name, String code, String date) {
    // 
    Condition condition = new Condition(PanoramicProductOfflineMeasurement.class, false);
    condition.createCriteria().andCondition("	code = '" + code + "' " + "AND f_id=2 AND delete_flag=1 " + "AND date_format(utime,'%Y%m%d%H') = date_format('" + date + "','%Y%m%d%H')");
    List<PanoramicProductOfflineMeasurement> offlineMeasurementList = panoramicProductOfflineMeasurementMapper.selectByCondition(condition);
    PanoramicProductOfflineMeasurement record = new PanoramicProductOfflineMeasurement();
    record.setCode(code);
    record.setName(name);
    record.setValue(String.valueOf("0.0"));
    record.setCtime(DateUtil.getCurFullTimestamp());
    record.setId(null);
    record.setOperator("auto_task");
    record.setfId("2");
    record.setUnit("吨");
    record.setDeleteFlag(1);
    final double[] sumValue = { 0.0 };
    if (null != offlineMeasurementList && offlineMeasurementList.size() > 0) {
        offlineMeasurementList.forEach(e -> {
            sumValue[0] += Double.valueOf(e.getValue()).doubleValue();
            record.setUtime(e.getUtime());
            record.setDtime(null);
            record.setOperator(e.getOperator());
            record.setfId(e.getfId());
            record.setName(e.getName());
            record.setDeleteFlag(e.getDeleteFlag());
            record.setCtime(e.getCtime());
            record.setId(null);
        });
    }
    PanoramicRealTimeConsumptionGather selectOne = realTimeConsumptionGatherMapper.selectByGatherTime(code, date);
    Optional<PanoramicRealTimeConsumptionGather> one = Optional.ofNullable(selectOne);
    if (one.isPresent()) {
        selectOne.setValue(sumValue[0]);
        selectOne.setUtime(DateUtil.getCurFullTimestamp());
        selectOne.setCtime(selectOne.getUtime());
        selectOne.setOperator("auto_task_update");
        selectOne.setGatherTime(date);
        realTimeConsumptionGatherMapper.updateByPrimaryKeySelective(selectOne);
    } else {
        PanoramicRealTimeConsumptionGather gather = new PanoramicRealTimeConsumptionGather();
        gather.setCode(code);
        gather.setName(name);
        gather.setDeleteFlag(record.getDeleteFlag());
        gather.setfId(record.getfId());
        gather.setGatherTime(date);
        gather.setId(null);
        gather.setCtime(DateUtil.getCurFullTimestamp());
        gather.setName(record.getName());
        gather.setOperator(record.getOperator());
        gather.setUnit(record.getUnit());
        gather.setDtime(record.getDtime());
        gather.setUtime(gather.getCtime());
        gather.setValue(sumValue[0]);
        realTimeConsumptionGatherMapper.insert(gather);
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicRealTimeConsumptionGather(com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather) PanoramicProductOfflineMeasurement(com.monitor.model.productofflinemeasurement.PanoramicProductOfflineMeasurement)

Example 23 with Condition

use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.

the class PanoramicRealTimeConsumptionServiceImpl method realtimeConsumptionSummaryTask.

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void realtimeConsumptionSummaryTask(String name, String code, String date) {
    // 先查出来,再去更新
    Condition condition = new Condition(PanoramicRealTimeConsumption.class, false);
    condition.createCriteria().andCondition("  substring(code, 1, 12) = '" + code + "' AND f_id=2 AND delete_flag=1 " + " AND date_format(utime,'%Y%m%d%H') = date_format('" + date + "','%Y%m%d%H')");
    List<PanoramicRealTimeConsumption> consumptionList = realTimeConsumptionMapper.selectByCondition(condition);
    PanoramicRealTimeConsumption record = new PanoramicRealTimeConsumption();
    record.setCode(code);
    record.setName(name);
    record.setValue(0.0);
    record.setCtime(DateUtil.getCurFullTimestamp());
    record.setId(null);
    record.setOperator("auto_task");
    record.setfId("2");
    record.setUnit(StringUtils.containsIgnoreCase(code, "0004A4000009") ? "度" : "吨");
    record.setDeleteFlag(1);
    final double[] sumValue = { 0.0 };
    if (null != consumptionList && consumptionList.size() > 0) {
        consumptionList.forEach(e -> {
            sumValue[0] += e.getValue();
            record.setUtime(e.getUtime());
            record.setDtime(null);
            record.setOperator("auto_task");
            record.setfId(e.getfId());
            record.setName(e.getName());
            record.setDeleteFlag(e.getDeleteFlag());
            record.setCtime(e.getCtime());
            record.setId(null);
        });
    }
    PanoramicRealTimeConsumptionGather selectOne = realTimeConsumptionGatherMapper.selectByGatherTime(code, date);
    Optional<PanoramicRealTimeConsumptionGather> one = Optional.ofNullable(selectOne);
    if (one.isPresent()) {
        selectOne.setValue(sumValue[0]);
        selectOne.setUtime(DateUtil.getCurFullTimestamp());
        selectOne.setCtime(selectOne.getUtime());
        selectOne.setOperator("auto_task_update");
        selectOne.setGatherTime(date);
        realTimeConsumptionGatherMapper.updateByPrimaryKeySelective(selectOne);
    } else {
        PanoramicRealTimeConsumptionGather gather = new PanoramicRealTimeConsumptionGather();
        gather.setCode(code);
        gather.setName(name);
        gather.setDeleteFlag(record.getDeleteFlag());
        gather.setfId(record.getfId());
        gather.setGatherTime(date);
        gather.setId(null);
        gather.setCtime(DateUtil.getCurFullTimestamp());
        gather.setName(record.getName());
        gather.setOperator(record.getOperator());
        gather.setUnit(record.getUnit());
        gather.setDtime(record.getDtime());
        gather.setUtime(gather.getCtime());
        gather.setValue(sumValue[0]);
        realTimeConsumptionGatherMapper.insert(gather);
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicRealTimeConsumptionGather(com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather) PanoramicRealTimeConsumption(com.monitor.model.realtimeconsumption.PanoramicRealTimeConsumption) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with Condition

use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.

the class PanoramicRealTimeConsumptionGatherServiceImpl method listByCodeAndDate.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public List<PanoramicRealTimeConsumptionGather> listByCodeAndDate(String date, String code) {
    Condition condition = new Condition(PanoramicRealTimeConsumptionGather.class, false);
    condition.createCriteria().andCondition(" code ='" + code + "' and f_id=2 and delete_flag=1 and gather_time > '" + DateUtil.parseTimestamp(date.concat(" 07:00"), "yyyy-MM-dd HH:mm") + "' and  gather_time < '" + DateUtil.parseTimestamp(DateUtil.getSpecifiedDayBefor(date, -1).concat(" 08:00"), "yyyy-MM-dd HH:mm") + "'");
    condition.setOrderByClause(" gather_time asc ");
    List<PanoramicRealTimeConsumptionGather> recordList = realTimeConsumptionGatherMapper.selectByCondition(condition);
    return recordList;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicRealTimeConsumptionGather(com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather) Transactional(org.springframework.transaction.annotation.Transactional)

Example 25 with Condition

use of tk.mybatis.mapper.entity.Condition 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)

Aggregations

Condition (tk.mybatis.mapper.entity.Condition)59 Criteria (tk.mybatis.mapper.entity.Example.Criteria)25 Transactional (org.springframework.transaction.annotation.Transactional)17 PostMapping (org.springframework.web.bind.annotation.PostMapping)13 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)10 Machine (com.eservice.api.model.machine.Machine)8 PageInfo (com.github.pagehelper.PageInfo)8 TaskRecord (com.eservice.api.model.task_record.TaskRecord)6 PanoramicRealTimeConsumptionGather (com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather)6 Date (java.util.Date)6 Contract (com.eservice.api.model.contract.Contract)5 ContractSign (com.eservice.api.model.contract_sign.ContractSign)5 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)5 User (com.cas.sim.tis.entity.User)4 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)4 Task (com.eservice.api.model.task.Task)4 OrderSign (com.eservice.api.model.order_sign.OrderSign)3 Library (com.cas.sim.tis.entity.Library)2 Resource (com.cas.sim.tis.entity.Resource)2 ResourceMapper (com.cas.sim.tis.mapper.ResourceMapper)2