From d6d5ff4ae38dd4389f184a7b80a43ff79947c8bb Mon Sep 17 00:00:00 2001 From: zhaoxiaolin Date: Fri, 1 Sep 2023 17:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E5=88=92bug=E4=BF=AE=E6=94=B9--=20?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E7=9A=84=E9=80=89=E6=8B=A9=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- op-auth/src/main/resources/bootstrap.yml | 4 +- .../controller/MesReportWorkController.java | 53 +++++- .../com/op/mes/domain/MesProcessReport.java | 150 +++++++++++++++++ .../op/mes/domain/MesReportProduction.java | 150 +++++++++++++++++ .../java/com/op/mes/domain/MesReportWork.java | 106 +++++++++++- .../op/mes/mapper/MesReportWorkMapper.java | 20 ++- .../op/mes/service/IMesReportWorkService.java | 21 ++- .../impl/MesReportWorkServiceImpl.java | 86 +++++++++- .../mapper/mes/MesReportWorkMapper.xml | 89 +++++++++- .../plan/controller/ProOrderController.java | 1 + .../com/op/plan/domain/ProOrderWorkorder.java | 10 ++ .../com/op/plan/domain/dto/SplitOrderDTO.java | 8 + .../com/op/plan/domain/vo/CascaderDTO.java | 69 ++++++++ .../com/op/plan/mapper/ProOrderMapper.java | 9 + .../com/op/plan/service/IProOrderService.java | 3 +- .../service/impl/ProOrderServiceImpl.java | 91 +++++++++- .../impl/ProOrderWorkorderServiceImpl.java | 71 ++++++-- .../resources/mapper/plan/ProOrderMapper.xml | 18 ++ .../com/op/quality/domain/QcProCheck.java | 50 ++---- .../op/quality/domain/QcProCheckMapper.java | 31 ---- .../com/op/quality/mapper/BaseFileMapper.java | 1 + .../op/quality/service/QcProCheckService.java | 3 +- .../serviceImpl/QcProCheckServiceImpl.java | 45 +++-- .../com/op/quality/utils/FileUploadUtils.java | 158 ------------------ .../op-wms/src/main/resources/bootstrap.yml | 4 +- 25 files changed, 957 insertions(+), 294 deletions(-) create mode 100644 op-modules/op-mes/src/main/java/com/op/mes/domain/MesProcessReport.java create mode 100644 op-modules/op-mes/src/main/java/com/op/mes/domain/MesReportProduction.java create mode 100644 op-modules/op-plan/src/main/java/com/op/plan/domain/vo/CascaderDTO.java delete mode 100644 op-modules/op-quality/src/main/java/com/op/quality/domain/QcProCheckMapper.java delete mode 100644 op-modules/op-quality/src/main/java/com/op/quality/utils/FileUploadUtils.java diff --git a/op-auth/src/main/resources/bootstrap.yml b/op-auth/src/main/resources/bootstrap.yml index 759df4ad..b455d9dd 100644 --- a/op-auth/src/main/resources/bootstrap.yml +++ b/op-auth/src/main/resources/bootstrap.yml @@ -17,12 +17,12 @@ spring: # 服务注册地址 #--spring.cloud.nacos.discovery.namespace=chj --spring.cloud.nacos.config.namespace=chj namespace: lanju-op - group: chj + group: zxl server-addr: 140.249.53.142:8848 config: #命名空间 namespace: lanju-op - group: chj + group: zxl # 配置中心地址 server-addr: 140.249.53.142:8848 # 配置文件格式 diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java index 95a14174..3b5849c2 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/MesReportWorkController.java @@ -4,6 +4,8 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import com.op.common.core.utils.uuid.IdUtils; +import com.op.mes.domain.MesProcessReport; +import com.op.mes.domain.MesReportProduction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -25,7 +27,7 @@ import com.op.common.core.web.page.TableDataInfo; /** * 报工报表Controller - * + * * @author Open Platform * @date 2023-08-24 */ @@ -97,4 +99,53 @@ public class MesReportWorkController extends BaseController { public AjaxResult remove(@PathVariable String[] ids) { return toAjax(mesReportWorkService.deleteMesReportWorkByIds(ids)); } + + /** + * 工单的工序完成列表 + */ + @RequiresPermissions("mes:processFinish:list") + @GetMapping("/getProcessFinishList") + public TableDataInfo getProcessFinishList(MesProcessReport mesReportWork) { + startPage(); + List list = mesReportWorkService.getProcessFinishList(mesReportWork); + TableDataInfo tableDataInfo = getDataTable(list); + tableDataInfo.setTotal(4);//TODO;zxl;测试用 + return tableDataInfo; + } + + /** + * 导出报工报表列表 + */ + @RequiresPermissions("mes:processFinish:list") + @Log(title = "工单各工序完成记录", businessType = BusinessType.EXPORT) + @PostMapping("/processFinishExport") + public void processFinishExport(HttpServletResponse response, MesProcessReport mesProcessReport) { + List list = mesReportWorkService.getProcessFinishList(mesProcessReport); + ExcelUtil util = new ExcelUtil(MesProcessReport.class); + util.exportExcel(response, list, "工单各工序完成数据"); + } + + /** + * 获取产量报表 + */ + @RequiresPermissions("mes:production:list") + @GetMapping("/getProductionList") + public TableDataInfo getProductionList(MesReportProduction mesReportProduction) { + startPage(); + List list = mesReportWorkService.getProductionList(mesReportProduction); + return getDataTable(list); + } + + /** + * 获取产量报表导出 + */ + @RequiresPermissions("mes:production:list") + @GetMapping("/productionExport") + public void productionExport(HttpServletResponse response, MesReportProduction mesReportProduction) { + List list = mesReportWorkService.getProductionList(mesReportProduction); + ExcelUtil util = new ExcelUtil(MesReportProduction.class); + util.exportExcel(response, list, "工单各工序完成数据"); + } } + + diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesProcessReport.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesProcessReport.java new file mode 100644 index 00000000..48495db3 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesProcessReport.java @@ -0,0 +1,150 @@ +package com.op.mes.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 报工报表对象 mes_report_work + * + * @author Open Platform + * @date 2023-08-24 + */ +public class MesProcessReport extends BaseEntity { + private static final long serialVersionUID = 1L; + + @Excel(name = "生产日期") + private String productDate; + @Excel(name = "订单编号") + private String orderCode; + @Excel(name = "排产数量") + private BigDecimal quantity; + @Excel(name = "产品编码") + private String productCode; + @Excel(name = "产品名称") + private String productName; + @Excel(name = "产品型号") + private String productSpc; + @Excel(name = "工单编号") + private String workorderCode; + @Excel(name = "工序编码") + private String processCode; + @Excel(name = "工序名称") + private String processName; + @Excel(name = "完成数量") + private BigDecimal quantityFeedback; + @Excel(name = "单位") + private String unit; + private String productDateStart; + private String productDateEnd; + + public String getProductDateStart() { + return productDateStart; + } + + public void setProductDateStart(String productDateStart) { + this.productDateStart = productDateStart; + } + + public String getProductDateEnd() { + return productDateEnd; + } + + public void setProductDateEnd(String productDateEnd) { + this.productDateEnd = productDateEnd; + } + + public String getProductDate() { + return productDate; + } + + public void setProductDate(String productDate) { + this.productDate = productDate; + } + + public String getOrderCode() { + return orderCode; + } + + public void setOrderCode(String orderCode) { + this.orderCode = orderCode; + } + + public BigDecimal getQuantity() { + return quantity; + } + + public void setQuantity(BigDecimal quantity) { + this.quantity = quantity; + } + + public BigDecimal getQuantityFeedback() { + return quantityFeedback; + } + + public void setQuantityFeedback(BigDecimal quantityFeedback) { + this.quantityFeedback = quantityFeedback; + } + + public String getProductCode() { + return productCode; + } + + public void setProductCode(String productCode) { + this.productCode = productCode; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProductSpc() { + return productSpc; + } + + public void setProductSpc(String productSpc) { + this.productSpc = productSpc; + } + + public String getWorkorderCode() { + return workorderCode; + } + + public void setWorkorderCode(String workorderCode) { + this.workorderCode = workorderCode; + } + + public String getProcessCode() { + return processCode; + } + + public void setProcessCode(String processCode) { + this.processCode = processCode; + } + + public String getProcessName() { + return processName; + } + + public void setProcessName(String processName) { + this.processName = processName; + } + + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesReportProduction.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesReportProduction.java new file mode 100644 index 00000000..abcfa9fd --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesReportProduction.java @@ -0,0 +1,150 @@ +package com.op.mes.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.op.common.core.annotation.Excel; +import com.op.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 报工报表对象 mes_report_work + * + * @author Open Platform + * @date 2023-08-24 + */ +public class MesReportProduction extends BaseEntity { + private static final long serialVersionUID = 1L; + @Excel(name = "工厂编码") + private String factoryCode; + @Excel(name = "工厂名称") + private String factoryName; + @Excel(name = "车间编码") + private String carCode; + @Excel(name = "工厂名称") + private String carName; + @Excel(name = "工厂编码") + private String machineCode; + @Excel(name = "工厂名称") + private String machineName; + @Excel(name = "订单编号") + private String orderCode; + @Excel(name = "产品编码") + private String productCode; + @Excel(name = "产品名称") + private String productName; + @Excel(name = "计划产量") + private String quantity; + @Excel(name = "报工产量") + private String quantityFeedback; + @Excel(name = "规格型号") + private String productSpc; + @Excel(name = "工厂编码") + private String unit; + + public String getFactoryCode() { + return factoryCode; + } + + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + + public String getFactoryName() { + return factoryName; + } + + public void setFactoryName(String factoryName) { + this.factoryName = factoryName; + } + + public String getCarCode() { + return carCode; + } + + public void setCarCode(String carCode) { + this.carCode = carCode; + } + + public String getCarName() { + return carName; + } + + public void setCarName(String carName) { + this.carName = carName; + } + + public String getMachineCode() { + return machineCode; + } + + public void setMachineCode(String machineCode) { + this.machineCode = machineCode; + } + + public String getMachineName() { + return machineName; + } + + public void setMachineName(String machineName) { + this.machineName = machineName; + } + + public String getOrderCode() { + return orderCode; + } + + public void setOrderCode(String orderCode) { + this.orderCode = orderCode; + } + + public String getProductCode() { + return productCode; + } + + public void setProductCode(String productCode) { + this.productCode = productCode; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getQuantityFeedback() { + return quantityFeedback; + } + + public void setQuantityFeedback(String quantityFeedback) { + this.quantityFeedback = quantityFeedback; + } + + public String getProductSpc() { + return productSpc; + } + + public void setProductSpc(String productSpc) { + this.productSpc = productSpc; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesReportWork.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesReportWork.java index e578e15e..b0a58328 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/domain/MesReportWork.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/MesReportWork.java @@ -10,7 +10,7 @@ import com.op.common.core.web.domain.BaseEntity; /** * 报工报表对象 mes_report_work - * + * * @author Open Platform * @date 2023-08-24 */ @@ -124,6 +124,78 @@ public class MesReportWork extends BaseEntity { /** 预留字段4 */ @Excel(name = "预留字段4") private String attr4; + @Excel(name = "计划生产日期") + private String productDate; + private String productDateStart; + private String productDateEnd; + @Excel(name = "订单编号") + private String orderCode; + @Excel(name = "规格型号") + private String productSpc; + @Excel(name = "工序名称") + private String processName; + @Excel(name = "工序编码") + private String processCode; + private String factoryCode; + private String factoryName; + private String carCode; + private String carName; + + public String getFactoryCode() { + return factoryCode; + } + + public void setFactoryCode(String factoryCode) { + this.factoryCode = factoryCode; + } + + public String getFactoryName() { + return factoryName; + } + + public void setFactoryName(String factoryName) { + this.factoryName = factoryName; + } + + public String getCarCode() { + return carCode; + } + + public void setCarCode(String carCode) { + this.carCode = carCode; + } + + public String getCarName() { + return carName; + } + + public void setCarName(String carName) { + this.carName = carName; + } + + public String getProcessCode() { + return processCode; + } + + public void setProcessCode(String processCode) { + this.processCode = processCode; + } + + public String getProductDateStart() { + return productDateStart; + } + + public void setProductDateStart(String productDateStart) { + this.productDateStart = productDateStart; + } + + public String getProductDateEnd() { + return productDateEnd; + } + + public void setProductDateEnd(String productDateEnd) { + this.productDateEnd = productDateEnd; + } public void setId(String id) { this.id = id; @@ -316,6 +388,38 @@ public class MesReportWork extends BaseEntity { return attr4; } + public String getProductDate() { + return productDate; + } + + public void setProductDate(String productDate) { + this.productDate = productDate; + } + + public String getOrderCode() { + return orderCode; + } + + public void setOrderCode(String orderCode) { + this.orderCode = orderCode; + } + + public String getProductSpc() { + return productSpc; + } + + public void setProductSpc(String productSpc) { + this.productSpc = productSpc; + } + + public String getProcessName() { + return processName; + } + + public void setProcessName(String processName) { + this.processName = processName; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java index da4d6174..d0fe9a7f 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/MesReportWorkMapper.java @@ -2,18 +2,20 @@ package com.op.mes.mapper; import java.util.List; +import com.op.mes.domain.MesProcessReport; +import com.op.mes.domain.MesReportProduction; import com.op.mes.domain.MesReportWork; /** * 报工报表Mapper接口 - * + * * @author Open Platform * @date 2023-08-24 */ public interface MesReportWorkMapper { /** * 查询报工报表 - * + * * @param id 报工报表主键 * @return 报工报表 */ @@ -21,7 +23,7 @@ public interface MesReportWorkMapper { /** * 查询报工报表列表 - * + * * @param mesReportWork 报工报表 * @return 报工报表集合 */ @@ -29,7 +31,7 @@ public interface MesReportWorkMapper { /** * 新增报工报表 - * + * * @param mesReportWork 报工报表 * @return 结果 */ @@ -37,7 +39,7 @@ public interface MesReportWorkMapper { /** * 修改报工报表 - * + * * @param mesReportWork 报工报表 * @return 结果 */ @@ -45,7 +47,7 @@ public interface MesReportWorkMapper { /** * 删除报工报表 - * + * * @param id 报工报表主键 * @return 结果 */ @@ -53,9 +55,13 @@ public interface MesReportWorkMapper { /** * 批量删除报工报表 - * + * * @param ids 需要删除的数据主键集合 * @return 结果 */ public int deleteMesReportWorkByIds(String[] ids); + + public List getProcessFinishList(MesProcessReport mesReportWork); + + public List getProductionList(MesReportProduction mesReportProduction); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorkService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorkService.java index f6ef21cf..f1eebbf0 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorkService.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IMesReportWorkService.java @@ -1,18 +1,21 @@ package com.op.mes.service; import java.util.List; + +import com.op.mes.domain.MesProcessReport; +import com.op.mes.domain.MesReportProduction; import com.op.mes.domain.MesReportWork; /** * 报工报表Service接口 - * + * * @author Open Platform * @date 2023-08-24 */ public interface IMesReportWorkService { /** * 查询报工报表 - * + * * @param id 报工报表主键 * @return 报工报表 */ @@ -20,7 +23,7 @@ public interface IMesReportWorkService { /** * 查询报工报表列表 - * + * * @param mesReportWork 报工报表 * @return 报工报表集合 */ @@ -28,7 +31,7 @@ public interface IMesReportWorkService { /** * 新增报工报表 - * + * * @param mesReportWork 报工报表 * @return 结果 */ @@ -36,7 +39,7 @@ public interface IMesReportWorkService { /** * 修改报工报表 - * + * * @param mesReportWork 报工报表 * @return 结果 */ @@ -44,7 +47,7 @@ public interface IMesReportWorkService { /** * 批量删除报工报表 - * + * * @param ids 需要删除的报工报表主键集合 * @return 结果 */ @@ -52,9 +55,13 @@ public interface IMesReportWorkService { /** * 删除报工报表信息 - * + * * @param id 报工报表主键 * @return 结果 */ public int deleteMesReportWorkById(String id); + + public List getProcessFinishList(MesProcessReport mesReportWork); + + public List getProductionList(MesReportProduction mesReportProduction); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java index 09c823be..10850f24 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkServiceImpl.java @@ -1,18 +1,23 @@ package com.op.mes.service.impl; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; import com.baomidou.dynamic.datasource.annotation.DS; import com.op.common.core.utils.DateUtils; +import com.op.mes.domain.MesProcessReport; +import com.op.mes.domain.MesReportProduction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.mes.mapper.MesReportWorkMapper; import com.op.mes.domain.MesReportWork; import com.op.mes.service.IMesReportWorkService; +import org.springframework.util.CollectionUtils; /** * 报工报表Service业务层处理 - * + * * @author Open Platform * @date 2023-08-24 */ @@ -23,7 +28,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { /** * 查询报工报表 - * + * * @param id 报工报表主键 * @return 报工报表 */ @@ -35,7 +40,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { /** * 查询报工报表列表 - * + * * @param mesReportWork 报工报表 * @return 报工报表 */ @@ -47,7 +52,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { /** * 新增报工报表 - * + * * @param mesReportWork 报工报表 * @return 结果 */ @@ -60,7 +65,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { /** * 修改报工报表 - * + * * @param mesReportWork 报工报表 * @return 结果 */ @@ -73,7 +78,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { /** * 批量删除报工报表 - * + * * @param ids 需要删除的报工报表主键 * @return 结果 */ @@ -85,7 +90,7 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { /** * 删除报工报表信息 - * + * * @param id 报工报表主键 * @return 结果 */ @@ -94,4 +99,71 @@ public class MesReportWorkServiceImpl implements IMesReportWorkService { public int deleteMesReportWorkById(String id) { return mesReportWorkMapper.deleteMesReportWorkById(id); } + + @Override + @DS("#header.poolName") + public List getProcessFinishList(MesProcessReport mesReportWork) { + List dtos = new ArrayList<>(); + dtos = mesReportWorkMapper.getProcessFinishList(mesReportWork); + MesProcessReport dto = null; + if(CollectionUtils.isEmpty(dtos)){ + dto = new MesProcessReport(); + dto.setProductDate("2023-08-31"); + dto.setOrderCode("000100220788"); + dto.setWorkorderCode("000100220788-1"); + dto.setProductCode("000000020000004232"); + dto.setProductName("榄菊小盘艾草型蚊香3+1家庭特惠装(1901)"); + dto.setProductSpc("23mm"); + dto.setProcessCode("ProdGX01"); + dto.setProcessName("包装线工序01"); + dto.setQuantityFeedback(new BigDecimal("500")); + dto.setQuantity(new BigDecimal("1000")); + dto.setUnit("KAR"); + dtos.add(dto); + dto = new MesProcessReport(); + dto.setProductDate("2023-08-31"); + dto.setOrderCode("000100220789"); + dto.setWorkorderCode("000100220789-1"); + dto.setProductCode("000000020000004234"); + dto.setProductName("白坯"); + dto.setProductSpc("23mm"); + dto.setProcessCode("BPGX01"); + dto.setProcessName("收胚机工序"); + dto.setQuantityFeedback(new BigDecimal("80")); + dto.setUnit("车"); + dtos.add(dto); + dto = new MesProcessReport(); + dto.setProductDate("2023-08-31"); + dto.setOrderCode("000100220789"); + dto.setWorkorderCode("000100220789-1"); + dto.setProductCode("000000020000004234"); + dto.setProductName("白坯"); + dto.setProductSpc("23mm"); + dto.setProcessCode("BPGX02"); + dto.setProcessName("烘房工序"); + dto.setQuantityFeedback(new BigDecimal("70")); + dto.setUnit("车"); + dtos.add(dto); + dto = new MesProcessReport(); + dto.setProductDate("2023-08-31"); + dto.setOrderCode("000100220789"); + dto.setWorkorderCode("000100220789-1"); + dto.setProductCode("000000020000004234"); + dto.setProductName("白坯"); + dto.setProductSpc("23mm"); + dto.setProcessCode("BPGX02"); + dto.setProcessName("收坯工序"); + dto.setQuantityFeedback(new BigDecimal("100")); + dto.setUnit("车"); + dtos.add(dto); + } + return dtos; + } + + @Override + @DS("#header.poolName") + public List getProductionList(MesReportProduction mesReportProduction) { + return mesReportWorkMapper.getProductionList(mesReportProduction); + } + } diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml index 959d74c2..b0f42dc8 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesReportWorkMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - + + + insert into mes_report_work @@ -195,9 +272,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from mes_report_work where id in + delete from mes_report_work where id in #{id} - \ No newline at end of file + diff --git a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java index cf595e6a..2e854970 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java @@ -265,4 +265,5 @@ public class ProOrderController extends BaseController { public R syncSAPOrders() { return proOrderService.syncSAPOrders(); } + } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java index ee920fb0..39756518 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java @@ -81,6 +81,8 @@ public class ProOrderWorkorder extends TreeEntity { @Excel(name = "线体") private String prodLineCode; + private String[][] prodLineCodeArray; + // TODO 暂时存放线体编码 private String prodLineName; @@ -457,6 +459,14 @@ public class ProOrderWorkorder extends TreeEntity { this.productDateEnd = productDateEnd; } + public String[][] getProdLineCodeArray() { + return prodLineCodeArray; + } + + public void setProdLineCodeArray(String[][] prodLineCodeArray) { + this.prodLineCodeArray = prodLineCodeArray; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/SplitOrderDTO.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/SplitOrderDTO.java index 5d634f37..d77d3cd7 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/SplitOrderDTO.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/SplitOrderDTO.java @@ -12,6 +12,7 @@ public class SplitOrderDTO { private List formFields; // 产线 private String prodLineCode; + private String[][] prodLineCodeArray; // 日期 private Date productDate; // 班次 @@ -89,6 +90,13 @@ public class SplitOrderDTO { this.product = product; } + public String[][] getProdLineCodeArray() { + return prodLineCodeArray; + } + + public void setProdLineCodeArray(String[][] prodLineCodeArray) { + this.prodLineCodeArray = prodLineCodeArray; + } public SplitOrderDTO() { } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/vo/CascaderDTO.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/vo/CascaderDTO.java new file mode 100644 index 00000000..0c72e963 --- /dev/null +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/vo/CascaderDTO.java @@ -0,0 +1,69 @@ +package com.op.plan.domain.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; +import java.util.List; + +/** + * Treeselect树结构实体类 + * + * @author OP + */ +public class CascaderDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** 节点ID */ + private Long id; + + private String value; + + /** 节点名称 */ + private String label; + + /** 子节点 */ + private List children; +// +// public TreeSelect() { +// +// } +// +// public TreeSelect(SysDept dept) { +// this.id = dept.getDeptId(); +// this.label = dept.getDeptName(); +// this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); +// } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java index d55dec19..15ec6c88 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java @@ -1,13 +1,16 @@ package com.op.plan.mapper; import java.util.List; +import java.util.Map; import com.op.plan.domain.Convert; import com.op.plan.domain.ProLine; import com.op.plan.domain.ProOrder; import com.op.plan.domain.ProShift; import com.op.plan.domain.*; +import com.op.plan.domain.vo.CascaderDTO; import com.op.system.api.model.SapProOrder; +import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -182,4 +185,10 @@ public interface ProOrderMapper { * @return */ List selectEquipment(String[] codes); + + List getRouteProcess(String routeCode); + + List getRouteProcessEquips(@Param("list") List level); + @MapKey("value") + Map getEquipInfoByCodes(String equipCodes); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java b/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java index eaccc994..dc466d2c 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/IProOrderService.java @@ -6,6 +6,7 @@ import com.op.common.core.domain.R; import com.op.common.core.web.domain.AjaxResult; import com.op.plan.domain.*; import com.op.plan.domain.dto.SplitOrderDTO; +import com.op.plan.domain.vo.CascaderDTO; /** * 订单Service接口 @@ -132,7 +133,7 @@ public interface IProOrderService { * @param routeCode * @return */ - List getProEquipment(String routeCode); + List getProEquipment(String routeCode); /** * 通过订单Code查询级联订单信息并封装返回 diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java index 143b5dea..6864aaec 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java @@ -8,7 +8,9 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import com.alibaba.csp.sentinel.util.StringUtil; -import com.baomidou.dynamic.datasource.DynamicRoutingDataSource; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.op.plan.domain.vo.CascaderDTO; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.op.common.core.context.SecurityContextHolder; @@ -98,6 +100,30 @@ public class ProOrderServiceImpl implements IProOrderService { } } } + //校验各工序设备是否已选择 + List processes= proOrderMapper.getRouteProcess(splitOrderDTO.getRouteCode()); + if(splitOrderDTO.getProdLineCodeArray().length == 0){ + checkout = false; + return error(500, "必须选择工单生产设备!"); + }else{ + String codeArray = JSONArray.toJSONString(splitOrderDTO.getProdLineCodeArray()); + for(int i=0;i equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.substring(1));//设备字典 + Set keys = equipMap.keySet(); + for (String key : keys) { + prodLineName += equipMap.get(key).getLabel()+","; + } + proOrderWorkorder.setProdLineCode(prodLineName); + // 通过工单id查询批次号 List batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId()); List batchCodes = new ArrayList<>(); @@ -225,7 +265,7 @@ public class ProOrderServiceImpl implements IProOrderService { } // 将查询结果设置到当前工单对象 proOrderWorkorder.setShiftDesc(shiftDesc); - proOrderWorkorder.setProdLineCode(prodLineName); + proOrderWorkorder.setBatchCodeList(batchCodes); // 通过母工单workorder_id查询子工单 @@ -509,9 +549,40 @@ public class ProOrderServiceImpl implements IProOrderService { */ @Override @DS("#header.poolName") - public List getProEquipment(String routeCode) { - String[] split = proOrderMapper.selectEquipmentListByRouteCode(routeCode).split(","); - return proOrderMapper.selectEquipment(split); + public List getProEquipment(String routeCode) { + List level= proOrderMapper.getRouteProcess(routeCode); + List level2= proOrderMapper.getRouteProcessEquips(level); + Map equipMap = new HashMap<>();//设备字典 + if(!CollectionUtils.isEmpty(level2)){ + List oldCodes = level2.stream() + .filter(value -> StringUtils.isNotEmpty(value.getValue())) + .map(value -> value.getValue()).collect(Collectors.toList()); + String equipCods = oldCodes.stream().reduce((sum,num) -> sum+","+num).get(); + equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.replace(",","','")); + } + if(equipMap.isEmpty()){ + return null; + } + List children = null; + for(CascaderDTO level1:level){ + children = new ArrayList<>();//最终结果 + List childrens = level2.stream() + .filter(dto ->dto.getLabel().equals(level1.getValue())) + .collect(Collectors.toList()); + for(CascaderDTO child:childrens){ + String[] equipstr = child.getValue().split(","); + for(String equipcode:equipstr){ + if(equipMap.get(equipcode) != null){ + children.add(equipMap.get(equipcode)); + } + } + } + if(!CollectionUtils.isEmpty(children)){ + level1.setChildren(children); + } + } + System.out.println(JSONArray.toJSONString(level)); + return level; } /** @@ -882,5 +953,11 @@ public class ProOrderServiceImpl implements IProOrderService { } return success(); } - + public static void main(String args[]){ + String arrayStr = "[[\"GX01\",\"LG1\"],[\"GX01\",\"LG2\"],[\"GX02\",\"S1\"],[\"GX02\",\"S2\"],[\"GX03\",\"HF01\"],[\"GX04\",\"SPJ01\"]]"; + JSONArray jsonArray = JSONArray.parseArray(arrayStr); + for(int c=0;c selectProOrderWorkorderList(ProOrderWorkorder proOrderWorkorder) { List workorderList = proOrderWorkorderMapper.selectProOrderWorkorderList(proOrderWorkorder); for (ProOrderWorkorder workorder : workorderList) { - // TODO 暂存线体code - workorder.setProdLineName(workorder.getProdLineCode()); + String prodLineName = ""; + String equipCods = "'"; + JSONArray codeArray = JSONArray.parseArray(workorder.getProdLineCode()); + for(int c=0;c equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.substring(1));//设备字典 + Set keys = equipMap.keySet(); + for (String key : keys) { + prodLineName += equipMap.get(key).getLabel()+","; + } + workorder.setProdLineName(prodLineName); // 通过设备code查询出机型名称 workorder.setProdLineCode(proOrderMapper.selectProdLineName(workorder.getProdLineCode())); // 通过工艺编码code查询出机型名称 @@ -445,11 +458,30 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { } } } + //校验各工序设备是否已选择 + List processes= proOrderMapper.getRouteProcess(splitOrderDTO.getRouteCode()); + if(splitOrderDTO.getProdLineCodeArray().length == 0){ + checkout = false; + return error(500, "必须选择工单生产设备!"); + }else{ + String codeArray = JSONArray.toJSONString(splitOrderDTO.getProdLineCodeArray()); + for(int i=0;i equipMap = proOrderMapper.getEquipInfoByCodes(equipCods.substring(1));//设备字典 + Set keys = equipMap.keySet(); + for (String key : keys) { + prodLineName += equipMap.get(key).getLabel()+","; + } + proOrderWorkorder.setProdLineCode(prodLineName); + // 通过工单id查询批次号 List batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId()); List batchCodes = new ArrayList<>(); @@ -626,7 +676,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService { } // 将查询结果设置到当前工单对象 proOrderWorkorder.setShiftDesc(shiftDesc); - proOrderWorkorder.setProdLineCode(prodLineName); proOrderWorkorder.setBatchCodeList(batchCodes); // 通过母工单workorder_id查询子工单 diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml index a87594c9..d37c4669 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml @@ -151,6 +151,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{code} + + + insert into pro_order diff --git a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcProCheck.java b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcProCheck.java index c1604737..74567406 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcProCheck.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcProCheck.java @@ -5,6 +5,7 @@ import com.op.common.core.annotation.Excel; import com.op.common.core.web.domain.BaseEntity; import java.util.Date; +import java.util.List; /** * @ClassName : qua @@ -53,6 +54,7 @@ public class QcProCheck extends BaseEntity { private String isqua; @Excel(name = "附件") + private List fileList; private String fileId; @Excel(name = "创建者") @@ -191,13 +193,7 @@ public class QcProCheck extends BaseEntity { this.isqua = isqua; } - public String getFileId() { - return fileId; - } - public void setFileId(String fileId) { - this.fileId = fileId; - } @Override public String getCreateBy() { @@ -271,34 +267,21 @@ public class QcProCheck extends BaseEntity { this.attr4 = attr4; } - public QcProCheck(String id, String rfid, String factoryId, String factoryCode, String workorderId, String workorderCode, String workorderName, String orderId, String orderCode, String machineId, String machineCode, String badMeg, String productId, String productCode, String isqua, String fileId, String createBy, Date createTime, String updateBy, Date updateTime, String attr1, String attr2, String attr3, String attr4) { - this.id = id; - this.rfid = rfid; - this.factoryId = factoryId; - this.factoryCode = factoryCode; - this.workorderId = workorderId; - this.workorderCode = workorderCode; - this.workorderName = workorderName; - this.orderId = orderId; - this.orderCode = orderCode; - this.machineId = machineId; - this.machineCode = machineCode; - this.badMeg = badMeg; - this.productId = productId; - this.productCode = productCode; - this.isqua = isqua; - this.fileId = fileId; - this.createBy = createBy; - this.createTime = createTime; - this.updateBy = updateBy; - this.updateTime = updateTime; - this.attr1 = attr1; - this.attr2 = attr2; - this.attr3 = attr3; - this.attr4 = attr4; + + public List getFileList() { + return fileList; + } + + public void setFileList(List fileList) { + this.fileList = fileList; } - public QcProCheck() { + public String getFileId() { + return fileId; + } + + public void setFileId(String fileId) { + this.fileId = fileId; } @Override @@ -319,7 +302,8 @@ public class QcProCheck extends BaseEntity { ", productId='" + productId + '\'' + ", productCode='" + productCode + '\'' + ", isqua='" + isqua + '\'' + - ", fileId='" + fileId + '\'' + + ", fileId=" + fileId + + ", fileList='" + fileList + '\'' + ", createBy='" + createBy + '\'' + ", createTime=" + createTime + ", updateBy='" + updateBy + '\'' + diff --git a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcProCheckMapper.java b/op-modules/op-quality/src/main/java/com/op/quality/domain/QcProCheckMapper.java deleted file mode 100644 index 743cd343..00000000 --- a/op-modules/op-quality/src/main/java/com/op/quality/domain/QcProCheckMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.op.quality.mapper; - -import com.op.common.core.domain.R; -import com.op.quality.domain.QcProCheck; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * @ClassName : QuaMapper - * @Description : - * @Author : - * @Date: 2023-08-17 10:40 - */ -@Mapper -public interface QcProCheckMapper { - - - - List selectQcProCheckList(); - - int insertQcProCheck(QcProCheck qcProCheck); - - int updateQcProCheckById(String rfid); - - int deleteQcProCheckById(String rfid); - - - - -} diff --git a/op-modules/op-quality/src/main/java/com/op/quality/mapper/BaseFileMapper.java b/op-modules/op-quality/src/main/java/com/op/quality/mapper/BaseFileMapper.java index 172df133..4ea57c8d 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/mapper/BaseFileMapper.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/mapper/BaseFileMapper.java @@ -1,6 +1,7 @@ package com.op.quality.mapper; import com.op.common.core.domain.BaseFileData; + import com.op.quality.domain.BaseFile; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/QcProCheckService.java b/op-modules/op-quality/src/main/java/com/op/quality/service/QcProCheckService.java index 1ab8ef46..cee4b148 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/service/QcProCheckService.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/QcProCheckService.java @@ -2,7 +2,6 @@ package com.op.quality.service; import com.op.common.core.domain.R; //import com.op.quality.domain.BaseFile; -import com.op.quality.domain.BaseFile; import com.op.quality.domain.QcProCheck; import java.util.List; @@ -17,7 +16,7 @@ public interface QcProCheckService { List selectQcProCheck(); - R saveQcProCheck(QcProCheck qcProCheck, BaseFile baseFile); + R saveQcProCheck(QcProCheck qcProCheck); int updateQcProCheck(String rfid); diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/serviceImpl/QcProCheckServiceImpl.java b/op-modules/op-quality/src/main/java/com/op/quality/service/serviceImpl/QcProCheckServiceImpl.java index 2bc9f2e1..aa8130ea 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/service/serviceImpl/QcProCheckServiceImpl.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/serviceImpl/QcProCheckServiceImpl.java @@ -1,10 +1,12 @@ package com.op.quality.service.serviceImpl; -import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import com.op.common.core.domain.BaseFileData; import com.op.common.core.domain.R; //import com.op.quality.domain.BaseFile; -import com.op.quality.domain.BaseFile; +import com.op.common.core.utils.StringUtils; +import com.op.common.core.utils.uuid.IdUtils; +import com.op.common.security.utils.SecurityUtils; import com.op.quality.domain.QcProCheck; import com.op.quality.mapper.BaseFileMapper; import com.op.quality.mapper.QcProCheckMapper; @@ -12,9 +14,9 @@ import com.op.quality.service.QcProCheckService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.HashMap; +import java.util.ArrayList; +import java.util.Date; import java.util.List; -import java.util.Map; import java.util.UUID; /** @@ -30,6 +32,7 @@ public class QcProCheckServiceImpl implements QcProCheckService { @Autowired private BaseFileMapper baseFileMapper; + @Override // @DS("#header.poolName") public List selectQcProCheck() { @@ -38,25 +41,31 @@ public class QcProCheckServiceImpl implements QcProCheckService { } @Override -// @DS("#header.poolName") - public R saveQcProCheck(QcProCheck qcProCheck, BaseFile baseFile) { -// System.out.println("qian"+DynamicDataSourceContextHolder.peek()); + public R saveQcProCheck(QcProCheck qcProCheck) { DynamicDataSourceContextHolder.push("ds_1000"); -// System.out.println("hou"+DynamicDataSourceContextHolder.peek()); - qcProCheck.setId(UUID.randomUUID().toString().replace("-", "")); - if (baseFile.getFileAddress()==null){ - qcProCheckMapper.insertQcProCheck(qcProCheck); - } - else { - baseFile.setFileId(UUID.randomUUID().toString().replace("-", "")); - qcProCheck.setFileId(baseFile.getFileId()); - qcProCheckMapper.insertQcProCheck(qcProCheck); - baseFileMapper.insertBaseFile(baseFile); + //上传附件 + if (StringUtils.isNotEmpty(qcProCheck.getFileId())) { + String[] ids = qcProCheck.getFileId().split(","); + List files = new ArrayList<>(); + BaseFileData file = null; + for (String id : ids) { + file = new BaseFileData(); + file.setFileId(IdUtils.fastSimpleUUID()); + file.setFileName(id.split("&fileName=")[1]); + file.setFileAddress(id); + file.setSourceId(qcProCheck.getId()); + file.setCreateBy(SecurityUtils.getUsername()); + file.setCreateTime(new Date()); + files.add(file); + } + baseFileMapper.insertBaseFileBatch(files); } - return R.ok(true); + qcProCheckMapper.insertQcProCheck(qcProCheck); + + return R.ok(); } diff --git a/op-modules/op-quality/src/main/java/com/op/quality/utils/FileUploadUtils.java b/op-modules/op-quality/src/main/java/com/op/quality/utils/FileUploadUtils.java deleted file mode 100644 index 496a01dd..00000000 --- a/op-modules/op-quality/src/main/java/com/op/quality/utils/FileUploadUtils.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.op.quality.utils; - -import com.op.common.core.exception.file.FileException; -import com.op.common.core.exception.file.FileNameLengthLimitExceededException; -import com.op.common.core.exception.file.FileSizeLimitExceededException; -import com.op.common.core.exception.file.InvalidExtensionException; -import com.op.common.core.utils.DateUtils; -import com.op.common.core.utils.StringUtils; -import com.op.common.core.utils.file.FileTypeUtils; -import com.op.common.core.utils.file.MimeTypeUtils; -import com.op.common.core.utils.uuid.Seq; -import org.apache.commons.io.FilenameUtils; -import org.springframework.web.multipart.MultipartFile; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Paths; -import java.util.Objects; - -/** - * 文件上传工具类 - * - * @author OP - */ -public class FileUploadUtils { - /** - * 默认大小 50M - */ - public static final long DEFAULT_MAX_SIZE = 50 * 1024 * 1024; - - /** - * 默认的文件名最大长度 100 - */ - public static final int DEFAULT_FILE_NAME_LENGTH = 100; - - /** - * 根据文件路径上传 - * - * @param baseDir 相对应用的基目录 - * @param file 上传的文件 - * @return 文件名称 - * @throws IOException - */ - public static final String upload(String baseDir, MultipartFile file) throws IOException { - try { - return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); - } catch (FileException fe) { - throw new IOException(fe.getDefaultMessage(), fe); - } catch (Exception e) { - throw new IOException(e.getMessage(), e); - } - } - - /** - * 文件上传 - * - * @param baseDir 相对应用的基目录 - * @param file 上传的文件 - * @param allowedExtension 上传文件类型 - * @return 返回上传成功的文件名 - * @throws FileSizeLimitExceededException 如果超出最大大小 - * @throws FileNameLengthLimitExceededException 文件名太长 - * @throws IOException 比如读写文件出错时 - * @throws InvalidExtensionException 文件校验异常 - */ - public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension) - throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException, - InvalidExtensionException { - int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length(); - if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { - throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); - } - - assertAllowed(file, allowedExtension); - - String fileName = extractFilename(file); - - String absPath = getAbsoluteFile(baseDir, fileName).getAbsolutePath(); - file.transferTo(Paths.get(absPath)); - return getPathFileName(fileName); - } - - /** - * 编码文件名 - */ - public static final String extractFilename(MultipartFile file) { - return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(), - FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), - FileTypeUtils.getExtension(file)); - } - - private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException { - File desc = new File(uploadDir + File.separator + fileName); - - if (!desc.exists()) { - if (!desc.getParentFile().exists()) { - desc.getParentFile().mkdirs(); - } - } - return desc.isAbsolute() ? desc : desc.getAbsoluteFile(); - } - - private static final String getPathFileName(String fileName) throws IOException { - String pathFileName = "/" + fileName; - return pathFileName; - } - - /** - * 文件大小校验 - * - * @param file 上传的文件 - * @throws FileSizeLimitExceededException 如果超出最大大小 - * @throws InvalidExtensionException 文件校验异常 - */ - public static final void assertAllowed(MultipartFile file, String[] allowedExtension) - throws FileSizeLimitExceededException, InvalidExtensionException { - long size = file.getSize(); - if (size > DEFAULT_MAX_SIZE) { - throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024); - } - - String fileName = file.getOriginalFilename(); - String extension = FileTypeUtils.getExtension(file); - if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) { - if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) { - throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension, - fileName); - } else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) { - throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension, - fileName); - } else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) { - throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension, - fileName); - } else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) { - throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension, - fileName); - } else { - throw new InvalidExtensionException(allowedExtension, extension, fileName); - } - } - } - - /** - * 判断MIME类型是否是允许的MIME类型 - * - * @param extension 上传文件类型 - * @param allowedExtension 允许上传文件类型 - * @return true/false - */ - public static final boolean isAllowedExtension(String extension, String[] allowedExtension) { - for (String str : allowedExtension) { - if (str.equalsIgnoreCase(extension)) { - return true; - } - } - return false; - } -} diff --git a/op-modules/op-wms/src/main/resources/bootstrap.yml b/op-modules/op-wms/src/main/resources/bootstrap.yml index 7eaee74c..01b12e10 100644 --- a/op-modules/op-wms/src/main/resources/bootstrap.yml +++ b/op-modules/op-wms/src/main/resources/bootstrap.yml @@ -14,12 +14,12 @@ spring: nacos: discovery: namespace: lanju-op - group: jgy + group: zxl # 服务注册地址 server-addr: 140.249.53.142:8848 config: namespace: lanju-op - group: jgy + group: zxl #命名空间 #group: local # 配置中心地址