diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteFileService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteFileService.java index 2339a9c4..24b8afd7 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteFileService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteFileService.java @@ -12,6 +12,7 @@ import com.op.system.api.domain.SysFile; import com.op.system.api.factory.RemoteFileFallbackFactory; import java.io.InputStream; +import java.util.List; /** * 文件服务 @@ -31,4 +32,5 @@ public interface RemoteFileService { @PostMapping(value = "/getFile/{id}") public InputStream getFile(@PathVariable("id") String id); + } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java new file mode 100644 index 00000000..b754bb0a --- /dev/null +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteMesService.java @@ -0,0 +1,22 @@ +package com.op.system.api; + +import com.op.common.core.constant.ServiceNameConstants; +import com.op.common.core.domain.BaseFileData; +import com.op.common.core.domain.R; +import com.op.system.api.factory.RemoteMesFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 用户服务 + * + * @author OP + */ +@FeignClient(contextId = "remoteMesService", value = ServiceNameConstants.MES_SERVICE, fallbackFactory = RemoteMesFallbackFactory.class) +public interface RemoteMesService { + + @PostMapping("/file/upLoadFile") + public R upLoadFile(@RequestBody List files); +} diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteUserService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteUserService.java index aedd0138..3717264f 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteUserService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteUserService.java @@ -1,5 +1,7 @@ package com.op.system.api; + +import com.op.common.core.domain.BaseFileData; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -13,9 +15,11 @@ import com.op.system.api.domain.SysUser; import com.op.system.api.factory.RemoteUserFallbackFactory; import com.op.system.api.model.LoginUser; +import java.util.List; + /** * 用户服务 - * + * * @author OP */ @FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class) @@ -41,4 +45,7 @@ public interface RemoteUserService { @PostMapping("/user/register") public R registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + + @PostMapping("/file/upLoadFile") + public R upLoadFile(@RequestBody List files); } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteMesFallbackFactory.java b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteMesFallbackFactory.java new file mode 100644 index 00000000..90269508 --- /dev/null +++ b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteMesFallbackFactory.java @@ -0,0 +1,35 @@ +package com.op.system.api.factory; + +import com.op.common.core.domain.BaseFileData; +import com.op.common.core.domain.R; +import com.op.system.api.RemoteMesService; +import com.op.system.api.RemoteUserService; +import com.op.system.api.domain.SysUser; +import com.op.system.api.model.LoginUser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cloud.openfeign.FallbackFactory; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 用户服务降级处理 + * + * @author OP + */ +@Component +public class RemoteMesFallbackFactory implements FallbackFactory { + private static final Logger log = LoggerFactory.getLogger(RemoteMesFallbackFactory.class); + + @Override + public RemoteMesService create(Throwable throwable) { + log.error("Mes服务调用失败:{}", throwable.getMessage()); + return new RemoteMesService() { + @Override + public R upLoadFile(List files) { + return R.fail("上传失败:" + throwable.getMessage()); + } + }; + } +} diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteUserFallbackFactory.java b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteUserFallbackFactory.java index 9de6a58a..4ce7932f 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteUserFallbackFactory.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteUserFallbackFactory.java @@ -1,5 +1,6 @@ package com.op.system.api.factory; +import com.op.common.core.domain.BaseFileData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; @@ -9,9 +10,11 @@ import com.op.system.api.RemoteUserService; import com.op.system.api.domain.SysUser; import com.op.system.api.model.LoginUser; +import java.util.List; + /** * 用户服务降级处理 - * + * * @author OP */ @Component @@ -31,6 +34,11 @@ public class RemoteUserFallbackFactory implements FallbackFactory registerUserInfo(SysUser sysUser, String source) { return R.fail("注册用户失败:" + throwable.getMessage()); } + + @Override + public R upLoadFile(List files) { + return R.fail("上传失败:" + throwable.getMessage()); + } }; } } diff --git a/op-common/op-common-core/src/main/java/com/op/common/core/constant/ServiceNameConstants.java b/op-common/op-common-core/src/main/java/com/op/common/core/constant/ServiceNameConstants.java index a7c3af01..d18dbb1f 100644 --- a/op-common/op-common-core/src/main/java/com/op/common/core/constant/ServiceNameConstants.java +++ b/op-common/op-common-core/src/main/java/com/op/common/core/constant/ServiceNameConstants.java @@ -2,7 +2,7 @@ package com.op.common.core.constant; /** * 服务名称 - * + * * @author OP */ public class ServiceNameConstants { @@ -20,4 +20,14 @@ public class ServiceNameConstants { * 文件服务的serviceid */ public static final String FILE_SERVICE = "op-file"; + + /** + * 系统模块的serviceid + */ + public static final String MES_SERVICE = "op-mes"; + + /** + * 系统模块的serviceid + */ + public static final String WMS_SERVICE = "op-wms"; } diff --git a/op-common/op-common-core/src/main/java/com/op/common/core/domain/BaseFileData.java b/op-common/op-common-core/src/main/java/com/op/common/core/domain/BaseFileData.java new file mode 100644 index 00000000..66efc7d6 --- /dev/null +++ b/op-common/op-common-core/src/main/java/com/op/common/core/domain/BaseFileData.java @@ -0,0 +1,123 @@ +package com.op.common.core.domain; + +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; + +/** + * 附件对象 base_file + * + * @author Open Platform + * @date 2023-07-10 + */ +public class BaseFileData extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 附件ID */ + private String fileId; + + /** 附件名称 */ + @Excel(name = "附件名称") + private String fileName; + + /** 附件地址 */ + @Excel(name = "附件地址") + private String fileAddress; + + /** 数据来源 */ + @Excel(name = "数据来源") + private String sourceId; + + /** 预留字段1 */ + @Excel(name = "预留字段1") + private String attr1; + + /** 预留字段2 */ + @Excel(name = "预留字段2") + private String attr2; + + /** 预留字段3 */ + @Excel(name = "预留字段3") + private Long attr3; + + /** 预留字段4 */ + @Excel(name = "预留字段4") + private Long attr4; + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getFileId() { + return fileId; + } + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFileName() { + return fileName; + } + public void setFileAddress(String fileAddress) { + this.fileAddress = fileAddress; + } + + public String getFileAddress() { + return fileAddress; + } + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getSourceId() { + return sourceId; + } + public void setAttr1(String attr1) { + this.attr1 = attr1; + } + + public String getAttr1() { + return attr1; + } + public void setAttr2(String attr2) { + this.attr2 = attr2; + } + + public String getAttr2() { + return attr2; + } + public void setAttr3(Long attr3) { + this.attr3 = attr3; + } + + public Long getAttr3() { + return attr3; + } + public void setAttr4(Long attr4) { + this.attr4 = attr4; + } + + public Long getAttr4() { + return attr4; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("fileId", getFileId()) + .append("fileName", getFileName()) + .append("fileAddress", getFileAddress()) + .append("sourceId", getSourceId()) + .append("remark", getRemark()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/op-modules/op-file/src/main/java/com/op/file/controller/SysFileController.java b/op-modules/op-file/src/main/java/com/op/file/controller/SysFileController.java index 331277ca..51b24acc 100644 --- a/op-modules/op-file/src/main/java/com/op/file/controller/SysFileController.java +++ b/op-modules/op-file/src/main/java/com/op/file/controller/SysFileController.java @@ -34,7 +34,7 @@ public class SysFileController { private ISysFileService sysFileService; /** - * 文件上传请求 + * 文件上传请求(用的是这个) */ @PostMapping("upload") public R upload(MultipartFile file) { @@ -42,7 +42,7 @@ public class SysFileController { // 上传并返回访问地址 String url = sysFileService.uploadFile(file); SysFile sysFile = new SysFile(); - sysFile.setName(FileUtils.getName(url)); + sysFile.setName(file.getOriginalFilename());//sysFile.setName(FileUtils.getName(url)); sysFile.setUrl(url); return R.ok(sysFile); } catch (Exception e) { @@ -57,7 +57,7 @@ public class SysFileController { // 上传并返回访问地址 String url = sysFileService.uploadFile(file); SysFile sysFile = new SysFile(); - sysFile.setName(FileUtils.getName(url)); + sysFile.setName(file.getOriginalFilename());//sysFile.setName(FileUtils.getName(url)); sysFile.setUrl(url); return R.ok(sysFile); } catch (Exception e) { diff --git a/op-modules/op-file/src/main/java/com/op/file/service/MongoFileImpl.java b/op-modules/op-file/src/main/java/com/op/file/service/MongoFileImpl.java index 5645bac0..3bf73e43 100644 --- a/op-modules/op-file/src/main/java/com/op/file/service/MongoFileImpl.java +++ b/op-modules/op-file/src/main/java/com/op/file/service/MongoFileImpl.java @@ -82,8 +82,7 @@ public class MongoFileImpl implements ISysFileService { * 图片上传 * * @param file - * @param userId - * @param fsgisOneMapMacroAnalysis + * @param * @return * @throws Exception */ diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/BaseFileController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/BaseFileController.java new file mode 100644 index 00000000..cb000551 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/BaseFileController.java @@ -0,0 +1,101 @@ +package com.op.mes.controller; + +import com.op.common.core.domain.BaseFileData; +import com.op.common.core.utils.poi.ExcelUtil; +import com.op.common.core.web.controller.BaseController; +import com.op.common.core.web.domain.AjaxResult; +import com.op.common.core.web.page.TableDataInfo; +import com.op.common.log.annotation.Log; +import com.op.common.log.enums.BusinessType; +import com.op.common.security.annotation.RequiresPermissions; + +import com.op.mes.domain.BaseFile; +import com.op.mes.service.IBaseFileService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 附件Controller + * + * @author Open Platform + * @date 2023-07-10 + */ +@RestController +@RequestMapping("/file") +public class BaseFileController extends BaseController { + @Autowired + private IBaseFileService baseFileService; + + /** + * 查询附件列表 + */ + @RequiresPermissions("system:file:list") + @GetMapping("/list") + public TableDataInfo list(BaseFile baseFile) { + startPage(); + List list = baseFileService.selectBaseFileList(baseFile); + return getDataTable(list); + } + + /** + * 导出附件列表 + */ + @RequiresPermissions("system:file:export") + @Log(title = "附件", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, BaseFile baseFile) { + List list = baseFileService.selectBaseFileList(baseFile); + ExcelUtil util = new ExcelUtil(BaseFile.class); + util.exportExcel(response, list, "附件数据"); + } + + /** + * 获取附件详细信息 + */ + @RequiresPermissions("system:file:query") + @GetMapping(value = "/{fileId}") + public AjaxResult getInfo(@PathVariable("fileId") String fileId) { + return success(baseFileService.selectBaseFileByFileId(fileId)); + } + + /** + * 新增附件 + */ + @RequiresPermissions("system:file:add") + @Log(title = "附件", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody BaseFile baseFile) { + return toAjax(baseFileService.insertBaseFile(baseFile)); + } + + /** + * 修改附件 + */ + @RequiresPermissions("system:file:edit") + @Log(title = "附件", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody BaseFile baseFile) { + return toAjax(baseFileService.updateBaseFile(baseFile)); + } + + /** + * 删除附件 + */ + @RequiresPermissions("system:file:remove") + @Log(title = "附件", businessType = BusinessType.DELETE) + @DeleteMapping("/{fileIds}") + public AjaxResult remove(@PathVariable String[] fileIds) { + return toAjax(baseFileService.deleteBaseFileByFileIds(fileIds)); + } + + + @Log(title = "批量上传附件", businessType = BusinessType.INSERT) + @PostMapping("/upLoadFile") + public Boolean add(@RequestBody List baseFiles) { + return baseFileService.insertBaseFileBatch(baseFiles); + } + +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/ProProcessController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/ProProcessController.java index c6f74e55..58d47960 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/ProProcessController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/ProProcessController.java @@ -1,16 +1,22 @@ package com.op.mes.controller; +import java.security.Security; +import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.alibaba.nacos.client.constant.Constants; import com.op.common.core.constant.UserConstants; +import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.poi.ExcelUtil; +import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.domain.AjaxResult; import com.op.common.core.web.page.TableDataInfo; import com.op.common.log.annotation.Log; import com.op.common.log.enums.BusinessType; import com.op.common.security.annotation.RequiresPermissions; +import com.op.common.security.utils.SecurityUtils; import com.op.mes.domain.ProProcess; import com.op.mes.service.IProProcessService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/BaseFile.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/BaseFile.java new file mode 100644 index 00000000..1f8adb4b --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/BaseFile.java @@ -0,0 +1,123 @@ +package com.op.mes.domain; + +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; + +/** + * 附件对象 base_file + * + * @author Open Platform + * @date 2023-07-10 + */ +public class BaseFile extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** 附件ID */ + private String fileId; + + /** 附件名称 */ + @Excel(name = "附件名称") + private String fileName; + + /** 附件地址 */ + @Excel(name = "附件地址") + private String fileAddress; + + /** 数据来源 */ + @Excel(name = "数据来源") + private String sourceId; + + /** 预留字段1 */ + @Excel(name = "预留字段1") + private String attr1; + + /** 预留字段2 */ + @Excel(name = "预留字段2") + private String attr2; + + /** 预留字段3 */ + @Excel(name = "预留字段3") + private Long attr3; + + /** 预留字段4 */ + @Excel(name = "预留字段4") + private Long attr4; + + public void setFileId(String fileId) { + this.fileId = fileId; + } + + public String getFileId() { + return fileId; + } + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFileName() { + return fileName; + } + public void setFileAddress(String fileAddress) { + this.fileAddress = fileAddress; + } + + public String getFileAddress() { + return fileAddress; + } + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getSourceId() { + return sourceId; + } + public void setAttr1(String attr1) { + this.attr1 = attr1; + } + + public String getAttr1() { + return attr1; + } + public void setAttr2(String attr2) { + this.attr2 = attr2; + } + + public String getAttr2() { + return attr2; + } + public void setAttr3(Long attr3) { + this.attr3 = attr3; + } + + public Long getAttr3() { + return attr3; + } + public void setAttr4(Long attr4) { + this.attr4 = attr4; + } + + public Long getAttr4() { + return attr4; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("fileId", getFileId()) + .append("fileName", getFileName()) + .append("fileAddress", getFileAddress()) + .append("sourceId", getSourceId()) + .append("remark", getRemark()) + .append("attr1", getAttr1()) + .append("attr2", getAttr2()) + .append("attr3", getAttr3()) + .append("attr4", getAttr4()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/domain/ProProcess.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/ProProcess.java index b2a58f8c..567c3cbf 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/domain/ProProcess.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/ProProcess.java @@ -47,6 +47,66 @@ public class ProProcess extends BaseEntity /** 预留字段4 */ private Long attr4; + private String fileList; + //s:拆分 m合并 + private String splitMerge; + //拆分合并数量 + private int splitMergNum; + //1允许多单并行 + private String sync; + //工作中心 + private String workCenter; + //工作时长 + private Double workTime; + + public String getWorkCenter() { + return workCenter; + } + + public void setWorkCenter(String workCenter) { + this.workCenter = workCenter; + } + + public Double getWorkTime() { + return workTime; + } + + public void setWorkTime(Double workTime) { + this.workTime = workTime; + } + + public String getSplitMerge() { + return splitMerge; + } + + public void setSplitMerge(String splitMerge) { + this.splitMerge = splitMerge; + } + + public int getSplitMergNum() { + return splitMergNum; + } + + public void setSplitMergNum(int splitMergNum) { + this.splitMergNum = splitMergNum; + } + + public String getSync() { + return sync; + } + + public void setSync(String sync) { + this.sync = sync; + } + + public String getFileList() { + return fileList; + } + + public void setFileList(String fileList) { + this.fileList = fileList; + } + public void setProcessId(String processId) { this.processId = processId; diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/BaseFileMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/BaseFileMapper.java new file mode 100644 index 00000000..515567e1 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/BaseFileMapper.java @@ -0,0 +1,67 @@ +package com.op.mes.mapper; + +import com.op.common.core.domain.BaseFileData; +import com.op.mes.domain.BaseFile; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 附件Mapper接口 + * + * @author Open Platform + * @date 2023-07-10 + */ +@Mapper +public interface BaseFileMapper { + /** + * 查询附件 + * + * @param fileId 附件主键 + * @return 附件 + */ + public BaseFile selectBaseFileByFileId(String fileId); + + /** + * 查询附件列表 + * + * @param baseFile 附件 + * @return 附件集合 + */ + public List selectBaseFileList(BaseFile baseFile); + + /** + * 新增附件 + * + * @param baseFile 附件 + * @return 结果 + */ + public int insertBaseFile(BaseFile baseFile); + + /** + * 修改附件 + * + * @param baseFile 附件 + * @return 结果 + */ + public int updateBaseFile(BaseFile baseFile); + + /** + * 删除附件 + * + * @param fileId 附件主键 + * @return 结果 + */ + public int deleteBaseFileByFileId(String fileId); + + /** + * 批量删除附件 + * + * @param fileIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteBaseFileByFileIds(String[] fileIds); + + Boolean insertBaseFileBatch(@Param("baseFiles") List baseFiles); +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IBaseFileService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IBaseFileService.java new file mode 100644 index 00000000..fa0a7e80 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IBaseFileService.java @@ -0,0 +1,64 @@ +package com.op.mes.service; + +import com.op.common.core.domain.BaseFileData; +import com.op.mes.domain.BaseFile; + +import java.util.List; + +/** + * 附件Service接口 + * + * @author Open Platform + * @date 2023-07-10 + */ +public interface IBaseFileService { + /** + * 查询附件 + * + * @param fileId 附件主键 + * @return 附件 + */ + public BaseFile selectBaseFileByFileId(String fileId); + + /** + * 查询附件列表 + * + * @param baseFile 附件 + * @return 附件集合 + */ + public List selectBaseFileList(BaseFile baseFile); + + /** + * 新增附件 + * + * @param baseFile 附件 + * @return 结果 + */ + public int insertBaseFile(BaseFile baseFile); + + /** + * 修改附件 + * + * @param baseFile 附件 + * @return 结果 + */ + public int updateBaseFile(BaseFile baseFile); + + /** + * 批量删除附件 + * + * @param fileIds 需要删除的附件主键集合 + * @return 结果 + */ + public int deleteBaseFileByFileIds(String[] fileIds); + + /** + * 删除附件信息 + * + * @param fileId 附件主键 + * @return 结果 + */ + public int deleteBaseFileByFileId(String fileId); + + public Boolean insertBaseFileBatch(List baseFiles); +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/BaseFileServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/BaseFileServiceImpl.java new file mode 100644 index 00000000..a868b0d6 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/BaseFileServiceImpl.java @@ -0,0 +1,102 @@ +package com.op.mes.service.impl; + +import com.op.common.core.domain.BaseFileData; +import com.op.common.core.utils.DateUtils; +import com.op.mes.domain.BaseFile; +import com.op.mes.mapper.BaseFileMapper; +import com.op.mes.service.IBaseFileService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 附件Service业务层处理 + * + * @author Open Platform + * @date 2023-07-10 + */ +@Service +public class BaseFileServiceImpl implements IBaseFileService { + @Autowired + private BaseFileMapper baseFileMapper; + + /** + * 查询附件 + * + * @param fileId 附件主键 + * @return 附件 + */ + @Override + public BaseFile selectBaseFileByFileId(String fileId) { + return baseFileMapper.selectBaseFileByFileId(fileId); + } + + /** + * 查询附件列表 + * + * @param baseFile 附件 + * @return 附件 + */ + @Override + public List selectBaseFileList(BaseFile baseFile) { + return baseFileMapper.selectBaseFileList(baseFile); + } + + /** + * 新增附件 + * + * @param baseFile 附件 + * @return 结果 + */ + @Override + public int insertBaseFile(BaseFile baseFile) { + baseFile.setCreateTime(DateUtils.getNowDate()); + return baseFileMapper.insertBaseFile(baseFile); + } + + /** + * 修改附件 + * + * @param baseFile 附件 + * @return 结果 + */ + @Override + public int updateBaseFile(BaseFile baseFile) { + baseFile.setUpdateTime(DateUtils.getNowDate()); + return baseFileMapper.updateBaseFile(baseFile); + } + + /** + * 批量删除附件 + * + * @param fileIds 需要删除的附件主键 + * @return 结果 + */ + @Override + public int deleteBaseFileByFileIds(String[] fileIds) { + return baseFileMapper.deleteBaseFileByFileIds(fileIds); + } + + /** + * 删除附件信息 + * + * @param fileId 附件主键 + * @return 结果 + */ + @Override + public int deleteBaseFileByFileId(String fileId) { + return baseFileMapper.deleteBaseFileByFileId(fileId); + } + + /** + * 新增附件 + * + * @param baseFiles 附件 + * @return 结果 + */ + @Override + public Boolean insertBaseFileBatch(List baseFiles) { + return baseFileMapper.insertBaseFileBatch(baseFiles); + } +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProProcessServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProProcessServiceImpl.java index 0c732f46..b10478b0 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProProcessServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProProcessServiceImpl.java @@ -1,15 +1,22 @@ package com.op.mes.service.impl; import com.op.common.core.constant.UserConstants; +import com.op.common.core.domain.BaseFileData; 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.security.utils.SecurityUtils; import com.op.mes.domain.ProProcess; +import com.op.mes.mapper.BaseFileMapper; import com.op.mes.mapper.ProProcessMapper; import com.op.mes.service.IProProcessService; + +import com.op.system.api.RemoteUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.Date; import java.util.List; /** @@ -24,6 +31,9 @@ public class ProProcessServiceImpl implements IProProcessService @Autowired private ProProcessMapper proProcessMapper; + @Autowired + private BaseFileMapper baseFileMapper; + /** * 查询生产工序 * @@ -89,6 +99,24 @@ public class ProProcessServiceImpl implements IProProcessService { proProcess.setProcessId(IdUtils.fastSimpleUUID()); proProcess.setCreateTime(DateUtils.getNowDate()); + + //上传附件 + if(StringUtils.isNotEmpty(proProcess.getFileList())){ + String[] ids = proProcess.getFileList().split(","); + List files = new ArrayList<>(); + BaseFileData file = null; + for(String id:ids){ + file = new BaseFileData(); + file.setFileId(IdUtils.fastSimpleUUID()); + file.setFileAddress(id); + file.setSourceId(proProcess.getProcessId()); + file.setCreateBy(SecurityUtils.getUsername()); + file.setCreateTime(new Date()); + files.add(file); + } + baseFileMapper.insertBaseFileBatch(files); + } + return proProcessMapper.insertProProcess(proProcess); } diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/BaseFileMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/BaseFileMapper.xml new file mode 100644 index 00000000..8126ac08 --- /dev/null +++ b/op-modules/op-mes/src/main/resources/mapper/mes/BaseFileMapper.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + select file_id, file_name, file_address, source_id, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from base_file + + + + + + + + insert into base_file + + file_id, + file_name, + file_address, + source_id, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + + + #{fileId}, + #{fileName}, + #{fileAddress}, + #{sourceId}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + INSERT INTO base_file(file_id, file_name, file_address, source_id, remark, create_by, create_time) + VALUES + + ( + #{baseFile.fileId}, + #{baseFile.fileName}, + #{baseFile.fileAddress}, + #{baseFile.sourceId}, + #{baseFile.remark}, + #{baseFile.createBy}, + #{baseFile.createTime} + ) + + + + + update base_file + + file_name = #{fileName}, + file_address = #{fileAddress}, + source_id = #{sourceId}, + remark = #{remark}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + attr4 = #{attr4}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where file_id = #{fileId} + + + + delete from base_file where file_id = #{fileId} + + + + delete from base_file where file_id in + + #{fileId} + + + diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/ProProcessMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/ProProcessMapper.xml index 6323c420..e1041e2b 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/ProProcessMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/ProProcessMapper.xml @@ -19,10 +19,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + + - select process_id, process_code, process_name, attention, enable_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from pro_process + select process_id, process_code, process_name, attention, + enable_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, + update_by, update_time,split_merge,split_merg_num,sync,work_center,work_time + from pro_process