|
@@ -12,22 +12,18 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.ruoyi.asset.domain.TbAssetInformation;
|
|
|
import com.ruoyi.inventory.domain.TbAssetInventory;
|
|
|
+import com.ruoyi.inventory.domain.TbInventoryCompare;
|
|
|
+import com.ruoyi.inventory.domain.TbInventoryCompareResult;
|
|
|
import com.ruoyi.inventory.domain.dto.AssetInventoryStatement;
|
|
|
import com.ruoyi.inventory.domain.enums.InventoryPlanResult;
|
|
|
import com.ruoyi.inventory.domain.enums.InventoryResult;
|
|
|
import com.ruoyi.inventory.domain.enums.InventoryStatus;
|
|
|
import com.ruoyi.inventory.mapper.TbAssetInventoryMapper;
|
|
|
+import com.ruoyi.inventory.mapper.TbInventoryDetailMapper;
|
|
|
import com.ruoyi.inventory.service.ITbAssetInventoryService;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
@@ -63,6 +59,68 @@ public class TbInventoryDetailController extends BaseController
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
+ private TbInventoryDetailMapper tbInventoryDetailMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询全单位或者部门的资产对比分析报表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('inventory:compare:list')")
|
|
|
+ @GetMapping("/getDepAssetLossTb")
|
|
|
+ public TableDataInfo compareList(@RequestParam(required = false) String deptId){
|
|
|
+ startPage();
|
|
|
+ TbInventoryCompareResult tbInventoryCompareResult = new TbInventoryCompareResult();
|
|
|
+ List<TbInventoryCompareResult> tbInventoryCompareResultList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<TbAssetInventory> tbAssetInventoryList = tbInventoryDetailService.selectTbInventoryCompareList(deptId);
|
|
|
+ if(tbAssetInventoryList.size() == 0){
|
|
|
+ throw new RuntimeException("该组织不存在盘点完毕的盘点或者该部门不存在盘点完毕的盘点");
|
|
|
+ }
|
|
|
+ if(tbAssetInventoryList.size() == 1){
|
|
|
+ throw new RuntimeException("该组织只存在一个盘点,不能进行盘点间类别数量损耗对比");
|
|
|
+ }
|
|
|
+
|
|
|
+ //最近一次盘点
|
|
|
+ String orderNumber = tbAssetInventoryList.get(0).getOrderNumber();
|
|
|
+ if (StrUtil.isBlank(orderNumber)) {
|
|
|
+ throw new RuntimeException("盘点计划编码不能为空");
|
|
|
+ }
|
|
|
+ List<TbInventoryDetail> tbInventoryDetailList1 = tbInventoryDetailMapper.selectTbInventoryDetailByOrderNumber(orderNumber);
|
|
|
+ List<AssetInventoryStatement> inventoryStatement1 = getInventoryStatement(tbAssetInventoryList.get(0), tbInventoryDetailList1);
|
|
|
+ List<TbInventoryCompare> tbInventoryCompareList = getTbInventoryCompareList(inventoryStatement1);
|
|
|
+ double total = 0.0;
|
|
|
+ for (TbInventoryCompare tbInventoryCompare : tbInventoryCompareList) {
|
|
|
+ total = tbInventoryCompare.getLossVal()+total;
|
|
|
+ }
|
|
|
+ tbInventoryCompareResult.setDate(tbAssetInventoryList.get(0).getInventoryDate());
|
|
|
+ tbInventoryCompareResult.setAssetResultList(tbInventoryCompareList);
|
|
|
+ tbInventoryCompareResult.setInventoryDepartment(tbAssetInventoryList.get(0).getInventoryDepartmentName());
|
|
|
+ tbInventoryCompareResult.setLossTotal(total);
|
|
|
+ tbInventoryCompareResultList.add(tbInventoryCompareResult);
|
|
|
+
|
|
|
+ //最近一次的上一次盘点
|
|
|
+ TbInventoryCompareResult tbInventoryCompareResult2 = new TbInventoryCompareResult();
|
|
|
+ orderNumber = tbAssetInventoryList.get(1).getOrderNumber();
|
|
|
+ if (StrUtil.isBlank(orderNumber)) {
|
|
|
+ throw new RuntimeException("盘点计划编码不能为空");
|
|
|
+ }
|
|
|
+ List<TbInventoryDetail> tbInventoryDetailList2 = tbInventoryDetailMapper.selectTbInventoryDetailByOrderNumber(orderNumber);
|
|
|
+ List<AssetInventoryStatement> inventoryStatement2 = getInventoryStatement(tbAssetInventoryList.get(0), tbInventoryDetailList2);
|
|
|
+ List<TbInventoryCompare> tbInventoryCompareList2 = getTbInventoryCompareList(inventoryStatement2);
|
|
|
+ total = 0.0;
|
|
|
+ for (TbInventoryCompare tbInventoryCompare : tbInventoryCompareList2) {
|
|
|
+ total = tbInventoryCompare.getLossVal()+total;
|
|
|
+ }
|
|
|
+ tbInventoryCompareResult2.setDate(tbAssetInventoryList.get(0).getInventoryDate());
|
|
|
+ tbInventoryCompareResult2.setAssetResultList(tbInventoryCompareList2);
|
|
|
+ tbInventoryCompareResult2.setInventoryDepartment(tbAssetInventoryList.get(1).getInventoryDepartmentName());
|
|
|
+ tbInventoryCompareResult2.setLossTotal(total);
|
|
|
+ tbInventoryCompareResultList.add(tbInventoryCompareResult2);
|
|
|
+
|
|
|
+ return getDataTable(tbInventoryCompareResultList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private ITbAssetInventoryService inventoryService;
|
|
|
|
|
|
/**
|
|
@@ -97,7 +155,7 @@ public class TbInventoryDetailController extends BaseController
|
|
|
@PostMapping("/export/detail")
|
|
|
public void exportDetail(HttpServletResponse response, TbAssetInventory tbAssetInventory)
|
|
|
{
|
|
|
- List<TbAssetInventory> tbAssetInventoryList = inventoryService.selectTbAssetInventoryList(tbAssetInventory);
|
|
|
+ List<TbAssetInventory> tbAssetInventoryList = tbAssetInventoryMapper.selectTbAssetInventoryList(tbAssetInventory);
|
|
|
List<AssetInventoryStatement> assetInventoryStatements = new ArrayList<>();
|
|
|
|
|
|
for (TbAssetInventory assetInventory : tbAssetInventoryList) {
|
|
@@ -114,6 +172,67 @@ public class TbInventoryDetailController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 导出全单位或者部门的资产对比分析报表
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('inventory:compare:export')")
|
|
|
+ @Log(title = "全单位资产对比分析报表", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/exportDepAssetLossTb")
|
|
|
+ public void exportCompare(HttpServletResponse response,@RequestParam(required = false) String deptId){
|
|
|
+ TbInventoryCompareResult tbInventoryCompareResult = new TbInventoryCompareResult();
|
|
|
+ List<TbInventoryCompareResult> tbInventoryCompareResultList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<TbAssetInventory> tbAssetInventoryList = tbInventoryDetailService.selectTbInventoryCompareList(deptId);
|
|
|
+ if(tbAssetInventoryList.size() == 0){
|
|
|
+ throw new RuntimeException("该组织不存在盘点完毕的盘点或者该部门不参在盘点完毕的盘点");
|
|
|
+ }
|
|
|
+ if(tbAssetInventoryList.size() == 1){
|
|
|
+ throw new RuntimeException("该组织只存在一个盘点,不能进行盘点间类别数量损耗对比");
|
|
|
+ }
|
|
|
+
|
|
|
+ //最近一次盘点
|
|
|
+ String orderNumber = tbAssetInventoryList.get(0).getOrderNumber();
|
|
|
+ if (StrUtil.isBlank(orderNumber)) {
|
|
|
+ throw new RuntimeException("盘点计划编码不能为空");
|
|
|
+ }
|
|
|
+ List<TbInventoryDetail> tbInventoryDetailList1 = tbInventoryDetailMapper.selectTbInventoryDetailByOrderNumber(orderNumber);
|
|
|
+ List<AssetInventoryStatement> inventoryStatement1 = getInventoryStatement(tbAssetInventoryList.get(0), tbInventoryDetailList1);
|
|
|
+ List<TbInventoryCompare> tbInventoryCompareList = getTbInventoryCompareList(inventoryStatement1);
|
|
|
+ double total = 0.0;
|
|
|
+ for (TbInventoryCompare tbInventoryCompare : tbInventoryCompareList) {
|
|
|
+ total = tbInventoryCompare.getLossVal()+total;
|
|
|
+ }
|
|
|
+ tbInventoryCompareResult.setDate(tbAssetInventoryList.get(0).getInventoryDate());
|
|
|
+ tbInventoryCompareResult.setAssetResultList(tbInventoryCompareList);
|
|
|
+ tbInventoryCompareResult.setInventoryDepartment(tbAssetInventoryList.get(0).getInventoryDepartmentName());
|
|
|
+ tbInventoryCompareResult.setLossTotal(total);
|
|
|
+ tbInventoryCompareResultList.add(tbInventoryCompareResult);
|
|
|
+
|
|
|
+ //最近一次的上一次盘点
|
|
|
+ TbInventoryCompareResult tbInventoryCompareResult2 = new TbInventoryCompareResult();
|
|
|
+ orderNumber = tbAssetInventoryList.get(1).getOrderNumber();
|
|
|
+ if (StrUtil.isBlank(orderNumber)) {
|
|
|
+ throw new RuntimeException("盘点计划编码不能为空");
|
|
|
+ }
|
|
|
+ List<TbInventoryDetail> tbInventoryDetailList2 = tbInventoryDetailMapper.selectTbInventoryDetailByOrderNumber(orderNumber);
|
|
|
+ List<AssetInventoryStatement> inventoryStatement2 = getInventoryStatement(tbAssetInventoryList.get(0), tbInventoryDetailList2);
|
|
|
+ List<TbInventoryCompare> tbInventoryCompareList2 = getTbInventoryCompareList(inventoryStatement2);
|
|
|
+ total = 0.0;
|
|
|
+ for (TbInventoryCompare tbInventoryCompare : tbInventoryCompareList2) {
|
|
|
+ total = tbInventoryCompare.getLossVal()+total;
|
|
|
+ }
|
|
|
+ tbInventoryCompareResult2.setDate(tbAssetInventoryList.get(0).getInventoryDate());
|
|
|
+ tbInventoryCompareResult2.setAssetResultList(tbInventoryCompareList2);
|
|
|
+ tbInventoryCompareResult2.setInventoryDepartment(tbAssetInventoryList.get(1).getInventoryDepartmentName());
|
|
|
+ tbInventoryCompareResult2.setLossTotal(total);
|
|
|
+ tbInventoryCompareResultList.add(tbInventoryCompareResult2);
|
|
|
+
|
|
|
+ ExcelUtil<TbInventoryCompareResult> util = new ExcelUtil<>(TbInventoryCompareResult.class);
|
|
|
+
|
|
|
+ util.exportExcel(response, tbInventoryCompareResultList , "资产对比分析报表");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取盘点报表
|
|
|
*
|
|
|
* @param tbAssetInventory 盘点计划信息
|
|
@@ -189,6 +308,9 @@ public class TbInventoryDetailController extends BaseController
|
|
|
String inventoryPlanResultName = InventoryPlanResult.getName(inventoryPlanResult);
|
|
|
assetInventoryStatement.setInventoryPlanResult(inventoryPlanResultName);
|
|
|
|
|
|
+ // 设置资产原值
|
|
|
+ assetInventoryStatement.setOriginalValue(assetInformation.getOriginalValue());
|
|
|
+
|
|
|
// 设置备注
|
|
|
assetInventoryStatement.setRemark(inventoryDetail.getRemark());
|
|
|
|
|
@@ -241,4 +363,39 @@ public class TbInventoryDetailController extends BaseController
|
|
|
return toAjax(tbInventoryDetailService.deleteTbInventoryDetailByIds(ids));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取全单位资产对比分析报表
|
|
|
+ * @param inventoryStatementList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<TbInventoryCompare> getTbInventoryCompareList
|
|
|
+ (List<AssetInventoryStatement> inventoryStatementList){
|
|
|
+ List<TbInventoryCompare> tbInventoryCompareList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (AssetInventoryStatement assetInventoryStatement : inventoryStatementList) {
|
|
|
+ String inventoryStatus = assetInventoryStatement.getInventoryStatus();
|
|
|
+ if(inventoryStatus.equals("已盘点")) {
|
|
|
+ TbInventoryCompare tbInventoryCompare = new TbInventoryCompare();
|
|
|
+ String assetName = assetInventoryStatement.getAssetName();
|
|
|
+ String inventoryLocation = assetInventoryStatement.getAssetLocation();
|
|
|
+ Integer quantity = assetInventoryStatement.getQuantity();
|
|
|
+ Integer inventoryQuantity = assetInventoryStatement.getInventoryQuantity();
|
|
|
+ tbInventoryCompare.setInventoryName(assetName);
|
|
|
+ tbInventoryCompare.setInventoryLocationName(inventoryLocation);
|
|
|
+ tbInventoryCompare.setExpectInventoryNumber(quantity);
|
|
|
+ tbInventoryCompare.setRealityInventoryNumber(inventoryQuantity);
|
|
|
+ if(quantity>inventoryQuantity){
|
|
|
+ tbInventoryCompare.setLossNumber(quantity - inventoryQuantity);
|
|
|
+ tbInventoryCompare.setLossVal(assetInventoryStatement.getOriginalValue()*(quantity - inventoryQuantity));
|
|
|
+
|
|
|
+ }else {
|
|
|
+ tbInventoryCompare.setLossNumber(0);
|
|
|
+ tbInventoryCompare.setLossVal(0.0);
|
|
|
+ }
|
|
|
+ tbInventoryCompare.setUnits(assetInventoryStatement.getUnits());
|
|
|
+ tbInventoryCompareList.add(tbInventoryCompare);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tbInventoryCompareList;
|
|
|
+ }
|
|
|
}
|