工序1.0

highway
zhaoxiaolin 1 year ago
parent 26ce694217
commit 7bbdd00a61

@ -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,6 +11,8 @@ 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;
/**
*
*
@ -25,4 +28,7 @@ public interface RemoteFileService {
*/
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
@PostMapping(value = "/getFile/{id}")
public InputStream getFile(@PathVariable("id") String id);
}

@ -9,6 +9,8 @@ import com.op.common.core.domain.R;
import com.op.system.api.RemoteFileService;
import com.op.system.api.domain.SysFile;
import java.io.InputStream;
/**
*
*
@ -26,6 +28,11 @@ public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileServ
public R<SysFile> upload(MultipartFile file) {
return R.fail("上传文件失败:" + throwable.getMessage());
}
@Override
public InputStream getFile(String id) {
return null;
}
};
}
}

@ -112,7 +112,6 @@
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
</dependencies>
</project>

@ -143,7 +143,6 @@
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.7.7" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:4.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.2.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.9" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.7" level="project" />
@ -191,6 +190,14 @@
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.swagger:swagger-models:1.6.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.mapstruct:mapstruct:1.3.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-mongodb:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-sync:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:bson:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongodb-driver-core:4.6.1" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.mongodb:bson-record-codec:4.6.1" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-mongodb:3.4.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.3.24" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.7.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-bootstrap:3.1.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:3.1.5" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.11.RELEASE" level="project" />

@ -65,7 +65,10 @@
<groupId>com.op</groupId>
<artifactId>op-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
<build>

@ -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;
@ -40,4 +50,76 @@ public class SysFileController {
return R.fail(e.getMessage());
}
}
@PostMapping("/file/upload")
public R<SysFile> 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();
}
}

@ -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];
}
}

@ -1,5 +1,7 @@
package com.op.file.service;
import java.io.InputStream;
import org.springframework.web.multipart.MultipartFile;
/**
@ -16,4 +18,10 @@ public interface ISysFileService {
* @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);
}

@ -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 {
/**
@ -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];
}
}

@ -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];
}
}

@ -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);
}
}

@ -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();
}
}

@ -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
# 共享配置

@ -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<ProProcessContent> 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<ProProcessContent> list = proProcessContentService.selectProProcessContentList(proProcessContent);
ExcelUtil<ProProcessContent> util = new ExcelUtil<ProProcessContent>(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));
}
}

@ -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<ProProcess> 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<ProProcess> 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<ProProcess> list = proProcessService.selectProProcessList(proProcess);
ExcelUtil<ProProcess> util = new ExcelUtil<ProProcess>(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));
}
}

@ -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<SysUser> 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<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据");
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) throws IOException {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(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));
}
}

@ -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();
}
}

@ -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();
}
}

@ -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<ProProcessContent> 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);
}

@ -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<ProProcess> 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);
}

@ -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<ProProcessContent> 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);
}

@ -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<ProProcess> 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);
}

@ -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<SysUser> selectUserList(SysUser user);
/**
*
*
* @param user
* @return
*/
public List<SysUser> selectAllocatedList(SysUser user);
/**
*
*
* @param user
* @return
*/
public List<SysUser> 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);
}

@ -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<ProProcessContent> 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);
}
}

@ -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<ProProcess> 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);
}
}

@ -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<SysUser> selectUserList(SysUser user) {
return userMapper.selectUserList(user);
}
/**
*
*
* @param user
* @return
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<SysUser> selectAllocatedList(SysUser user) {
return userMapper.selectAllocatedList(user);
}
/**
*
*
* @param user
* @return
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<SysUser> 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<SysUser> 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);
}
}

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.mes.mapper.ProProcessContentMapper">
<resultMap type="ProProcessContent" id="ProProcessContentResult">
<result property="contentId" column="content_id" />
<result property="processId" column="process_id" />
<result property="orderNum" column="order_num" />
<result property="contentText" column="content_text" />
<result property="device" column="device" />
<result property="material" column="material" />
<result property="docUrl" column="doc_url" />
<result property="remark" column="remark" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="attr4" column="attr4" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectProProcessContentVo">
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
</sql>
<select id="selectProProcessContentList" parameterType="ProProcessContent" resultMap="ProProcessContentResult">
<include refid="selectProProcessContentVo"/>
<where>
<if test="processId != null "> and process_id = #{processId}</if>
<if test="orderNum != null "> and order_num = #{orderNum}</if>
<if test="contentText != null and contentText != ''"> and content_text = #{contentText}</if>
<if test="device != null and device != ''"> and device = #{device}</if>
<if test="material != null and material != ''"> and material = #{material}</if>
<if test="docUrl != null and docUrl != ''"> and doc_url = #{docUrl}</if>
</where>
order by order_num asc
</select>
<select id="selectProProcessContentByContentId" parameterType="String" resultMap="ProProcessContentResult">
<include refid="selectProProcessContentVo"/>
where content_id = #{contentId}
</select>
<insert id="insertProProcessContent" parameterType="ProProcessContent" useGeneratedKeys="true" keyProperty="contentId">
insert into pro_process_content
<trim prefix="(" suffix=")" suffixOverrides=",">
content_id,
<if test="processId != null">process_id,</if>
<if test="orderNum != null">order_num,</if>
<if test="contentText != null">content_text,</if>
<if test="device != null">device,</if>
<if test="material != null">material,</if>
<if test="docUrl != null">doc_url,</if>
<if test="remark != null">remark,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="attr4 != null">attr4,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{contentId},
<if test="processId != null">#{processId},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="contentText != null">#{contentText},</if>
<if test="device != null">#{device},</if>
<if test="material != null">#{material},</if>
<if test="docUrl != null">#{docUrl},</if>
<if test="remark != null">#{remark},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="attr4 != null">#{attr4},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateProProcessContent" parameterType="ProProcessContent">
update pro_process_content
<trim prefix="SET" suffixOverrides=",">
<if test="processId != null">process_id = #{processId},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="contentText != null">content_text = #{contentText},</if>
<if test="device != null">device = #{device},</if>
<if test="material != null">material = #{material},</if>
<if test="docUrl != null">doc_url = #{docUrl},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="attr4 != null">attr4 = #{attr4},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where content_id = #{contentId}
</update>
<delete id="deleteProProcessContentByContentId" parameterType="String">
delete from pro_process_content where content_id = #{contentId}
</delete>
<delete id="deleteProProcessContentByContentIds" parameterType="String">
delete from pro_process_content where content_id in
<foreach item="contentId" collection="array" open="(" separator="," close=")">
#{contentId}
</foreach>
</delete>
</mapper>

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.mes.mapper.ProProcessMapper">
<resultMap type="ProProcess" id="ProProcessResult">
<result property="processId" column="process_id" />
<result property="processCode" column="process_code" />
<result property="processName" column="process_name" />
<result property="attention" column="attention" />
<result property="enableFlag" column="enable_flag" />
<result property="remark" column="remark" />
<result property="attr1" column="attr1" />
<result property="attr2" column="attr2" />
<result property="attr3" column="attr3" />
<result property="attr4" column="attr4" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectProProcessVo">
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
</sql>
<select id="selectProProcessList" parameterType="ProProcess" resultMap="ProProcessResult">
<include refid="selectProProcessVo"/>
<where>
<if test="processCode != null and processCode != ''"> and process_code = #{processCode}</if>
<if test="processName != null and processName != ''"> and process_name like concat('%', #{processName}, '%')</if>
<if test="attention != null and attention != ''"> and attention = #{attention}</if>
<if test="enableFlag != null and enableFlag != ''"> and enable_flag = #{enableFlag}</if>
</where>
order by create_time desc
</select>
<select id="selectProProcessByProcessId" parameterType="String" resultMap="ProProcessResult">
<include refid="selectProProcessVo"/>
where process_id = #{processId}
</select>
<select id="checkProcessCodeUnique" parameterType="ProProcess" resultMap="ProProcessResult">
select top 1 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
where process_code = #{processCode}
</select>
<select id="checkProcessNameUnique" parameterType="ProProcess" resultMap="ProProcessResult">
select top 1 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
where process_name = #{processName}
</select>
<insert id="insertProProcess" parameterType="ProProcess" useGeneratedKeys="true" keyProperty="processId">
insert into pro_process
<trim prefix="(" suffix=")" suffixOverrides=",">
process_id,
<if test="processCode != null and processCode != ''">process_code,</if>
<if test="processName != null and processName != ''">process_name,</if>
<if test="attention != null">attention,</if>
<if test="enableFlag != null and enableFlag != ''">enable_flag,</if>
<if test="remark != null">remark,</if>
<if test="attr1 != null">attr1,</if>
<if test="attr2 != null">attr2,</if>
<if test="attr3 != null">attr3,</if>
<if test="attr4 != null">attr4,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{processId},
<if test="processCode != null and processCode != ''">#{processCode},</if>
<if test="processName != null and processName != ''">#{processName},</if>
<if test="attention != null">#{attention},</if>
<if test="enableFlag != null and enableFlag != ''">#{enableFlag},</if>
<if test="remark != null">#{remark},</if>
<if test="attr1 != null">#{attr1},</if>
<if test="attr2 != null">#{attr2},</if>
<if test="attr3 != null">#{attr3},</if>
<if test="attr4 != null">#{attr4},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateProProcess" parameterType="ProProcess">
update pro_process
<trim prefix="SET" suffixOverrides=",">
<if test="processCode != null and processCode != ''">process_code = #{processCode},</if>
<if test="processName != null and processName != ''">process_name = #{processName},</if>
<if test="attention != null">attention = #{attention},</if>
<if test="enableFlag != null and enableFlag != ''">enable_flag = #{enableFlag},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="attr1 != null">attr1 = #{attr1},</if>
<if test="attr2 != null">attr2 = #{attr2},</if>
<if test="attr3 != null">attr3 = #{attr3},</if>
<if test="attr4 != null">attr4 = #{attr4},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where process_id = #{processId}
</update>
<delete id="deleteProProcessByProcessId" parameterType="String">
delete from pro_process where process_id = #{processId}
</delete>
<delete id="deleteProProcessByProcessIds" parameterType="String">
delete from pro_process where process_id in
<foreach item="processId" collection="array" open="(" separator="," close=")">
#{processId}
</foreach>
</delete>
</mapper>

@ -1,221 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.op.mes.mapper.SysUserMapper">
<resultMap type="SysUser" id="SysUserResult">
<id property="userId" column="user_id" />
<result property="deptId" column="dept_id" />
<result property="userName" column="user_name" />
<result property="nickName" column="nick_name" />
<result property="email" column="email" />
<result property="phonenumber" column="phonenumber" />
<result property="sex" column="sex" />
<result property="avatar" column="avatar" />
<result property="password" column="password" />
<result property="status" column="status" />
<result property="delFlag" column="del_flag" />
<result property="loginIp" column="login_ip" />
<result property="loginDate" column="login_date" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
<resultMap id="deptResult" type="SysDept">
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="deptName" column="dept_name" />
<result property="ancestors" column="ancestors" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="status" column="dept_status" />
</resultMap>
<resultMap id="RoleResult" type="SysRole">
<id property="roleId" column="role_id" />
<result property="roleName" column="role_name" />
<result property="roleKey" column="role_key" />
<result property="roleSort" column="role_sort" />
<result property="dataScope" column="data_scope" />
<result property="status" column="role_status" />
</resultMap>
<sql id="selectUserVo">
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
</sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="userId != null and userId != 0">
AND u.user_id = #{userId}
</if>
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="status != null and status != ''">
AND u.status = #{status}
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(u.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(u.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
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
where u.del_flag = '0' and r.role_id = #{roleId}
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
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
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
<if test="userName != null and userName != ''">
AND u.user_name like concat('%', #{userName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND u.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_name = #{userName} and u.del_flag = '0'
</select>
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_id = #{userId}
</select>
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
select top 1 user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0'
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
select top 1 user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0'
</select>
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
select top 1 user_id, email from sys_user where email = #{email} and del_flag = '0'
</select>
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="password != null and password != ''">password,</if>
<if test="status != null and status != ''">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="remark != null and remark != ''">remark,</if>
create_time
)values(
<if test="userId != null and userId != ''">#{userId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="avatar != null and avatar != ''">#{avatar},</if>
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="remark != null and remark != ''">#{remark},</if>
GETDATE()
)
</insert>
<update id="updateUser" parameterType="SysUser">
update sys_user
<set>
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="email != null ">email = #{email},</if>
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
<if test="sex != null and sex != ''">sex = #{sex},</if>
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
<if test="password != null and password != ''">password = #{password},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
<if test="loginDate != null">login_date = #{loginDate},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
update_time = GETDATE()
</set>
where user_id = #{userId}
</update>
<update id="updateUserStatus" parameterType="SysUser">
update sys_user set status = #{status} where user_id = #{userId}
</update>
<update id="updateUserAvatar" parameterType="SysUser">
update sys_user set avatar = #{avatar} where user_name = #{userName}
</update>
<update id="resetUserPwd" parameterType="SysUser">
update sys_user set password = #{password} where user_name = #{userName}
</update>
<delete id="deleteUserById" parameterType="Long">
update sys_user set del_flag = '2' where user_id = #{userId}
</delete>
<delete id="deleteUserByIds" parameterType="Long">
update sys_user set del_flag = '2' where user_id in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
</mapper>

@ -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)) {

@ -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;
@ -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);
}
}

Loading…
Cancel
Save