Search in sources :

Example 66 with Condition

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

the class PanoramicMaterialThresholdConfigurationServiceImpl method findByCode.

@Override
public PanoramicMaterialThresholdConfiguration findByCode(String category, String code) {
    Condition condition = new Condition(PanoramicMaterialThresholdConfiguration.class, false);
    condition.createCriteria().andCondition("code ='" + code + "' and status =1 and delete_flag =1");
    List<PanoramicMaterialThresholdConfiguration> configurationList = materialThresholdConfigurationMapper.selectByCondition(condition);
    return (null == configurationList || configurationList.size() == 0) ? null : configurationList.get(0);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicMaterialThresholdConfiguration(com.monitor.model.materialthresholdconfiguration.PanoramicMaterialThresholdConfiguration)

Example 67 with Condition

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

the class PanoramicProductMaterialsServiceImpl method productSummaryTask.

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void productSummaryTask(String name, String code, String date) {
    // 先查出来,再去更新
    Condition condition = new Condition(PanoramicProductMaterials.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<PanoramicProductMaterials> consumptionList = productMaterialsMapper.selectByCondition(condition);
    PanoramicProductMaterials record = new PanoramicProductMaterials();
    record.setCode(code);
    record.setName(name);
    record.setValue("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 != consumptionList && consumptionList.size() > 0) {
        consumptionList.forEach(e -> {
            try {
                sumValue[0] += Double.parseDouble(e.getValue());
            } catch (NumberFormatException e1) {
                sumValue[0] = 0;
            }
            record.setUtime(e.getUtime());
            record.setDtime(null);
            record.setUnit(e.getUnit());
            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) PanoramicProductMaterials(com.monitor.model.productmaterials.PanoramicProductMaterials) Transactional(org.springframework.transaction.annotation.Transactional)

Example 68 with Condition

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

the class PanoramicRealTimeConsumptionGatherServiceImpl method queryMonthlyStatisticsByDate.

@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public PanoramicRealTimeConsumptionGather queryMonthlyStatisticsByDate(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 date_format(gather_time,'%Y%m') = date_format('" + date + "','%Y%m')");
    condition.setOrderByClause(" gather_time asc ");
    List<PanoramicRealTimeConsumptionGather> recordList = realTimeConsumptionGatherMapper.selectByCondition(condition);
    PanoramicRealTimeConsumptionGather gather = new PanoramicRealTimeConsumptionGather();
    gather.setCode(code);
    gather.setValue(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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 69 with Condition

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

the class PanoramicMaterialThresholdConfigurationController method listByCategory.

/**
 * 根据category查询所有物料上下线配置
 *
 * @param category
 * @return
 */
@ApiOperation(value = "根据category查询所有物料上下线配置接口", notes = "根据category查询所有物料上下线配置")
@GetMapping("/list/{category}")
public ResultCode<List<PanoramicMaterialThresholdConfiguration>> listByCategory(@PathVariable("category") String category) {
    Condition condition = new Condition(PanoramicMaterialThresholdConfiguration.class, false);
    condition.createCriteria().andCondition("category ='" + category + "' and status =1 and delete_flag =1");
    List<PanoramicMaterialThresholdConfiguration> list = materialThresholdConfigurationService.findByCondition(condition);
    return ResultCode.getSuccessReturn(list);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicMaterialThresholdConfiguration(com.monitor.model.materialthresholdconfiguration.PanoramicMaterialThresholdConfiguration) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

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