package com.jdc.jdcproject.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.jdc.jdcproject.entity.DicekePlatearea;
import com.jdc.jdcproject.entity.DicekeShovel;
import com.jdc.jdcproject.entity.VO.DicekeMininglossVo;
import com.jdc.jdcproject.mapper.DicekeMininglossMapper;
import com.jdc.jdcproject.mapper.DicekePlateareaMapper;
import com.jdc.jdcproject.mapper.DicekeShovelMapper;
import com.jdc.jdcproject.service.IDicekeMininglossService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jdc.jdcproject.service.IDicekePlateareaService;
import com.jdc.jdcproject.service.IDicekeShovelService;
import com.jdc.jdcproject.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*
* 采剥与贫损表; 服务实现类
*
*
* @author haoyanlu
* @since 2025-04-26
*/
@Service
public class DicekeMininglossServiceImpl extends ServiceImpl implements IDicekeMininglossService {
@Autowired
private DicekeMininglossMapper dicekeMininglossMapper;
@Autowired
private DicekeShovelMapper dicekeShovelMapper;
@Autowired
private DicekePlateareaMapper dicekePlateareaMapper;
@Override
public List findAllLoss() {
return baseMapper.findAllLoss();
}
@Override
public int savedml(DicekeMininglossVo dicekeMininglossVo) {
/*
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("plateRange",dicekeMininglossVo.getPlateRange());
DicekePlatearea dp = dicekePlateareaService.getOne(queryWrapper);
*/
//平盘和电铲查找单独一个工具类(使用次数多)
DicekePlatearea dp = dicekePlateareaMapper.selectOne(
new QueryWrapper().eq("plateRange", dicekeMininglossVo.getPlateRange())
);
System.out.println(dp);
if (dp == null){
return 1;
}
//不确定是否是数据库表的问题 报错
DicekeShovel ds = dicekeShovelMapper.selectOne(
new QueryWrapper().eq("shovelCode", dicekeMininglossVo.getShovelCode())
);
System.out.println(ds);
if (ds == null){
// return Result.errorResult().data("电铲不存在",ds);
return 2;
}
//构建报表实体
//Loss的id生成
DicekeMiningloss dml = new DicekeMiningloss();
dml.setShovelID(ds.getShovelID());
dml.setPlateID(dp.getPlateID());
dml.setMonth(dicekeMininglossVo.getMonth());
dml.setStrippingTon(dicekeMininglossVo.getStrippingTon());
dml.setStrippingAndTotalMiningTon(dicekeMininglossVo.getStrippingAndTotalMiningTon());
dml.setWasteRockTon(dicekeMininglossVo.getWasteRockTon());
dml.setDilutionRate(dicekeMininglossVo.getDilutionRate());
dml.setLossRate(dicekeMininglossVo.getLossRate());
dml.setAllocationTon(dicekeMininglossVo.getAllocationTon());
dicekeMininglossMapper.insert(dml);
//时间戳接收前端传还是后端获取
return 20000;
}
}