2026-6-30:

1.后端代码2次更新
This commit is contained in:
朱春声99
2026-06-29 17:37:53 +08:00
parent 71fca48178
commit 041a446933
27 changed files with 897 additions and 18 deletions

View File

@@ -29,6 +29,7 @@
<pagehelper.version>2.1.0</pagehelper.version>
<jwt.version>4.4.0</jwt.version>
<knife4j.version>4.5.0</knife4j.version>
<easyexcel.version>3.3.4</easyexcel.version>
<jakarta.servlet-api.version>6.0.0</jakarta.servlet-api.version>
<lombok.version>1.18.30</lombok.version>
</properties>
@@ -104,6 +105,12 @@
<artifactId>commons-pool2</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>${easyexcel.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -76,6 +76,12 @@
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<!-- Excel导出 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
<!-- 这里可以添加PLC通信相关的依赖 -->
<!-- 例如:
<dependency>

View File

@@ -157,6 +157,10 @@ public class DevInfoController {
@RequestParam Integer pageSize) {
try {
PageInfo<DevInfo> pageInfo = devInfoService.getDevInfoPage(devInfo, pageNum, pageSize);
pageInfo.getList().forEach(devInfo1 -> {
//为每个设备获取缓存中最新状态
devInfo1.setStatus(1);
});
Result<PageInfo<DevInfo>> success = Result.success(pageInfo);
return success;
} catch (Exception e) {

View File

@@ -3,6 +3,7 @@ package com.rczn.rcznautoplc.controller;
import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.cache.PlcRunStatus;
import com.rczn.rcznautoplc.domain.GoodsInfo;
import com.rczn.rcznautoplc.domain.query.GoodsInfoQuery;
import com.rczn.rcznautoplc.service.GoodsInfoService;
@@ -13,11 +14,12 @@ import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.*;
@RestController
@RequestMapping("/goodsInfo")
@@ -35,10 +37,6 @@ public class GoodsInfoController {
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY)
// @Parameter(name = "goodsName", description = "样品名称(可选,模糊查询)", required = false, example = "手机", in = ParameterIn.QUERY),
// @Parameter(name = "goodsType", description = "样品类型(可选,模糊查询)", required = false, example = "电子产品", in = ParameterIn.QUERY),
// @Parameter(name = "goodFrom", description = "样品来源(可选,模糊查询)", required = false, example = "深圳", in = ParameterIn.QUERY),
// @Parameter(name = "goodBatch", description = "样品批次(可选,精准查询)", required = false, example = "202501", in = ParameterIn.QUERY)
})
public Result getGoodsInfoPage(
@RequestParam Integer pageNum,
@@ -82,13 +80,31 @@ public class GoodsInfoController {
@Operation(summary = "新增样品信息", description = "样品名称、类型、入库时间为必填项")
public Result addGoodsInfo(@RequestBody GoodsInfo goodsInfo) {
try {
Long goodsInfoId = goodsInfoService.insert(goodsInfo);
return Result.success(goodsInfoId);
goodsInfoService.insert(goodsInfo);
return Result.success(goodsInfo.getId());
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 批量新增样品信息
*/
@PostMapping(value = "/batchAdd", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "批量新增样品信息", description = "批量传入样品列表返回生成的ID列表")
public Result batchAddGoodsInfo(@RequestBody List<GoodsInfo> goodsInfoList) {
try {
// 批量插入返回所有生成的ID
List<Long> idList = new ArrayList<>();
goodsInfoList.forEach(goodsInfo -> {
goodsInfoService.insert(goodsInfo);
idList.add(goodsInfo.getId());
});
return Result.success(idList);
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
/**
* 扫码新增样品信息
* 扫码信息:样品类型、样品编码、样品名称、样品点位
@@ -131,4 +147,46 @@ public class GoodsInfoController {
return Result.error(e.getMessage());
}
}
/**
* 分样接口一个样品码分成多个样品的过程首例404杂质铀项目送样开始每个样品执行5个sop
*/
@PostMapping(value = "/dividInfo",produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "样品分码",description = "每个样品分成多个sop的样品码")
public Result dividGoodsInfoList(
@RequestBody
@Parameter(description = "传入分样母编码样品列表")
List<GoodsInfo> infoList,
@RequestParam(defaultValue = "5")
@Parameter(description = "样品分样数量")
Integer divideNum){
Map<String,List<GoodsInfo>> goodsMap = new HashMap<>();
infoList.forEach(info ->{
// 删除原样品数据:
goodsInfoService.deleteById(info.getId());
for (int i = 1; i <= divideNum; i++) {
GoodsInfo copyInfo = new GoodsInfo();
BeanUtils.copyProperties(info,copyInfo);
copyInfo.setBarCode(copyInfo.getBarCode()+"0"+i);
if(goodsMap.containsKey(info.getBarCode())){
List<GoodsInfo> list = goodsMap.get(info.getBarCode());
list.add(copyInfo);
}else {
List<GoodsInfo> list = new ArrayList<>();
list.add(copyInfo);
goodsMap.put(info.getBarCode(),list);
}
// 保存原样品数据,删除标识
copyInfo.setDelSign(false);
goodsInfoService.insert(copyInfo);
}
});
//分样后修改主PLC的样品准备状态
PlcRunStatus.goodsScanStatus = 0;
return Result.success(goodsMap);
}
}

View File

@@ -36,6 +36,10 @@ public class IslandInfoController {
@RequestParam(required = false) String islandName,
@RequestParam(required = false) String islandCode) {
PageInfo<IslandInfo> pageBean = islandInfoService.selectPage(pageNum, pageSize, islandName, islandCode);
//为每个功能岛获取缓存中的状态数据:
pageBean.getList().forEach(islandInfo -> {
islandInfo.setStatus(1);
});
return Result.success(pageBean);
}

View File

@@ -3,7 +3,9 @@ package com.rczn.rcznautoplc.controller;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.ManageLog;
import com.rczn.rcznautoplc.domain.ManageLogExcelVO;
import com.rczn.rcznautoplc.service.ManageLogService;
import com.alibaba.excel.EasyExcel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -14,7 +16,13 @@ import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/manage-log")
@@ -117,4 +125,53 @@ public class ManageLogController {
return Result.error(e.getMessage());
}
}
/**
* 导出操作日志到Excel
*/
@GetMapping(value = "/export")
@Operation(summary = "导出操作日志", description = "根据筛选条件导出操作日志为Excel文件不填条件则导出全部")
public void exportLog(
@RequestParam(required = false) String logName,
@RequestParam(required = false) String logType,
@RequestParam(required = false) Long createId,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime logWritetimeStart,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime logWritetimeEnd,
HttpServletResponse response) throws IOException {
ManageLog query = new ManageLog();
query.setLogName(logName);
query.setLogType(logType);
query.setCreateId(createId);
query.setStartTime(logWritetimeStart);
query.setEndTime(logWritetimeEnd);
List<ManageLog> logList = manageLogService.selectList(query);
List<ManageLogExcelVO> exportList = new ArrayList<>(logList.size());
for (ManageLog log : logList) {
ManageLogExcelVO vo = new ManageLogExcelVO();
vo.setId(log.getId());
vo.setLogName(log.getLogName());
vo.setLogType(log.getLogType());
vo.setLogContent(log.getLogContent());
vo.setLogWritetime(log.getLogWritetime());
vo.setCreateId(log.getCreateId());
vo.setCreateTime(log.getCreateTime());
vo.setRemark(log.getRemark());
exportList.add(vo);
}
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("操作日志导出", StandardCharsets.UTF_8).replaceAll("\\+", "%20");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), ManageLogExcelVO.class)
.sheet("操作日志")
.doWrite(exportList);
}
}

View File

@@ -215,6 +215,26 @@ public class PlcController {
}
}
/**
* 根据plc ip地址获取plc设备状态
*/
@PostMapping(value = "/setPlcScanStatus")
@Operation(summary = "设置主PLC扫码样品专题", description = "goodsScanStatus = 0; //货物扫描:0-准备1-扫描完毕;")
public Result setPlcScanStatus(
@RequestParam(required = true)
@Parameter(description = "货物扫描:0-准备1-扫描完毕")
Integer goodsScanStatus
) {
try {
PlcRunStatus.goodsScanStatus = goodsScanStatus;
return Result.success("设置成功!");
} catch (Exception e) {
return Result.error("停止失败!");
}
}
/**
* 根据plc ip地址设置plc设备模式
* 0-手动模式1-自动模式

View File

@@ -4,7 +4,9 @@ import com.github.pagehelper.PageInfo;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.RecordInfo;
import com.rczn.rcznautoplc.domain.RecordInfoExcelVO;
import com.rczn.rcznautoplc.service.RecordInfoService;
import com.alibaba.excel.EasyExcel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@@ -14,6 +16,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
@RestController
@RequestMapping("/recordInfo")
@Tag(name = "记录信息管理", description = "记录信息增删改查+分页查询接口")
@@ -28,6 +36,8 @@ public class RecordInfoController {
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "islandId", description = "功能岛主键ID", required = false, example = "122", in = ParameterIn.QUERY),
@Parameter(name = "devId", description = "动作单元主键ID", required = false, example = "111", in = ParameterIn.QUERY),
@Parameter(name = "recordName", description = "记录名称(可选,模糊查询)", required = false, example = "设备故障", in = ParameterIn.QUERY),
@Parameter(name = "recordType", description = "记录类型可选精准查询1-设备异常2-样品异常3-操作异常)", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "recordStatus", description = "记录状态可选精准查询false-未处理true-已处理)", required = false, example = "false", in = ParameterIn.QUERY)
@@ -35,10 +45,12 @@ public class RecordInfoController {
public Result getRecordInfoPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) Integer islandId,
@RequestParam(required = false) Integer devId,
@RequestParam(required = false) String recordName,
@RequestParam(required = false) Integer recordType,
@RequestParam(required = false) Boolean recordStatus) {
PageInfo<RecordInfo> pageBean = recordInfoService.selectPage(pageNum, pageSize, recordName, recordType, recordStatus);
PageInfo<RecordInfo> pageBean = recordInfoService.selectPage(pageNum, pageSize,islandId,devId, recordName, recordType, recordStatus);
return Result.success(pageBean);
}
@@ -81,4 +93,30 @@ public class RecordInfoController {
return Result.error(e.getMessage());
}
}
/**
* 导出记录信息到Excel包含功能岛名称、动作单元名称
*/
@GetMapping(value = "/export")
@Operation(summary = "导出记录信息", description = "根据筛选条件导出记录信息为Excel文件不填条件则导出全部。包含功能岛名称和动作单元名称")
public void exportRecordInfo(
@RequestParam(required = false) Integer islandId,
@RequestParam(required = false) Integer devId,
@RequestParam(required = false) String recordName,
@RequestParam(required = false) Integer recordType,
@RequestParam(required = false) Boolean recordStatus,
HttpServletResponse response) throws IOException {
List<RecordInfoExcelVO> exportList = recordInfoService.selectList(
islandId, devId, recordName, recordType, recordStatus);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("记录信息导出", StandardCharsets.UTF_8).replaceAll("\\+", "%20");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), RecordInfoExcelVO.class)
.sheet("记录信息")
.doWrite(exportList);
}
}

View File

@@ -0,0 +1,101 @@
package com.rczn.rcznautoplc.controller;
import com.rczn.domain.PageBean;
import com.rczn.domain.Result;
import com.rczn.rcznautoplc.domain.TaskInfo;
import com.rczn.rcznautoplc.service.TaskInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
@RestController
@RequestMapping("/taskInfo")
@Tag(name = "任务信息管理", description = "任务信息增删改查+分页查询接口")
public class TaskInfoController {
@Autowired
private TaskInfoService taskInfoService;
@GetMapping(value = "/listPage", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "分页查询任务", description = "支持多条件筛选,空条件自动忽略")
@Parameters({
@Parameter(name = "pageNum", description = "页码(必填)", required = true, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "pageSize", description = "每页条数(必填)", required = true, example = "10", in = ParameterIn.QUERY),
@Parameter(name = "sopId", description = "SOP ID可选", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "status", description = "状态可选0-未执行1-执行中5-暂停10-通过11-失败)", required = false, example = "0", in = ParameterIn.QUERY),
@Parameter(name = "createId", description = "创建人ID可选", required = false, example = "1", in = ParameterIn.QUERY),
@Parameter(name = "playTimeStart", description = "执行时间起可选格式yyyy-MM-dd HH:mm:ss", required = false, example = "2025-01-01 00:00:00", in = ParameterIn.QUERY),
@Parameter(name = "playTimeEnd", description = "执行时间止可选格式yyyy-MM-dd HH:mm:ss", required = false, example = "2025-12-31 23:59:59", in = ParameterIn.QUERY)
})
public Result<PageBean<TaskInfo>> getTaskPage(
@RequestParam Integer pageNum,
@RequestParam Integer pageSize,
@RequestParam(required = false) Long sopId,
@RequestParam(required = false) Integer status,
@RequestParam(required = false) Long createId,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime playTimeStart,
@RequestParam(required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
LocalDateTime playTimeEnd) {
TaskInfo query = new TaskInfo();
query.setSopId(sopId);
query.setStatus(status);
query.setCreateId(createId);
query.setStartTime(playTimeStart);
query.setEndTime(playTimeEnd);
PageBean<TaskInfo> pageBean = taskInfoService.selectPage(pageNum, pageSize, query);
return Result.success(pageBean);
}
@GetMapping(value = "/getById/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "查询单个任务", description = "按任务ID查询详情")
public Result getTaskById(@PathVariable Long id) {
TaskInfo taskInfo = taskInfoService.selectById(id);
return taskInfo != null ? Result.success(taskInfo) : Result.error("任务不存在或已删除");
}
@PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "新增任务", description = "SOP ID、样品列表为必填项其他字段可选")
public Result addTask(@RequestBody TaskInfo taskInfo) {
try {
Long taskId = taskInfoService.insert(taskInfo);
return Result.success("任务新增成功");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@PutMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "更新任务", description = "需传入任务ID其他字段非空则更新")
public Result updateTask(@RequestBody TaskInfo taskInfo) {
try {
Boolean success = taskInfoService.update(taskInfo);
return success ? Result.success("任务更新成功") : Result.error("更新失败(任务不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@DeleteMapping(value = "/del/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "删除任务", description = "物理删除,不可恢复")
public Result deleteTask(@PathVariable Long id) {
try {
Boolean success = taskInfoService.deleteById(id);
return success ? Result.success("任务删除成功") : Result.error("删除失败(任务不存在或已删除)");
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
}

View File

@@ -55,6 +55,14 @@ public class IslandInfo extends BaseBean {
this.islandLogo = islandLogo;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getDesc() {
return desc;
}

View File

@@ -0,0 +1,52 @@
package com.rczn.rcznautoplc.domain;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import java.time.LocalDateTime;
public class ManageLogExcelVO {
@ExcelProperty("ID")
private Long id;
@ExcelProperty("日志名称")
private String logName;
@ExcelProperty("日志类型")
private String logType;
@ExcelProperty("日志内容")
private String logContent;
@ExcelProperty("日志写入时间")
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
private LocalDateTime logWritetime;
@ExcelProperty("创建人ID")
private Long createId;
@ExcelProperty("创建时间")
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ExcelProperty("备注")
private String remark;
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public String getLogName() { return logName; }
public void setLogName(String logName) { this.logName = logName; }
public String getLogType() { return logType; }
public void setLogType(String logType) { this.logType = logType; }
public String getLogContent() { return logContent; }
public void setLogContent(String logContent) { this.logContent = logContent; }
public LocalDateTime getLogWritetime() { return logWritetime; }
public void setLogWritetime(LocalDateTime logWritetime) { this.logWritetime = logWritetime; }
public Long getCreateId() { return createId; }
public void setCreateId(Long createId) { this.createId = createId; }
public LocalDateTime getCreateTime() { return createTime; }
public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
public String getRemark() { return remark; }
public void setRemark(String remark) { this.remark = remark; }
}

View File

@@ -0,0 +1,56 @@
package com.rczn.rcznautoplc.domain;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import java.time.LocalDateTime;
public class RecordInfoExcelVO {
@ExcelProperty("ID")
private Long id;
@ExcelProperty("功能岛名称")
private String islandName;
@ExcelProperty("动作单元名称")
private String devName;
@ExcelProperty("记录名称")
private String recordName;
@ExcelProperty("记录类型")
private String recordTypeStr;
@ExcelProperty("处理状态")
private String recordStatusStr;
@ExcelProperty("记录内容")
private String recordContent;
@ExcelProperty("创建时间")
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ExcelProperty("备注")
private String remark;
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public String getIslandName() { return islandName; }
public void setIslandName(String islandName) { this.islandName = islandName; }
public String getDevName() { return devName; }
public void setDevName(String devName) { this.devName = devName; }
public String getRecordName() { return recordName; }
public void setRecordName(String recordName) { this.recordName = recordName; }
public String getRecordTypeStr() { return recordTypeStr; }
public void setRecordTypeStr(String recordTypeStr) { this.recordTypeStr = recordTypeStr; }
public String getRecordStatusStr() { return recordStatusStr; }
public void setRecordStatusStr(String recordStatusStr) { this.recordStatusStr = recordStatusStr; }
public String getRecordContent() { return recordContent; }
public void setRecordContent(String recordContent) { this.recordContent = recordContent; }
public LocalDateTime getCreateTime() { return createTime; }
public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
public String getRemark() { return remark; }
public void setRemark(String remark) { this.remark = remark; }
}

View File

@@ -0,0 +1,117 @@
package com.rczn.rcznautoplc.domain;
import java.time.LocalDateTime;
public class TaskInfo {
private Long id;
private Long sopId;
private String goodsList;
private LocalDateTime playTime;
private Integer status;
private Long createId;
private LocalDateTime createTime;
// 扩展字段:用于时间范围查询(非数据库字段)
private LocalDateTime startTime;
private LocalDateTime endTime;
public TaskInfo() {
}
public TaskInfo(Long id, Long createId, LocalDateTime createTime) {
this.id = id;
this.createId = createId;
this.createTime = createTime;
}
@Override
public String toString() {
return "TaskInfo{" +
"id=" + id +
", sopId=" + sopId +
", goodsList='" + goodsList + '\'' +
", playTime=" + playTime +
", status=" + status +
", createId=" + createId +
", createTime=" + createTime +
'}';
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getSopId() {
return sopId;
}
public void setSopId(Long sopId) {
this.sopId = sopId;
}
public String getGoodsList() {
return goodsList;
}
public void setGoodsList(String goodsList) {
this.goodsList = goodsList;
}
public LocalDateTime getPlayTime() {
return playTime;
}
public void setPlayTime(LocalDateTime playTime) {
this.playTime = playTime;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Long getCreateId() {
return createId;
}
public void setCreateId(Long createId) {
this.createId = createId;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
public LocalDateTime getStartTime() {
return startTime;
}
public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
public LocalDateTime getEndTime() {
return endTime;
}
public void setEndTime(LocalDateTime endTime) {
this.endTime = endTime;
}
}

View File

@@ -24,4 +24,7 @@ public interface ManageLogMapper {
// 查询分页总数(与分页查询条件一致)
Long selectTotal(ManageLog manageLog);
// 查询全部日志(不分页,支持筛选条件,用于导出)
List<ManageLog> selectList(ManageLog manageLog);
}

View File

@@ -1,6 +1,7 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.RecordInfo;
import com.rczn.rcznautoplc.domain.RecordInfoExcelVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -13,4 +14,7 @@ public interface RecordInfoMapper {
Boolean deleteById(@Param("id") Long id);
RecordInfo selectById(@Param("id") Long id);
List<RecordInfo> selectPage(RecordInfo recordInfo);
// 导出查询(关联查询功能岛和动作单元名称)
List<RecordInfoExcelVO> selectList(RecordInfo recordInfo);
}

View File

@@ -0,0 +1,23 @@
package com.rczn.rcznautoplc.mapper;
import com.rczn.rcznautoplc.domain.TaskInfo;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface TaskInfoMapper {
int insert(TaskInfo taskInfo);
int deleteById(Long id);
int update(TaskInfo taskInfo);
TaskInfo selectById(Long id);
List<TaskInfo> selectPage(TaskInfo taskInfo);
Long selectTotal(TaskInfo taskInfo);
List<TaskInfo> selectList(TaskInfo taskInfo);
}

View File

@@ -3,6 +3,8 @@ package com.rczn.rcznautoplc.service;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.ManageLog;
import java.util.List;
public interface ManageLogService {
// 新增日志
Long insert(ManageLog manageLog);
@@ -18,4 +20,7 @@ public interface ManageLogService {
// 分页查询日志(支持多条件筛选)
PageBean<ManageLog> selectPage(Integer pageNum, Integer pageSize, ManageLog manageLog);
// 查询全部日志(不分页,支持筛选条件,用于导出)
List<ManageLog> selectList(ManageLog manageLog);
}

View File

@@ -2,11 +2,17 @@ package com.rczn.rcznautoplc.service;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.RecordInfo;
import com.rczn.rcznautoplc.domain.RecordInfoExcelVO;
import java.util.List;
public interface RecordInfoService {
PageInfo<RecordInfo> selectPage(Integer pageNum, Integer pageSize, String recordName, Integer recordType, Boolean recordStatus);
PageInfo<RecordInfo> selectPage(Integer pageNum, Integer pageSize,Integer islandId,Integer devId, String recordName, Integer recordType, Boolean recordStatus);
RecordInfo selectById(Long id);
Long insert(RecordInfo recordInfo);
Boolean update(RecordInfo recordInfo);
Boolean deleteById(Long id);
// 导出查询(关联查询功能岛和动作单元名称)
List<RecordInfoExcelVO> selectList(Integer islandId, Integer devId, String recordName, Integer recordType, Boolean recordStatus);
}

View File

@@ -0,0 +1,20 @@
package com.rczn.rcznautoplc.service;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.TaskInfo;
import java.util.List;
public interface TaskInfoService {
Long insert(TaskInfo taskInfo);
Boolean deleteById(Long id);
Boolean update(TaskInfo taskInfo);
TaskInfo selectById(Long id);
PageBean<TaskInfo> selectPage(Integer pageNum, Integer pageSize, TaskInfo taskInfo);
List<TaskInfo> selectList(TaskInfo taskInfo);
}

View File

@@ -65,11 +65,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
if (goodsInfo.getGoodsName() == null || goodsInfo.getGoodsName().isEmpty()) {
throw new IllegalArgumentException("货物名称不能为空");
}
if (goodsInfo.getGoodsType() == null || goodsInfo.getGoodsType().isEmpty()) {
throw new IllegalArgumentException("货物类型不能为空");
}
if (goodsInfo.getIncomeTime() == null) {
throw new IllegalArgumentException("入库时间不能为空");
if (goodsInfo.getBarCode() == null || goodsInfo.getBarCode().isEmpty()) {
throw new IllegalArgumentException("样品编码不能为空");
}
return goodsInfoMapper.insert(goodsInfo);
}

View File

@@ -82,4 +82,9 @@ public class ManageLogServiceImpl implements ManageLogService {
// 封装PageBean返回
return pageBean;
}
@Override
public List<ManageLog> selectList(ManageLog manageLog) {
return manageLogMapper.selectList(manageLog);
}
}

View File

@@ -3,6 +3,7 @@ package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rczn.rcznautoplc.domain.RecordInfo;
import com.rczn.rcznautoplc.domain.RecordInfoExcelVO;
import com.rczn.rcznautoplc.mapper.RecordInfoMapper;
import com.rczn.rcznautoplc.service.RecordInfoService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -17,9 +18,11 @@ public class RecordInfoServiceImpl implements RecordInfoService {
RecordInfoMapper recordInfoMapper;
@Override
public PageInfo<RecordInfo> selectPage(Integer pageNum, Integer pageSize, String recordName, Integer recordType, Boolean recordStatus) {
public PageInfo<RecordInfo> selectPage(Integer pageNum, Integer pageSize,Integer islandId,Integer devId, String recordName, Integer recordType, Boolean recordStatus) {
PageHelper.startPage(pageNum, pageSize);
RecordInfo queryParam = new RecordInfo();
queryParam.setIslandId(islandId);
queryParam.setDevId(devId);
queryParam.setRecordName(recordName);
queryParam.setRecordType(recordType);
queryParam.setRecordStatus(recordStatus);
@@ -58,4 +61,15 @@ public class RecordInfoServiceImpl implements RecordInfoService {
if (id == null) throw new IllegalArgumentException("ID不能为空");
return recordInfoMapper.deleteById(id);
}
@Override
public List<RecordInfoExcelVO> selectList(Integer islandId, Integer devId, String recordName, Integer recordType, Boolean recordStatus) {
RecordInfo queryParam = new RecordInfo();
queryParam.setIslandId(islandId);
queryParam.setDevId(devId);
queryParam.setRecordName(recordName);
queryParam.setRecordType(recordType);
queryParam.setRecordStatus(recordStatus);
return recordInfoMapper.selectList(queryParam);
}
}

View File

@@ -0,0 +1,75 @@
package com.rczn.rcznautoplc.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rczn.domain.PageBean;
import com.rczn.rcznautoplc.domain.TaskInfo;
import com.rczn.rcznautoplc.mapper.TaskInfoMapper;
import com.rczn.rcznautoplc.service.TaskInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.time.LocalDateTime;
import java.util.List;
@Service
public class TaskInfoServiceImpl implements TaskInfoService {
@Autowired
private TaskInfoMapper taskInfoMapper;
@Override
public Long insert(TaskInfo taskInfo) {
Assert.notNull(taskInfo.getSopId(), "SOP ID不能为空");
Assert.notNull(taskInfo.getGoodsList(), "样品列表不能为空");
if (taskInfo.getCreateTime() == null) {
taskInfo.setCreateTime(LocalDateTime.now());
}
int rows = taskInfoMapper.insert(taskInfo);
return rows > 0 ? taskInfo.getId() : null;
}
@Override
public Boolean deleteById(Long id) {
Assert.notNull(id, "任务ID不能为空");
int rows = taskInfoMapper.deleteById(id);
return rows > 0;
}
@Override
public Boolean update(TaskInfo taskInfo) {
Assert.notNull(taskInfo.getId(), "任务ID不能为空");
int rows = taskInfoMapper.update(taskInfo);
return rows > 0;
}
@Override
public TaskInfo selectById(Long id) {
Assert.notNull(id, "任务ID不能为空");
return taskInfoMapper.selectById(id);
}
@Override
public PageBean<TaskInfo> selectPage(Integer pageNum, Integer pageSize, TaskInfo taskInfo) {
Assert.notNull(pageNum, "页码不能为空");
Assert.notNull(pageSize, "每页条数不能为空");
Assert.isTrue(pageNum > 0, "页码必须大于0");
Assert.isTrue(pageSize > 0 && pageSize <= 100000, "每页条数必须在1-10000之间");
PageHelper.startPage(pageNum, pageSize);
List<TaskInfo> taskList = taskInfoMapper.selectPage(taskInfo);
Page<TaskInfo> page = (Page<TaskInfo>) taskList;
PageBean<TaskInfo> pageBean = new PageBean<>();
pageBean.setTotal(page.getTotal());
pageBean.setItems(page.getResult());
return pageBean;
}
@Override
public List<TaskInfo> selectList(TaskInfo taskInfo) {
return taskInfoMapper.selectList(taskInfo);
}
}

View File

@@ -14,7 +14,7 @@
<include refid="goodsInfoColumn"/>,
create_id, create_time, update_id, update_time, del_sign
) VALUES (
#{goodsName}, #{goodsType}, #{incomeTime}, #{goodFrom}, #{goodBatch},#{pointNum},#{goalDetect}, #{barCode}, #{flowId}, #{goodsStatus}, #{desc},
#{goodsName}, #{goodsType}, NOW(), #{goodFrom}, #{goodBatch},#{pointNum},#{goalDetect}, #{barCode}, #{flowId}, #{goodsStatus}, #{desc},
#{createId}, NOW(), #{updateId}, NOW(), 0
)
</insert>
@@ -84,7 +84,7 @@
<if test="incomeTime != null and incomeTime!=''" >AND income_time = #{incomeTime}</if>
<if test="startTime != null" >AND income_time >= #{startTime}</if>
<if test="endTime != null" >AND income_time &lt;= #{endTime}</if>
<if test="goodsStatus != null and goodsStatus != ''">AND goods_status LIKE CONCAT('%', #{goodsStatus}, '%')</if>
<if test="goodsStatus != null ">AND goods_status = #{goodsStatus} </if>
ORDER BY income_time,point_num DESC
</select>
<select id="selectByBarCode" resultType="com.rczn.rcznautoplc.domain.GoodsInfo">

View File

@@ -143,7 +143,39 @@
ORDER BY log_writetime DESC <!-- 按日志写入时间倒序 -->
</select>
<!-- 6. 查询分页总数(与分页查询条件一致 -->
<!-- 6. 查询全部日志(不分页,支持筛选条件,用于导出 -->
<select id="selectList" resultMap="LogResultMap" parameterType="com.rczn.rcznautoplc.domain.ManageLog">
SELECT
<include refid="baseColumn"/>,
<include refid="logColumn"/>
FROM sys_manage_log
<where>
<if test="delSign == null">
AND del_sign = 0
</if>
<if test="delSign != null">
AND del_sign = #{delSign}
</if>
<if test="logName != null and logName != ''">
AND log_name LIKE CONCAT('%', #{logName}, '%')
</if>
<if test="logType != null and logType != ''">
AND log_type = #{logType}
</if>
<if test="startTime != null">
AND log_writetime >= #{startTime}
</if>
<if test="endTime != null">
AND log_writetime &lt;= #{endTime}
</if>
<if test="createId != null">
AND create_id = #{createId}
</if>
</where>
ORDER BY log_writetime DESC
</select>
<!-- 7. 查询分页总数(与分页查询条件一致) -->
<select id="selectTotal" resultType="java.lang.Long" parameterType="com.rczn.rcznautoplc.domain.ManageLog">
SELECT COUNT(*)
FROM sys_manage_log

View File

@@ -59,4 +59,37 @@
<if test="recordStatus != null">AND record_status = #{recordStatus}</if>
ORDER BY create_time DESC
</select>
<!-- 导出查询LEFT JOIN 功能岛和动作单元表获取名称CASE WHEN 转换状态显示 -->
<select id="selectList" resultType="com.rczn.rcznautoplc.domain.RecordInfoExcelVO">
SELECT
r.id,
i.island_name AS islandName,
d.dev_name AS devName,
r.record_name AS recordName,
CASE r.record_type
WHEN 1 THEN '设备异常'
WHEN 2 THEN '样品异常'
WHEN 3 THEN '操作异常'
ELSE '未知'
END AS recordTypeStr,
CASE r.record_status
WHEN 0 THEN '未处理异常'
WHEN 1 THEN '已处理'
ELSE '未知'
END AS recordStatusStr,
r.record_content AS recordContent,
r.create_time AS createTime,
r.remark
FROM tb_record_info r
LEFT JOIN tb_island_info i ON r.island_id = i.id AND i.del_sign = 0
LEFT JOIN tb_dev_info d ON r.dev_id = d.id AND d.del_sign = 0
WHERE r.del_sign = 0
<if test="islandId != null">AND r.island_id = #{islandId}</if>
<if test="devId != null">AND r.dev_id = #{devId}</if>
<if test="recordName != null and recordName != ''">AND r.record_name LIKE CONCAT('%', #{recordName}, '%')</if>
<if test="recordType != null">AND r.record_type = #{recordType}</if>
<if test="recordStatus != null">AND r.record_status = #{recordStatus}</if>
ORDER BY r.create_time DESC
</select>
</mapper>

View File

@@ -0,0 +1,134 @@
<?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.rczn.rcznautoplc.mapper.TaskInfoMapper">
<sql id="baseColumn">
id, sop_id, goods_list, play_tiime, status, create_id, create_time
</sql>
<resultMap id="TaskInfoResultMap" type="com.rczn.rcznautoplc.domain.TaskInfo">
<id column="id" property="id"/>
<result column="sop_id" property="sopId"/>
<result column="goods_list" property="goodsList"/>
<result column="play_tiime" property="playTime"/>
<result column="status" property="status"/>
<result column="create_id" property="createId"/>
<result column="create_time" property="createTime"/>
</resultMap>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO tb_task_info (
<trim suffixOverrides=",">
<if test="sopId != null"> sop_id,</if>
<if test="goodsList != null and goodsList != ''"> goods_list,</if>
<if test="playTime != null"> play_tiime,</if>
<if test="status != null"> status,</if>
<if test="createId != null"> create_id,</if>
<if test="createTime != null"> create_time,</if>
</trim>
) VALUES (
<trim suffixOverrides=",">
<if test="sopId != null"> #{sopId},</if>
<if test="goodsList != null and goodsList != ''"> #{goodsList},</if>
<if test="playTime != null"> #{playTime},</if>
<if test="status != null"> #{status},</if>
<if test="createId != null"> #{createId},</if>
<if test="createTime != null"> #{createTime},</if>
</trim>
)
</insert>
<update id="update">
UPDATE tb_task_info
<set>
<if test="sopId != null">sop_id = #{sopId},</if>
<if test="goodsList != null and goodsList != ''">goods_list = #{goodsList},</if>
<if test="playTime != null">play_tiime = #{playTime},</if>
<if test="status != null">status = #{status},</if>
</set>
WHERE id = #{id}
</update>
<delete id="deleteById">
DELETE FROM tb_task_info
WHERE id = #{id}
</delete>
<select id="selectById" resultMap="TaskInfoResultMap">
SELECT
<include refid="baseColumn"/>
FROM tb_task_info
WHERE id = #{id}
</select>
<select id="selectPage" resultMap="TaskInfoResultMap" parameterType="com.rczn.rcznautoplc.domain.TaskInfo">
SELECT
<include refid="baseColumn"/>
FROM tb_task_info
<where>
<if test="sopId != null">
AND sop_id = #{sopId}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="createId != null">
AND create_id = #{createId}
</if>
<if test="startTime != null">
AND play_tiime >= #{startTime}
</if>
<if test="endTime != null">
AND play_tiime &lt;= #{endTime}
</if>
</where>
ORDER BY create_time DESC
</select>
<select id="selectList" resultMap="TaskInfoResultMap" parameterType="com.rczn.rcznautoplc.domain.TaskInfo">
SELECT
<include refid="baseColumn"/>
FROM tb_task_info
<where>
<if test="sopId != null">
AND sop_id = #{sopId}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="createId != null">
AND create_id = #{createId}
</if>
<if test="startTime != null">
AND play_tiime >= #{startTime}
</if>
<if test="endTime != null">
AND play_tiime &lt;= #{endTime}
</if>
</where>
ORDER BY create_time DESC
</select>
<select id="selectTotal" resultType="java.lang.Long" parameterType="com.rczn.rcznautoplc.domain.TaskInfo">
SELECT COUNT(*)
FROM tb_task_info
<where>
<if test="sopId != null">
AND sop_id = #{sopId}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="createId != null">
AND create_id = #{createId}
</if>
<if test="startTime != null">
AND play_tiime >= #{startTime}
</if>
<if test="endTime != null">
AND play_tiime &lt;= #{endTime}
</if>
</where>
</select>
</mapper>