diff --git a/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/DictTypeConstants.java b/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/DictTypeConstants.java index 87f0f83..720582d 100644 --- a/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/DictTypeConstants.java +++ b/win-module-eam/win-module-eam-api/src/main/java/com/win/module/eam/enums/DictTypeConstants.java @@ -102,4 +102,6 @@ public interface DictTypeConstants { String EQUIPMENT_INDEX_NAME = "equipment_index_name"; //设备年度目标指标名称分类字段 String FACTORY_TYPE = "factory_type"; // 月指标导入厂区字典 String ITEM_ACCOUNT_LOCATION_TYPE = "item_account_location_type"; // 备件台账库位类型 + String TRANSACTION_TYPE = "transaction_Type"; // 库存事务类型 + String INVENTORY_ACTION = "inventory_action"; // 库存动作 } diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/TransactionController.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/TransactionController.java index cc34dee..e34f2be 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/TransactionController.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/TransactionController.java @@ -3,6 +3,7 @@ package com.win.module.eam.controller.transaction; import com.win.framework.common.pojo.CommonResult; import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.PageResult; +import com.win.framework.dict.core.util.DictFrameworkUtils; import com.win.framework.excel.core.util.ExcelUtils; import com.win.framework.operatelog.core.annotations.OperateLog; import com.win.module.eam.controller.item.vo.ItemPageReqVO; @@ -12,6 +13,7 @@ import com.win.module.eam.convert.item.ItemConvert; import com.win.module.eam.convert.transaction.TransactionConvert; import com.win.module.eam.dal.dataobject.item.ItemDO; import com.win.module.eam.dal.dataobject.transaction.TransactionDO; +import com.win.module.eam.enums.DictTypeConstants; import com.win.module.eam.service.item.ItemService; import com.win.module.eam.service.transaction.TransactionService; import io.swagger.v3.oas.annotations.Operation; @@ -25,9 +27,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; +import java.util.*; import static com.win.framework.common.pojo.CommonResult.success; import static com.win.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @@ -101,9 +101,14 @@ public class TransactionController { public void exportExcel(@Valid TransactionExportReqVO exportReqVO, HttpServletResponse response) throws IOException { List list = Service.getList(exportReqVO); + Map mapDropDown = new HashMap<>(); + String[] transaction_type = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.TRANSACTION_TYPE); + String[] inventory_action = DictFrameworkUtils.dictTypeDictDataValue(DictTypeConstants.INVENTORY_ACTION); + mapDropDown.put(2, transaction_type); + mapDropDown.put(3, inventory_action); // 导出 Excel List datas = TransactionConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "库存事务.xls", "数据", TransactionExcelVO.class, datas); + ExcelUtils.write(response, "库存事务.xls", "数据", TransactionExcelVO.class, datas,mapDropDown); } @GetMapping("/get-import-template") diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/vo/TransactionExcelVO.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/vo/TransactionExcelVO.java index 095ff76..2fa7fba 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/vo/TransactionExcelVO.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/controller/transaction/vo/TransactionExcelVO.java @@ -1,6 +1,8 @@ package com.win.module.eam.controller.transaction.vo; import com.alibaba.excel.annotation.ExcelProperty; +import com.win.framework.excel.core.annotations.DictFormat; +import com.win.framework.excel.core.convert.DictConvert; import lombok.Data; import java.math.BigDecimal; @@ -19,10 +21,12 @@ public class TransactionExcelVO { @ExcelProperty("库位编号") private String locationNumber; - @ExcelProperty("事务类型IN、OUT") + @ExcelProperty(value = "事务类型", converter = DictConvert.class) + @DictFormat("transaction_Type") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 private String transactionType; - @ExcelProperty("库存动作枚举采购入库、领用出库、归还入库、维修入库") + @ExcelProperty(value = "库存类型", converter = DictConvert.class) + @DictFormat("inventory_action") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 private String inventoryAction; @ExcelProperty("库存状态") diff --git a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java index 3c5c355..e899a63 100644 --- a/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java +++ b/win-module-eam/win-module-eam-biz/src/main/java/com/win/module/eam/dal/mysql/itemaccounts/ItemAccountsMapper.java @@ -100,7 +100,7 @@ public interface ItemAccountsMapper extends BaseMapperX { transactionDO0.setType(inLocation.getType()); list.add(transactionDO0); BigDecimal subtractInQty = subtractOutQty.subtract(inQty);//减去之后的数量 - if (inQty.compareTo(BigDecimal.ZERO) > 0 && inQty.compareTo(subtractInQty) >= 0) {//新到货存在且足够差额 + if (newQty.compareTo(BigDecimal.ZERO) > 0 && newQty.compareTo(subtractInQty) >= 0) {//新到货存在且足够差额 BigDecimal subtractNewQty = newQty.subtract(subtractInQty);//减去之后的数量 newLocation.setQty(subtractNewQty); result = this.updateById(newLocation);