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);
}
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);
}
}
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;
}
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);
}
Aggregations