first commit
This commit is contained in:
50
ktg-weixin/pom.xml
Normal file
50
ktg-weixin/pom.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.ktg</groupId>
|
||||
<artifactId>ktg</artifactId>
|
||||
<version>3.8.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>ktg-weixin</artifactId>
|
||||
|
||||
<description>微信小程序业务模块</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ktg</groupId>
|
||||
<artifactId>ktg-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 核心模块-->
|
||||
<dependency>
|
||||
<groupId>com.ktg</groupId>
|
||||
<artifactId>ktg-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MES业务模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ktg</groupId>
|
||||
<artifactId>ktg-mes</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger3-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-models</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,59 @@
|
||||
package com.ktg.weixin.controller;
|
||||
|
||||
import com.ktg.common.constant.Constants;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.domain.model.LoginBody;
|
||||
import com.ktg.common.core.domain.model.LoginUser;
|
||||
import com.ktg.framework.web.service.TokenService;
|
||||
import com.ktg.weixin.service.AuthService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
* @author lishitian
|
||||
* @date 2024-09-04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
public class ApiAuthController {
|
||||
|
||||
@Autowired
|
||||
private AuthService authService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @param loginBody 登录信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
public AjaxResult login(@RequestBody LoginBody loginBody) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = authService.login(loginBody.getUsername(), loginBody.getPassword());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登出
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/logout")
|
||||
@ResponseBody
|
||||
public AjaxResult logout(HttpServletRequest request) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||
if (null != loginUser) {
|
||||
tokenService.delLoginUser(loginUser.getToken());
|
||||
}
|
||||
return AjaxResult.success("退出成功!");
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package com.ktg.weixin.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
import com.ktg.common.utils.SecurityUtils;
|
||||
import com.ktg.mes.dv.domain.DvCheckMaintenRecord;
|
||||
import com.ktg.mes.dv.domain.DvCheckMaintenRecordLine;
|
||||
import com.ktg.mes.dv.service.IDvCheckMaintenRecordLineService;
|
||||
import com.ktg.mes.dv.service.IDvCheckMaintenRecordService;
|
||||
import com.ktg.mes.dv.vo.req.DvCheckReq;
|
||||
import com.ktg.mes.dv.vo.res.DvCheckResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 点检保养
|
||||
*
|
||||
* @author jiangbin
|
||||
* @date 2024-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/check")
|
||||
public class ApiCheckController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IDvCheckMaintenRecordService checkMaintenRecordService;
|
||||
@Autowired
|
||||
private IDvCheckMaintenRecordLineService checkMaintenRecordLineService;
|
||||
|
||||
/**
|
||||
* 获取点检/保养单列表
|
||||
*/
|
||||
@GetMapping("/getList")
|
||||
public TableDataInfo list() {
|
||||
startPage();
|
||||
LambdaQueryWrapper<DvCheckMaintenRecord> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.orderByDesc(DvCheckMaintenRecord::getCreateTime);
|
||||
List<DvCheckMaintenRecord> list = checkMaintenRecordService.list(lqw);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取点检/保养单详细信息
|
||||
*/
|
||||
@GetMapping("/getInfo")
|
||||
public AjaxResult getInfo(Long recordId) {
|
||||
if (recordId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
DvCheckMaintenRecord record = checkMaintenRecordService.getById(recordId);
|
||||
LambdaQueryWrapper<DvCheckMaintenRecordLine> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(DvCheckMaintenRecordLine::getRecordId, recordId);
|
||||
List<DvCheckMaintenRecordLine> lines = checkMaintenRecordLineService.list(lqw);
|
||||
DvCheckResponse res = new DvCheckResponse();
|
||||
res.setRecord(record);
|
||||
res.setLines(lines);
|
||||
return AjaxResult.success(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存点检/保养单
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public AjaxResult save(@RequestBody @Validated DvCheckReq req) {
|
||||
DvCheckMaintenRecord dvRepair = checkMaintenRecordService.getById(req.getRecordId());
|
||||
if (dvRepair == null || dvRepair.getRecordId() == null) {
|
||||
return AjaxResult.error("单据不存在");
|
||||
}
|
||||
if (!"1".equals(dvRepair.getStatus())) {
|
||||
return AjaxResult.error("单据已处理或过期");
|
||||
}
|
||||
DvCheckMaintenRecord record = new DvCheckMaintenRecord();
|
||||
record.setRecordId(req.getRecordId());
|
||||
record.setCheckResult(req.getCheckResult());
|
||||
record.setAttr1(JSONArray.toJSONString(req.getAttachmentList()));
|
||||
record.setCheckStatus(req.getCheckStatus());
|
||||
record.setUpdateBy(SecurityUtils.getUsername());
|
||||
record.setUpdateTime(new Date());
|
||||
checkMaintenRecordService.updateById(record);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交点检/保养单
|
||||
*/
|
||||
@PostMapping("/commit")
|
||||
public AjaxResult handle(@RequestBody @Validated DvCheckReq req) {
|
||||
DvCheckMaintenRecord dvRepair = checkMaintenRecordService.getById(req.getRecordId());
|
||||
if (dvRepair == null || dvRepair.getRecordId() == null) {
|
||||
return AjaxResult.error("单据不存在");
|
||||
}
|
||||
if (!"1".equals(dvRepair.getStatus())) {
|
||||
return AjaxResult.error("单据已处理或过期");
|
||||
}
|
||||
DvCheckMaintenRecord record = new DvCheckMaintenRecord();
|
||||
record.setRecordId(req.getRecordId());
|
||||
record.setCheckResult(req.getCheckResult());
|
||||
record.setAttr1(JSONArray.toJSONString(req.getAttachmentList()));
|
||||
record.setCheckStatus(req.getCheckStatus());
|
||||
record.setStatus("2");
|
||||
Date now = new Date();
|
||||
record.setCheckTime(now);
|
||||
record.setCheckBy(SecurityUtils.getUsername());
|
||||
record.setUpdateTime(now);
|
||||
record.setUpdateBy(SecurityUtils.getUsername());
|
||||
checkMaintenRecordService.updateById(record);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,337 @@
|
||||
package com.ktg.weixin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ktg.common.config.RuoYiConfig;
|
||||
import com.ktg.common.constant.Constants;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.domain.entity.SysDictData;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.common.utils.file.FileUploadUtils;
|
||||
import com.ktg.common.utils.file.FileUtils;
|
||||
import com.ktg.framework.config.ServerConfig;
|
||||
import com.ktg.mes.dv.domain.DvMachinery;
|
||||
import com.ktg.mes.dv.service.IDvMachineryService;
|
||||
import com.ktg.mes.md.domain.MdClient;
|
||||
import com.ktg.mes.md.domain.MdItem;
|
||||
import com.ktg.mes.md.domain.MdVendor;
|
||||
import com.ktg.mes.md.domain.MdWorkstation;
|
||||
import com.ktg.mes.md.service.IMdClientService;
|
||||
import com.ktg.mes.md.service.IMdItemService;
|
||||
import com.ktg.mes.md.service.IMdVendorService;
|
||||
import com.ktg.mes.md.service.IMdWorkstationService;
|
||||
import com.ktg.mes.pro.domain.ProWorkorder;
|
||||
import com.ktg.mes.pro.service.IProWorkorderService;
|
||||
import com.ktg.mes.qc.domain.QcTemplateIndex;
|
||||
import com.ktg.mes.qc.domain.QcTemplateProduct;
|
||||
import com.ktg.mes.qc.service.IQcTemplateIndexService;
|
||||
import com.ktg.mes.qc.service.IQcTemplateProductService;
|
||||
import com.ktg.system.service.ISysDictTypeService;
|
||||
import com.ktg.system.strategy.AutoCodeUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用请求处理
|
||||
*
|
||||
* @author lishitian
|
||||
* @date 2024-09-04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/common")
|
||||
public class ApiCommonController {
|
||||
private static final Logger log = LoggerFactory.getLogger(ApiCommonController.class);
|
||||
|
||||
@Autowired
|
||||
private ISysDictTypeService dictTypeService;
|
||||
@Autowired
|
||||
private IDvMachineryService dvMachineryService;
|
||||
@Autowired
|
||||
private IMdItemService mdItemService;
|
||||
@Autowired
|
||||
private IMdVendorService mdVendorService;
|
||||
@Autowired
|
||||
private IMdClientService mdClientService;
|
||||
@Autowired
|
||||
private IQcTemplateProductService qcTemplateProductService;
|
||||
@Autowired
|
||||
private IQcTemplateIndexService qcTemplateIndexService;
|
||||
@Autowired
|
||||
private IMdWorkstationService workstationService;
|
||||
@Autowired
|
||||
private IProWorkorderService workorderService;
|
||||
@Autowired
|
||||
private ServerConfig serverConfig;
|
||||
|
||||
@Autowired
|
||||
private AutoCodeUtil autoCodeUtil;
|
||||
|
||||
private static final String FILE_DELIMETER = ",";
|
||||
|
||||
/**
|
||||
* 自动生成编码
|
||||
* QC_IQC_CODE: 来料检验单编码
|
||||
* IPQC_CODE:过程检验单编码
|
||||
* OQC_CODE:出货检验单编码
|
||||
* REPAIR_CODE:维修单编码
|
||||
*
|
||||
* @param ruleCode
|
||||
* @param inputCharacter
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = {"/get/{ruleCode}/{inputCharacter}", "/get/{ruleCode}"})
|
||||
public String getAutoCode(@PathVariable String ruleCode, @PathVariable(required = false) String inputCharacter) {
|
||||
return autoCodeUtil.genSerialCode(ruleCode, inputCharacter);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@GetMapping(value = "/selectDictDataByType/{dictType}")
|
||||
public AjaxResult selectDictDataByType(@PathVariable String dictType) {
|
||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNull(data)) {
|
||||
data = new ArrayList<>();
|
||||
}
|
||||
return AjaxResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备列表
|
||||
*/
|
||||
@GetMapping("/getMachineryList")
|
||||
public AjaxResult getMachineryList() {
|
||||
DvMachinery dvMachinery = new DvMachinery();
|
||||
dvMachinery.setMachineryType("1");
|
||||
List<DvMachinery> list = dvMachineryService.selectDvMachineryList(dvMachinery);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取产品物料列表
|
||||
*/
|
||||
@GetMapping("/getItemList")
|
||||
public AjaxResult getItemList() {
|
||||
List<MdItem> list = mdItemService.selectMdItemAll();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户列表
|
||||
*/
|
||||
@GetMapping("/getClientList")
|
||||
public AjaxResult getClientList() {
|
||||
List<MdClient> list = mdClientService.selectMdClientList(new MdClient());
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取供货商列表
|
||||
*/
|
||||
@GetMapping("/getVendorList")
|
||||
public AjaxResult getVendorList() {
|
||||
List<MdVendor> list = mdVendorService.selectMdVendorList(new MdVendor());
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据产品id获取检验项
|
||||
*/
|
||||
@GetMapping("/getQcTemplateByItemId")
|
||||
public AjaxResult getQcTemplateByItemId(Long itemId) {
|
||||
if (itemId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
QcTemplateProduct param = new QcTemplateProduct();
|
||||
param.setItemId(itemId);
|
||||
List<QcTemplateProduct> templates = qcTemplateProductService.selectQcTemplateProductList(param);
|
||||
if (CollUtil.isNotEmpty(templates)) {
|
||||
QcTemplateProduct qcTemplateProduct = templates.get(0);
|
||||
QcTemplateIndex param1 = new QcTemplateIndex();
|
||||
param1.setTemplateId(qcTemplateProduct.getTemplateId());
|
||||
List<QcTemplateIndex> indexes = qcTemplateIndexService.selectQcTemplateIndexList(param1);
|
||||
if (CollUtil.isNotEmpty(indexes)) {
|
||||
return AjaxResult.success(indexes);
|
||||
} else {
|
||||
return AjaxResult.error("当前产品未配置检测项!");
|
||||
}
|
||||
} else {
|
||||
return AjaxResult.error("当前产品未配置检测模板!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工作站列表
|
||||
*/
|
||||
@GetMapping("/getWorkstationList")
|
||||
public AjaxResult getWorkstationList() {
|
||||
List<MdWorkstation> list = workstationService.selectMdWorkstationList(new MdWorkstation());
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取生产工单列表
|
||||
*/
|
||||
@GetMapping("/getWorkorderList")
|
||||
public AjaxResult getWorkorderList() {
|
||||
List<ProWorkorder> list = workorderService.selectProWorkorderList(new ProWorkorder());
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据生产工单获取产品检验项
|
||||
*/
|
||||
@GetMapping("/getQcTemplateByWorkorderId")
|
||||
public AjaxResult getQcTemplate(Long workorderId) {
|
||||
if (workorderId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
ProWorkorder proWorkorder = workorderService.selectProWorkorderByWorkorderId(workorderId);
|
||||
QcTemplateProduct param = new QcTemplateProduct();
|
||||
param.setItemId(proWorkorder.getProductId());
|
||||
List<QcTemplateProduct> templates = qcTemplateProductService.selectQcTemplateProductList(param);
|
||||
if (CollUtil.isNotEmpty(templates)) {
|
||||
QcTemplateProduct qcTemplateProduct = templates.get(0);
|
||||
QcTemplateIndex param1 = new QcTemplateIndex();
|
||||
param1.setTemplateId(qcTemplateProduct.getTemplateId());
|
||||
List<QcTemplateIndex> indexes = qcTemplateIndexService.selectQcTemplateIndexList(param1);
|
||||
if (CollUtil.isNotEmpty(indexes)) {
|
||||
return AjaxResult.success(indexes);
|
||||
} else {
|
||||
return AjaxResult.error("当前产品未配置检测项!");
|
||||
}
|
||||
} else {
|
||||
return AjaxResult.error("当前产品未配置检测模板!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用下载请求
|
||||
*
|
||||
* @param fileName 文件名称
|
||||
* @param delete 是否删除
|
||||
*/
|
||||
@GetMapping("/download")
|
||||
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
|
||||
try {
|
||||
if (!FileUtils.checkAllowDownload(fileName)) {
|
||||
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
||||
}
|
||||
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
||||
String filePath = RuoYiConfig.getDownloadPath() + fileName;
|
||||
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
FileUtils.setAttachmentResponseHeader(response, realFileName);
|
||||
FileUtils.writeBytes(filePath, response.getOutputStream());
|
||||
if (delete) {
|
||||
FileUtils.deleteFile(filePath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用上传请求(单个)
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult uploadFile(MultipartFile file) throws Exception {
|
||||
try {
|
||||
// 上传文件路径
|
||||
String filePath = RuoYiConfig.getUploadPath();
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String baseUrl = "https://www.sdhuixinjituan.com:8081";
|
||||
String url = baseUrl + fileName;
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("url", url);
|
||||
ajax.put("fileName", fileName);
|
||||
ajax.put("newFileName", FileUtils.getName(fileName));
|
||||
ajax.put("originalFilename", file.getOriginalFilename());
|
||||
return ajax;
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用上传请求(多个)
|
||||
*/
|
||||
@PostMapping("/uploads")
|
||||
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception {
|
||||
try {
|
||||
// 上传文件路径
|
||||
String filePath = RuoYiConfig.getUploadPath();
|
||||
List<String> urls = new ArrayList<String>();
|
||||
List<String> fileNames = new ArrayList<String>();
|
||||
List<String> newFileNames = new ArrayList<String>();
|
||||
List<String> originalFilenames = new ArrayList<String>();
|
||||
for (MultipartFile file : files) {
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
urls.add(url);
|
||||
fileNames.add(fileName);
|
||||
newFileNames.add(FileUtils.getName(fileName));
|
||||
originalFilenames.add(file.getOriginalFilename());
|
||||
}
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
|
||||
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
|
||||
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
|
||||
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
|
||||
return ajax;
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地资源通用下载
|
||||
*/
|
||||
@GetMapping("/download/resource")
|
||||
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
|
||||
throws Exception {
|
||||
try {
|
||||
if (!FileUtils.checkAllowDownload(resource)) {
|
||||
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
|
||||
}
|
||||
// 本地资源路径
|
||||
String localPath = RuoYiConfig.getProfile();
|
||||
// 数据库资源地址
|
||||
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
|
||||
// 下载名称
|
||||
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
FileUtils.setAttachmentResponseHeader(response, downloadName);
|
||||
FileUtils.writeBytes(downloadPath, response.getOutputStream());
|
||||
} catch (Exception e) {
|
||||
log.error("下载文件失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/uploadMinio")
|
||||
public AjaxResult uploadFileMinio(MultipartFile file) throws Exception {
|
||||
try {
|
||||
String fileName = FileUploadUtils.uploadMinio(file);
|
||||
AjaxResult rt = AjaxResult.success();
|
||||
rt.put("url", fileName);
|
||||
rt.put("fileName", fileName);
|
||||
rt.put("newFileName", FileUtils.getName(fileName));
|
||||
rt.put("originalFileName", file.getOriginalFilename());
|
||||
return rt;
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,353 @@
|
||||
package com.ktg.weixin.controller;
|
||||
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.domain.entity.SysUser;
|
||||
import com.ktg.common.utils.SecurityUtils;
|
||||
import com.ktg.mes.dv.service.IDvMachineryService;
|
||||
import com.ktg.mes.dv.vo.res.DvMachineryResponse;
|
||||
import com.ktg.mes.pro.service.IProMachineryJobService;
|
||||
import com.ktg.mes.pro.service.IProWorkorderService;
|
||||
import com.ktg.mes.pro.vo.req.*;
|
||||
import com.ktg.mes.pro.vo.res.ProJobProgressDetail;
|
||||
import com.ktg.mes.pro.vo.res.ProJobProgressResponse;
|
||||
import com.ktg.mes.pro.vo.res.ProWorkorderResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 生产进度
|
||||
*
|
||||
* @author lishitian
|
||||
* @date 2024-09-04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/pro")
|
||||
public class ApiProController extends BaseController {
|
||||
@Autowired
|
||||
private IDvMachineryService dvMachineryService;
|
||||
@Autowired
|
||||
private IProWorkorderService proWorkorderService;
|
||||
@Autowired
|
||||
private IProMachineryJobService proMachineryJobService;
|
||||
|
||||
/**
|
||||
* 获取设备列表
|
||||
*/
|
||||
@GetMapping("/getMachineryList")
|
||||
public AjaxResult getMachineryList() {
|
||||
List<DvMachineryResponse> list = dvMachineryService.getMachineryJobProgressList();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取(已确认)生产工单列表
|
||||
*/
|
||||
@GetMapping("/getProWorkOrderList")
|
||||
public AjaxResult getProWorkOrderList(Long machineryId) {
|
||||
if (machineryId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
List<ProWorkorderResponse> list = proWorkorderService.getProWorkOrderList(machineryId);
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备生产作业进度列表
|
||||
*
|
||||
* @param jobId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getJobProgressList")
|
||||
public AjaxResult getJobProgressList(Long jobId) {
|
||||
if (jobId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
ProJobProgressResponse res = proMachineryJobService.getJobProgressList(jobId);
|
||||
return AjaxResult.success(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看设备生产作业进度详情
|
||||
*
|
||||
* @param progressId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getJobProgressDetail")
|
||||
public AjaxResult getJobProgressDetail(Long progressId) {
|
||||
if (progressId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
ProJobProgressDetail res = proMachineryJobService.getJobProgressDetail(progressId);
|
||||
return AjaxResult.success(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择生产工单
|
||||
* <p>
|
||||
* return 生产作业id
|
||||
*/
|
||||
@PostMapping("/chooseWorkorder")
|
||||
public AjaxResult chooseWorkorder(@Validated @RequestBody ChooseWorkorderRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Map<String, Object> res = proMachineryJobService.chooseWorkorder(req, currentUser);
|
||||
return AjaxResult.success(res);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤1-加料
|
||||
*/
|
||||
@PostMapping("/jl")
|
||||
public AjaxResult jl(@Validated @RequestBody ProJLRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.jl(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤2-开火升温
|
||||
*/
|
||||
@PostMapping("/khsw")
|
||||
public AjaxResult khsw(@Validated @RequestBody ProKHSWRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.khsw(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤3-开始搅拌
|
||||
*/
|
||||
@PostMapping("/startJb")
|
||||
public AjaxResult startJb(@Validated @RequestBody ProJBRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
proMachineryJobService.startJb(req, currentUser);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤3-结束搅拌
|
||||
*/
|
||||
@PostMapping("/finishJb")
|
||||
public AjaxResult finishJb(@Validated @RequestBody ProJBRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.finishJb(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤4-扒渣
|
||||
*/
|
||||
@PostMapping("/bz")
|
||||
public AjaxResult bz(@Validated @RequestBody ProBZRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.bz(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤5-搅拌取样
|
||||
*/
|
||||
@PostMapping("/jbqy")
|
||||
public AjaxResult jbqy(@Validated @RequestBody ProJBQYRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.jbqy(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤6-开始精炼除气
|
||||
*/
|
||||
@PostMapping("/startJlcq")
|
||||
public AjaxResult startJlcq(@Validated @RequestBody ProJLCQRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
proMachineryJobService.startJlcq(req, currentUser);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤6-结束精炼除气
|
||||
*/
|
||||
@PostMapping("/finishJlcq")
|
||||
public AjaxResult finishJlcq(@Validated @RequestBody ProJLCQRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.finishJlcq(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤7-取样化验 007
|
||||
*/
|
||||
@PostMapping("/qyhy")
|
||||
public AjaxResult qyhy(@Validated @RequestBody ProQYHYRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.qyhy(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤7.1-炉内成分调节 008
|
||||
*/
|
||||
@PostMapping("/lncftj")
|
||||
public AjaxResult lncftj(@Validated @RequestBody ProLNCFTJRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.lncftj(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 步骤8-加镁锭 009
|
||||
*/
|
||||
@PostMapping("/jmd")
|
||||
public AjaxResult jmd(@Validated @RequestBody ProJMDRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.jmd(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 步骤9-取样化验(镁锭) 007
|
||||
// */
|
||||
//
|
||||
// /**
|
||||
// * 步骤9.1-炉内成分调节(镁锭) 008
|
||||
// */
|
||||
|
||||
/**
|
||||
* 步骤10-开始静止 010
|
||||
*/
|
||||
@PostMapping("/startJz")
|
||||
public AjaxResult startJz(@Validated @RequestBody ProJLCQRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
proMachineryJobService.startJz(req, currentUser);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤10-结束静止 010
|
||||
*/
|
||||
@PostMapping("/finishJz")
|
||||
public AjaxResult finishJz(@Validated @RequestBody ProJLCQRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.finishJz(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤11-放水浇筑 011
|
||||
*/
|
||||
@PostMapping("/fsjz")
|
||||
public AjaxResult fsjz(@Validated @RequestBody ProFSJZRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.fsjz(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤12-开始脱膜 012
|
||||
*/
|
||||
@PostMapping("/startTm")
|
||||
public AjaxResult startTm(@Validated @RequestBody ProTMRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
proMachineryJobService.startTm(req, currentUser);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤12-结束脱膜 012
|
||||
*/
|
||||
@PostMapping("/finishTm")
|
||||
public AjaxResult finishTm(@Validated @RequestBody ProTMRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long nextProgressId = proMachineryJobService.finishTm(req, currentUser);
|
||||
return AjaxResult.success(nextProgressId);
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤13-质检 013
|
||||
*/
|
||||
@PostMapping("/zj")
|
||||
public AjaxResult zj(@Validated @RequestBody ProZJRequest req) {
|
||||
try {
|
||||
SysUser currentUser = SecurityUtils.getLoginUser().getUser();
|
||||
proMachineryJobService.zj(req, currentUser);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.ktg.weixin.controller;
|
||||
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
import com.ktg.mes.qc.domain.QcIpqc;
|
||||
import com.ktg.mes.qc.domain.QcIpqcLine;
|
||||
import com.ktg.mes.qc.service.IQcIpqcLineService;
|
||||
import com.ktg.mes.qc.service.IQcIpqcService;
|
||||
import com.ktg.mes.qc.vo.req.AddQcIpqcReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 过程检验单
|
||||
*
|
||||
* @author jiangbin
|
||||
* @date 2024-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/qcIpqc")
|
||||
public class ApiQcIpqcController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IQcIpqcService qcIpqcService;
|
||||
@Autowired
|
||||
private IQcIpqcLineService qcIpqcLineService;
|
||||
|
||||
/**
|
||||
* 查询过程检验单列表
|
||||
*/
|
||||
@GetMapping("/getList")
|
||||
public TableDataInfo list() {
|
||||
startPage();
|
||||
List<QcIpqc> list = qcIpqcService.selectQcIpqcList(new QcIpqc());
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取过程检验单详细信息
|
||||
*/
|
||||
@GetMapping("/getInfo")
|
||||
public AjaxResult getInfo(Long ipqcId) {
|
||||
if (ipqcId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
QcIpqc qcIqc = qcIpqcService.selectQcIpqcByIpqcId(ipqcId);
|
||||
QcIpqcLine param = new QcIpqcLine();
|
||||
param.setIpqcId(ipqcId);
|
||||
List<QcIpqcLine> lines = qcIpqcLineService.selectQcIpqcLineList(param);
|
||||
Map<String, Object> map = new HashMap();
|
||||
map.put("info", qcIqc);
|
||||
map.put("lines", lines);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存过程检验单
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public AjaxResult save(@RequestBody @Validated AddQcIpqcReq req) {
|
||||
try {
|
||||
qcIpqcService.saveWxQcIpqc(req);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交过程检验单
|
||||
*/
|
||||
@PostMapping("/commit")
|
||||
public AjaxResult commit(@RequestBody @Validated(AddQcIpqcReq.Commit.class) AddQcIpqcReq req) {
|
||||
try {
|
||||
qcIpqcService.commitWxQcIpqc(req);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除过程检验单
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
public AjaxResult remove(Long ipqcId) {
|
||||
if (ipqcId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
QcIpqc qcIpqc = qcIpqcService.selectQcIpqcByIpqcId(ipqcId);
|
||||
if (qcIpqc == null || qcIpqc.getIpqcId() == null) {
|
||||
return AjaxResult.error("过程检验单不存在");
|
||||
}
|
||||
if (!"PREPARE".equals(qcIpqc.getStatus())) {
|
||||
return AjaxResult.error("当前状态不允许删除");
|
||||
}
|
||||
return toAjax(qcIpqcService.deleteQcIpqcByIpqcId(ipqcId));
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.ktg.weixin.controller;
|
||||
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
import com.ktg.mes.qc.domain.QcIqc;
|
||||
import com.ktg.mes.qc.domain.QcIqcLine;
|
||||
import com.ktg.mes.qc.service.IQcIqcLineService;
|
||||
import com.ktg.mes.qc.service.IQcIqcService;
|
||||
import com.ktg.mes.qc.vo.req.AddQcIqcReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 来料检验单
|
||||
*
|
||||
* @author jiangbin
|
||||
* @date 2024-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/qcIqc")
|
||||
public class ApiQcIqcController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IQcIqcService qcIqcService;
|
||||
@Autowired
|
||||
private IQcIqcLineService qcIqcLineService;
|
||||
|
||||
/**
|
||||
* 查询来料检验单列表
|
||||
*/
|
||||
@GetMapping("/getList")
|
||||
public TableDataInfo list() {
|
||||
startPage();
|
||||
List<QcIqc> list = qcIqcService.selectQcIqcList(new QcIqc());
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取来料检验单详细信息
|
||||
*/
|
||||
@GetMapping("/getInfo")
|
||||
public AjaxResult getInfo(Long iqcId) {
|
||||
if (iqcId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
QcIqc qcIqc = qcIqcService.selectQcIqcByIqcId(iqcId);
|
||||
QcIqcLine param = new QcIqcLine();
|
||||
param.setIqcId(iqcId);
|
||||
List<QcIqcLine> lines = qcIqcLineService.selectQcIqcLineList(param);
|
||||
Map<String, Object> map = new HashMap();
|
||||
map.put("info", qcIqc);
|
||||
map.put("lines", lines);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存来料检验单
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public AjaxResult save(@RequestBody @Validated AddQcIqcReq req) {
|
||||
try {
|
||||
qcIqcService.saveWxQcIqc(req);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交来料检验单
|
||||
*/
|
||||
@PostMapping("/commit")
|
||||
public AjaxResult commit(@RequestBody @Validated(AddQcIqcReq.Commit.class) AddQcIqcReq req) {
|
||||
try {
|
||||
qcIqcService.commitWxQcIqc(req);
|
||||
return AjaxResult.success();
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除来料检验单
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
public AjaxResult remove(Long iqcId) {
|
||||
if (iqcId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
QcIqc qcIqc = qcIqcService.selectQcIqcByIqcId(iqcId);
|
||||
if (qcIqc == null || qcIqc.getIqcId() == null) {
|
||||
return AjaxResult.error("来料检验单不存在");
|
||||
}
|
||||
if (!"PREPARE".equals(qcIqc.getStatus())) {
|
||||
return AjaxResult.error("当前状态不允许删除");
|
||||
}
|
||||
return toAjax(qcIqcService.deleteQcIqcByIqcId(iqcId));
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
package com.ktg.weixin.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.mes.qc.domain.QcOqc;
|
||||
import com.ktg.mes.qc.domain.QcTemplateProduct;
|
||||
import com.ktg.mes.qc.service.IQcOqcService;
|
||||
import com.ktg.mes.qc.service.IQcTemplateProductService;
|
||||
import com.ktg.mes.qc.vo.req.AddQcOqcReq;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 出货检验单
|
||||
*
|
||||
* @author jiangbin
|
||||
* @date 2024-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/qcOqc")
|
||||
public class ApiQcOqcController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IQcOqcService qcOqcService;
|
||||
@Autowired
|
||||
private IQcTemplateProductService qcTemplateProductService;
|
||||
|
||||
/**
|
||||
* 查询出货检验单列表
|
||||
*/
|
||||
@GetMapping("/getList")
|
||||
public TableDataInfo list() {
|
||||
startPage();
|
||||
List<QcOqc> list = qcOqcService.selectQcOqcList(new QcOqc());
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取出货检验单详细信息
|
||||
*/
|
||||
@GetMapping("/getInfo")
|
||||
public AjaxResult getInfo(Long oqcId) {
|
||||
if (oqcId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
return AjaxResult.success(qcOqcService.selectQcOqcByOqcId(oqcId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增出货检验单
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
public AjaxResult save(@RequestBody @Validated AddQcOqcReq req) {
|
||||
Date now = new Date();
|
||||
if (req.getOqcId() == null) {
|
||||
QcOqc qcOqc = new QcOqc();
|
||||
BeanUtils.copyProperties(req, qcOqc);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("bq", StringUtils.isBlank(req.getBq()) ? "" : req.getBq());
|
||||
map.put("dw", StringUtils.isBlank(req.getDw()) ? "" : req.getDw());
|
||||
map.put("wg", StringUtils.isBlank(req.getWg()) ? "" : req.getWg());
|
||||
qcOqc.setAttr1(JSON.toJSONString(map));
|
||||
qcOqc.setStatus("PREPARE");
|
||||
qcOqc.setCreateTime(now);
|
||||
qcOqc.setCreateBy(getUsername());
|
||||
if (UserConstants.NOT_UNIQUE.equals(qcOqcService.checkOqcCodeUnique(qcOqc))) {
|
||||
return AjaxResult.error("出货单编号已存在!");
|
||||
}
|
||||
//自动获取对应的检测模板
|
||||
QcTemplateProduct param = new QcTemplateProduct();
|
||||
param.setItemId(qcOqc.getItemId());
|
||||
List<QcTemplateProduct> templates = qcTemplateProductService.selectQcTemplateProductList(param);
|
||||
if (CollUtil.isNotEmpty(templates)) {
|
||||
qcOqc.setTemplateId(templates.get(0).getTemplateId());
|
||||
} else {
|
||||
return AjaxResult.error("当前产品未配置检测模板!");
|
||||
}
|
||||
qcOqcService.insertQcOqc(qcOqc);
|
||||
} else {
|
||||
QcOqc qcOqc = qcOqcService.selectQcOqcByOqcId(req.getOqcId());
|
||||
if (qcOqc == null) {
|
||||
return AjaxResult.error("出货单不存在");
|
||||
}
|
||||
if (!"PREPARE".equals(qcOqc.getStatus())) {
|
||||
return AjaxResult.error("出货单已提交,请勿重复操作");
|
||||
}
|
||||
BeanUtils.copyProperties(req, qcOqc);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("bq", StringUtils.isBlank(req.getBq()) ? "" : req.getBq());
|
||||
map.put("dw", StringUtils.isBlank(req.getDw()) ? "" : req.getDw());
|
||||
map.put("wg", StringUtils.isBlank(req.getWg()) ? "" : req.getWg());
|
||||
qcOqc.setAttr1(JSON.toJSONString(map));
|
||||
qcOqc.setStatus("PREPARE");
|
||||
qcOqc.setUpdateTime(now);
|
||||
qcOqc.setUpdateBy(getUsername());
|
||||
if (UserConstants.NOT_UNIQUE.equals(qcOqcService.checkOqcCodeUnique(qcOqc))) {
|
||||
return AjaxResult.error("出货单编号已存在!");
|
||||
}
|
||||
qcOqcService.updateQcOqc(qcOqc);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 提交出货检验单
|
||||
*/
|
||||
@PostMapping("/commit")
|
||||
public AjaxResult commit(@RequestBody @Validated(AddQcOqcReq.Commit.class) AddQcOqcReq req) {
|
||||
Date now = new Date();
|
||||
if (req.getOqcId() == null) {
|
||||
QcOqc qcOqc = new QcOqc();
|
||||
BeanUtils.copyProperties(req, qcOqc);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("bq", StringUtils.isBlank(req.getBq()) ? "" : req.getBq());
|
||||
map.put("dw", StringUtils.isBlank(req.getDw()) ? "" : req.getDw());
|
||||
map.put("wg", StringUtils.isBlank(req.getWg()) ? "" : req.getWg());
|
||||
qcOqc.setAttr1(JSON.toJSONString(map));
|
||||
qcOqc.setStatus("CONFIRMED");
|
||||
qcOqc.setCreateTime(now);
|
||||
qcOqc.setCreateBy(getUsername());
|
||||
qcOqc.setInspectDate(now);
|
||||
qcOqc.setInspector(getUsername());
|
||||
if (UserConstants.NOT_UNIQUE.equals(qcOqcService.checkOqcCodeUnique(qcOqc))) {
|
||||
return AjaxResult.error("单据编号已存在!");
|
||||
}
|
||||
//自动获取对应的检测模板
|
||||
QcTemplateProduct param = new QcTemplateProduct();
|
||||
param.setItemId(qcOqc.getItemId());
|
||||
List<QcTemplateProduct> templates = qcTemplateProductService.selectQcTemplateProductList(param);
|
||||
if (CollUtil.isNotEmpty(templates)) {
|
||||
qcOqc.setTemplateId(templates.get(0).getTemplateId());
|
||||
} else {
|
||||
return AjaxResult.error("当前产品未配置检测模板!");
|
||||
}
|
||||
qcOqcService.insertQcOqc(qcOqc);
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
QcOqc qcOqc = qcOqcService.selectQcOqcByOqcId(req.getOqcId());
|
||||
if (qcOqc == null) {
|
||||
return AjaxResult.error("出货单不存在");
|
||||
}
|
||||
if (!"PREPARE".equals(qcOqc.getStatus())) {
|
||||
return AjaxResult.error("出货单已提交,请勿重复操作");
|
||||
}
|
||||
BeanUtils.copyProperties(req, qcOqc);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("bq", StringUtils.isBlank(req.getBq()) ? "" : req.getBq());
|
||||
map.put("dw", StringUtils.isBlank(req.getDw()) ? "" : req.getDw());
|
||||
map.put("wg", StringUtils.isBlank(req.getWg()) ? "" : req.getWg());
|
||||
qcOqc.setAttr1(JSON.toJSONString(map));
|
||||
qcOqc.setStatus("CONFIRMED");
|
||||
qcOqc.setInspectDate(now);
|
||||
qcOqc.setInspector(getUsername());
|
||||
qcOqc.setUpdateTime(now);
|
||||
qcOqc.setUpdateBy(getUsername());
|
||||
qcOqcService.updateQcOqc(qcOqc);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除出货检验单
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
public AjaxResult remove(Long oqcId) {
|
||||
if (oqcId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
QcOqc qcOqc = qcOqcService.selectQcOqcByOqcId(oqcId);
|
||||
if (qcOqc == null || qcOqc.getOqcId() == null) {
|
||||
return AjaxResult.error("出货检验单不存在");
|
||||
}
|
||||
if (!"PREPARE".equals(qcOqc.getStatus())) {
|
||||
return AjaxResult.error("当前状态不允许删除");
|
||||
}
|
||||
return toAjax(qcOqcService.deleteQcOqcByOqcId(oqcId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package com.ktg.weixin.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
import com.ktg.common.utils.SecurityUtils;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.mes.dv.domain.DvRepair;
|
||||
import com.ktg.mes.dv.service.IDvRepairService;
|
||||
import com.ktg.mes.dv.vo.req.AddDvRepairReq;
|
||||
import com.ktg.mes.dv.vo.req.DvRepairReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 维修单
|
||||
*
|
||||
* @author jiangbin
|
||||
* @date 2024-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/repair")
|
||||
public class ApiRepairController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IDvRepairService dvRepairService;
|
||||
|
||||
/**
|
||||
* 获取维修单列表
|
||||
*/
|
||||
@GetMapping("/getList")
|
||||
public TableDataInfo list() {
|
||||
startPage();
|
||||
List<DvRepair> list = dvRepairService.selectWxRepairList();
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备维修单详细信息
|
||||
*/
|
||||
@GetMapping("/getInfo")
|
||||
public AjaxResult getInfo(Long repairId) {
|
||||
if (repairId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
return AjaxResult.success(dvRepairService.selectDvRepairByRepairId(repairId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备维修单
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody @Validated AddDvRepairReq req) {
|
||||
DvRepair repair = new DvRepair();
|
||||
Date now = new Date();
|
||||
repair.setRepairCode(req.getRepairCode());
|
||||
repair.setRepairName(req.getRepairName());
|
||||
repair.setMachineryId(req.getMachineryId());
|
||||
repair.setMachineryCode(req.getMachineryCode());
|
||||
repair.setMachineryName(req.getMachineryName());
|
||||
repair.setMachineryBrand(req.getMachineryBrand());
|
||||
repair.setMachineryTypeId(req.getMachineryTypeId());
|
||||
repair.setRemark(req.getRemark());
|
||||
repair.setRequireDate(now);
|
||||
repair.setCreateTime(now);
|
||||
repair.setCreateBy(SecurityUtils.getUsername());
|
||||
repair.setStatus("APPROVING");
|
||||
if (UserConstants.NOT_UNIQUE.equals(dvRepairService.checkCodeUnique(repair))) {
|
||||
return AjaxResult.error("维修单编号已存在!");
|
||||
}
|
||||
return toAjax(dvRepairService.insertDvRepair(repair));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备维修单
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
public AjaxResult remove(Long repairId) {
|
||||
if (repairId == null) {
|
||||
return AjaxResult.error("参数异常");
|
||||
}
|
||||
DvRepair dvRepair = dvRepairService.selectDvRepairByRepairId(repairId);
|
||||
if (dvRepair == null || dvRepair.getRepairId() == null) {
|
||||
return AjaxResult.error("维修单不存在");
|
||||
}
|
||||
if (!"APPROVING".equals(dvRepair.getStatus())) {
|
||||
return AjaxResult.error("当前状态不允许删除");
|
||||
}
|
||||
return toAjax(dvRepairService.deleteDvRepairByRepairId(repairId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理设备维修单
|
||||
*/
|
||||
@PostMapping("/handle")
|
||||
public AjaxResult handle(@RequestBody @Validated DvRepairReq req) {
|
||||
DvRepair dvRepair = dvRepairService.selectDvRepairByRepairId(req.getRepairId());
|
||||
if (dvRepair == null || dvRepair.getRepairId() == null) {
|
||||
return AjaxResult.error("维修单不存在");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dvRepair.getRepairResult())) {
|
||||
return AjaxResult.error("该维修单已处理");
|
||||
}
|
||||
DvRepair dvRepairUpdate = new DvRepair();
|
||||
dvRepairUpdate.setRepairId(req.getRepairId());
|
||||
dvRepairUpdate.setRepairResult(req.getRepairResult());
|
||||
dvRepairUpdate.setFinishDate(new Date());
|
||||
dvRepairUpdate.setAcceptedBy(SecurityUtils.getUsername());
|
||||
dvRepairUpdate.setStatus("FINISHED");
|
||||
dvRepairUpdate.setAttr1(JSONArray.toJSONString(req.getAttachmentList()));
|
||||
dvRepairUpdate.setUpdateBy(SecurityUtils.getUsername());
|
||||
dvRepairService.updateDvRepair(dvRepairUpdate);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package com.ktg.weixin.controller;
|
||||
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.core.domain.entity.SysUser;
|
||||
import com.ktg.common.core.domain.model.LoginUser;
|
||||
import com.ktg.common.utils.SecurityUtils;
|
||||
import com.ktg.framework.web.service.TokenService;
|
||||
import com.ktg.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* 个人信息 业务处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/user")
|
||||
public class ApiUserController extends BaseController {
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*/
|
||||
@GetMapping("/profile")
|
||||
public AjaxResult getUserProfile() {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
SysUser user = loginUser.getUser();
|
||||
AjaxResult ajax = AjaxResult.success(user);
|
||||
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
||||
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@PostMapping("/updatePwd")
|
||||
public AjaxResult updatePwd(@Validated @RequestBody UpdatePwdReq req) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
String userName = loginUser.getUsername();
|
||||
String password = loginUser.getPassword();
|
||||
if (!SecurityUtils.matchesPassword(req.getOldPassword(), password)) {
|
||||
return AjaxResult.error("修改密码失败,旧密码错误");
|
||||
}
|
||||
if (SecurityUtils.matchesPassword(req.getNewPassword(), password)) {
|
||||
return AjaxResult.error("新密码不能与旧密码相同");
|
||||
}
|
||||
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(req.getNewPassword())) > 0) {
|
||||
// 更新缓存用户密码
|
||||
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(req.getNewPassword()));
|
||||
tokenService.setLoginUser(loginUser);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
return AjaxResult.error("修改密码异常,请联系管理员");
|
||||
}
|
||||
|
||||
public static class UpdatePwdReq {
|
||||
@NotEmpty(message = "旧密码不能为空")
|
||||
private String oldPassword;
|
||||
@NotEmpty(message = "新密码不能为空")
|
||||
private String newPassword;
|
||||
|
||||
public String getOldPassword() {
|
||||
return oldPassword;
|
||||
}
|
||||
|
||||
public void setOldPassword(String oldPassword) {
|
||||
this.oldPassword = oldPassword;
|
||||
}
|
||||
|
||||
public String getNewPassword() {
|
||||
return newPassword;
|
||||
}
|
||||
|
||||
public void setNewPassword(String newPassword) {
|
||||
this.newPassword = newPassword;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// * 修改用户
|
||||
// */
|
||||
// @PostMapping("/updateUserProfile")
|
||||
// public AjaxResult updateUserProfile(@RequestBody SysUser user) {
|
||||
// LoginUser loginUser = getLoginUser();
|
||||
// SysUser sysUser = loginUser.getUser();
|
||||
// user.setUserName(sysUser.getUserName());
|
||||
// if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
// && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||
// return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
// }
|
||||
// if (StringUtils.isNotEmpty(user.getEmail())
|
||||
// && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
// return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
// }
|
||||
// user.setUserId(sysUser.getUserId());
|
||||
// user.setPassword(null);
|
||||
// if (userService.updateUserProfile(user) > 0) {
|
||||
// // 更新缓存用户信息
|
||||
// sysUser.setNickName(user.getNickName());
|
||||
// sysUser.setPhonenumber(user.getPhonenumber());
|
||||
// sysUser.setEmail(user.getEmail());
|
||||
// sysUser.setSex(user.getSex());
|
||||
// tokenService.setLoginUser(loginUser);
|
||||
// return AjaxResult.success();
|
||||
// }
|
||||
// return AjaxResult.error("修改个人信息异常,请联系管理员");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 头像上传
|
||||
// */
|
||||
// @PostMapping("/avatar")
|
||||
// public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException {
|
||||
// if (!file.isEmpty()) {
|
||||
// LoginUser loginUser = getLoginUser();
|
||||
// String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
|
||||
// if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) {
|
||||
// AjaxResult ajax = AjaxResult.success();
|
||||
// ajax.put("imgUrl", avatar);
|
||||
// // 更新缓存用户头像
|
||||
// loginUser.getUser().setAvatar(avatar);
|
||||
// tokenService.setLoginUser(loginUser);
|
||||
// return ajax;
|
||||
// }
|
||||
// }
|
||||
// return AjaxResult.error("上传图片异常,请联系管理员");
|
||||
// }
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.ktg.weixin.service;
|
||||
|
||||
import com.ktg.common.constant.Constants;
|
||||
import com.ktg.common.core.domain.entity.SysUser;
|
||||
import com.ktg.common.core.domain.model.LoginUser;
|
||||
import com.ktg.common.exception.ServiceException;
|
||||
import com.ktg.common.exception.user.UserPasswordNotMatchException;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.common.utils.MessageUtils;
|
||||
import com.ktg.common.utils.ServletUtils;
|
||||
import com.ktg.common.utils.ip.IpUtils;
|
||||
import com.ktg.framework.manager.AsyncManager;
|
||||
import com.ktg.framework.manager.factory.AsyncFactory;
|
||||
import com.ktg.framework.web.service.TokenService;
|
||||
import com.ktg.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 登录校验方法
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component
|
||||
public class AuthService {
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Resource
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
/**
|
||||
* 登录验证
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
public String login(String username, String password) {
|
||||
// 用户验证
|
||||
Authentication authentication = null;
|
||||
try {
|
||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||
authentication = authenticationManager
|
||||
.authenticate(new UsernamePasswordAuthenticationToken(username, password));
|
||||
} catch (Exception e) {
|
||||
if (e instanceof BadCredentialsException) {
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
||||
throw new UserPasswordNotMatchException();
|
||||
} else {
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
}
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||
recordLoginInfo(loginUser.getUserId());
|
||||
// 生成token
|
||||
return tokenService.createToken(loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
public void recordLoginInfo(Long userId) {
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserId(userId);
|
||||
sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
||||
sysUser.setLoginDate(DateUtils.getNowDate());
|
||||
userService.updateUserProfile(sysUser);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user