|
@@ -13,6 +13,7 @@ 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.InventoryResult;
|
|
|
import com.ruoyi.inventory.domain.enums.InventoryStatus;
|
|
@@ -20,14 +21,7 @@ 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;
|
|
|
-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;
|
|
@@ -66,16 +60,19 @@ public class TbInventoryDetailController extends BaseController
|
|
|
private TbInventoryDetailMapper tbInventoryDetailMapper;
|
|
|
|
|
|
/**
|
|
|
- * 查询全单位资产对比分析报表
|
|
|
+ * 查询全单位或者部门的资产对比分析报表
|
|
|
* @return
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('inventory:compare:list')")
|
|
|
- @GetMapping("/compareList")
|
|
|
- public TableDataInfo compareList(){
|
|
|
+ @GetMapping("/getDepAssetLossTb")
|
|
|
+ public TableDataInfo compareList(@RequestParam(required = false) String deptId){
|
|
|
startPage();
|
|
|
- List<TbAssetInventory> tbAssetInventoryList = tbInventoryDetailService.selectTbInventoryCompareList();
|
|
|
+ TbInventoryCompareResult tbInventoryCompareResult = new TbInventoryCompareResult();
|
|
|
+ List<TbInventoryCompareResult> tbInventoryCompareResultList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<TbAssetInventory> tbAssetInventoryList = tbInventoryDetailService.selectTbInventoryCompareList(deptId);
|
|
|
if(tbAssetInventoryList.size() == 0){
|
|
|
- throw new RuntimeException("该组织不存在盘点完毕的盘点");
|
|
|
+ throw new RuntimeException("该组织不存在盘点完毕的盘点或者该部门不存在盘点完毕的盘点");
|
|
|
}
|
|
|
if(tbAssetInventoryList.size() == 1){
|
|
|
throw new RuntimeException("该组织只存在一个盘点,不能进行盘点间类别数量损耗对比");
|
|
@@ -88,17 +85,37 @@ public class TbInventoryDetailController extends BaseController
|
|
|
}
|
|
|
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);
|
|
|
|
|
|
- List<TbInventoryCompare> tbInventoryCompareList = getTbInventoryCompareList(inventoryStatement1, inventoryStatement2);
|
|
|
- return getDataTable(tbInventoryCompareList);
|
|
|
+ return getDataTable(tbInventoryCompareResultList);
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@@ -152,16 +169,19 @@ 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();
|
|
|
+ @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("该组织不存在盘点完毕的盘点");
|
|
|
+ throw new RuntimeException("该组织不存在盘点完毕的盘点或者该部门不参在盘点完毕的盘点");
|
|
|
}
|
|
|
if(tbAssetInventoryList.size() == 1){
|
|
|
throw new RuntimeException("该组织只存在一个盘点,不能进行盘点间类别数量损耗对比");
|
|
@@ -174,20 +194,39 @@ public class TbInventoryDetailController extends BaseController
|
|
|
}
|
|
|
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);
|
|
|
|
|
|
- List<TbInventoryCompare> tbInventoryCompareList = getTbInventoryCompareList(inventoryStatement1, inventoryStatement2);
|
|
|
-
|
|
|
- ExcelUtil<TbInventoryCompare> util = new ExcelUtil<>(TbInventoryCompare.class);
|
|
|
+ ExcelUtil<TbInventoryCompareResult> util = new ExcelUtil<>(TbInventoryCompareResult.class);
|
|
|
|
|
|
- util.exportExcel(response, tbInventoryCompareList , "全单位资产对比分析报表");
|
|
|
+ util.exportExcel(response, tbInventoryCompareResultList , "资产对比分析报表");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -261,6 +300,9 @@ public class TbInventoryDetailController extends BaseController
|
|
|
// 设置盘点时间
|
|
|
assetInventoryStatement.setInventoryDate(tbAssetInventory.getInventoryDate());
|
|
|
|
|
|
+ // 设置资产原值
|
|
|
+ assetInventoryStatement.setOriginalValue(assetInformation.getOriginalValue());
|
|
|
+
|
|
|
// 设置备注
|
|
|
assetInventoryStatement.setRemark(inventoryDetail.getRemark());
|
|
|
|
|
@@ -315,39 +357,34 @@ public class TbInventoryDetailController extends BaseController
|
|
|
|
|
|
/**
|
|
|
* 获取全单位资产对比分析报表
|
|
|
- * @param inventoryStatement1
|
|
|
- * @param inventoryStatement2
|
|
|
+ * @param inventoryStatementList
|
|
|
* @return
|
|
|
*/
|
|
|
private List<TbInventoryCompare> getTbInventoryCompareList
|
|
|
- (List<AssetInventoryStatement> inventoryStatement1,List<AssetInventoryStatement> inventoryStatement2){
|
|
|
+ (List<AssetInventoryStatement> inventoryStatementList){
|
|
|
List<TbInventoryCompare> tbInventoryCompareList = new ArrayList<>();
|
|
|
|
|
|
- for (AssetInventoryStatement assetInventoryStatement : inventoryStatement1) {
|
|
|
+ for (AssetInventoryStatement assetInventoryStatement : inventoryStatementList) {
|
|
|
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;
|
|
|
- }
|
|
|
+ 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);
|
|
|
}
|
|
|
}
|