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 c86f4814..2339a9c4 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 @@ -2,6 +2,7 @@ package com.op.system.api; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; @@ -10,9 +11,11 @@ import com.op.common.core.domain.R; import com.op.system.api.domain.SysFile; import com.op.system.api.factory.RemoteFileFallbackFactory; +import java.io.InputStream; + /** * 文件服务 - * + * * @author OP */ @FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class) @@ -25,4 +28,7 @@ public interface RemoteFileService { */ @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public R upload(@RequestPart(value = "file") MultipartFile file); + + @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/factory/RemoteFileFallbackFactory.java b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteFileFallbackFactory.java index b6e230be..8528de43 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteFileFallbackFactory.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteFileFallbackFactory.java @@ -9,9 +9,11 @@ import com.op.common.core.domain.R; import com.op.system.api.RemoteFileService; import com.op.system.api.domain.SysFile; +import java.io.InputStream; + /** * 文件服务降级处理 - * + * * @author OP */ @Component @@ -26,6 +28,11 @@ public class RemoteFileFallbackFactory implements FallbackFactory upload(MultipartFile file) { return R.fail("上传文件失败:" + throwable.getMessage()); } + + @Override + public InputStream getFile(String id) { + return null; + } }; } } diff --git a/op-common/op-common-core/pom.xml b/op-common/op-common-core/pom.xml index 16ef6f53..95274fd2 100644 --- a/op-common/op-common-core/pom.xml +++ b/op-common/op-common-core/pom.xml @@ -10,7 +10,7 @@ 4.0.0 op-common-core - + op-common-core核心模块 @@ -22,7 +22,7 @@ org.springframework.cloud spring-cloud-starter-openfeign - + org.springframework.cloud @@ -112,7 +112,6 @@ io.swagger swagger-annotations - diff --git a/op-modules/op-file/op-modules-file.iml b/op-modules/op-file/op-modules-file.iml index 3430da71..2d701e10 100644 --- a/op-modules/op-file/op-modules-file.iml +++ b/op-modules/op-file/op-modules-file.iml @@ -143,7 +143,6 @@ - @@ -191,6 +190,14 @@ + + + + + + + + diff --git a/op-modules/op-file/pom.xml b/op-modules/op-file/pom.xml index 2a10739b..c6ae931b 100644 --- a/op-modules/op-file/pom.xml +++ b/op-modules/op-file/pom.xml @@ -16,56 +16,59 @@ - - + + com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery - + com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config - + com.alibaba.cloud spring-cloud-starter-alibaba-sentinel - + org.springframework.boot spring-boot-starter-actuator - + com.github.tobato fastdfs-client - + io.minio minio ${minio.version} - + com.op op-api-system - + com.op op-common-swagger - + + org.springframework.boot + spring-boot-starter-data-mongodb + @@ -84,5 +87,5 @@ - - \ No newline at end of file + + 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 4e5c4b11..331277ca 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 @@ -1,11 +1,21 @@ package com.op.file.controller; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; + import com.op.common.core.domain.R; import com.op.common.core.utils.file.FileUtils; import com.op.file.service.ISysFileService; @@ -13,7 +23,7 @@ import com.op.system.api.domain.SysFile; /** * 文件请求处理 - * + * * @author OP */ @RestController @@ -40,4 +50,76 @@ public class SysFileController { return R.fail(e.getMessage()); } } -} \ No newline at end of file + + @PostMapping("/file/upload") + public R fileUpload(MultipartFile file) { + try { + // 上传并返回访问地址 + String url = sysFileService.uploadFile(file); + SysFile sysFile = new SysFile(); + sysFile.setName(FileUtils.getName(url)); + sysFile.setUrl(url); + return R.ok(sysFile); + } catch (Exception e) { + log.error("上传文件失败", e); + return R.fail(e.getMessage()); + } + } + + // 在线显示 + @GetMapping("/online") + public void previewPng(HttpServletRequest request, HttpServletResponse response) { + OutputStream out = null; + response.setHeader("Content-Disposition", "inline;fileName=1.png"); + byte[] io = sysFileService.imageOnline(request.getParameter("id")); + response.setContentLength(io.length); + try { + out = response.getOutputStream(); + out.write(io); + } catch (IOException e) { + log.error("Online error", e); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + log.error("Close error", e); + } + } + } + } + + // 下载 + @GetMapping("/downLoadFile") + public void downLoadFile(HttpServletRequest request, HttpServletResponse response) { + OutputStream out = null; + response.setHeader("Content-Disposition", "attachment;fileName=1.png"); + byte[] io = sysFileService.imageOnline(request.getParameter("id")); + response.setContentLength(io.length); + try { + out = response.getOutputStream(); + out.write(io); + } catch (IOException e) { + log.error("Online error", e); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException e) { + log.error("Close error", e); + } + } + } + } + + // 转byte[] + public static byte[] toByteArray(InputStream input) throws IOException { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int n = 0; + while (-1 != (n = input.read(buffer))) { + output.write(buffer, 0, n); + } + return output.toByteArray(); + } +} diff --git a/op-modules/op-file/src/main/java/com/op/file/service/FastDfsSysFileServiceImpl.java b/op-modules/op-file/src/main/java/com/op/file/service/FastDfsSysFileServiceImpl.java index 8af9673f..372229a5 100644 --- a/op-modules/op-file/src/main/java/com/op/file/service/FastDfsSysFileServiceImpl.java +++ b/op-modules/op-file/src/main/java/com/op/file/service/FastDfsSysFileServiceImpl.java @@ -40,4 +40,14 @@ public class FastDfsSysFileServiceImpl implements ISysFileService { inputStream.close(); return domain + "/" + storePath.getFullPath(); } + + @Override + public InputStream searchGridFs(String id) { + return null; + } + + @Override + public byte[] imageOnline(String imageId) { + return new byte[0]; + } } diff --git a/op-modules/op-file/src/main/java/com/op/file/service/ISysFileService.java b/op-modules/op-file/src/main/java/com/op/file/service/ISysFileService.java index c1c814db..191b2a80 100644 --- a/op-modules/op-file/src/main/java/com/op/file/service/ISysFileService.java +++ b/op-modules/op-file/src/main/java/com/op/file/service/ISysFileService.java @@ -1,19 +1,27 @@ package com.op.file.service; +import java.io.InputStream; + import org.springframework.web.multipart.MultipartFile; /** * 文件上传接口 - * + * * @author OP */ public interface ISysFileService { /** * 文件上传接口 - * + * * @param file 上传的文件 * @return 访问地址 * @throws Exception */ public String uploadFile(MultipartFile file) throws Exception; + + public InputStream searchGridFs(String id); + +// public String imageUpload(MultipartFile file) throws Exception; + + public byte[] imageOnline(String imageId); } diff --git a/op-modules/op-file/src/main/java/com/op/file/service/LocalSysFileServiceImpl.java b/op-modules/op-file/src/main/java/com/op/file/service/LocalSysFileServiceImpl.java index 8c1dd638..d965c1fe 100644 --- a/op-modules/op-file/src/main/java/com/op/file/service/LocalSysFileServiceImpl.java +++ b/op-modules/op-file/src/main/java/com/op/file/service/LocalSysFileServiceImpl.java @@ -6,12 +6,14 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import com.op.file.utils.FileUploadUtils; +import java.io.InputStream; + /** * 本地文件存储 - * + * * @author OP */ -@Primary +//@Primary @Service public class LocalSysFileServiceImpl implements ISysFileService { /** @@ -34,7 +36,7 @@ public class LocalSysFileServiceImpl implements ISysFileService { /** * 本地文件上传接口 - * + * * @param file 上传的文件 * @return 访问地址 * @throws Exception @@ -45,4 +47,14 @@ public class LocalSysFileServiceImpl implements ISysFileService { String url = domain + localFilePrefix + name; return url; } + + @Override + public InputStream searchGridFs(String id) { + return null; + } + + @Override + public byte[] imageOnline(String imageId) { + return new byte[0]; + } } diff --git a/op-modules/op-file/src/main/java/com/op/file/service/MinioSysFileServiceImpl.java b/op-modules/op-file/src/main/java/com/op/file/service/MinioSysFileServiceImpl.java index c1966085..8256baaa 100644 --- a/op-modules/op-file/src/main/java/com/op/file/service/MinioSysFileServiceImpl.java +++ b/op-modules/op-file/src/main/java/com/op/file/service/MinioSysFileServiceImpl.java @@ -39,4 +39,14 @@ public class MinioSysFileServiceImpl implements ISysFileService { inputStream.close(); return minioConfig.getUrl() + "/" + minioConfig.getBucketName() + "/" + fileName; } + + @Override + public InputStream searchGridFs(String id) { + return null; + } + + @Override + public byte[] imageOnline(String imageId) { + return new byte[0]; + } } 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 new file mode 100644 index 00000000..5645bac0 --- /dev/null +++ b/op-modules/op-file/src/main/java/com/op/file/service/MongoFileImpl.java @@ -0,0 +1,109 @@ +package com.op.file.service; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.bson.types.ObjectId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Primary; +import org.springframework.data.mongodb.MongoDatabaseFactory; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.gridfs.GridFsResource; +import org.springframework.data.mongodb.gridfs.GridFsTemplate; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import com.mongodb.client.MongoDatabase; +import com.mongodb.client.gridfs.GridFSBucket; +import com.mongodb.client.gridfs.GridFSBuckets; +import com.mongodb.client.gridfs.model.GridFSFile; + +@Primary +@Service +public class MongoFileImpl implements ISysFileService { + + private static final Logger log = LoggerFactory.getLogger(MongoFileImpl.class); + + /** + * 域名或本机访问地址 + */ + @Value("${mongo.domain}") + public String domain; + @Autowired + private GridFsTemplate gridFsTemplate; + @Autowired + private MongoTemplate mongoTemplate; + + @Override + public InputStream searchGridFs(String id) { + InputStream inputStream = null; + try { + Query query = Query.query(Criteria.where("_id").is(id)); + GridFSFile gridFSDBFile = gridFsTemplate.findOne(query); + GridFsResource gridFsResource = new GridFsResource(gridFSDBFile, + defaultGridFsBucket().openDownloadStream(gridFSDBFile.getObjectId())); + inputStream = gridFsResource.getInputStream(); + } catch (Exception e) { + log.error("Mongo searchGridFs error", e); + } finally { + } + return inputStream; + } + + private GridFSBucket defaultGridFsBucket() { + // 通过mongoTemplate来获取默认的数据库连接 + MongoDatabaseFactory mongoDatabaseFactory = mongoTemplate.getMongoDatabaseFactory(); + MongoDatabase db = mongoDatabaseFactory.getMongoDatabase("op_cloud"); + // 创建GridFSBucket 并指定文件系统使用的bucket + return GridFSBuckets.create(db); + } + + // 转byte[] + public static byte[] toByteArray(InputStream input) throws IOException { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + byte[] buffer = new byte[4096]; + int n = 0; + while (-1 != (n = input.read(buffer))) { + output.write(buffer, 0, n); + } + return output.toByteArray(); + } + + @Autowired + private MongoService mongoService; + + /** + * 图片上传 + * + * @param file + * @param userId + * @param fsgisOneMapMacroAnalysis + * @return + * @throws Exception + */ + @Override + public String uploadFile(MultipartFile file) throws Exception { + String fileName = file.getOriginalFilename(); + String id = this.mongoService.uploadFile(file, fileName); + String url = domain + "/online?id=" + id; + return url; + } + + /** + * 图片预览 + * + * @param imageid + * @return + */ + @Override + public byte[] imageOnline(String id) { + return this.mongoService.downloadImageByte(id); + } + +} diff --git a/op-modules/op-file/src/main/java/com/op/file/service/MongoService.java b/op-modules/op-file/src/main/java/com/op/file/service/MongoService.java new file mode 100644 index 00000000..d73b5ad3 --- /dev/null +++ b/op-modules/op-file/src/main/java/com/op/file/service/MongoService.java @@ -0,0 +1,111 @@ +package com.op.file.service; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.bson.types.ObjectId; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.mongodb.MongoDatabaseFactory; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.data.mongodb.gridfs.GridFsResource; +import org.springframework.data.mongodb.gridfs.GridFsTemplate; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import com.mongodb.client.MongoDatabase; +import com.mongodb.client.gridfs.GridFSBucket; +import com.mongodb.client.gridfs.GridFSBuckets; +import com.mongodb.client.gridfs.GridFSDownloadStream; +import com.mongodb.client.gridfs.model.GridFSFile; + +/** + * /** + * + * @program: + * @description: MongoService + */ +@Service +public class MongoService { + + @Autowired + private GridFsTemplate gridFsTemplate; + @Autowired + private MongoTemplate mongoTemplate; + + /** + * 文件上传到mongo服务器上 + * + * @param multipartFile 文件 + * @param fileName 存入mongo中的名字 + * @return + * @throws Exception + */ + public String uploadFile(MultipartFile multipartFile, String fileName) throws Exception { + + // 查看mongo中是否已经保存图片 + Query filename = Query.query(Criteria.where("filename").is(fileName)); + // 获得文件输入流 + InputStream fileIn = multipartFile.getInputStream(); + + // 将文件存储到mongodb中,mongodb 将会返回这个文件的具体信息 + ObjectId objectId = gridFsTemplate.store(fileIn, fileName); + + return objectId.toString(); + } + + /** + * 图片预览 + * + * @param fileId + * @param + * @return + */ + public byte[] downloadImageByte(String fileId) { + byte[] fileBytes = null; + try { + // 查询单个文件 + Query query = Query.query(Criteria.where("_id").is(fileId)); + GridFSFile gfsFile = gridFsTemplate.findOne(query); + InputStream inputStream = null; + if (gfsFile != null) { + GridFSBucket gridFSBucket = defaultGridFsBucket(); + GridFSDownloadStream gridFSDownloadStream = gridFSBucket.openDownloadStream(gfsFile.getObjectId()); + // 创建GridFsResource对象,获取流 + GridFsResource gridFsResource = new GridFsResource(gfsFile, gridFSDownloadStream); + + inputStream = gridFsResource.getInputStream(); + } + fileBytes = is2ByeteArray(inputStream); + inputStream.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + return fileBytes; + + } + + private GridFSBucket defaultGridFsBucket() { + // 通过mongoTemplate来获取默认的数据库连接 + MongoDatabaseFactory mongoDatabaseFactory = mongoTemplate.getMongoDatabaseFactory(); + MongoDatabase db = mongoDatabaseFactory.getMongoDatabase("op_cloud"); + // 创建GridFSBucket 并指定文件系统使用的bucket + return GridFSBuckets.create(db); + } + + // 转化inputStream 为byte[] + public byte[] is2ByeteArray(InputStream is) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buff = new byte[100]; + int rc = 0; + while ((rc = is.read(buff, 0, 100)) > 0) { + baos.write(buff, 0, rc); + } + + return baos.toByteArray(); + } + +} diff --git a/op-modules/op-file/src/main/resources/bootstrap.yml b/op-modules/op-file/src/main/resources/bootstrap.yml index ee020df5..3cc00fca 100644 --- a/op-modules/op-file/src/main/resources/bootstrap.yml +++ b/op-modules/op-file/src/main/resources/bootstrap.yml @@ -3,7 +3,7 @@ server: port: 9300 # Spring -spring: +spring: application: # 应用名称 name: op-file @@ -14,10 +14,16 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: localhost:8848 + namespace: lanju-op + group: zxl + # 服务注册地址 + server-addr: 140.249.53.142:8848 config: # 配置中心地址 - server-addr: localhost:8848 + namespace: lanju-op + group: zxl + # 服务注册地址 + server-addr: 140.249.53.142:8848 # 配置文件格式 file-extension: yml # 共享配置 diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/ProProcessContentController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/ProProcessContentController.java new file mode 100644 index 00000000..5a9c6785 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/ProProcessContentController.java @@ -0,0 +1,107 @@ +package com.op.mes.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.op.common.core.utils.poi.ExcelUtil; +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.ProProcessContent; +import com.op.mes.service.IProProcessContentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.op.common.core.web.controller.BaseController; + + +/** + * 生产工序内容Controller + * + * @author yinjinlu + * @date 2022-05-12 + */ +@RestController +@RequestMapping("/pro/processcontent") +public class ProProcessContentController extends BaseController +{ + @Autowired + private IProProcessContentService proProcessContentService; + + /** + * 查询生产工序内容列表 + */ + @RequiresPermissions("mes:pro:processcontent:list") + @GetMapping("/list") + public TableDataInfo list(ProProcessContent proProcessContent) + { + startPage(); + List list = proProcessContentService.selectProProcessContentList(proProcessContent); + return getDataTable(list); + } + + /** + * 导出生产工序内容列表 + */ + @RequiresPermissions("mes:pro:processcontent:export") + @Log(title = "生产工序内容", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ProProcessContent proProcessContent) + { + List list = proProcessContentService.selectProProcessContentList(proProcessContent); + ExcelUtil util = new ExcelUtil(ProProcessContent.class); + util.exportExcel(response, list, "生产工序内容数据"); + } + + /** + * 获取生产工序内容详细信息 + */ + @RequiresPermissions("mes:pro:processcontent:query") + @GetMapping(value = "/{contentId}") + public AjaxResult getInfo(@PathVariable("contentId") String contentId) + { + return AjaxResult.success(proProcessContentService.selectProProcessContentByContentId(contentId)); + } + + /** + * 新增生产工序内容 + */ + @RequiresPermissions("mes:pro:processcontent:add") + @Log(title = "生产工序内容", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ProProcessContent proProcessContent) + { + return toAjax(proProcessContentService.insertProProcessContent(proProcessContent)); + } + + /** + * 修改生产工序内容 + */ + @RequiresPermissions("mes:pro:processcontent:edit") + @Log(title = "生产工序内容", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ProProcessContent proProcessContent) + { + return toAjax(proProcessContentService.updateProProcessContent(proProcessContent)); + } + + /** + * 删除生产工序内容 + */ + @RequiresPermissions("mes:pro:processcontent:remove") + @Log(title = "生产工序内容", businessType = BusinessType.DELETE) + @DeleteMapping("/{contentIds}") + public AjaxResult remove(@PathVariable String[] contentIds) + { + return toAjax(proProcessContentService.deleteProProcessContentByContentIds(contentIds)); + } +} 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 new file mode 100644 index 00000000..c6f74e55 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/ProProcessController.java @@ -0,0 +1,132 @@ +package com.op.mes.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.op.common.core.constant.UserConstants; +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.ProProcess; +import com.op.mes.service.IProProcessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * 生产工序Controller + * + * @author yinjinlu + * @date 2022-05-11 + */ +@RestController +@RequestMapping("/pro/process") +public class ProProcessController extends BaseController +{ + @Autowired + private IProProcessService proProcessService; + + /** + * 查询生产工序列表 + */ + @RequiresPermissions("mes:pro:process:list") + @GetMapping("/list") + public TableDataInfo list(ProProcess proProcess) + { + startPage(); + List list = proProcessService.selectProProcessList(proProcess); + return getDataTable(list); + } + + /** + * 查询所有可用工序的清单 + * @return + */ + @RequiresPermissions("mes:pro:process:list") + @GetMapping("/listAll") + public AjaxResult listAll(){ + ProProcess process = new ProProcess(); + process.setEnableFlag("Y"); + List list =proProcessService.selectProProcessList(process); + return AjaxResult.success(list); + } + + /** + * 导出生产工序列表 + */ + @RequiresPermissions("@ss.hasPermi('mes:pro:process:export')") + @Log(title = "生产工序", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ProProcess proProcess) + { + List list = proProcessService.selectProProcessList(proProcess); + ExcelUtil util = new ExcelUtil(ProProcess.class); + util.exportExcel(response, list, "生产工序数据"); + } + + /** + * 获取生产工序详细信息 + */ + @RequiresPermissions("mes:pro:process:query") + @GetMapping(value = "/{processId}") + public AjaxResult getInfo(@PathVariable("processId") String processId) + { + return AjaxResult.success(proProcessService.selectProProcessByProcessId(processId)); + } + + /** + * 新增生产工序 + */ + @RequiresPermissions("mes:pro:process:add") + @Log(title = "生产工序", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ProProcess proProcess) + { + if(!proProcessService.checkProcessCodeUnique(proProcess)){ + return AjaxResult.error("工序编码已存在!"); + } + if(!proProcessService.checkProcessNameUnique(proProcess)){ + return AjaxResult.error("工序名称已存在!"); + } + return toAjax(proProcessService.insertProProcess(proProcess)); + } + + /** + * 修改生产工序 + */ + @RequiresPermissions("mes:pro:process:edit") + @Log(title = "生产工序", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ProProcess proProcess) + { + if(proProcessService.checkProcessCodeUnique(proProcess)){ + return AjaxResult.error("工序编码已存在!"); + } + if(proProcessService.checkProcessNameUnique(proProcess)){ + return AjaxResult.error("工序名称已存在!"); + } + return toAjax(proProcessService.updateProProcess(proProcess)); + } + + /** + * 删除生产工序 + */ + @RequiresPermissions("mes:pro:process:remove") + @Log(title = "生产工序", businessType = BusinessType.DELETE) + @DeleteMapping("/{processIds}") + public AjaxResult remove(@PathVariable String[] processIds) + { + return toAjax(proProcessService.deleteProProcessByProcessIds(processIds)); + } +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/SysUserController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/SysUserController.java deleted file mode 100644 index 6389a944..00000000 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/SysUserController.java +++ /dev/null @@ -1,127 +0,0 @@ -package com.op.mes.controller; - -import java.io.IOException; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; -import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang3.ArrayUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; -import com.op.common.core.domain.R; -import com.op.common.core.utils.StringUtils; -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.InnerAuth; -import com.op.common.security.annotation.RequiresPermissions; -import com.op.common.security.utils.SecurityUtils; -import com.op.system.api.domain.SysDept; -import com.op.system.api.domain.SysRole; -import com.op.system.api.domain.SysUser; -import com.op.system.api.model.LoginUser; -import com.op.mes.service.ISysUserService; - -/** - * 用户信息 - * - * @author OP - */ -@RestController -@RequestMapping("/user") -public class SysUserController extends BaseController { - @Autowired - private ISysUserService userService; - - - /** - * 获取用户列表 - */ - @RequiresPermissions("system:user:list") - @GetMapping("/list") - public TableDataInfo list(SysUser user) { - startPage(); - List list = userService.selectUserList(user); - return getDataTable(list); - } - - @Log(title = "用户管理", businessType = BusinessType.EXPORT) - @RequiresPermissions("system:user:export") - @PostMapping("/export") - public void export(HttpServletResponse response, SysUser user) { - List list = userService.selectUserList(user); - ExcelUtil util = new ExcelUtil(SysUser.class); - util.exportExcel(response, list, "用户数据"); - } - - - - @PostMapping("/importTemplate") - public void importTemplate(HttpServletResponse response) throws IOException { - ExcelUtil util = new ExcelUtil(SysUser.class); - util.importTemplateExcel(response, "用户数据"); - } - - - - /** - * 新增用户 - */ - @RequiresPermissions("system:user:add") - @Log(title = "用户管理", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@Validated @RequestBody SysUser user) { - if (!userService.checkUserNameUnique(user)) { - return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); - } else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { - return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); - } else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) { - return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); - } - user.setCreateBy(SecurityUtils.getUsername()); - user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); - return toAjax(userService.insertUser(user)); - } - - - - /** - * 重置密码 - */ - @RequiresPermissions("system:user:edit") - @Log(title = "用户管理", businessType = BusinessType.UPDATE) - @PutMapping("/resetPwd") - public AjaxResult resetPwd(@RequestBody SysUser user) { - userService.checkUserAllowed(user); - userService.checkUserDataScope(user.getUserId()); - user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); - user.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(userService.resetPwd(user)); - } - - /** - * 状态修改 - */ - @RequiresPermissions("system:user:edit") - @Log(title = "用户管理", businessType = BusinessType.UPDATE) - @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysUser user) { - userService.checkUserAllowed(user); - userService.checkUserDataScope(user.getUserId()); - user.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(userService.updateUserStatus(user)); - } - -} 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 new file mode 100644 index 00000000..b2a58f8c --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/ProProcess.java @@ -0,0 +1,151 @@ +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; + + +/** + * 生产工序对象 pro_process + * + * @author yinjinlu + * @date 2022-05-12 + */ +public class ProProcess extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 工序ID */ + private String processId; + + /** 工序编码 */ + @Excel(name = "工序编码") + private String processCode; + + /** 工序名称 */ + @Excel(name = "工序名称") + private String processName; + + /** 工艺要求 */ + @Excel(name = "工艺要求") + private String attention; + + /** 是否启用 */ + @Excel(name = "是否启用") + private String enableFlag; + + /** 预留字段1 */ + private String attr1; + + /** 预留字段2 */ + private String attr2; + + /** 预留字段3 */ + private Long attr3; + + /** 预留字段4 */ + private Long attr4; + + public void setProcessId(String processId) + { + this.processId = processId; + } + + public String getProcessId() + { + return processId; + } + public void setProcessCode(String processCode) + { + this.processCode = processCode; + } + + public String getProcessCode() + { + return processCode; + } + public void setProcessName(String processName) + { + this.processName = processName; + } + + public String getProcessName() + { + return processName; + } + public void setAttention(String attention) + { + this.attention = attention; + } + + public String getAttention() + { + return attention; + } + public void setEnableFlag(String enableFlag) + { + this.enableFlag = enableFlag; + } + + public String getEnableFlag() + { + return enableFlag; + } + 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("processId", getProcessId()) + .append("processCode", getProcessCode()) + .append("processName", getProcessName()) + .append("attention", getAttention()) + .append("enableFlag", getEnableFlag()) + .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/ProProcessContent.java b/op-modules/op-mes/src/main/java/com/op/mes/domain/ProProcessContent.java new file mode 100644 index 00000000..8a7956c6 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/domain/ProProcessContent.java @@ -0,0 +1,178 @@ +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; + +/** + * 生产工序内容对象 pro_process_content + * + * @author yinjinlu + * @date 2022-05-12 + */ +public class ProProcessContent extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 内容ID */ + private String contentId; + + /** 工序ID */ + @Excel(name = "工序ID") + private String processId; + + /** 顺序编号 */ + @Excel(name = "顺序编号") + private Integer orderNum; + + /** 内容说明 */ + @Excel(name = "内容说明") + private String contentText; + + /** 辅助设备 */ + @Excel(name = "辅助设备") + private String device; + + /** 辅助材料 */ + @Excel(name = "辅助材料") + private String material; + + /** 材料URL */ + @Excel(name = "材料URL") + private String docUrl; + + /** 预留字段1 */ + private String attr1; + + /** 预留字段2 */ + private String attr2; + + /** 预留字段3 */ + private Long attr3; + + /** 预留字段4 */ + private Long attr4; + + public void setContentId(String contentId) + { + this.contentId = contentId; + } + + public String getContentId() + { + return contentId; + } + public void setProcessId(String processId) + { + this.processId = processId; + } + + public String getProcessId() + { + return processId; + } + public void setOrderNum(Integer orderNum) + { + this.orderNum = orderNum; + } + + public Integer getOrderNum() + { + return orderNum; + } + public void setContentText(String contentText) + { + this.contentText = contentText; + } + + public String getContentText() + { + return contentText; + } + public void setDevice(String device) + { + this.device = device; + } + + public String getDevice() + { + return device; + } + public void setMaterial(String material) + { + this.material = material; + } + + public String getMaterial() + { + return material; + } + public void setDocUrl(String docUrl) + { + this.docUrl = docUrl; + } + + public String getDocUrl() + { + return docUrl; + } + 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("contentId", getContentId()) + .append("processId", getProcessId()) + .append("orderNum", getOrderNum()) + .append("contentText", getContentText()) + .append("device", getDevice()) + .append("material", getMaterial()) + .append("docUrl", getDocUrl()) + .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/mapper/ProProcessContentMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProProcessContentMapper.java new file mode 100644 index 00000000..9c4f278b --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProProcessContentMapper.java @@ -0,0 +1,65 @@ +package com.op.mes.mapper; + +import com.op.mes.domain.ProProcessContent; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + + +/** + * 生产工序内容Mapper接口 + * + * @author yinjinlu + * @date 2022-05-12 + */ +@Mapper +public interface ProProcessContentMapper +{ + /** + * 查询生产工序内容 + * + * @param contentId 生产工序内容主键 + * @return 生产工序内容 + */ + public ProProcessContent selectProProcessContentByContentId(String contentId); + + /** + * 查询生产工序内容列表 + * + * @param proProcessContent 生产工序内容 + * @return 生产工序内容集合 + */ + public List selectProProcessContentList(ProProcessContent proProcessContent); + + /** + * 新增生产工序内容 + * + * @param proProcessContent 生产工序内容 + * @return 结果 + */ + public int insertProProcessContent(ProProcessContent proProcessContent); + + /** + * 修改生产工序内容 + * + * @param proProcessContent 生产工序内容 + * @return 结果 + */ + public int updateProProcessContent(ProProcessContent proProcessContent); + + /** + * 删除生产工序内容 + * + * @param contentId 生产工序内容主键 + * @return 结果 + */ + public int deleteProProcessContentByContentId(String contentId); + + /** + * 批量删除生产工序内容 + * + * @param contentIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteProProcessContentByContentIds(String[] contentIds); +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProProcessMapper.java b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProProcessMapper.java new file mode 100644 index 00000000..2e92c801 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/mapper/ProProcessMapper.java @@ -0,0 +1,69 @@ +package com.op.mes.mapper; + +import com.op.mes.domain.ProProcess; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + + +/** + * 生产工序Mapper接口 + * + * @author yinjinlu + * @date 2022-05-11 + */ +@Mapper +public interface ProProcessMapper +{ + /** + * 查询生产工序 + * + * @param processId 生产工序主键 + * @return 生产工序 + */ + public ProProcess selectProProcessByProcessId(String processId); + + /** + * 查询生产工序列表 + * + * @param proProcess 生产工序 + * @return 生产工序集合 + */ + public List selectProProcessList(ProProcess proProcess); + + public ProProcess checkProcessCodeUnique(ProProcess proProcess); + public ProProcess checkProcessNameUnique(ProProcess proProcess); + + + /** + * 新增生产工序 + * + * @param proProcess 生产工序 + * @return 结果 + */ + public int insertProProcess(ProProcess proProcess); + + /** + * 修改生产工序 + * + * @param proProcess 生产工序 + * @return 结果 + */ + public int updateProProcess(ProProcess proProcess); + + /** + * 删除生产工序 + * + * @param processId 生产工序主键 + * @return 结果 + */ + public int deleteProProcessByProcessId(String processId); + + /** + * 批量删除生产工序 + * + * @param processIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteProProcessByProcessIds(String[] processIds); +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IProProcessContentService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IProProcessContentService.java new file mode 100644 index 00000000..c4510c8b --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IProProcessContentService.java @@ -0,0 +1,63 @@ +package com.op.mes.service; + +import com.op.mes.domain.ProProcessContent; + +import java.util.List; + + +/** + * 生产工序内容Service接口 + * + * @author yinjinlu + * @date 2022-05-12 + */ +public interface IProProcessContentService +{ + /** + * 查询生产工序内容 + * + * @param contentId 生产工序内容主键 + * @return 生产工序内容 + */ + public ProProcessContent selectProProcessContentByContentId(String contentId); + + /** + * 查询生产工序内容列表 + * + * @param proProcessContent 生产工序内容 + * @return 生产工序内容集合 + */ + public List selectProProcessContentList(ProProcessContent proProcessContent); + + /** + * 新增生产工序内容 + * + * @param proProcessContent 生产工序内容 + * @return 结果 + */ + public int insertProProcessContent(ProProcessContent proProcessContent); + + /** + * 修改生产工序内容 + * + * @param proProcessContent 生产工序内容 + * @return 结果 + */ + public int updateProProcessContent(ProProcessContent proProcessContent); + + /** + * 批量删除生产工序内容 + * + * @param contentIds 需要删除的生产工序内容主键集合 + * @return 结果 + */ + public int deleteProProcessContentByContentIds(String[] contentIds); + + /** + * 删除生产工序内容信息 + * + * @param contentId 生产工序内容主键 + * @return 结果 + */ + public int deleteProProcessContentByContentId(String contentId); +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/IProProcessService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/IProProcessService.java new file mode 100644 index 00000000..069acf80 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/IProProcessService.java @@ -0,0 +1,65 @@ +package com.op.mes.service; + +import com.op.mes.domain.ProProcess; + +import java.util.List; + +/** + * 生产工序Service接口 + * + * @author yinjinlu + * @date 2022-05-11 + */ +public interface IProProcessService +{ + /** + * 查询生产工序 + * + * @param processId 生产工序主键 + * @return 生产工序 + */ + public ProProcess selectProProcessByProcessId(String processId); + + /** + * 查询生产工序列表 + * + * @param proProcess 生产工序 + * @return 生产工序集合 + */ + public List selectProProcessList(ProProcess proProcess); + + public Boolean checkProcessCodeUnique(ProProcess proProcess); + public Boolean checkProcessNameUnique(ProProcess proProcess); + + /** + * 新增生产工序 + * + * @param proProcess 生产工序 + * @return 结果 + */ + public int insertProProcess(ProProcess proProcess); + + /** + * 修改生产工序 + * + * @param proProcess 生产工序 + * @return 结果 + */ + public int updateProProcess(ProProcess proProcess); + + /** + * 批量删除生产工序 + * + * @param processIds 需要删除的生产工序主键集合 + * @return 结果 + */ + public int deleteProProcessByProcessIds(String[] processIds); + + /** + * 删除生产工序信息 + * + * @param processId 生产工序主键 + * @return 结果 + */ + public int deleteProProcessByProcessId(String processId); +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/ISysUserService.java b/op-modules/op-mes/src/main/java/com/op/mes/service/ISysUserService.java deleted file mode 100644 index 03e39a0f..00000000 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/ISysUserService.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.op.mes.service; - -import java.util.List; -import com.op.system.api.domain.SysUser; - -/** - * 用户 业务层 - * - * @author OP - */ -public interface ISysUserService { - /** - * 根据条件分页查询用户列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - public List selectUserList(SysUser user); - - /** - * 根据条件分页查询已分配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - public List selectAllocatedList(SysUser user); - - /** - * 根据条件分页查询未分配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - public List selectUnallocatedList(SysUser user); - - /** - * 通过用户名查询用户 - * - * @param userName 用户名 - * @return 用户对象信息 - */ - public SysUser selectUserByUserName(String userName); - - /** - * 通过用户ID查询用户 - * - * @param userId 用户ID - * @return 用户对象信息 - */ - public SysUser selectUserById(Long userId); - - /** - * 校验用户名称是否唯一 - * - * @param user 用户信息 - * @return 结果 - */ - public boolean checkUserNameUnique(SysUser user); - - /** - * 校验手机号码是否唯一 - * - * @param user 用户信息 - * @return 结果 - */ - public boolean checkPhoneUnique(SysUser user); - - /** - * 校验email是否唯一 - * - * @param user 用户信息 - * @return 结果 - */ - public boolean checkEmailUnique(SysUser user); - - /** - * 校验用户是否允许操作 - * - * @param user 用户信息 - */ - public void checkUserAllowed(SysUser user); - - /** - * 校验用户是否有数据权限 - * - * @param userId 用户id - */ - public void checkUserDataScope(Long userId); - - /** - * 新增用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - public int insertUser(SysUser user); - - /** - * 注册用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - public boolean registerUser(SysUser user); - - - /** - * 修改用户状态 - * - * @param user 用户信息 - * @return 结果 - */ - public int updateUserStatus(SysUser user); - - /** - * 修改用户基本信息 - * - * @param user 用户信息 - * @return 结果 - */ - public int updateUserProfile(SysUser user); - - /** - * 修改用户头像 - * - * @param userName 用户名 - * @param avatar 头像地址 - * @return 结果 - */ - public boolean updateUserAvatar(String userName, String avatar); - - /** - * 重置用户密码 - * - * @param user 用户信息 - * @return 结果 - */ - public int resetPwd(SysUser user); - - /** - * 重置用户密码 - * - * @param userName 用户名 - * @param password 密码 - * @return 结果 - */ - public int resetUserPwd(String userName, String password); - -} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProProcessContentServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProProcessContentServiceImpl.java new file mode 100644 index 00000000..5c799a2a --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProProcessContentServiceImpl.java @@ -0,0 +1,99 @@ +package com.op.mes.service.impl; + +import java.util.List; + +import com.op.common.core.utils.DateUtils; +import com.op.common.core.utils.uuid.IdUtils; +import com.op.mes.domain.ProProcessContent; +import com.op.mes.mapper.ProProcessContentMapper; +import com.op.mes.service.IProProcessContentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 生产工序内容Service业务层处理 + * + * @author yinjinlu + * @date 2022-05-12 + */ +@Service +public class ProProcessContentServiceImpl implements IProProcessContentService +{ + @Autowired + private ProProcessContentMapper proProcessContentMapper; + + /** + * 查询生产工序内容 + * + * @param contentId 生产工序内容主键 + * @return 生产工序内容 + */ + @Override + public ProProcessContent selectProProcessContentByContentId(String contentId) + { + return proProcessContentMapper.selectProProcessContentByContentId(contentId); + } + + /** + * 查询生产工序内容列表 + * + * @param proProcessContent 生产工序内容 + * @return 生产工序内容 + */ + @Override + public List selectProProcessContentList(ProProcessContent proProcessContent) + { + return proProcessContentMapper.selectProProcessContentList(proProcessContent); + } + + /** + * 新增生产工序内容 + * + * @param proProcessContent 生产工序内容 + * @return 结果 + */ + @Override + public int insertProProcessContent(ProProcessContent proProcessContent) + { + proProcessContent.setCreateTime(DateUtils.getNowDate()); + proProcessContent.setContentId(IdUtils.fastSimpleUUID()); + return proProcessContentMapper.insertProProcessContent(proProcessContent); + } + + /** + * 修改生产工序内容 + * + * @param proProcessContent 生产工序内容 + * @return 结果 + */ + @Override + public int updateProProcessContent(ProProcessContent proProcessContent) + { + proProcessContent.setUpdateTime(DateUtils.getNowDate()); + return proProcessContentMapper.updateProProcessContent(proProcessContent); + } + + /** + * 批量删除生产工序内容 + * + * @param contentIds 需要删除的生产工序内容主键 + * @return 结果 + */ + @Override + public int deleteProProcessContentByContentIds(String[] contentIds) + { + return proProcessContentMapper.deleteProProcessContentByContentIds(contentIds); + } + + /** + * 删除生产工序内容信息 + * + * @param contentId 生产工序内容主键 + * @return 结果 + */ + @Override + public int deleteProProcessContentByContentId(String contentId) + { + return proProcessContentMapper.deleteProProcessContentByContentId(contentId); + } +} 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 new file mode 100644 index 00000000..0c732f46 --- /dev/null +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProProcessServiceImpl.java @@ -0,0 +1,131 @@ +package com.op.mes.service.impl; + +import com.op.common.core.constant.UserConstants; +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.mes.domain.ProProcess; +import com.op.mes.mapper.ProProcessMapper; +import com.op.mes.service.IProProcessService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 生产工序Service业务层处理 + * + * @author yinjinlu + * @date 2022-05-11 + */ +@Service +public class ProProcessServiceImpl implements IProProcessService +{ + @Autowired + private ProProcessMapper proProcessMapper; + + /** + * 查询生产工序 + * + * @param processId 生产工序主键 + * @return 生产工序 + */ + @Override + public ProProcess selectProProcessByProcessId(String processId) + { + return proProcessMapper.selectProProcessByProcessId(processId); + } + + /** + * 查询生产工序列表 + * + * @param proProcess 生产工序 + * @return 生产工序 + */ + @Override + public List selectProProcessList(ProProcess proProcess) + { + return proProcessMapper.selectProProcessList(proProcess); + } + + /** + * 检查工序编码是否唯一 + * @param proProcess + * @return + */ + @Override + public Boolean checkProcessCodeUnique(ProProcess proProcess) { + ProProcess process = proProcessMapper.checkProcessCodeUnique(proProcess); + if(StringUtils.isNotNull(process) && process.getProcessId().equals(proProcess.getProcessId())){ + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + + /** + * 检查工序名称是否唯一 + * @param proProcess + * @return + */ + @Override + public Boolean checkProcessNameUnique(ProProcess proProcess) { + ProProcess process = proProcessMapper.checkProcessNameUnique(proProcess); + + if(StringUtils.isNotNull(process) && process.getProcessId().equals(proProcess.getProcessId())){ + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 新增生产工序 + * + * @param proProcess 生产工序 + * @return 结果 + */ + @Override + public int insertProProcess(ProProcess proProcess) + { + proProcess.setProcessId(IdUtils.fastSimpleUUID()); + proProcess.setCreateTime(DateUtils.getNowDate()); + return proProcessMapper.insertProProcess(proProcess); + } + + /** + * 修改生产工序 + * + * @param proProcess 生产工序 + * @return 结果 + */ + @Override + public int updateProProcess(ProProcess proProcess) + { + proProcess.setUpdateTime(DateUtils.getNowDate()); + return proProcessMapper.updateProProcess(proProcess); + } + + /** + * 批量删除生产工序 + * + * @param processIds 需要删除的生产工序主键 + * @return 结果 + */ + @Override + public int deleteProProcessByProcessIds(String[] processIds) + { + return proProcessMapper.deleteProProcessByProcessIds(processIds); + } + + /** + * 删除生产工序信息 + * + * @param processId 生产工序主键 + * @return 结果 + */ + @Override + public int deleteProProcessByProcessId(String processId) + { + return proProcessMapper.deleteProProcessByProcessId(processId); + } +} diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/SysUserServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/SysUserServiceImpl.java deleted file mode 100644 index e06bfd21..00000000 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/SysUserServiceImpl.java +++ /dev/null @@ -1,262 +0,0 @@ -package com.op.mes.service.impl; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import javax.validation.Validator; - -import com.op.mes.service.ISysUserService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import com.op.common.core.constant.UserConstants; -import com.op.common.core.exception.ServiceException; -import com.op.common.core.utils.SpringUtils; -import com.op.common.core.utils.StringUtils; -import com.op.common.core.utils.bean.BeanValidators; -import com.op.common.datascope.annotation.DataScope; -import com.op.common.security.utils.SecurityUtils; -import com.op.system.api.domain.SysRole; -import com.op.system.api.domain.SysUser; -import com.op.mes.mapper.SysUserMapper; - -/** - * 用户 业务层处理 - * - * @author OP - */ -@Service -public class SysUserServiceImpl implements ISysUserService { - private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); - - @Autowired - private SysUserMapper userMapper; - - - @Autowired - protected Validator validator; - - /** - * 根据条件分页查询用户列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - @Override - @DataScope(deptAlias = "d", userAlias = "u") - public List selectUserList(SysUser user) { - return userMapper.selectUserList(user); - } - - /** - * 根据条件分页查询已分配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - @Override - @DataScope(deptAlias = "d", userAlias = "u") - public List selectAllocatedList(SysUser user) { - return userMapper.selectAllocatedList(user); - } - - /** - * 根据条件分页查询未分配用户角色列表 - * - * @param user 用户信息 - * @return 用户信息集合信息 - */ - @Override - @DataScope(deptAlias = "d", userAlias = "u") - public List selectUnallocatedList(SysUser user) { - return userMapper.selectUnallocatedList(user); - } - - /** - * 通过用户名查询用户 - * - * @param userName 用户名 - * @return 用户对象信息 - */ - @Override - public SysUser selectUserByUserName(String userName) { - return userMapper.selectUserByUserName(userName); - } - - /** - * 通过用户ID查询用户 - * - * @param userId 用户ID - * @return 用户对象信息 - */ - @Override - public SysUser selectUserById(Long userId) { - return userMapper.selectUserById(userId); - } - - - /** - * 校验用户名称是否唯一 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - public boolean checkUserNameUnique(SysUser user) { - Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); - SysUser info = userMapper.checkUserNameUnique(user.getUserName()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { - return UserConstants.NOT_UNIQUE; - } - return UserConstants.UNIQUE; - } - - /** - * 校验手机号码是否唯一 - * - * @param user 用户信息 - * @return - */ - @Override - public boolean checkPhoneUnique(SysUser user) { - Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); - SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { - return UserConstants.NOT_UNIQUE; - } - return UserConstants.UNIQUE; - } - - /** - * 校验email是否唯一 - * - * @param user 用户信息 - * @return - */ - @Override - public boolean checkEmailUnique(SysUser user) { - Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); - SysUser info = userMapper.checkEmailUnique(user.getEmail()); - if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { - return UserConstants.NOT_UNIQUE; - } - return UserConstants.UNIQUE; - } - - /** - * 校验用户是否允许操作 - * - * @param user 用户信息 - */ - @Override - public void checkUserAllowed(SysUser user) { - if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) { - throw new ServiceException("不允许操作超级管理员用户"); - } - } - - /** - * 校验用户是否有数据权限 - * - * @param userId 用户id - */ - @Override - public void checkUserDataScope(Long userId) { - if (!SysUser.isAdmin(SecurityUtils.getUserId())) { - SysUser user = new SysUser(); - user.setUserId(userId); - List users = SpringUtils.getAopProxy(this).selectUserList(user); - if (StringUtils.isEmpty(users)) { - throw new ServiceException("没有权限访问用户数据!"); - } - } - } - - /** - * 新增保存用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - @Transactional(rollbackFor = Exception.class) - public int insertUser(SysUser user) { - // 新增用户信息 - int rows = userMapper.insertUser(user); - - return rows; - } - - /** - * 注册用户信息 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - public boolean registerUser(SysUser user) { - return userMapper.insertUser(user) > 0; - } - - - /** - * 修改用户状态 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - public int updateUserStatus(SysUser user) { - return userMapper.updateUser(user); - } - - /** - * 修改用户基本信息 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - public int updateUserProfile(SysUser user) { - return userMapper.updateUser(user); - } - - /** - * 修改用户头像 - * - * @param userName 用户名 - * @param avatar 头像地址 - * @return 结果 - */ - @Override - public boolean updateUserAvatar(String userName, String avatar) { - return userMapper.updateUserAvatar(userName, avatar) > 0; - } - - /** - * 重置用户密码 - * - * @param user 用户信息 - * @return 结果 - */ - @Override - public int resetPwd(SysUser user) { - return userMapper.updateUser(user); - } - - /** - * 重置用户密码 - * - * @param userName 用户名 - * @param password 密码 - * @return 结果 - */ - @Override - public int resetUserPwd(String userName, String password) { - return userMapper.resetUserPwd(userName, password); - } - -} diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/ProProcessContentMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/ProProcessContentMapper.xml new file mode 100644 index 00000000..64bac0b4 --- /dev/null +++ b/op-modules/op-mes/src/main/resources/mapper/mes/ProProcessContentMapper.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + select content_id, process_id, order_num, content_text, device, material, doc_url, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from pro_process_content + + + + + + + + insert into pro_process_content + + content_id, + process_id, + order_num, + content_text, + device, + material, + doc_url, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + + + #{contentId}, + #{processId}, + #{orderNum}, + #{contentText}, + #{device}, + #{material}, + #{docUrl}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update pro_process_content + + process_id = #{processId}, + order_num = #{orderNum}, + content_text = #{contentText}, + device = #{device}, + material = #{material}, + doc_url = #{docUrl}, + remark = #{remark}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + attr4 = #{attr4}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where content_id = #{contentId} + + + + delete from pro_process_content where content_id = #{contentId} + + + + delete from pro_process_content where content_id in + + #{contentId} + + + 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 new file mode 100644 index 00000000..6323c420 --- /dev/null +++ b/op-modules/op-mes/src/main/resources/mapper/mes/ProProcessMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + + + + + insert into pro_process + + process_id, + process_code, + process_name, + attention, + enable_flag, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time, + + + #{processId}, + #{processCode}, + #{processName}, + #{attention}, + #{enableFlag}, + #{remark}, + #{attr1}, + #{attr2}, + #{attr3}, + #{attr4}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update pro_process + + process_code = #{processCode}, + process_name = #{processName}, + attention = #{attention}, + enable_flag = #{enableFlag}, + remark = #{remark}, + attr1 = #{attr1}, + attr2 = #{attr2}, + attr3 = #{attr3}, + attr4 = #{attr4}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where process_id = #{processId} + + + + delete from pro_process where process_id = #{processId} + + + + delete from pro_process where process_id in + + #{processId} + + + diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/SysUserMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/SysUserMapper.xml deleted file mode 100644 index 223b1688..00000000 --- a/op-modules/op-mes/src/main/resources/mapper/mes/SysUserMapper.xml +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, - d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, - r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status - from sys_user u - left join sys_dept d on u.dept_id = d.dept_id - left join sys_user_role ur on u.user_id = ur.user_id - left join sys_role r on r.role_id = ur.role_id - - - - - - - - - - - - - - - - - - - - insert into sys_user( - user_id, - dept_id, - user_name, - nick_name, - email, - avatar, - phonenumber, - sex, - password, - status, - create_by, - remark, - create_time - )values( - #{userId}, - #{deptId}, - #{userName}, - #{nickName}, - #{email}, - #{avatar}, - #{phonenumber}, - #{sex}, - #{password}, - #{status}, - #{createBy}, - #{remark}, - GETDATE() - ) - - - - update sys_user - - dept_id = #{deptId}, - user_name = #{userName}, - nick_name = #{nickName}, - email = #{email}, - phonenumber = #{phonenumber}, - sex = #{sex}, - avatar = #{avatar}, - password = #{password}, - status = #{status}, - login_ip = #{loginIp}, - login_date = #{loginDate}, - update_by = #{updateBy}, - remark = #{remark}, - update_time = GETDATE() - - where user_id = #{userId} - - - - update sys_user set status = #{status} where user_id = #{userId} - - - - update sys_user set avatar = #{avatar} where user_name = #{userName} - - - - update sys_user set password = #{password} where user_name = #{userName} - - - - update sys_user set del_flag = '2' where user_id = #{userId} - - - - update sys_user set del_flag = '2' where user_id in - - #{userId} - - - - diff --git a/op-modules/op-system/src/main/java/com/op/system/controller/SysProfileController.java b/op-modules/op-system/src/main/java/com/op/system/controller/SysProfileController.java index 00107d3c..c7794324 100644 --- a/op-modules/op-system/src/main/java/com/op/system/controller/SysProfileController.java +++ b/op-modules/op-system/src/main/java/com/op/system/controller/SysProfileController.java @@ -28,7 +28,7 @@ import com.op.system.service.ISysUserService; /** * 个人信息 业务处理 - * + * * @author OP */ @RestController @@ -118,6 +118,9 @@ public class SysProfileController extends BaseController { @PostMapping("/avatar") public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) { if (!file.isEmpty()) { + + String fileName = file.getName(); + LoginUser loginUser = SecurityUtils.getLoginUser(); String extension = FileTypeUtils.getExtension(file); if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) { diff --git a/op-modules/op-system/src/main/java/com/op/system/controller/SysUserOnlineController.java b/op-modules/op-system/src/main/java/com/op/system/controller/SysUserOnlineController.java index 45fa3ef9..e79bd8ef 100644 --- a/op-modules/op-system/src/main/java/com/op/system/controller/SysUserOnlineController.java +++ b/op-modules/op-system/src/main/java/com/op/system/controller/SysUserOnlineController.java @@ -1,9 +1,12 @@ package com.op.system.controller; +import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; + +import com.op.system.api.RemoteFileService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -25,7 +28,7 @@ import com.op.system.service.ISysUserOnlineService; /** * 在线用户监控 - * + * * @author OP */ @RestController @@ -36,6 +39,8 @@ public class SysUserOnlineController extends BaseController { @Autowired private RedisService redisService; + @Autowired + private RemoteFileService remoteFileService; @RequiresPermissions("monitor:online:list") @GetMapping("/list") @@ -69,4 +74,9 @@ public class SysUserOnlineController extends BaseController { redisService.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId); return success(); } + + @GetMapping("/{id}") + public InputStream list(@PathVariable String id) { + return remoteFileService.getFile(id); + } }