Search in sources :

Example 1 with PanoramicInventoryEntry

use of com.monitor.model.inventoryentry.PanoramicInventoryEntry 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 PanoramicInventoryEntry

use of com.monitor.model.inventoryentry.PanoramicInventoryEntry in project new-cloud by xie-summer.

the class PanoramicInventoryEntryController method list.

@GetMapping("/{date}/{page}/{size}")
public ResultCode<PageInfo> list(@PathVariable("date") String date, @PathVariable("page") Integer page, @PathVariable("size") Integer size) {
    PageHelper.startPage(page, size);
    List<PanoramicInventoryEntry> list = inventoryEntryService.findAll();
    PageInfo pageInfo = new PageInfo(list);
    return ResultCode.getSuccessReturn(pageInfo);
}
Also used : PageInfo(com.github.pagehelper.PageInfo) PanoramicInventoryEntry(com.monitor.model.inventoryentry.PanoramicInventoryEntry)

Example 3 with PanoramicInventoryEntry

use of com.monitor.model.inventoryentry.PanoramicInventoryEntry in project new-cloud by xie-summer.

the class PanoramicInventoryEntryServiceImpl method saveOrUpdate.

@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void saveOrUpdate(List<PanoramicInventoryEntry> panoramicInventoryEntryList) {
    panoramicInventoryEntryList.forEach(e -> {
        e.setOperator("人工录入");
        PanoramicInventoryEntry record = inventoryEntryMapper.selectByCodeAndTime(e.getCode(), e.getCtime(), e.getSchedule());
        if (Optional.ofNullable(record).isPresent()) {
            record.setUtime(DateUtil.getCurFullTimestamp());
            record.setValue(e.getValue());
            record.setOperator(e.getOperator());
            inventoryEntryMapper.updateByPrimaryKeySelective(record);
        } else {
            inventoryEntryMapper.insertSelective(e);
        }
    });
}
Also used : PanoramicInventoryEntry(com.monitor.model.inventoryentry.PanoramicInventoryEntry) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

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