package com.ruoyi.web.controller.api;
|
|
|
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.basic.PageInfo;
|
import com.ruoyi.common.core.domain.R;
|
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.system.model.*;
|
import com.ruoyi.system.query.InventoryStorageListQuery;
|
import com.ruoyi.system.query.ProjectMainListQuery;
|
import com.ruoyi.system.service.*;
|
import com.ruoyi.system.vo.*;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.math.RoundingMode;
|
import java.time.LocalDate;
|
import java.util.List;
|
|
/**
|
* <p>
|
* 存量项目管理 前端控制器
|
* </p>
|
*
|
* @author WuGuanFengYue
|
* @since 2025-10-16
|
*/
|
@RestController
|
@Api(tags = "存量项目情况")
|
@RequestMapping("/project-inventory")
|
public class ProjectInventoryController {
|
@Resource
|
private ProjectInventoryService projectInventoryService;
|
@Resource
|
private ProjectStorageItemService projectStorageItemService;
|
|
@Resource
|
private ProjectStorageService projectStorageService;
|
@ApiOperation(value = "获取存量项目顶部数据")
|
@PostMapping(value = "/topData")
|
public R<ProjectInventory> topData() {
|
int year = LocalDate.now().getYear();
|
List<ProjectStorageItem> projectStorageItemList = projectStorageItemService.lambdaQuery()
|
.like(ProjectStorageItem::getMonth, year).list();
|
List<ProjectStorage> projectStorageList = projectStorageService.lambdaQuery()
|
.like(ProjectStorage::getInTime, year).list();
|
BigDecimal investmentTaskFinish = projectStorageItemList.stream().map(ProjectStorageItem::getAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
BigDecimal storageTaskFinish = projectStorageList.stream().map(ProjectStorage::getTotalAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
|
List<ProjectInventory> projectInventories = projectInventoryService.list();
|
if (projectInventories.isEmpty()){
|
ProjectInventory projectInventory = new ProjectInventory();
|
projectInventory.setInvestmentTask(BigDecimal.ZERO);
|
projectInventory.setInvestmentTaskFinish(investmentTaskFinish);
|
projectInventory.setInvestmentTaskRating(new BigDecimal("100"));
|
projectInventory.setStorageTask(BigDecimal.ZERO);
|
projectInventory.setStorageTaskFinish(storageTaskFinish);
|
projectInventory.setStorageTaskRating(new BigDecimal("100"));
|
projectInventoryService.save(projectInventory);
|
return R.ok(projectInventory);
|
}else{
|
ProjectInventory projectInventory = projectInventories.get(0);
|
projectInventory.setInvestmentTaskFinish(investmentTaskFinish);
|
projectInventory.setInvestmentTaskRating(investmentTaskFinish.divide(projectInventory.getInvestmentTask(),2, RoundingMode.HALF_UP));
|
projectInventory.setStorageTaskFinish(storageTaskFinish);
|
projectInventory.setStorageTaskRating(storageTaskFinish.divide(projectInventory.getStorageTask(),2, RoundingMode.HALF_UP));
|
return R.ok(projectInventory);
|
}
|
}
|
@ApiOperation(value = "修改存量项目顶部数据")
|
@Log(title = "修改存量项目顶部数据", businessType = BusinessType.UPDATE)
|
@PostMapping(value = "/saveOrUpdate")
|
public R<Boolean> saveOrUpdate(@RequestBody ProjectInventory entity) {
|
projectInventoryService.updateById( entity);
|
return R.ok();
|
}
|
@ApiOperation(value = "存量项目情况分页列表")
|
@PostMapping(value = "/storagePageList")
|
public R<PageInfo<InventoryStorageListVO>> storagePageList(@RequestBody InventoryStorageListQuery inventoryStorageListQuery) {
|
return R.ok(projectInventoryService.storagePageList(inventoryStorageListQuery));
|
}
|
@ApiOperation(value = "月新增入库项目情况分页列表")
|
@PostMapping(value = "/inStoragePageList")
|
public R<PageInfo<InStorageListVO>> inStoragePageList(@RequestBody InventoryStorageListQuery inventoryStorageListQuery) {
|
return R.ok(projectInventoryService.inStoragePageList(inventoryStorageListQuery));
|
}
|
@ApiOperation(value = "月新增出库项目情况分页列表")
|
@PostMapping(value = "/outStoragePageList")
|
public R<PageInfo<OutStorageListVO>> outStoragePageList(@RequestBody InventoryStorageListQuery inventoryStorageListQuery) {
|
return R.ok(projectInventoryService.outStoragePageList(inventoryStorageListQuery));
|
}
|
@ApiOperation(value = "月新增入库项目情况分页列表")
|
@PostMapping(value = "/monthStoragePageList")
|
public R<PageInfo<MonthStorageListVO>> monthStoragePageList(@RequestBody InventoryStorageListQuery inventoryStorageListQuery) {
|
return R.ok(projectInventoryService.monthStoragePageList(inventoryStorageListQuery));
|
}
|
}
|