提交 2a1c02cf authored 作者: 黄夏豪's avatar 黄夏豪

项目重构代码补充

上级 3df11845
......@@ -2,12 +2,17 @@ package controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.task.service.TaskLogService;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.bto.TaskLogBto;
import com.tykj.dev.device.task.subject.common.BusinessEnum;
import com.tykj.dev.device.task.subject.common.StatusEnum;
import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.task.subject.vo.FileVo;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.user.util.AuthenticationUtils;
......@@ -21,6 +26,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
......@@ -47,25 +53,28 @@ public class DeviceDestroyController {
private final DeviceLibraryService deviceLibraryService;
final UserPublicService userPublicService;
private final UserPublicService userPublicService;
private final DeviceLogService deviceLogService;
private final TaskLogService taskLogService;
/**
* 装备销毁对应的生命周期编号
*/
private static final Integer DEVICE_DESTROY_LIFE_STATUS = 10;
public DeviceDestroyController(DeviceDestroyBillService deviceDestroyBillServiceyBillService, TaskService taskService, DeviceLibraryService deviceLibraryService, UserPublicService userPublicService) {
public DeviceDestroyController(DeviceDestroyBillService deviceDestroyBillServiceyBillService, TaskService taskService, DeviceLibraryService deviceLibraryService, UserPublicService userPublicService, DeviceLogService deviceLogService, TaskLogService taskLogService) {
this.deviceDestroyBillService = deviceDestroyBillServiceyBillService;
this.taskService = taskService;
this.deviceLibraryService = deviceLibraryService;
this.userPublicService = userPublicService;
this.deviceLogService = deviceLogService;
this.taskLogService = taskLogService;
}
// @Autowired
// MyWebSocket myWebSocket;
//
// @Autowired
// private DeviceLogService deviceLogService;
@ApiOperation(value = "查询销毁单", notes = "可以通过这个接口查询销毁单")
@PostMapping(value = "/summary")
......@@ -82,7 +91,17 @@ public class DeviceDestroyController {
DeviceDestroyBill destroyBill = DeviceDestroyBill.formVoToBill(formVo,currentUserInfo);
//保存销毁账单
DeviceDestroyBill deviceDestroyBillEntitySaved = deviceDestroyBillService.addEntity(destroyBill);
taskService.start( initTaskBto(deviceDestroyBillEntitySaved));
//生成日志所需的文件列表
ArrayList<FileVo> billList = ListUtil.createList(
new FileVo("标签替换单据", deviceDestroyBillEntitySaved.getFileName(), deviceDestroyBillEntitySaved.getFileUrl())
);
//生成装备变更日志
//生成销毁审核任务
Task task = taskService.start(initTaskBto(deviceDestroyBillEntitySaved));
//生成任务日志
taskLogService.addLog(new TaskLogBto(task.getId(),"发起标签销毁",billList));
taskLogService.addLog(new TaskLogBto(task.getId(),"标签销毁待审核",billList));
// myWebSocket.sendMessage1();
return ResultUtil.success("销毁-出库申请成功");
}
......
......@@ -31,6 +31,7 @@ public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(Exception.class)
public ResponseEntity errorMessage(Exception e){
e.printStackTrace();
return ResultUtil.failed();
}
......@@ -41,6 +42,7 @@ public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(ApiException.class)
public ResponseEntity errorMessage(ApiException e){
e.printStackTrace();
if (e.getResponseEntity()!=null){
return e.getResponseEntity();
}
......@@ -54,6 +56,7 @@ public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(BindException.class)
public ResponseEntity errorMessage(BindException e){
e.printStackTrace();
BindingResult bindingResult = e.getBindingResult();
String message = null;
if (bindingResult.hasErrors()) {
......@@ -72,6 +75,7 @@ public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(AuthenticationException.class)
public ResponseEntity errorMessage(AuthenticationException e){
e.printStackTrace();
return ResultUtil.unauthorized();
}
......@@ -82,6 +86,7 @@ public class GlobalExceptionHandler {
@ResponseBody
@ExceptionHandler(AccessDeniedException.class)
public ResponseEntity errorMessage(AccessDeniedException e){
e.printStackTrace();
return ResultUtil.forbidden();
}
......
......@@ -13,6 +13,7 @@ import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.task.subject.bto.TaskLogBto;
import com.tykj.dev.device.task.subject.common.BusinessEnum;
import com.tykj.dev.device.task.subject.common.StatusEnum;
import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.task.subject.vo.FileVo;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.subject.service.UserPublicService;
......@@ -121,11 +122,11 @@ public class RfidController {
//生成详情信息
rfidChangeLogService.addEntity(initRfidChangeLog(currentUserInfo, rfidChangeBillSaved, d));
//生成装备变更日志
deviceLogService.addLog(new DeviceLogDto(rfidChangeBillSaved.getId(),"发起入库",billList));
deviceLogService.addLog(new DeviceLogDto(rfidChangeBillSaved.getId(),"发起标签替换",billList));
deviceLogService.addLog(new DeviceLogDto(rfidChangeBillSaved.getId(),"标签替换待审核",billList));
});
//生成Task
TaskBto task = initTaskBto(currentUserInfo, rfidChangeBillSaved);
taskService.start(task);
Task task = taskService.start(initTaskBto(currentUserInfo, rfidChangeBillSaved));
//生成任务日志
taskLogService.addLog(new TaskLogBto(task.getId(),"发起标签销毁",billList));
taskLogService.addLog(new TaskLogBto(task.getId(),"标签销毁待审核",billList));
......@@ -166,16 +167,33 @@ public class RfidController {
RfidChangeBill rfidChangeBill = rfidChangeBillService.getOne(task.getBillId());
//判断审核结果
if (rfidChangeConfirmVo.getResult()==0){
//更改账单状态
//更改账单状态 为 审核失败
rfidChangeBill.setStatus(RfidChangeStatus.CONFIRM_FAILED.getStatus());
}else {
//更改账单状态
//更改账单状态 为 审核成功
rfidChangeBill.setStatus(RfidChangeStatus.CONFIRM_SUCCESS.getStatus());
//构建查询VO
RfidChangeLogSelectVo rfidChangeLogSelectVo = new RfidChangeLogSelectVo();
rfidChangeLogSelectVo.setBillId(task.getBillId());
List<RfidChangeLog> rfidChangeLogEntities = rfidChangeLogService.getList(rfidChangeLogSelectVo);
rfidChangeLogEntities.forEach(d->{
}
//生成日志所需的文件列表
ArrayList<FileVo> billList = ListUtil.createList(
new FileVo("标签替换单据", rfidChangeBill.getFileName(), rfidChangeBill.getFileUrl())
);
//处理详情和生成日志
handleBillDetail(task,billList,rfidChangeConfirmVo.getResult());
//更新账单
rfidChangeBillService.updateEntity(rfidChangeBill);
//更改对应任务的状态
taskService.update(taskService.moveToEnd(task));
return selectRfidChangeDetail(rfidChangeBill.getId());
}
private void handleBillDetail(TaskBto task, ArrayList<FileVo> billList,Integer flag) {
//构建查询VO
RfidChangeLogSelectVo rfidChangeLogSelectVo = new RfidChangeLogSelectVo();
rfidChangeLogSelectVo.setBillId(task.getBillId());
//查询账单详情
List<RfidChangeLog> rfidChangeLogEntities = rfidChangeLogService.getList(rfidChangeLogSelectVo);
rfidChangeLogEntities.forEach(d->{
if (flag==1){
//更改对应装备的RFID号
DeviceLibrary device = deviceLibraryService.getOne(d.getDeviceId());
device.setRfidCardId(d.getNewCardId());
......@@ -183,12 +201,13 @@ public class RfidController {
//将对应的账单详情记录变为审核成功
d.setValidTag(1);
rfidChangeLogService.updateEntity(d);
});
}
rfidChangeBillService.updateEntity(rfidChangeBill);
//更改对应任务的状态
taskService.update(taskService.moveToEnd(task));
return selectRfidChangeDetail(rfidChangeBill.getId());
//生成装备日志
deviceLogService.addLog(new DeviceLogDto(task.getBillId(),"标签替换成功",billList));
}else {
deviceLogService.addLog(new DeviceLogDto(task.getBillId(),"标签替换审核事变",billList));
}
});
}
@ApiOperation(value = "标签管理概览",notes = "通过这个借口可以查看标签管理的概览")
......
......@@ -7,11 +7,9 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.*;
import java.util.Date;
/**
......@@ -20,6 +18,7 @@ import java.util.Date;
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update library_warning_log set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("库房告警日志")
......
......@@ -7,11 +7,9 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.*;
import java.util.Date;
/**
......@@ -21,6 +19,7 @@ import java.util.Date;
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update library_warning_log_detail set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("库房告警详情")
......
......@@ -11,11 +11,9 @@ import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.*;
import java.util.Date;
/**
......@@ -26,6 +24,7 @@ import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EntityListeners(AuditingEntityListener.class)
@Entity
@SQLDelete(sql = "update rfid_change_bill set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
......
......@@ -11,6 +11,7 @@ import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
......@@ -23,6 +24,7 @@ import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EntityListeners(AuditingEntityListener.class)
@Entity
@SQLDelete(sql = "update rfid_change_log set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论