|
@@ -12,10 +12,12 @@ 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.dto.AssetInventoryStatement;
|
|
|
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 org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -61,6 +63,45 @@ public class TbInventoryDetailController extends BaseController
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
|
+ private TbInventoryDetailMapper tbInventoryDetailMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询全单位资产对比分析报表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('inventory:compare:list')")
|
|
|
+ @GetMapping("/compareList")
|
|
|
+ public TableDataInfo compareList(){
|
|
|
+ startPage();
|
|
|
+ List<TbAssetInventory> tbAssetInventoryList = tbInventoryDetailService.selectTbInventoryCompareList();
|
|
|
+ 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);
|
|
|
+
|
|
|
+ //最近一次的上一次盘点
|
|
|
+ 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> tbInventoryCompareList = getTbInventoryCompareList(inventoryStatement1, inventoryStatement2);
|
|
|
+ return getDataTable(tbInventoryCompareList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private TbAssetInventoryMapper tbAssetInventoryMapper;
|
|
|
|
|
|
/**
|
|
@@ -86,12 +127,11 @@ public class TbInventoryDetailController extends BaseController
|
|
|
|
|
|
util.exportExcel(response, assetInventoryStatements, DateUtil.format(tbAssetInventory.getInventoryDate(), "yyyy年MM月dd日"), tbAssetInventory.getName());
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 导出资产盘点记录列表
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('inventory:inventory:export')")
|
|
|
- @Log(title = "资产盘点报表", businessType = BusinessType.EXPORT)
|
|
|
+ @Log(title = "全单位资产对比分析报表", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export/detail")
|
|
|
public void exportDetail(HttpServletResponse response, TbAssetInventory tbAssetInventory)
|
|
|
{
|
|
@@ -112,6 +152,45 @@ public class TbInventoryDetailController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 导出全单位资产对比分析报表
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('inventory:compare:export')")
|
|
|
+ @Log(title = "全单位资产对比分析报表", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export/compare")
|
|
|
+ public void exportCompare(HttpServletResponse response){
|
|
|
+ List<TbAssetInventory> tbAssetInventoryList = tbInventoryDetailService.selectTbInventoryCompareList();
|
|
|
+ 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);
|
|
|
+
|
|
|
+ //最近一次的上一次盘点
|
|
|
+ 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> tbInventoryCompareList = getTbInventoryCompareList(inventoryStatement1, inventoryStatement2);
|
|
|
+
|
|
|
+ ExcelUtil<TbInventoryCompare> util = new ExcelUtil<>(TbInventoryCompare.class);
|
|
|
+
|
|
|
+ util.exportExcel(response, tbInventoryCompareList , "全单位资产对比分析报表");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取盘点报表
|
|
|
*
|
|
|
* @param tbAssetInventory 盘点计划信息
|
|
@@ -234,4 +313,44 @@ public class TbInventoryDetailController extends BaseController
|
|
|
return toAjax(tbInventoryDetailService.deleteTbInventoryDetailByIds(ids));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取全单位资产对比分析报表
|
|
|
+ * @param inventoryStatement1
|
|
|
+ * @param inventoryStatement2
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<TbInventoryCompare> getTbInventoryCompareList
|
|
|
+ (List<AssetInventoryStatement> inventoryStatement1,List<AssetInventoryStatement> inventoryStatement2){
|
|
|
+ List<TbInventoryCompare> tbInventoryCompareList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (AssetInventoryStatement assetInventoryStatement : inventoryStatement1) {
|
|
|
+ String inventoryStatus = assetInventoryStatement.getInventoryStatus();
|
|
|
+ String assetName = assetInventoryStatement.getAssetName();
|
|
|
+ String inventoryLocation = assetInventoryStatement.getAssetLocation();
|
|
|
+ if(inventoryStatus.equals("已盘点")) {
|
|
|
+ TbInventoryCompare tbInventoryCompare = new TbInventoryCompare();
|
|
|
+ for (AssetInventoryStatement inventoryStatement : inventoryStatement2) {
|
|
|
+ if (!inventoryStatement.getInventoryStatus().equals("已盘点")) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ String assetName2 = assetInventoryStatement.getAssetName();
|
|
|
+ String inventoryLocation2 = assetInventoryStatement.getAssetLocation();
|
|
|
+ if (assetName2.equals(assetName) && inventoryLocation2.equals(inventoryLocation)) {
|
|
|
+ Integer inventoryQuantity1 = assetInventoryStatement.getInventoryQuantity();
|
|
|
+ Integer inventoryQuantity2 = inventoryStatement.getInventoryQuantity();
|
|
|
+ tbInventoryCompare.setInventoryName(assetName);
|
|
|
+ tbInventoryCompare.setInventoryLocationName(inventoryLocation);
|
|
|
+ tbInventoryCompare.setFirstInventoryNumber(inventoryQuantity1);
|
|
|
+ tbInventoryCompare.setSecondInventoryNumber(inventoryQuantity2);
|
|
|
+ tbInventoryCompare.setLossNumber(inventoryQuantity1 - inventoryQuantity2);
|
|
|
+ tbInventoryCompare.setUnits(inventoryStatement.getUnits());
|
|
|
+ tbInventoryCompare.setInventoryDate(inventoryStatement.getInventoryDate());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tbInventoryCompareList.add(tbInventoryCompare);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tbInventoryCompareList;
|
|
|
+ }
|
|
|
}
|