diff --git a/op-modules/op-device/src/main/java/com/op/device/controller/SparePartsLedgerController.java b/op-modules/op-device/src/main/java/com/op/device/controller/SparePartsLedgerController.java index b79e3f85..f183ea58 100644 --- a/op-modules/op-device/src/main/java/com/op/device/controller/SparePartsLedgerController.java +++ b/op-modules/op-device/src/main/java/com/op/device/controller/SparePartsLedgerController.java @@ -1,8 +1,14 @@ package com.op.device.controller; +import java.io.IOException; +import java.util.ArrayList; import java.util.List; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; +import com.op.common.core.domain.ExcelCol; +import com.op.common.core.utils.poi.ExcelMapUtil; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -21,6 +27,7 @@ import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.utils.poi.ExcelUtil; import com.op.common.core.web.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; /** * 备品备件台账管理Controller @@ -95,4 +102,74 @@ public class SparePartsLedgerController extends BaseController { public AjaxResult remove(@PathVariable String[] storageIds) { return toAjax(sparePartsLedgerService.deleteSparePartsLedgerByStorageIds(storageIds)); } + + /** + * 生成设备信息模板 + * + * @param response + * @throws IOException + */ + @PostMapping("/importTemplate") + @Log(title = "生成备品备件信息模板", businessType = BusinessType.EXPORT) + public void importTemplate(HttpServletResponse response) throws IOException { + + ArrayList excelCols = new ArrayList<>(); + excelCols.add(new ExcelCol("备品备件编码", "materialCode", 20)); + excelCols.add(new ExcelCol("备品备件名称", "materialDesc", 20)); + excelCols.add(new ExcelCol("所属设备编码", "ownEquipmentCode", 20)); + excelCols.add(new ExcelCol("所属设备名称", "ownEquipmentName", 20)); + excelCols.add(new ExcelCol("设备厂家", "spareSupplier", 20)); + excelCols.add(new ExcelCol("规格型号", "spareMode", 20)); + excelCols.add(new ExcelCol("单机装配数量", "unitQuantity", 20)); + excelCols.add(new ExcelCol("单价", "unitPrice", 20)); + excelCols.add(new ExcelCol("单位", "userDefined1", 20)); + excelCols.add(new ExcelCol("代用件", "substituteParts", 20)); + excelCols.add(new ExcelCol("安全库存", "safeStock", 20)); + excelCols.add(new ExcelCol("现有库存", "amount", 20)); + excelCols.add(new ExcelCol("采购方式", "procurementMethod", 20)); + excelCols.add(new ExcelCol("更换周期(月)", "spareReplacementCycle", 20)); + excelCols.add(new ExcelCol("采购周期(天)", "procurementCycle", 20)); + excelCols.add(new ExcelCol("期初结存", "openingBalance", 20)); + excelCols.add(new ExcelCol("入库记录", "inputRecords", 20)); + excelCols.add(new ExcelCol("出库记录", "outputRecords", 20)); + excelCols.add(new ExcelCol("期末盘点", "endInventory", 20)); + excelCols.add(new ExcelCol("期末金额", "endMoney", 20)); + + String titleName = "备品备件信息导入"; + SXSSFWorkbook workbook = null; + try { + //设置响应头 + response.setHeader("Content-disposition", + "attachment; filename=" + titleName); + response.setContentType("application/octet-stream;charset=UTF-8"); + ServletOutputStream outputStream = response.getOutputStream(); + //调用工具类 + workbook = ExcelMapUtil.initWorkbook(titleName, null, excelCols, null); + workbook.write(outputStream); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (workbook != null) { + workbook.dispose(); + } + } + } + + /** + * 导入备品备件基本信息接口 + * + * @param file + * @return + * @throws Exception + */ + @Log(title = "导入备品备件基本信息", businessType = BusinessType.IMPORT) + @PostMapping("/importFile") + @RequiresPermissions("device:sparePartsLedger:import") + public AjaxResult importFile(MultipartFile file) throws Exception { + // 创建接收对象 + ExcelUtil util = new ExcelUtil<>(SparePartsLedger.class); + // 接收表格信息 + List orderList = util.importExcel(file.getInputStream()); + return sparePartsLedgerService.importFile(orderList); + } } diff --git a/op-modules/op-device/src/main/java/com/op/device/domain/SparePartsLedger.java b/op-modules/op-device/src/main/java/com/op/device/domain/SparePartsLedger.java index 75371225..e68f6be5 100644 --- a/op-modules/op-device/src/main/java/com/op/device/domain/SparePartsLedger.java +++ b/op-modules/op-device/src/main/java/com/op/device/domain/SparePartsLedger.java @@ -18,63 +18,109 @@ import com.op.common.core.web.domain.BaseEntity; public class SparePartsLedger extends BaseEntity { private static final long serialVersionUID = 1L; - /** - * 唯一序列 - */ @Excel(name = "唯一序列") private String storageId; - /** - * 仓库编码 - */ + @Excel(name = "备品备件编码") + //以前是物料编码 + private String materialCode; + + @Excel(name = "备品备件名称") + //以前是物料名称 + private String materialDesc; + + @Excel(name = "所属设备编码") + private String ownEquipmentCode; + + @Excel(name = "所属设备名称") + private String ownEquipmentName; + + @Excel(name = "设备厂家") + //以前是供应商 + private String spareSupplier; + + @Excel(name = "规格型号") + private String spareMode; + + @Excel(name = "单机装配数量") + private String unitQuantity; + + @Excel(name = "单价") + private BigDecimal unitPrice; + + @Excel(name = "单位") + private String userDefined1; + + @Excel(name = "代用件") + private String substituteParts; + + @Excel(name = "安全库存") + private String safeStock; + + @Excel(name = "现有库存") + //以前是总数量 + private BigDecimal amount; + + @Excel(name = "采购方式") + private String procurementMethod; + + @Excel(name = "更换周期(月)") + private String spareReplacementCycle; + + @Excel(name = "采购周期(天)") + private String procurementCycle; + + @Excel(name = "期初结存") + private String openingBalance; + + @Excel(name = "出库记录") + private String outputRecords; + + @Excel(name = "入库记录") + private String inputRecords; + + @Excel(name = "期末盘点") + private String endInventory; + + @Excel(name = "期末金额") + private BigDecimal endMoney; + + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date gmtCreate; + + @Excel(name = "最后更新人") + private String lastModifiedBy; + + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date gmtModified; + + @Excel(name = "有效标记") + private String activeFlag; + + @Excel(name = "工厂号") + private String factoryCode; + + private String delFlag; + + ///////////////////////////////////////暂时不用字段 + @Excel(name = "仓库编码") private String whCode; - /** - * 区域编号 - */ @Excel(name = "区域编号") private String regionCode; - /** - * 库区编码 - */ @Excel(name = "库区编码") private String waCode; - /** - * 库存类型:BC-包材 - */ @Excel(name = "库存类型:BC-包材") private String storageType; - /** - * 库位编码 - */ @Excel(name = "库位编码") private String wlCode; - /** - * 物料号 - */ - @Excel(name = "物料号") - private String materialCode; - - /** - * 物料描述 - */ - @Excel(name = "物料描述") - private String materialDesc; - - /** - * 总数量 - */ - @Excel(name = "总数量") - private BigDecimal amount; - - /** - * 冻结数量(预留) - */ @Excel(name = "冻结数量", readConverterExp = "预=留") private BigDecimal storageAmount; @@ -83,328 +129,86 @@ public class SparePartsLedger extends BaseEntity { // @Excel(name = "库存可用数量") // private BigDecimal availableQuantity; - /** - * 占用数量 - */ @Excel(name = "占用数量") private BigDecimal occupyAmount; - /** - * LPN(预留) - */ @Excel(name = "LPN", readConverterExp = "预=留") private String lpn; - /** - * 入库批次号(预留) - */ @Excel(name = "入库批次号", readConverterExp = "预=留") private String productBatch; - /** - * 入库时间x(预留) - */ @Excel(name = "入库时间x", readConverterExp = "预=留") private Date receiveDate; - /** - * 生产时间(预留) - */ @Excel(name = "生产时间", readConverterExp = "预=留") private Date productDate; - /** - * 单位 - */ - @Excel(name = "单位") - private String userDefined1; - - /** - * SAP库位 - */ @Excel(name = "SAP库位") private String userDefined2; - /** - * 备用3 - */ @Excel(name = "备用3") private String userDefined3; - /** - * 备用4 - */ @Excel(name = "备用4") private String userDefined4; - /** - * 备用5 - */ @Excel(name = "备用5") private String userDefined5; - /** - * 备用6 - */ @Excel(name = "备用6") private String userDefined6; - /** - * 备用7 - */ @Excel(name = "备用7") private String userDefined7; - /** - * 备用8 - */ @Excel(name = "备用8") private String userDefined8; - /** - * 备用9 - */ @Excel(name = "备用9") private String userDefined9; - /** - * 备用10 - */ @Excel(name = "备用10") private String userDefined10; - /** - * 创建时间 - */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date gmtCreate; - - /** - * 最后更新人 - */ - @Excel(name = "最后更新人") - private String lastModifiedBy; - - /** - * 最后更新时间 - */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "最后更新时间", width = 30, dateFormat = "yyyy-MM-dd") - private Date gmtModified; - - /** - * 有效标记 - */ - @Excel(name = "有效标记") - private String activeFlag; - - /** - * 工厂号 - */ - @Excel(name = "工厂号") - private String factoryCode; - - /** - * SAP工厂号 - */ @Excel(name = "SAP工厂号") private String sapFactoryCode; - /** - * 库位名称 - */ @Excel(name = "库位名称") private String wlName; - /** - * 0存在 - */ - private String delFlag; - - /** - * 使用寿命(备件用) - */ - @Excel(name = "使用寿命", readConverterExp = "备=件用") + @Excel(name = "使用寿命") private String spareUseLife; - /** - * 备件名称(备件用) - */ - @Excel(name = "备件名称", readConverterExp = "备=件用") + @Excel(name = "备件名称") private String spareName; - /** - * 规格型号(备件用) - */ - @Excel(name = "规格型号", readConverterExp = "备=件用") - private String spareMode; - - /** - * 生产厂商(备件用) - */ - @Excel(name = "生产厂商", readConverterExp = "备=件用") + @Excel(name = "生产厂商") private String spareManufacturer; - /** - * 供应商(备件用) - */ - @Excel(name = "供应商", readConverterExp = "备=件用") - private String spareSupplier; - - /** - * 循环周期(备件用) - */ - @Excel(name = "循环周期", readConverterExp = "备=件用") - private String spareReplacementCycle; - - /** - * 计量单位(备件用) - */ - @Excel(name = "计量单位", readConverterExp = "备=件用") + @Excel(name = "计量单位") private String spareMeasurementUnit; - /** - * 换算单位(备件用) - */ - @Excel(name = "换算单位", readConverterExp = "备=件用") + @Excel(name = "换算单位") private String spareConversionUnit; - /** - * 换算比例(备件用) - */ - @Excel(name = "换算比例", readConverterExp = "备=件用") + @Excel(name = "换算比例") private String spareConversionRatio; - /** - * 库存上限(备件用) - */ - @Excel(name = "库存上限", readConverterExp = "备=件用") + @Excel(name = "库存上限") private String spareInventoryFloor; - /** - * 库存下限(备件用) - */ - @Excel(name = "库存下限", readConverterExp = "备=件用") + @Excel(name = "库存下限") private String spareInventoryUpper; - /** - * 备件类型 - */ - @Excel(name = "备件类型", readConverterExp = "备=件用") + @Excel(name = "备件类型") private String spareType; //////////////////////////////////////////////////////////附属表 - /** - * id - */ - private String id; - - /** - * 主表备件编码 - */ - @Excel(name = "主表备件编码") - private String primaryCode; - - /** - * 所属设备名称 - */ - @Excel(name = "所属设备名称") - private String ownEquipmentName; - - /** - * 单机装配数量 - */ - @Excel(name = "单机装配数量") - private String unitQuantity; - - /** - * 安全库存 - */ - @Excel(name = "安全库存") - private String safeStock; - - /** - * 单价 - */ - @Excel(name = "单价") - private BigDecimal unitPrice; - - /** - * 采购方式 - */ - @Excel(name = "采购方式") - private String procurementMethod; - - /** - * 采购周期 - */ - @Excel(name = "采购周期") - private String procurementCycle; - - /** - * 期初结存 - */ - @Excel(name = "期初结存") - private String openingBalance; - - /** - * 出库记录 - */ - @Excel(name = "出库记录") - private String outputRecords; - - /** - * 入库记录 - */ - @Excel(name = "入库记录") - private String inputRecords; - - /** - * 期末盘点 - */ - @Excel(name = "期末盘点") - private String endInventory; - - /** - * 期末金额 - */ - @Excel(name = "期末金额") - private BigDecimal endMoney; - - /** - * 代用件 - */ - @Excel(name = "代用件") - private String substituteParts; - - /** - * 所属设备编码 - */ - @Excel(name = "所属设备编码") - private String ownEquipmentCode; - - public void setId(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - public void setPrimaryCode(String primaryCode) { - this.primaryCode = primaryCode; - } - - public String getPrimaryCode() { - return primaryCode; - } - public void setOwnEquipmentName(String ownEquipmentName) { this.ownEquipmentName = ownEquipmentName; } - public String getOwnEquipmentName() { return ownEquipmentName; } @@ -412,7 +216,6 @@ public class SparePartsLedger extends BaseEntity { public void setUnitQuantity(String unitQuantity) { this.unitQuantity = unitQuantity; } - public String getUnitQuantity() { return unitQuantity; } @@ -420,7 +223,6 @@ public class SparePartsLedger extends BaseEntity { public void setSafeStock(String safeStock) { this.safeStock = safeStock; } - public String getSafeStock() { return safeStock; } @@ -428,7 +230,6 @@ public class SparePartsLedger extends BaseEntity { public void setUnitPrice(BigDecimal unitPrice) { this.unitPrice = unitPrice; } - public BigDecimal getUnitPrice() { return unitPrice; } @@ -436,7 +237,6 @@ public class SparePartsLedger extends BaseEntity { public void setProcurementMethod(String procurementMethod) { this.procurementMethod = procurementMethod; } - public String getProcurementMethod() { return procurementMethod; } @@ -444,7 +244,6 @@ public class SparePartsLedger extends BaseEntity { public void setProcurementCycle(String procurementCycle) { this.procurementCycle = procurementCycle; } - public String getProcurementCycle() { return procurementCycle; } @@ -452,7 +251,6 @@ public class SparePartsLedger extends BaseEntity { public void setOpeningBalance(String openingBalance) { this.openingBalance = openingBalance; } - public String getOpeningBalance() { return openingBalance; } @@ -460,7 +258,6 @@ public class SparePartsLedger extends BaseEntity { public void setOutputRecords(String outputRecords) { this.outputRecords = outputRecords; } - public String getOutputRecords() { return outputRecords; } @@ -468,7 +265,6 @@ public class SparePartsLedger extends BaseEntity { public void setInputRecords(String inputRecords) { this.inputRecords = inputRecords; } - public String getInputRecords() { return inputRecords; } @@ -476,7 +272,6 @@ public class SparePartsLedger extends BaseEntity { public void setEndInventory(String endInventory) { this.endInventory = endInventory; } - public String getEndInventory() { return endInventory; } @@ -484,7 +279,6 @@ public class SparePartsLedger extends BaseEntity { public void setEndMoney(BigDecimal endMoney) { this.endMoney = endMoney; } - public BigDecimal getEndMoney() { return endMoney; } @@ -492,7 +286,6 @@ public class SparePartsLedger extends BaseEntity { public void setSubstituteParts(String substituteParts) { this.substituteParts = substituteParts; } - public String getSubstituteParts() { return substituteParts; } @@ -500,20 +293,16 @@ public class SparePartsLedger extends BaseEntity { public void setOwnEquipmentCode(String ownEquipmentCode) { this.ownEquipmentCode = ownEquipmentCode; } - public String getOwnEquipmentCode() { return ownEquipmentCode; } - ///////////////////////////// - // 领用数量-保养备件领用使用 private BigDecimal applyNum; public BigDecimal getApplyNum() { return applyNum; } - public void setApplyNum(BigDecimal applyNum) { this.applyNum = applyNum; } @@ -521,7 +310,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareType(String spareType) { this.spareType = spareType; } - public String getSpareType() { return spareType; } @@ -529,7 +317,6 @@ public class SparePartsLedger extends BaseEntity { public void setStorageId(String storageId) { this.storageId = storageId; } - public String getStorageId() { return storageId; } @@ -537,7 +324,6 @@ public class SparePartsLedger extends BaseEntity { public void setWhCode(String whCode) { this.whCode = whCode; } - public String getWhCode() { return whCode; } @@ -545,7 +331,6 @@ public class SparePartsLedger extends BaseEntity { public void setRegionCode(String regionCode) { this.regionCode = regionCode; } - public String getRegionCode() { return regionCode; } @@ -553,7 +338,6 @@ public class SparePartsLedger extends BaseEntity { public void setWaCode(String waCode) { this.waCode = waCode; } - public String getWaCode() { return waCode; } @@ -561,7 +345,6 @@ public class SparePartsLedger extends BaseEntity { public void setStorageType(String storageType) { this.storageType = storageType; } - public String getStorageType() { return storageType; } @@ -569,7 +352,6 @@ public class SparePartsLedger extends BaseEntity { public void setWlCode(String wlCode) { this.wlCode = wlCode; } - public String getWlCode() { return wlCode; } @@ -577,7 +359,6 @@ public class SparePartsLedger extends BaseEntity { public void setMaterialCode(String materialCode) { this.materialCode = materialCode; } - public String getMaterialCode() { return materialCode; } @@ -585,7 +366,6 @@ public class SparePartsLedger extends BaseEntity { public void setMaterialDesc(String materialDesc) { this.materialDesc = materialDesc; } - public String getMaterialDesc() { return materialDesc; } @@ -593,7 +373,6 @@ public class SparePartsLedger extends BaseEntity { public void setAmount(BigDecimal amount) { this.amount = amount; } - public BigDecimal getAmount() { return amount; } @@ -601,7 +380,6 @@ public class SparePartsLedger extends BaseEntity { public void setStorageAmount(BigDecimal storageAmount) { this.storageAmount = storageAmount; } - public BigDecimal getStorageAmount() { return storageAmount; } @@ -617,7 +395,6 @@ public class SparePartsLedger extends BaseEntity { public void setOccupyAmount(BigDecimal occupyAmount) { this.occupyAmount = occupyAmount; } - public BigDecimal getOccupyAmount() { return occupyAmount; } @@ -625,7 +402,6 @@ public class SparePartsLedger extends BaseEntity { public void setLpn(String lpn) { this.lpn = lpn; } - public String getLpn() { return lpn; } @@ -633,7 +409,6 @@ public class SparePartsLedger extends BaseEntity { public void setProductBatch(String productBatch) { this.productBatch = productBatch; } - public String getProductBatch() { return productBatch; } @@ -641,7 +416,6 @@ public class SparePartsLedger extends BaseEntity { public void setReceiveDate(Date receiveDate) { this.receiveDate = receiveDate; } - public Date getReceiveDate() { return receiveDate; } @@ -649,7 +423,6 @@ public class SparePartsLedger extends BaseEntity { public void setProductDate(Date productDate) { this.productDate = productDate; } - public Date getProductDate() { return productDate; } @@ -657,7 +430,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined1(String userDefined1) { this.userDefined1 = userDefined1; } - public String getUserDefined1() { return userDefined1; } @@ -665,7 +437,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined2(String userDefined2) { this.userDefined2 = userDefined2; } - public String getUserDefined2() { return userDefined2; } @@ -673,7 +444,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined3(String userDefined3) { this.userDefined3 = userDefined3; } - public String getUserDefined3() { return userDefined3; } @@ -681,7 +451,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined4(String userDefined4) { this.userDefined4 = userDefined4; } - public String getUserDefined4() { return userDefined4; } @@ -689,7 +458,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined5(String userDefined5) { this.userDefined5 = userDefined5; } - public String getUserDefined5() { return userDefined5; } @@ -697,7 +465,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined6(String userDefined6) { this.userDefined6 = userDefined6; } - public String getUserDefined6() { return userDefined6; } @@ -705,7 +472,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined7(String userDefined7) { this.userDefined7 = userDefined7; } - public String getUserDefined7() { return userDefined7; } @@ -713,7 +479,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined8(String userDefined8) { this.userDefined8 = userDefined8; } - public String getUserDefined8() { return userDefined8; } @@ -721,7 +486,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined9(String userDefined9) { this.userDefined9 = userDefined9; } - public String getUserDefined9() { return userDefined9; } @@ -729,7 +493,6 @@ public class SparePartsLedger extends BaseEntity { public void setUserDefined10(String userDefined10) { this.userDefined10 = userDefined10; } - public String getUserDefined10() { return userDefined10; } @@ -737,7 +500,6 @@ public class SparePartsLedger extends BaseEntity { public void setGmtCreate(Date gmtCreate) { this.gmtCreate = gmtCreate; } - public Date getGmtCreate() { return gmtCreate; } @@ -745,7 +507,6 @@ public class SparePartsLedger extends BaseEntity { public void setLastModifiedBy(String lastModifiedBy) { this.lastModifiedBy = lastModifiedBy; } - public String getLastModifiedBy() { return lastModifiedBy; } @@ -753,7 +514,6 @@ public class SparePartsLedger extends BaseEntity { public void setGmtModified(Date gmtModified) { this.gmtModified = gmtModified; } - public Date getGmtModified() { return gmtModified; } @@ -761,7 +521,6 @@ public class SparePartsLedger extends BaseEntity { public void setActiveFlag(String activeFlag) { this.activeFlag = activeFlag; } - public String getActiveFlag() { return activeFlag; } @@ -769,7 +528,6 @@ public class SparePartsLedger extends BaseEntity { public void setFactoryCode(String factoryCode) { this.factoryCode = factoryCode; } - public String getFactoryCode() { return factoryCode; } @@ -777,7 +535,6 @@ public class SparePartsLedger extends BaseEntity { public void setSapFactoryCode(String sapFactoryCode) { this.sapFactoryCode = sapFactoryCode; } - public String getSapFactoryCode() { return sapFactoryCode; } @@ -785,7 +542,6 @@ public class SparePartsLedger extends BaseEntity { public void setWlName(String wlName) { this.wlName = wlName; } - public String getWlName() { return wlName; } @@ -793,7 +549,6 @@ public class SparePartsLedger extends BaseEntity { public void setDelFlag(String delFlag) { this.delFlag = delFlag; } - public String getDelFlag() { return delFlag; } @@ -801,7 +556,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareUseLife(String spareUseLife) { this.spareUseLife = spareUseLife; } - public String getSpareUseLife() { return spareUseLife; } @@ -809,7 +563,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareName(String spareName) { this.spareName = spareName; } - public String getSpareName() { return spareName; } @@ -817,7 +570,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareMode(String spareMode) { this.spareMode = spareMode; } - public String getSpareMode() { return spareMode; } @@ -825,7 +577,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareManufacturer(String spareManufacturer) { this.spareManufacturer = spareManufacturer; } - public String getSpareManufacturer() { return spareManufacturer; } @@ -833,7 +584,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareSupplier(String spareSupplier) { this.spareSupplier = spareSupplier; } - public String getSpareSupplier() { return spareSupplier; } @@ -841,7 +591,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareReplacementCycle(String spareReplacementCycle) { this.spareReplacementCycle = spareReplacementCycle; } - public String getSpareReplacementCycle() { return spareReplacementCycle; } @@ -849,7 +598,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareMeasurementUnit(String spareMeasurementUnit) { this.spareMeasurementUnit = spareMeasurementUnit; } - public String getSpareMeasurementUnit() { return spareMeasurementUnit; } @@ -857,7 +605,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareConversionUnit(String spareConversionUnit) { this.spareConversionUnit = spareConversionUnit; } - public String getSpareConversionUnit() { return spareConversionUnit; } @@ -865,7 +612,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareConversionRatio(String spareConversionRatio) { this.spareConversionRatio = spareConversionRatio; } - public String getSpareConversionRatio() { return spareConversionRatio; } @@ -873,7 +619,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareInventoryFloor(String spareInventoryFloor) { this.spareInventoryFloor = spareInventoryFloor; } - public String getSpareInventoryFloor() { return spareInventoryFloor; } @@ -881,7 +626,6 @@ public class SparePartsLedger extends BaseEntity { public void setSpareInventoryUpper(String spareInventoryUpper) { this.spareInventoryUpper = spareInventoryUpper; } - public String getSpareInventoryUpper() { return spareInventoryUpper; } diff --git a/op-modules/op-device/src/main/java/com/op/device/mapper/SparePartsLedgerMapper.java b/op-modules/op-device/src/main/java/com/op/device/mapper/SparePartsLedgerMapper.java index 7a57b9fa..1a30e10b 100644 --- a/op-modules/op-device/src/main/java/com/op/device/mapper/SparePartsLedgerMapper.java +++ b/op-modules/op-device/src/main/java/com/op/device/mapper/SparePartsLedgerMapper.java @@ -85,4 +85,6 @@ public interface SparePartsLedgerMapper { void updateSpareNumAdd(EquSpareApply apply); void updateAmount(SparePartsLedger sparePartsLedger); + + SparePartsLedger selectExistByMaterialCode(String materialCode); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/ISparePartsLedgerService.java b/op-modules/op-device/src/main/java/com/op/device/service/ISparePartsLedgerService.java index 1acad6ae..5917fc55 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/ISparePartsLedgerService.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/ISparePartsLedgerService.java @@ -2,6 +2,7 @@ package com.op.device.service; import java.util.List; +import com.op.common.core.web.domain.AjaxResult; import com.op.device.domain.SparePartsLedger; /** @@ -58,4 +59,6 @@ public interface ISparePartsLedgerService { * @return 结果 */ public int deleteSparePartsLedgerByStorageId(String storageId); + + AjaxResult importFile(List orderList); } diff --git a/op-modules/op-device/src/main/java/com/op/device/service/impl/SparePartsLedgerServiceImpl.java b/op-modules/op-device/src/main/java/com/op/device/service/impl/SparePartsLedgerServiceImpl.java index 0b92a189..9ecfd3d1 100644 --- a/op-modules/op-device/src/main/java/com/op/device/service/impl/SparePartsLedgerServiceImpl.java +++ b/op-modules/op-device/src/main/java/com/op/device/service/impl/SparePartsLedgerServiceImpl.java @@ -4,13 +4,25 @@ import java.util.List; import com.baomidou.dynamic.datasource.annotation.DS; import com.op.common.core.utils.DateUtils; +import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.uuid.IdUtils; +import com.op.common.core.web.domain.AjaxResult; import com.op.common.security.utils.SecurityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.device.mapper.SparePartsLedgerMapper; import com.op.device.domain.SparePartsLedger; import com.op.device.service.ISparePartsLedgerService; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +import static com.op.common.core.web.domain.AjaxResult.error; +import static com.op.common.core.web.domain.AjaxResult.success; /** * 备品备件台账管理Service业务层处理 @@ -23,6 +35,8 @@ public class SparePartsLedgerServiceImpl implements ISparePartsLedgerService { @Autowired private SparePartsLedgerMapper sparePartsLedgerMapper; + protected Logger logger = LoggerFactory.getLogger(getClass()); + /** * 查询备品备件台账管理 * @@ -99,4 +113,135 @@ public class SparePartsLedgerServiceImpl implements ISparePartsLedgerService { public int deleteSparePartsLedgerByStorageId(String storageId) { return sparePartsLedgerMapper.deleteSparePartsLedgerByStorageId(storageId); } + + /** + * 处理设备基础信息 + * + * @param sparePartsLedger + * @return + */ + @Override + @DS("#header.poolName") + @Transactional + public AjaxResult importFile(List sparePartsLedger) { + SparePartsLedger example = null; + for (SparePartsLedger table : sparePartsLedger) { + table.setStorageId(IdUtils.fastSimpleUUID()); + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String key = "#header.poolName"; + table.setFactoryCode(request.getHeader(key.substring(8)).replace("ds_", "")); //工厂号 + table.setCreateBy(SecurityUtils.getUsername()); //创建人 + table.setGmtCreate(DateUtils.getNowDate()); //创建时间 + table.setDelFlag("0"); //删除标志 + table.setActiveFlag("1"); //有效标记 + } + + // 数据校验 + AjaxResult checkResult = checkImportFile(sparePartsLedger); + + // 如果数据校验成功 + if (checkResult.isSuccess()) { + String info = syncImportFunc(sparePartsLedger); + return success("信息导入完成。其中导入失败备品备件:" + info); + } + // 校验失败 + return checkResult; + } + + /** + * 校验导入设备基础信息 + * + * @param sparePartsLedger + */ + public AjaxResult checkImportFile(List sparePartsLedger) { + + // 传入对象不能为空 + if (sparePartsLedger.size() == 0 || StringUtils.isNull(sparePartsLedger)) { + return error(500, "导入的备品备件信息不能为空!信息导入失败!"); + } + + // 循环遍历校验数据是否为空 + for (SparePartsLedger table : sparePartsLedger) { + // 备品备件编码 + if (table.getMaterialCode().isEmpty() || table.getMaterialCode() == null) { + return error(500, "备品备件编码不能为空!信息导入失败!"); + } + // 备品备件名称 + if (table.getMaterialDesc().isEmpty() || table.getMaterialDesc() == null) { + return error(500, "备品备件名称不能为空!信息导入失败!"); + } + // 所属设备编码 + if (table.getOwnEquipmentCode().isEmpty() || table.getOwnEquipmentCode() == null) { + return error(500, "所属设备编码不能为空!信息导入失败!"); + } + // 所属设备名称 + if (table.getOwnEquipmentName().isEmpty() || table.getOwnEquipmentName() == null) { + return error(500, "所属设备名称不能为空!信息导入失败!"); + } + // 设备厂家 + if (table.getSpareSupplier().isEmpty() || table.getSpareSupplier() == null) { + return error(500, "设备厂家不能为空!信息导入失败!"); + } + // 规格型号 + if (table.getSpareMode().isEmpty() || table.getSpareMode() == null) { + return error(500, "规格型号不能为空!信息导入失败!"); + } + // 单机装配数量 + if (table.getUnitQuantity().isEmpty() || table.getUnitQuantity() == null) { + return error(500, "单机装配数量不能为空!信息导入失败!"); + } + // 单价 + if (table.getUnitPrice().toString().isEmpty() || table.getUnitPrice() == null) { + return error(500, "单价不能为空!信息导入失败!"); + } + // 安全库存 + if (table.getSafeStock().isEmpty() || table.getSafeStock() == null) { + return error(500, "安全库存不能为空!信息导入失败!"); + } + // 现有库存 + if (table.getAmount().toString().isEmpty() || table.getAmount() == null) { + return error(500, "现有库存不能为空!信息导入失败!"); + } + // 采购方式 + if (table.getProcurementMethod().isEmpty() || table.getProcurementMethod() == null) { + return error(500, "采购方式不能为空!信息导入失败!"); + } + // 更换周期(月) + if (table.getSpareReplacementCycle().toString().isEmpty() || table.getSpareReplacementCycle() == null) { + return error(500, "更换周期不能为空!信息导入失败!"); + } + // 采购周期(天) + if (table.getProcurementCycle().toString().isEmpty() || table.getProcurementCycle() == null) { + return error(500, "采购周期不能为空!信息导入失败!"); + } + } + return success(); + } + + public String syncImportFunc(List sparePartsLedger) { + String failEquipment = ""; + for (SparePartsLedger table : sparePartsLedger) { + String msg = syncFunc(table); + if (StringUtils.isNotBlank(msg)) { + failEquipment += msg + ","; + } + } + return failEquipment; + } + + @Transactional(rollbackFor = Exception.class) + public String syncFunc(SparePartsLedger table) { + String failSpareParts = ""; + SparePartsLedger Exist = sparePartsLedgerMapper.selectExistByMaterialCode(table.getMaterialCode()); + //不存在就插入 + if (Exist == null) { + sparePartsLedgerMapper.insertSparePartsLedger(table); + logger.info("=======备品备件" + table.getMaterialCode() + "=======导入成功"); + //存在,不允许插入 + } else { + failSpareParts = table.getMaterialCode(); + logger.info("=======备品备件" + failSpareParts + "=======导入失败"); + } + return failSpareParts; + } } diff --git a/op-modules/op-device/src/main/resources/mapper/device/SparePartsLedgerMapper.xml b/op-modules/op-device/src/main/resources/mapper/device/SparePartsLedgerMapper.xml index d06483b4..1bdcbbdb 100644 --- a/op-modules/op-device/src/main/resources/mapper/device/SparePartsLedgerMapper.xml +++ b/op-modules/op-device/src/main/resources/mapper/device/SparePartsLedgerMapper.xml @@ -375,4 +375,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{storageId} + + \ No newline at end of file