| | |
| | | package com.ruoyi.production.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | |
| | | import com.ruoyi.production.mapper.SpeculativeTradingInfoMapper; |
| | | import com.ruoyi.production.pojo.SpeculativeTradingInfo; |
| | | import com.ruoyi.production.service.impl.SalesLedgerSchedulingServiceImpl; |
| | | import com.ruoyi.sales.mapper.LossMapper; |
| | | import com.ruoyi.sales.pojo.Loss; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | private SpeculativeTradingInfoMapper speculativeTradingInfoMapper; |
| | | |
| | | @Autowired |
| | | private LossMapper lossMapper; |
| | | |
| | | @GetMapping("/loss") |
| | | @Log(title = "生产管理-生产派工-损耗率", businessType = BusinessType.OTHER) |
| | | @ApiOperation("生产管理-生产派工-损耗率") |
| | | public AjaxResult loss() { |
| | | return AjaxResult.success(lossMapper.selectOne(new LambdaQueryWrapper<Loss>().last("limit 1"))); |
| | | } |
| | | |
| | | @PostMapping("/addLoss") |
| | | @Log(title = "生产管理-生产派工-添加损耗率", businessType = BusinessType.INSERT) |
| | | @ApiOperation("生产管理-生产派工-添加损耗率") |
| | | public AjaxResult addLoss(@RequestBody Loss loss) { |
| | | lossMapper.insert(loss); |
| | | return AjaxResult.success("添加损耗率成功"); |
| | | } |
| | | |
| | | @PostMapping("/updateLoss") |
| | | @Log(title = "生产管理-生产派工-修改损耗率", businessType = BusinessType.UPDATE) |
| | | @ApiOperation("生产管理-生产派工-修改损耗率") |
| | | public AjaxResult updateLoss(@RequestBody Loss loss) { |
| | | lossMapper.updateById(loss); |
| | | return AjaxResult.success("修改损耗率成功"); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @Log(title = "生产管理-生产派工-炒机信息", businessType = BusinessType.OTHER) |
| | | @ApiOperation("生产管理-生产派工-炒机信息") |
| | | public AjaxResult list() { |
| | | List<SpeculativeTradingInfo> result = speculativeTradingInfoMapper.selectList(null); |
| | | result.forEach(item -> { |
| | | |
| | | item.setCurrentWorkLoad(salesLedgerSchedulingService.getSchedulingNumBySpeculativeTradingName(item.getName()).divide(new BigDecimal(1000),2, RoundingMode.CEILING)); |
| | | item.setVacant(item.getWorkLoad().subtract(item.getCurrentWorkLoad())); |
| | | item.setVacant(item.getWorkLoad().subtract(item.getCurrentWorkLoad()).setScale(2, RoundingMode.HALF_UP)); //保留两位小数 |
| | | }); |
| | | return AjaxResult.success(result); |
| | | } |