提交 3df11845 authored 作者: 黄夏豪's avatar 黄夏豪

项目重构代码补充

上级 da2a9e72
......@@ -10,6 +10,11 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>device-destory</artifactId>
<dependencies>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package entity.domain;
import com.tykj.dev.device.user.subject.entity.User;
import entity.enums.DestroyStatus;
import entity.vo.DeviceDestroyFormVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
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;
import java.util.List;
/**
* entity class for device_destroy_bill
* 装备销毁账单
* @author huangxiahao
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_destroy_bill set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("装备销毁账单")
public class DeviceDestroyBill {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id ;
/**
* 发起销毁业务经办人id(A岗)
*/
@ApiModelProperty(value = "发起销毁业务经办人id(A岗)")
private Integer startUserAId ;
/**
* 发起销毁业务审核人id(B岗)
*/
@ApiModelProperty(value = "发起销毁业务审核人id(B岗)")
private Integer startUserBId ;
/**
* 销毁状态(0:销毁装备出库待审核,1:销毁装备出库审核失败,2:已销毁)
*/
@ApiModelProperty(value = "销毁状态(0:销毁装备出库待审核,1:销毁装备出库审核失败,2:已销毁)")
private Integer destroyStatus ;
/**
* 出库附件文件名
*/
@ApiModelProperty(value = "出库附件文件名")
private String fileName ;
/**
* 出库附件文件地址URL
*/
@ApiModelProperty(value = "出库附件文件地址URL")
private String fileUrl ;
/**
* 装备销毁出库详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增
*/
@ApiModelProperty(value = "装备销毁出库详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增")
private String destroyDeviceDetail ;
/**
* 创建用户id
*/
@ApiModelProperty(value = "创建用户id")
@CreatedBy
private Integer createUserId ;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@CreatedDate
private Date createTime ;
/**
* 更新用户id
*/
@ApiModelProperty(value = "更新用户id")
@LastModifiedBy
private Integer updateUserId ;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
@LastModifiedDate
private Date updateTime ;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0 ;
/**
* 文号
*/
@ApiModelProperty(value = "文号")
private Integer docNumber ;
/**
* 监销人
*/
@ApiModelProperty(value = "监销人")
private String supervisor ;
/**
* 主管领导
*/
@ApiModelProperty(value = "主管领导")
private String leader ;
/**
* 承办人
*/
@ApiModelProperty(value = "承办人")
private String undertaker ;
/**
* 销毁日期
*/
@ApiModelProperty(value = "销毁日期")
private Date destroyTime ;
@ApiModelProperty(value = "经办人")
@Transient
private String userA ;
@ApiModelProperty(value = "型号")
@Transient
private String model ;
@ApiModelProperty(value = "名称")
@Transient
private String name ;
public DeviceDestroyBill(Integer startUserAId, Integer startUserBId, Integer destroyStatus, String fileName, String fileUrl, String supervisor, String leader, String undertaker, String userA, String destroyDeviceDetail) {
this.startUserAId = startUserAId;
this.startUserBId = startUserBId;
this.destroyStatus = destroyStatus;
this.fileName = fileName;
this.fileUrl = fileUrl;
this.supervisor = supervisor;
this.leader = leader;
this.undertaker = undertaker;
this.userA = userA;
}
public static DeviceDestroyBill formVoToBill(DeviceDestroyFormVo formVo, User user){
return new DeviceDestroyBill(
user.getUserId(),
formVo.getConfirmUserId(),
DestroyStatus.NEED_CONFIRM.getStatus(),
formVo.getFileName(),
formVo.getFileUrl(),
formVo.getSupervisor(),
formVo.getLeader(),
formVo.getUndertaker(),
user.getName(),
deviceDetailListToString(formVo.getDevices())
);
}
/**
* 生成装备销毁出库详情
*
* @return 装备出库详情
*/
public static String deviceDetailListToString(List<Integer> deviceIds) {
StringBuffer deviceDetail = new StringBuffer();
deviceDetail.append("x");
deviceIds.forEach(device -> {
//拼接对应的字符串 例如: 21x
deviceDetail.append(device.toString());
deviceDetail.append(1);
deviceDetail.append("x");
});
return deviceDetail.toString();
}
}
package entity.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
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;
/**
* entity class for device_destory_detail
* 销毁退回详情
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_destory_detail set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("销毁退回详情")
public class DeviceDestroyDetail {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id;
/**
* 销毁账单id
*/
@ApiModelProperty(value = "销毁账单id")
private Integer destoryBillId;
/**
* 销毁标题
*/
@ApiModelProperty(value = "销毁标题")
private String title;
/**
* 申请文号
*/
@ApiModelProperty(value = "申请文号")
private String applyNumber;
/**
* 批复文号
*/
@ApiModelProperty(value = "批复文号")
private String replayNumber;
/**
* 发件单位
*/
@ApiModelProperty(value = "发件单位")
private String sendUnit;
/**
* 收件单位
*/
@ApiModelProperty(value = "收件单位")
private String receiveUnit;
/**
* 发送时间
*/
@ApiModelProperty(value = "发送时间")
private Date sendTime;
/**
* 接收时间
*/
@ApiModelProperty(value = "接收时间")
private Date receiveTime;
/**
* 发件方id(A岗位)
*/
@ApiModelProperty(value = "发件方id(A岗位)")
private Integer sendUserAId;
/**
* 发件方id(B岗位)
*/
@ApiModelProperty(value = "发件方id(B岗位)")
private Integer sendUserBId;
/**
* 收件方id(A岗位)
*/
@ApiModelProperty(value = "收件方id(A岗位)")
private Integer receiveUserAId;
/**
* 收件方id(B岗位)
*/
@ApiModelProperty(value = "收件方id(B岗位)")
private Integer receiveUserBId;
/**
* 出库附件文件名
*/
@ApiModelProperty(value = "出库附件文件名")
private String fileName;
/**
* 出库附件文件地址URL
*/
@ApiModelProperty(value = "出库附件文件地址URL")
private String fileUrl;
/**
* 账单文件名
*/
@ApiModelProperty(value = "账单文件名")
private String billFileName;
/**
* 账单文件地址URL
*/
@ApiModelProperty(value = "账单文件地址URL")
private String billFileUrl;
/**
* 待销毁装备退回状态(1:销毁出库待审核,2:出库审核失败,3:待销毁装备退回中,4:退回接收待审核,5:退回接收审核失败,6:待销毁装备退回成功)
*/
@ApiModelProperty(value = "待销毁装备退回状态(1:销毁出库待审核,2:出库审核失败,3:待销毁装备退回中,4:退回接收待审核,5:退回接收审核失败,6:待销毁装备退回成功)")
private Integer sendBackStatus;
/**
* 待销毁装备退回数量
*/
@ApiModelProperty(value = "待销毁装备退回数量")
private Integer sendBackCount;
/**
* 已出库装备数量
*/
@ApiModelProperty(value = "已出库装备数量")
private Integer sendedCount;
/**
* 已接收装备数量
*/
@ApiModelProperty(value = "已接收装备数量")
private Integer receiveCount;
/**
* 出库检查详情(装备主键id+核对结果(0缺失1无误3不匹配,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的不匹配
*/
@ApiModelProperty(value = "出库检查详情(装备主键id+核对结果(0缺失1无误3不匹配,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的不匹配")
private String sendCheckDetail;
/**
* 出库检查结果
*/
@ApiModelProperty(value = "出库检查结果")
private String sendCheckResult;
/**
* 接收方入库检查详情(装备主键id+核对结果(0缺失1无误3不匹配,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的不匹配
*/
@ApiModelProperty(value = "接收方入库检查详情(装备主键id+核对结果(0缺失1无误3不匹配,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的不匹配")
private String receiveCheckDetail;
/**
* 接收方检查结果
*/
@ApiModelProperty(value = "接收方检查结果")
private String receiveCheckResult;
/**
* 创建用户id
*/
@CreatedBy
@ApiModelProperty(value = "创建用户id")
private Integer createUserId;
/**
* 创建时间
*/
@CreatedDate
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新用户id
*/
@LastModifiedBy
@ApiModelProperty(value = "更新用户id")
private Integer updateUserId;
/**
* 更新时间
*/
@LastModifiedDate
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag;
/**
* 预留字段1
*/
@ApiModelProperty(value = "预留字段1")
private String var1;
/**
* 预留字段2
*/
@ApiModelProperty(value = "预留字段2")
private String var2;
}
package entity.enums;
/**
* @author huangxiahao
*
*/
public enum DestroyStatus {
/**
* 待审核状态
*/
NEED_CONFIRM(0),
/**
* 审核失败
*/
CONFIRM_FAILED(1),
/**
* 审核成功
*/
CONFIRM_SUCCESS(2);
private Integer status;
DestroyStatus(Integer status) {
this.status = status;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
package entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author HuangXiahao
* @version V1.0
* @class CanDestoryDeviceSelectVo
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@ApiModel("可销毁装备查询类")
@Data
public class CanDestroyDeviceSelectVo {
@ApiModelProperty(value = "名称",example = "装备1")
private String name;
@ApiModelProperty(value = "模糊查询",example = "装备1")
private String content;
@ApiModelProperty(value = "型号",example = "bmxx")
public Integer model;
@ApiModelProperty(value = "类型",example = "1")
public Integer type;
@ApiModelProperty(value = "密级",example = "1")
public Integer secretLevel;
}
package entity.vo;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author dengdiyi
*/
@Data
@ApiModel("销毁单查询")
public class DeviceDestroyBillSelectVo extends CustomPage {
/**
* 监销人
*/
@ApiModelProperty(value = "监销人")
private String supervisor ;
/**
* 主管领导
*/
@ApiModelProperty(value = "主管领导")
private String leader ;
/**
* 承办人
*/
@ApiModelProperty(value = "承办人")
private String undertaker ;
@ApiModelProperty(value = "模糊查询关键字",example = "测试")
public String content;
@ApiModelProperty(value = "开始时间",example = "2020-10-10 01:10:10")
public Date startTime;
@ApiModelProperty(value = "结束时间",example = "2020-10-10 01:10:10")
public Date endTime;
}
package entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceDestoryConfirmVo
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@Data
@ApiModel("销毁单确认")
public class DeviceDestroyConfirmVo {
@NotNull
@ApiModelProperty(value = "工作ID",example = "1")
private Integer jobId;
@NotNull
@ApiModelProperty(value = "任务ID",example = "1")
private Integer taskId;
@NotNull
@ApiModelProperty(value = "审核结果 0为不通过 1为通过 ",example = "1")
private Integer result;
}
package entity.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceDestoryDetailSelectVo
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@Data
@ApiModel("销毁详情查询类")
public class DeviceDestroyDetailResultVo {
@ApiModelProperty(value = "发起人ID",example = "1")
private Integer startUserId;
@ApiModelProperty(value = "审核人ID",example = "1")
private Integer confirmUserId;
@ApiModelProperty(value = "发起人",example = "1")
private String startUser;
@ApiModelProperty(value = "审核人",example = "1")
private String confirmUser;
@ApiModelProperty(value = "销毁状态(0:销毁装备出库待审核,1:销毁装备出库审核失败,2:已销毁)")
private Integer destoryStatus ;
@ApiModelProperty(value = "出库附件文件名")
private String fileName ;
@ApiModelProperty(value = "出库附件文件地址URL")
private String fileUrl ;
@ApiModelProperty(value = "文号")
private String docNumber;
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime ;
@ApiModelProperty(value = "承办人")
private String undertaker ;
@ApiModelProperty(value = "主管领导")
private String leader ;
@ApiModelProperty(value = "监销人")
private String supervisor ;
@ApiModelProperty(value = "名称")
private String name ;
@ApiModelProperty(value = "型号")
private String model ;
@ApiModelProperty(value = "销毁单位")
private String unit ;
@ApiModelProperty(value = "销毁装备列表",example = "1")
private List<DeviceLibrary> devices = new ArrayList<>();
public DeviceDestroyDetailResultVo(Integer startUserId, Integer confirmUserId, String startUser, String confirmUser, Integer destoryStatus, String fileName, String fileUrl, String docNumber, Date createTime, String undertaker, String leader, String supervisor, String name, String model, String unit, List<DeviceLibrary> devices) {
this.startUserId = startUserId;
this.confirmUserId = confirmUserId;
this.startUser = startUser;
this.confirmUser = confirmUser;
this.destoryStatus = destoryStatus;
this.fileName = fileName;
this.fileUrl = fileUrl;
this.docNumber = docNumber;
this.createTime = createTime;
this.undertaker = undertaker;
this.leader = leader;
this.supervisor = supervisor;
this.name = name;
this.model = model;
this.unit = unit;
this.devices = devices;
}
}
package entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class DestoryFormVo
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@Data
public class DeviceDestroyFormVo {
@NotNull
@ApiModelProperty(value = "待审核人ID",example = "1")
private Integer confirmUserId;
@NotNull
@ApiModelProperty(value = "装备列表")
private List<Integer> devices;
@ApiModelProperty(value = "文件名称",example = "文件X")
private String fileName;
@ApiModelProperty(value = "文件URL",example = "/images/xxxxx")
private String fileUrl;
@ApiModelProperty(value = "承办人")
private String undertaker ;
@ApiModelProperty(value = "主管领导")
private String leader ;
@ApiModelProperty(value = "监销人")
private String supervisor ;
}
package entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
/**
* @author zjm
* @version 1.0.0
* @ClassName DeviceDestotyListVo.java
* @Description 销毁单列表页
* @createTime 2020年08月19日 14:04:00
*/
@ApiModel("销毁清单列表")
@AllArgsConstructor
@NoArgsConstructor
@Data
public class DeviceDestroyListVo {
/**
* 主键id
*/
@ApiModelProperty(name = "主键id")
private Integer id ;
/**
* 发起销毁业务经办人id(A岗)
*/
@ApiModelProperty(value = "发起销毁业务经办人id(A岗)")
private Integer startUserAId ;
/**
* 发起销毁业务审核人id(B岗)
*/
@ApiModelProperty(value = "发起销毁业务审核人id(B岗)")
private Integer startUserBId ;
/**
* 销毁状态(0:销毁装备出库待审核,1:销毁装备出库审核失败,2:已销毁)
*/
@ApiModelProperty(value = "销毁状态(0:销毁装备出库待审核,1:销毁装备出库审核失败,2:已销毁)")
private Integer destoryStatus ;
/**
* 装备销毁出库详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增
*/
@ApiModelProperty(value = "装备销毁出库详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增")
private String destoryDeviceDetail ;
/**
* 文号
*/
@Column(name = "doc_number",columnDefinition = "null int(11) COMMENT ' 文号 '")
@ApiModelProperty(value = "文号")
private Integer docNumber ;
/**
* 监销人
*/
@ApiModelProperty(value = "监销人")
private String supervisor ;
/**
* 主管领导
*/
@ApiModelProperty(value = "主管领导")
private String leader ;
/**
* 承办人
*/
@ApiModelProperty(value = "承办人")
private String undertaker ;
/**
* 型号
*/
@ApiModelProperty(value = "型号")
private String model;
/**
* 名称
*/
@ApiModelProperty(value = "名称")
private String name;
}
package entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceDestoryReadComfirm
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@ApiModel("销毁状态阅读确认")
@Data
public class DeviceDestroyReadConfirm {
@NotNull
@ApiModelProperty(value = "工作ID",example = "1")
private Integer jobId;
@NotNull
@ApiModelProperty(value = "任务ID",example = "1")
private Integer taskId;
}
package repository;
import entity.domain.DeviceDestroyBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author dengdiyi
*/
public interface DeviceDestroyBillDao extends JpaRepository<DeviceDestroyBill,Integer>, JpaSpecificationExecutor<DeviceDestroyBill> {
}
package service;
import entity.domain.DeviceDestroyBill;
import entity.vo.DeviceDestroyBillSelectVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.text.ParseException;
/**
* @author dengdiyi
*/
public interface DeviceDestroyBillService {
DeviceDestroyBill addEntity(DeviceDestroyBill deviceDestoryBillEntity);
Page<DeviceDestroyBill> getPage(DeviceDestroyBillSelectVo deviceDestoryBillSelectVo, Pageable pageable);
DeviceDestroyBill getOne(Integer id);
DeviceDestroyBill updateEntity(DeviceDestroyBill deviceDestoryBillEntity);
void delete(Integer id);
Integer getNewDocNumber() throws ParseException;
}
package service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.misc.utils.StringSplitUtil;
import com.tykj.dev.misc.utils.TimestampUtil;
import entity.domain.DeviceDestroyBill;
import entity.vo.DeviceDestroyBillSelectVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import repository.DeviceDestroyBillDao;
import service.DeviceDestroyBillService;
import javax.persistence.Transient;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.util.*;
/**
* @author dengdiyi
*/
@Service
public class DeviceDestroyBillServiceImpl implements DeviceDestroyBillService {
@Autowired
private DeviceDestroyBillDao deviceDestroyBillDao;
@Autowired
private UserPublicService userService;
@Autowired
private DeviceLibraryService deviceLibraryService;
@Override
public DeviceDestroyBill addEntity(DeviceDestroyBill deviceDestroyBillEntity) {
return deviceDestroyBillDao.save(deviceDestroyBillEntity);
}
@Override
public Page<DeviceDestroyBill> getPage(DeviceDestroyBillSelectVo deviceDestoryBillSelectVo, Pageable pageable) {
Page<DeviceDestroyBill> page = deviceDestroyBillDao.findAll(getSelectSpecification(deviceDestoryBillSelectVo),deviceDestoryBillSelectVo.getPageable());
for (DeviceDestroyBill d:page.getContent()) {
d.setUserA(userService.getOne(d.getStartUserAId()).getName());
List<Integer> list = StringSplitUtil.split(d.getDestroyDeviceDetail());
Set<String> nameSet = new HashSet<>();
Set<String> modelSet = new HashSet<>();
for (Integer id:list) {
if (id>0){
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(id);
if (deviceLibraryEntity!=null){
nameSet.add(deviceLibraryEntity.getName());
modelSet.add(deviceLibraryEntity.getModel());
}
}
}
d.setName(StringUtils.join(nameSet,","));
d.setModel(StringUtils.join(modelSet,","));
}
return page;
}
@Override
public DeviceDestroyBill getOne(Integer id) {
Optional<DeviceDestroyBill> resultEntity = deviceDestroyBillDao.findById(id);
return resultEntity.orElse(null);
}
@Override
public DeviceDestroyBill updateEntity(DeviceDestroyBill deviceDestoryBillEntity) {
return deviceDestroyBillDao.save(deviceDestoryBillEntity);
}
@Override
public void delete(Integer id) {
deviceDestroyBillDao.deleteById(id);
}
@Override
public Integer getNewDocNumber() throws ParseException {
PredicateBuilder<DeviceDestroyBill> predicateBuilder = Specifications.and();
predicateBuilder.ne("docNumber",null);
predicateBuilder.ge("createTime", TimestampUtil.getYearStart());
predicateBuilder.le("createTime",TimestampUtil.getYearEnd());
List<Sort.Order> orders = new ArrayList<>();
orders.add(new Sort.Order(Sort.Direction.DESC,"createTime"));
Sort by = Sort.by(orders);
List<DeviceDestroyBill> all = deviceDestroyBillDao.findAll(predicateBuilder.build(), by);
// 如果有数据则取第一个
if (all.size()!=0){
DeviceDestroyBill deviceDestoryBillEntity = all.get(0);
return deviceDestoryBillEntity.getDocNumber();
}else {
// 如果没有则取1
return 1;
}
}
private Specification<DeviceDestroyBill> getSelectSpecification(DeviceDestroyBillSelectVo deviceDestoryBillSelectVo){
PredicateBuilder<DeviceDestroyBill> predicateBuilder = Specifications.and();
if (deviceDestoryBillSelectVo!=null) {
if (deviceDestoryBillSelectVo.getUndertaker()!=null){
predicateBuilder.eq("supervisor",deviceDestoryBillSelectVo.getSupervisor());
}
if (deviceDestoryBillSelectVo.getSupervisor()!=null){
predicateBuilder.eq("supervisor",deviceDestoryBillSelectVo.getSupervisor());
}
if (deviceDestoryBillSelectVo.getLeader()!=null){
predicateBuilder.eq("leader",deviceDestoryBillSelectVo.getLeader());
}
if (deviceDestoryBillSelectVo.getContent() != null) {
Class<DeviceDestroyBill> deviceDestoryBillEntityClass = DeviceDestroyBill.class;
Field[] declaredFields = deviceDestoryBillEntityClass.getDeclaredFields();
PredicateBuilder<DeviceDestroyBill> p = Specifications.or();
for (Field field : declaredFields) {
if (field.getType().equals(String.class)&&field.getAnnotation(Transient.class)==null) {
p.like(field.getName(), "%" + deviceDestoryBillSelectVo.getContent() + "%");
}
}
predicateBuilder.predicate(p.build());
}
if (deviceDestoryBillSelectVo.getStartTime() != null) {
predicateBuilder.gt("destroyTime", deviceDestoryBillSelectVo.getStartTime());
}
if (deviceDestoryBillSelectVo.getEndTime() != null) {
predicateBuilder.lt("destroyTime", deviceDestoryBillSelectVo.getEndTime());
}
}
predicateBuilder.eq("destroyStatus",2);
return predicateBuilder.build();
}
}
......@@ -10,6 +10,16 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>device-retired</artifactId>
<dependencies>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-packing</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package entity.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
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;
/**
* entity class for device_retired_bill
* 退装账单
* @author admin
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_retired_bill set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("退装账单")
public class DeviceRetiredBill {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id ; /**
* 省A岗id
*/
@ApiModelProperty(value = "省A岗id")
private Integer userAId ; /**
* 省B岗id
*/
@ApiModelProperty(value = "省B岗id")
private Integer userBId ; /**
* 退装状态(0:待审核,1:审核失败,2:退装成功)
*/
@ApiModelProperty(value = "退装状态(0:待审核,1:审核失败,2:退装成功)")
private Integer retiredStatus ; /**
* 列装库主键id(x作为分隔符),例如1x2,意为列装库id为1和2的退装
*/
@ApiModelProperty(value = "列装库主键id(x作为分隔符),例如x1x2,意为列装库id为1和2的退装")
private String retiredDetail ; /**
* 创建用户id
*/
@ApiModelProperty(value = "创建用户id")
@CreatedBy
private Integer createUserId ; /**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@CreatedDate
private Date createTime ; /**
* 更新用户id
*/
@ApiModelProperty(value = "更新用户id")
@LastModifiedBy
private Integer updateUserId ; /**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
@LastModifiedDate
private Date updateTime ; /**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0 ;
public DeviceRetiredBill(Integer userAId, Integer userBId, Integer retiredStatus, String retiredDetail) {
this.userAId = userAId;
this.userBId = userBId;
this.retiredStatus = retiredStatus;
this.retiredDetail = retiredDetail;
}
}
package entity.enums;
/**
* @author huangxiahao
*/
public enum RetiredStatus {
/**
* 待审核状态
*/
NEED_CONFIRM(0),
/**
* 审核失败
*/
CONFIRM_FAILED(1),
/**
* 审核成功
*/
CONFIRM_SUCCESS(2);
private Integer status;
RetiredStatus(Integer status) {
this.status = status;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
package entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author HuangXiahao
* @version V1.0
* @class CanDestoryDeviceSelectVo
* @packageName com.tykj.dev.device.retired.subject.entity.vo
**/
@ApiModel("可销毁装备查询类")
@Data
public class CanRetiredDeviceSelectVo {
@ApiModelProperty(value = "模糊查询",example = "装备1")
private String content;
@ApiModelProperty(value = "型号",example = "xxx-1")
private String model;
@ApiModelProperty(value = "密级(0:绝密,1:机密,2:秘密)",example = "1")
private Integer secretLevel;
@ApiModelProperty(value = "类型",example = "1")
private Integer type;
}
package entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceDestoryConfirmVo
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@Data
@ApiModel("退装单确认")
public class DeviceRetiredConfirmVo {
@NotNull
@ApiModelProperty(value = "工作ID",example = "1")
private Integer jobId;
@NotNull
@ApiModelProperty(value = "任务ID",example = "1")
private Integer taskId;
@NotNull
@ApiModelProperty(value = "审核结果 0为不通过 1为通过 ",example = "1")
private Integer result;
}
package entity.vo;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceDestoryDetailSelectVo
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@Data
@ApiModel("销毁详情查询类")
public class DeviceRetiredDetailResultVo {
@ApiModelProperty(value = "发起人ID",example = "1")
private Integer startUserId;
@ApiModelProperty(value = "审核人ID",example = "1")
private Integer confirmUserId;
@ApiModelProperty(value = "销毁状态(0:销毁装备出库待审核,1:销毁装备出库审核失败,2:已销毁)")
private Integer retiredStatus ;
@ApiModelProperty(value = "销毁装备列表",example = "1")
private List<PackingLibrary> packingLibrarys = new ArrayList<>();
}
package entity.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class DestoryFormVo
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@ApiModel("销毁表单")
@Data
public class DeviceRetiredFormVo {
@NotNull
private Integer confirmUserId;
@NotNull
private List<Integer> packings;
}
package entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceDestoryReadComfirm
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@ApiModel("退装状态阅读确认")
@Data
public class DeviceRetiredReadConfirm {
@NotNull
@ApiModelProperty(value = "工作ID",example = "1")
private Integer jobId;
@NotNull
@ApiModelProperty(value = "任务ID",example = "1")
private Integer taskId;
}
package entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceRetierResultVo
* @packageName com.tykj.dev.device.retired.subject.entity.vo
**/
@ApiModel("退装-列装详情")
@Data
public class DeviceRetiredResultVo {
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "型号",example = "xxx-1")
private String model;
@ApiModelProperty(value = "经办人/主管领导",example = "密级")
private Integer secretLevel;
@ApiModelProperty(value = "类型",example = "1")
private Integer type;
@ApiModelProperty(value = "数量",example = "1")
private Long count;
@ApiModelProperty(value = "数量",example = "1")
private List<DeviceRetiredResultVo> childNodes = new ArrayList<>();
}
package repository;
import entity.domain.DeviceRetiredBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceRetiredBillDao
* @packageName com.tykj.dev.device.retired.subject.repository
**/
public interface DeviceRetiredBillDao extends JpaRepository<DeviceRetiredBill,Integer>, JpaSpecificationExecutor<DeviceRetiredBill> {
}
package service;
import entity.domain.DeviceRetiredBill;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceRetiredBillService
* @packageName com.tykj.dev.device.retired.subject.service
**/
public interface DeviceRetiredBillService {
DeviceRetiredBill addEntity(DeviceRetiredBill deviceRetiredBillEntity);
DeviceRetiredBill getOne(Integer id);
DeviceRetiredBill update(DeviceRetiredBill deviceRetiredBillEntity);
void delete(Integer id);
/**
* 获取列装库不能被退装的装备数量
* @param packingLibraryId
* @return
*/
Long getCantPackingCount(Integer packingLibraryId);
}
package service.Impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import entity.domain.DeviceRetiredBill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import repository.DeviceRetiredBillDao;
import service.DeviceRetiredBillService;
import java.util.Optional;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceRetiredBillServiceImpl
* @packageName com.tykj.dev.device.retired.subject.service
**/
@Service
public class DeviceRetiredBillServiceImpl implements DeviceRetiredBillService {
@Autowired
DeviceRetiredBillDao deviceRetiredBillDao;
@Autowired
DeviceLibraryDao deviceLibraryDao;
@Override
public DeviceRetiredBill addEntity(DeviceRetiredBill deviceRetiredBillEntity) {
return deviceRetiredBillDao.save(deviceRetiredBillEntity);
}
@Override
public DeviceRetiredBill getOne(Integer id) {
Optional<DeviceRetiredBill> resultEntity = deviceRetiredBillDao.findById(id);
return resultEntity.orElse(null);
}
@Override
public DeviceRetiredBill update(DeviceRetiredBill deviceRetiredBillEntity) {
return deviceRetiredBillDao.save(deviceRetiredBillEntity);
}
@Override
public void delete(Integer id) {
deviceRetiredBillDao.deleteById(id);
}
@Override
public Long getCantPackingCount(Integer packingLibraryId) {
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.notIn("lifeStatus",10,13);
predicateBuilder.eq("packingId",packingLibraryId);
return deviceLibraryDao.count(predicateBuilder.build());
}
}
......@@ -9,6 +9,7 @@ import com.tykj.dev.device.task.subject.domin.Task;
import com.tykj.dev.device.task.subject.vo.TaskSelectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ExceptionHandler;
import java.util.Collections;
import java.util.List;
......@@ -197,6 +198,7 @@ public class TaskServiceImpl implements TaskService {
* 新增Task
*/
@Override
@ExceptionHandler(Exception.class)
public Task start(TaskBto taskBto) {
return taskDao.save(taskBto.toDo());
}
......
......@@ -13,6 +13,7 @@ import org.modelmapper.ModelMapper;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -76,6 +77,8 @@ public class TaskBto {
return task;
}
/**
* bto类转化为vo类
*/
......
......@@ -60,7 +60,7 @@ public enum BusinessEnum {
/**
* 销毁业务
*/
DESTORY(14,"销毁业务"),
DESTROY(14,"销毁业务"),
/**
* 退装业务
*/
......
......@@ -9,6 +9,34 @@ import lombok.AllArgsConstructor;
@AllArgsConstructor
public enum StatusEnum {
/**
* RFID标签制作
*/
CREATE_RFID_BUSINESS(8100,"标签制作业务开始"),
RFID_BUSINESS_NEED_CONFIRM(8101,"等待审核"),
RFID_BUSINESS_CONFIRM_FINISH_SUCCESS(8102,"审核成功"),
RFID_BUSINESS_CONFIRM_FINISH_FAILED(8103,"审核失败"),
/**
* 销毁业务
*/
CREATE_DESTROY_BUSINESS(8110,"标签制作业务开始"),
DESTROY_BUSINESS_NEED_CONFIRM(8111,"等待审核"),
DESTROY_BUSINESS_CONFIRM_FINISH_SUCCESS(8112,"审核成功"),
DESTROY_BUSINESS_CONFIRM_FINISH_FAILED(8113,"审核失败"),
/**
* 退装业务
*/
CREATE_RETIRED_BUSINESS(8120,"标签制作业务开始"),
RETIRED_BUSINESS_NEED_CONFIRM(8121,"等待审核"),
RETIRED_BUSINESS_CONFIRM_FINISH_SUCCESS(8122,"审核成功"),
RETIRED_BUSINESS_CONFIRM_FINISH_FAILED(8123,"审核失败"),
/**
* 业务完结
*/
......
......@@ -10,7 +10,7 @@
<module>device-allot</module>
<module>device-apply</module>
<module>device-confitmcheck</module>
<module>device-destory</module>
<module>device-destroy</module>
<module>device-library</module>
<module>device-finalcheck</module>
<module>device-matching</module>
......@@ -20,7 +20,7 @@
<module>device-scrap</module>
<module>device-selfcheck</module>
<module>device-sendback</module>
<module>device-stotage</module>
<module>device-storage</module>
<module>device-task</module>
<module>device-train</module>
<module>device-user</module>
......
package com.tykj.dev.misc.utils;
import java.util.ArrayList;
/**
* @author HuangXiahao
* @version V1.0
* @class ListUtil
* @packageName com.tykj.dev.misc.utils
**/
public class ListUtil<T> {
/**
* 通过数组创建一个设计人员的List
* 数组转列表
*/
public static<T> ArrayList<T> createList (T ... elements){
ArrayList<T> arrayList = new ArrayList<>();
for (T element :
elements) {
arrayList.add(element);
}
return arrayList;
}
}
......@@ -37,14 +37,14 @@ public class ResultUtil<T> {
* 失败返回结果
*/
public static <T> ResponseEntity<T> failed() {
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
/**
* 失败返回结果
*/
public static <T> ResponseEntity<T> failed(T content) {
return new ResponseEntity<>(content,HttpStatus.BAD_REQUEST);
return new ResponseEntity<>(content,HttpStatus.INTERNAL_SERVER_ERROR);
}
/**
......@@ -65,7 +65,7 @@ public class ResultUtil<T> {
* 参数验证失败返回结果
*/
public static <T> ResponseEntity<T> validateFailed(T content) {
return failed(HttpStatus.BAD_REQUEST,content);
return failed(HttpStatus.INTERNAL_SERVER_ERROR,content);
}
......
package com.tykj.dev.misc.utils;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @author HuangXiahao
......@@ -18,4 +22,90 @@ public class TimestampUtil {
public static Timestamp getCurrentTimestamp(){
return new Timestamp(System.currentTimeMillis());
}
/**
* 获取今天
* @return String
* */
public static Date getToday() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String format = simpleDateFormat.format(new Date());
return simpleDateFormat.parse(format);
}
/**
* 获取本月开始日期
* @return String
* **/
public static Date getMonthStart() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.add(Calendar.MONTH, 0);
cal.set(Calendar.DAY_OF_MONTH, 1);
Date time=cal.getTime();
String format = simpleDateFormat.format(time);
return simpleDateFormat.parse(format);
}
/**
* 获取本月最后一天
* @return String
* **/
public static Date getMonthEnd() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
Date time=cal.getTime();
String format = simpleDateFormat.format(time)+" 23:59:59";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(format);
}
/**
* 获取本周的第一天
* @return String
* **/
public static Date getWeekStart() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.add(Calendar.WEEK_OF_MONTH, 0);
cal.set(Calendar.DAY_OF_WEEK, 2);
Date time=cal.getTime();
String format = simpleDateFormat.format(time);
return simpleDateFormat.parse(format);
}
/**
* 获取本周的最后一天
* @return String
* **/
public static Date getWeekEnd() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, cal.getActualMaximum(Calendar.DAY_OF_WEEK));
cal.add(Calendar.DAY_OF_WEEK, 1);
Date time=cal.getTime();
String format = simpleDateFormat.format(time)+" 23:59:59";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(format);
}
/**
* 获取本年的第一天
* @return String
* **/
public static Date getYearStart() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
String format = simpleDateFormat.format(new Date())+"-01-01 00:00:00";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(format);
}
/**
* 获取本年的最后一天
* @return String
* **/
public static Date getYearEnd() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MONTH,calendar.getActualMaximum(Calendar.MONTH));
calendar.set(Calendar.DAY_OF_MONTH,calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
Date currYearLast = calendar.getTime();
String format = simpleDateFormat.format(currYearLast)+" 23:59:59";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(format);
}
}
......@@ -81,6 +81,24 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-user</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
......
......@@ -2,7 +2,11 @@ package com.tykj.dev.rfid;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author huangxiahao
*/
@SpringBootApplication
public class RfidApplication {
......
package com.tykj.dev.rfid.entity.domin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
/**
* entity class for library_warning_log
* 库房告警日志
*/
@Data
@Entity
@SQLDelete(sql = "update library_warning_log set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("库房告警日志")
public class LibraryWarningLog {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id;
/**
* 告警单位
*/
@ApiModelProperty(value = "告警单位")
private String unit;
/**
* 告警状态
*/
@ApiModelProperty(value = "告警状态 0为正常 1为异常 ")
private String status;
/**
/**
* 告警类型(0:入库异常,1:出库异常,2:盘点异常)
*/
@ApiModelProperty(value = "告警类型(0:入库异常,1:出库异常,2:盘点异常)")
private Integer warningType;
/**
* 是否处理 0为否 1为是
*/
@ApiModelProperty(value = "是否处理 0为未处理 1为已处理 2为正常")
private Integer warningHandle;
/**
* 盘点结果
*/
@ApiModelProperty(value = "异常情况(正常 新增X台 缺失X台)")
private String inventoryResults;
/**
* 应有数量
*/
@ApiModelProperty(value = "应有数量")
private String dueQuantity;
/**
* 实际数量
*/
@ApiModelProperty(value = "实际数量")
private String actualQuantity;
/**
* 创建用户id
*/
@ApiModelProperty(value = "创建用户id")
private Integer createUserId = 0;
/**
* 创建时间
*/
@CreatedDate
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新用户id
*/
@ApiModelProperty(value = "更新用户id")
private Integer updateUserId = 0;
/**
* 更新时间
*/
@LastModifiedDate
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
}
package com.tykj.dev.rfid.entity.domin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
/**
* entity class for library_warning_log_detail
* 库房告警详情
* @author huangxiahao
*/
@Data
@Entity
@SQLDelete(sql = "update library_warning_log_detail set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("库房告警详情")
public class LibraryWarningLogDetail {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id ;
/**
* 告警日志ID
*/
@ApiModelProperty(value = "告警日志ID")
private Integer libraryWarningLogId ;
/**
* 装备ID
*/
@ApiModelProperty(value = "装备ID")
private Integer deviceId ;
/**
* 0为正常 1为异常
*/
@ApiModelProperty(value = "0为正常 1为异常")
private Integer status ;
/**
* 是否处理 0为否 1为是
*/
@ApiModelProperty(value = "是否处理 0为否 1为是")
private Integer warningHandle ;
/**
* 处理结果
*/
@ApiModelProperty(value = "处理结果")
private String handleResult ;
/**
* 异常情况
*/
@ApiModelProperty(value = "异常情况")
private String inventoryResults ;
/**
* 创建用户id
*/
@ApiModelProperty(value = "创建用户id")
private Integer createUserId = 0;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@CreatedDate
private Date createTime ;
/**
* 更新用户id
*/
@ApiModelProperty(value = "更新用户id")
private Integer updateUserId = 0;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
@LastModifiedDate
private Date updateTime ;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0 ;
}
package com.tykj.dev.rfid.entity.domin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
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 javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.Date;
/**
* entity class for rfid_change_bill
* RFID修改记录账单
* @author admin
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@SQLDelete(sql = "update rfid_change_bill set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("RFID修改记录账单")
public class RfidChangeBill {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id ;
/**
* 经办人id(A岗)
*/
@ApiModelProperty(value = "经办人id(A岗)")
private Integer userAId ;
/**
* 审核人id(B岗)
*/
@ApiModelProperty(value = "审核人id(B岗)")
private Integer userBId ;
/**
* 创建用户id
*/
@ApiModelProperty(value = "创建用户id")
@CreatedBy
private Integer createUserId ;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@CreatedDate
private Date createTime ;
/**
* 更新用户id
*/
@ApiModelProperty(value = "更新用户id")
@LastModifiedBy
private Integer updateUserId ;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
@LastModifiedDate
private Date updateTime ;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0 ;
/**
* 修改单位
*/
@ApiModelProperty(value = "修改单位")
private Integer unit ;
/**
* 状态(0未完成,1审核失败,2审核成功)
*/
@ApiModelProperty(value = "状态(0未完成,1审核失败,2审核成功)")
private Integer status ;
/**
* 附件文件名
*/
@ApiModelProperty(value = "附件文件名")
private String fileName ;
/**
* 附件文件地址URL
*/
@ApiModelProperty(value = "附件文件地址URL")
private String fileUrl ;
public RfidChangeBill(Integer userAId, Integer userBId, Integer unit, Integer status, String fileName, String fileUrl) {
this.userAId = userAId;
this.userBId = userBId;
this.unit = unit;
this.status = status;
this.fileName = fileName;
this.fileUrl = fileUrl;
}
}
package com.tykj.dev.rfid.entity.domin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
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 javax.persistence.*;
import java.util.Date;
/**
* entity class for rfid_change_log
* RFID修改日志
* @author admin
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@SQLDelete(sql = "update rfid_change_log set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("RFID修改日志")
public class RfidChangeLog {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id ;
/**
* 对应装备IDid
*/
@ApiModelProperty(value = "对应装备ID")
private Integer deviceId ;
/**
* 修改单位
*/
@ApiModelProperty(value = "修改单位")
private String unit ;
/**
* 修改人A
*/
@ApiModelProperty(value = "修改人A")
private Integer userAId ;
/**
* 修改人B
*/
@ApiModelProperty(value = "修改人B")
private Integer userBId ;
/**
* rfid卡号
*/
@ApiModelProperty(value = "rfid卡号")
private String oldCardId ;
/**
* rfid卡号
*/
@ApiModelProperty(value = "rfid卡号")
private String newCardId ;
/**
* 创建用户id
*/
@ApiModelProperty(value = "创建用户id")
@CreatedBy
private Integer createUserId ;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
@CreatedDate
private Date createTime ;
/**
* 更新用户id
*/
@ApiModelProperty(value = "更新用户id")
@LastModifiedBy
private Integer updateUserId ;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
@LastModifiedDate
private Date updateTime ;
/**
* 删除标记(0:未删除,1:已删除)
*/
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0 ;
/**
* 对应装备ID
*/
@ApiModelProperty(value = "对应账单ID")
private Integer rfidChangeBillId ;
/**
* 生效标记(0:未生效,1:已生效)
*/
@ApiModelProperty(value = "生效标记(0:未生效,1:已生效)")
private Integer validTag ;
public RfidChangeLog(Integer deviceId, String unit, Integer userAId, Integer userBId, String oldCardId, String newCardId, Integer rfidChangeBillId, Integer validTag) {
this.deviceId = deviceId;
this.unit = unit;
this.userAId = userAId;
this.userBId = userBId;
this.oldCardId = oldCardId;
this.newCardId = newCardId;
this.rfidChangeBillId = rfidChangeBillId;
this.validTag = validTag;
}
}
package com.tykj.dev.rfid.entity.enums;
/**
* @author huangxiahao
*/
public enum RfidChangeStatus {
/**
* 待审核状态
*/
NEED_CONFIRM(0),
/**
* 审核失败
*/
CONFIRM_FAILED(1),
/**
* 审核成功
*/
CONFIRM_SUCCESS(2);
private Integer status;
RfidChangeStatus(Integer status) {
this.status = status;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.misc.base.CustomPage;
import org.springframework.beans.BeanUtils;
import java.util.Arrays;
/**
* @author HuangXiahao
* @version V1.0
* @class IndexLogSelectVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
public class IndexLogSelectVo extends CustomPage {
public LibraryWarningLogSelectVo toWarningVo(){
LibraryWarningLogSelectVo libraryWarningLogSelectVo = new LibraryWarningLogSelectVo();
BeanUtils.copyProperties(this,libraryWarningLogSelectVo);
libraryWarningLogSelectVo.setWarningType(Arrays.asList(0,1,2));
return libraryWarningLogSelectVo;
}
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class WarningDetailVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("盘存记录组装返回类")
public class InoutWarningDetailVo {
@ApiModelProperty(value = "详情信息")
List<WarningDetailListVo> detailListVos;
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
}
package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class InputOutpuLogSelectVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("出入库报警查询类")
public class InputOutpuLogSelectVo extends CustomPage {
@ApiModelProperty(value = "告警类型(0:入库异常,1:出库异常)")
private List<Integer> warningType;
@ApiModelProperty(value = "模糊查询")
private String content;
@ApiModelProperty("查询开始时间")
private Date startTime;
@ApiModelProperty("查询结束时间")
private Date endTime;
public LibraryWarningLogSelectVo toWarningVo(){
LibraryWarningLogSelectVo libraryWarningLogSelectVo = new LibraryWarningLogSelectVo();
BeanUtils.copyProperties(this,libraryWarningLogSelectVo);
if (this.warningType==null){
libraryWarningLogSelectVo.setWarningType(Arrays.asList(0,1));
}
return libraryWarningLogSelectVo;
}
}
package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author dengdiyi
*/
@Data
@ApiModel("库房报警记录查询类")
public class LibraryWarningLogSelectVo extends CustomPage {
@ApiModelProperty(value = "告警单位")
private String unit;
@ApiModelProperty(value = "告警类型(0:入库异常,1:出库异常,2:盘点异常)")
private List<Integer> warningType;
@ApiModelProperty(value = "模糊查询")
private String content;
@ApiModelProperty(value = "是否处理 0为未处理 1为已处理")
private Integer warningHandle;
@ApiModelProperty(value = "异常情况(正常 新增 缺失)")
private String inventoryResults;
@ApiModelProperty(value = "告警状态 0为正常 1为异常 ")
private Integer status;
@ApiModelProperty("时间 0为 本年 1为本月 2为本周 3为本日")
private Integer time;
@ApiModelProperty("查询开始时间")
private Date startTime;
@ApiModelProperty("查询结束时间")
private Date endTime;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class RFIDChangeVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("RFID修改日志")
public class RfidChangeBillResultVo {
@ApiModelProperty(value = "发起人ID",example = "1")
private Integer userAId ;
@ApiModelProperty(value = "审核人ID",example = "1")
private Integer userBId ;
@ApiModelProperty(value = "发起人",example = "1")
private String userAName;
@ApiModelProperty(value = "审核人",example = "1")
private String userBName;
@ApiModelProperty(value = "附件文件名")
private String fileName ;
@ApiModelProperty(value = "附件文件地址URL")
private String fileUrl ;
private List<RfidChangeLogResultVo> RfidChangeLogResultVos = new ArrayList<>();
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime ;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author HuangXiahao
* @version V1.0
* @class DeviceDestoryConfirmVo
* @packageName com.tykj.dev.device.destory.subject.entity.vo
**/
@Data
@ApiModel("rfid修改确认")
public class RfidChangeConfirmVo {
@NotNull
@ApiModelProperty(value = "工作ID",example = "1")
private Integer jobId;
@NotNull
@ApiModelProperty(value = "任务ID",example = "1")
private Integer taskId;
@NotNull
@ApiModelProperty(value = "审核结果 0为不通过 1为通过 ",example = "1")
private Integer result;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
/**
* @author HuangXiahao
* @version V1.0
* @class RFIDChangeInfoVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("从前端接收rfid变更信息")
public class RfidChangeInfoVo {
@Min(value = 1)
@ApiModelProperty(value = "装备ID",example = "1")
private Integer deviceId;
@ApiModelProperty(value = "新RFID卡号",example = "xxx1")
private String newRfidCardId;
@ApiModelProperty(value = "旧RFID卡号",example = "xxx1")
private String oldRfidCardId;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* entity class for rfid_change_log
* RFID修改日志
* @author admin
*/
@Data
@ApiModel("RFID修改日志详情返回给前端用的类")
public class RfidChangeLogResultVo {
@ApiModelProperty(name = "主键id")
private Integer id ;
@ApiModelProperty(value = "修改单位")
private String unit ;
@ApiModelProperty(value = "修改人A")
private Integer userAId ;
@ApiModelProperty(value = "修改人B")
private Integer userBId ;
@ApiModelProperty(value = "旧rfid卡号")
private String oldCardId ;
@ApiModelProperty(value = "新rfid卡号")
private String newCardId ;
@ApiModelProperty(value = "修改人A名称")
private String userAName;
@ApiModelProperty(value = "修改人B名称")
private String userBName;
@ApiModelProperty(value = "型号")
private String model;
@ApiModelProperty(value = "装备名称")
private String name;
@ApiModelProperty(value = "类型")
private Integer type;
@ApiModelProperty(value = "rfid表面号")
private String rfidSurfaceId;
@ApiModelProperty(value = "装备序列号")
private String seqNumber;
@ApiModelProperty(value = "生产序列号")
private String prodNumber;
@ApiModelProperty(value = "所属单位")
private String ownUnit;
@ApiModelProperty(value = "所在单位")
private String locationUnit;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author HuangXiahao
* @version V1.0
* @class RfidChangeLogSelectVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("标签更改记录查询类")
public class RfidChangeLogSelectVo {
@ApiModelProperty(value = "对应装备id")
private Integer deviceId ;
@ApiModelProperty(value = "对应账单id")
private Integer billId ;
@ApiModelProperty(value = "是否已经生效")
private Integer validTag ;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* entity class for rfid_change_log
* RFID修改日志
*/
@Data
@ApiModel("RFID修改日志")
public class RfidChangeLogVo {
@ApiModelProperty(name = "主键id")
private Integer id ;
@ApiModelProperty(value = "修改单位")
private String unit ;
@ApiModelProperty(value = "修改人A")
private Integer userAId ;
@ApiModelProperty(value = "修改人B")
private Integer userBId ;
@ApiModelProperty(value = "旧rfid卡号")
private String oldCardId ;
@ApiModelProperty(value = "新rfid卡号")
private String newCardId ;
@ApiModelProperty(value = "修改人A名称")
private String userAName;
@ApiModelProperty(value = "修改人B名称")
private String userBName;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author dengdiyi
*/
@Data
@ApiModel("生成RFID表面号类")
public class RfidCreateVo {
@ApiModelProperty(value = "装备ID 已入库装备使用该属性获取标签表面号 未入库装备不传该字段")
private Integer deviceTId;
@ApiModelProperty(value = "装备型号 共10位")
private String deviceType;
@ApiModelProperty(value = "配件类型 主体为0 共1位")
private String partType;
@ApiModelProperty(value = "装备序列号")
private String deviceNumber;
@ApiModelProperty(value = "生产序列号")
private String produceNumber;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class DestoryFormVo
**/
@Data
@ApiModel("RFID标签表单提交")
public class RfidFormVo {
@ApiModelProperty(value = "标签修改具体内容")
List<RfidChangeInfoVo> content;
@ApiModelProperty(value = "出库附件文件名")
private String fileName ;
@ApiModelProperty(value = "出库附件文件地址URL")
private String fileUrl ;
@ApiModelProperty(value = "审核人ID",example = "1")
private Integer confirmId;
}
package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class TagDetailVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@AllArgsConstructor
@ApiModel("标签详情")
public class TagDetailVo {
private DeviceLibrary deviceLibraryEntity;
private List<RfidChangeLogVo> rfidChangeLogEntities;
}
package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import java.util.Arrays;
import java.util.Date;
/**
* @author HuangXiahao
* @version V1.0
* @class InventoryLogSelectVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("库房报警记录查询类")
public class WarehouseLogSelectVo extends CustomPage {
@ApiModelProperty("查询开始时间")
private Date startTime;
@ApiModelProperty("查询结束时间")
private Date endTime;
public LibraryWarningLogSelectVo toWarningVo(){
LibraryWarningLogSelectVo libraryWarningLogSelectVo = new LibraryWarningLogSelectVo();
BeanUtils.copyProperties(this,libraryWarningLogSelectVo);
libraryWarningLogSelectVo.setWarningType(Arrays.asList(2));
return libraryWarningLogSelectVo;
}
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class WarningDetailVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("盘存记录组装返回类")
public class WarehouseWarningDetailVo {
@ApiModelProperty(value = "详情信息")
List<WarningDetailListVo> detailListVos;
@ApiModelProperty(value = "应有数量")
private String dueQuantity;
@ApiModelProperty(value = "实际数量")
private String actualQuantity;
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
}
package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import java.util.Arrays;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class WaringLogSelectVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("告警管理页面")
public class WaringLogSelectVo extends CustomPage {
@ApiModelProperty(value = "告警类型(0:入库异常,1:出库异常,2:盘点异常)")
private List<Integer> warningType;
@ApiModelProperty("时间 0为 本年 1为本月 2为本周 3为本日")
private Integer time;
@ApiModelProperty(value = "模糊查询")
private String content;
public LibraryWarningLogSelectVo toWarningVo(){
LibraryWarningLogSelectVo libraryWarningLogSelectVo = new LibraryWarningLogSelectVo();
BeanUtils.copyProperties(this,libraryWarningLogSelectVo);
if (this.warningType==null){
libraryWarningLogSelectVo.setWarningType(Arrays.asList(0,1,2));
}
libraryWarningLogSelectVo.setStatus(1);
return libraryWarningLogSelectVo;
}
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author HuangXiahao
* @version V1.0
* @class WarningCountVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("库房报警记录查询类")
public class WarningCountVo {
@ApiModelProperty(value = "本地告警")
private Long localWarning;
@ApiModelProperty(value = "盘点告警")
private Long inventoryWarning;
@ApiModelProperty(value = "进出库告警")
private Long enterOutWarning;
@ApiModelProperty(value = "处理告警")
private Long handleWaring;
}
package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author HuangXiahao
* @version V1.0
* @class WarningDetailVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("库房报警记录详情")
public class WarningDetailListVo {
@ApiModelProperty(name = "主键id")
private Integer id ;
@ApiModelProperty(value = "告警日志ID")
private Integer libraryWarningLogId ;
@ApiModelProperty(value = "0为正常 1为异常")
private Integer status ;
@ApiModelProperty(value = "是否处理 0为否 1为是")
private Integer warningHandle ;
@ApiModelProperty(value = "处理结果")
private String handleResult ;
@ApiModelProperty(value = "异常情况")
private String inventoryResults ;
@ApiModelProperty(value = "装备详情")
private DeviceLibrary deviceLibraryEntity;
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime ;
}
package com.tykj.dev.rfid.entity.vo;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author HuangXiahao
* @version V1.0
* @class WarningDetailSelectVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("告警详情查询类")
public class WarningDetailSelectVo extends CustomPage {
@ApiModelProperty(value = "告警记录ID")
Integer warningId;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class WarningDetailVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("盘存记录组装返回类")
public class WarningDetailVo {
@ApiModelProperty(value = "详情信息")
List<WarningDetailListVo> detailListVos;
@ApiModelProperty(value = "应有数量")
private String dueQuantity;
@ApiModelProperty(value = "实际数量")
private String actualQuantity;
@ApiModelProperty(value = "创建时间")
private java.util.Date createTime;
}
package com.tykj.dev.rfid.entity.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author HuangXiahao
* @version V1.0
* @class WarningDetailSelectVo
* @packageName com.tykj.dev.rfid.entity.vo
**/
@Data
@ApiModel("告警处理类")
public class WarningHandleVo {
@ApiModelProperty(value = "告警详情ID")
Integer warningDetailId;
@ApiModelProperty(value = "处理情况")
private String handleResult;
}
package com.tykj.dev.rfid.repository;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author dengdiyi
*/
public interface LibraryWarningLogDao extends JpaRepository<LibraryWarningLog,Integer>, JpaSpecificationExecutor<LibraryWarningLog> {
}
package com.tykj.dev.rfid.repository;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLogDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author dengdiyi
*/
public interface LibraryWarningLogDetailDao extends JpaRepository<LibraryWarningLogDetail,Integer>, JpaSpecificationExecutor<LibraryWarningLogDetail> {
}
package com.tykj.dev.rfid.repository;
import com.tykj.dev.rfid.entity.domin.RfidChangeBill;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author HuangXiahao
* @version V1.0
* @packageName com.tykj.dev.rfid.repository
**/
public interface RfidChangeBillDao extends JpaRepository<RfidChangeBill,Integer>, JpaSpecificationExecutor<RfidChangeBill> {
}
package com.tykj.dev.rfid.repository;
import com.tykj.dev.rfid.entity.domin.RfidChangeLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author HuangXiahao
* @version V1.0
* @class RfidChangeLogDao
* @packageName com.tykj.dev.rfid.repository
**/
public interface RfidChangeLogDao extends JpaRepository<RfidChangeLog,Integer>, JpaSpecificationExecutor<RfidChangeLog> {
}
package com.tykj.dev.rfid.service;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLogDetail;
/**
* @author HuangXiahao
* @version V1.0
* @packageName com.tykj.dev.rfid.service
**/
public interface LibraryWarningLogDetailService {
LibraryWarningLogDetail addEntity(LibraryWarningLogDetail libraryWarningLogDetail);
}
package com.tykj.dev.rfid.service;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLog;
import com.tykj.dev.rfid.entity.vo.LibraryWarningLogSelectVo;
import com.tykj.dev.rfid.entity.vo.WarningCountVo;
import com.tykj.dev.rfid.entity.vo.WarningDetailListVo;
import com.tykj.dev.rfid.entity.vo.WarningHandleVo;
import org.springframework.data.domain.Page;
import java.text.ParseException;
import java.util.List;
/**
* @author dengdiyi
*/
public interface LibraryWarningLogService {
LibraryWarningLog addEntity(LibraryWarningLog libraryWarningLog);
Page<LibraryWarningLog> getPage(LibraryWarningLogSelectVo libraryWarningLogSelectVo) throws ParseException;
List<WarningDetailListVo> getWarningDetail(Integer warningId,Boolean isHandle);
Integer updateDetailHandleResult(WarningHandleVo warningHandleVo);
LibraryWarningLog getOne(Integer id);
WarningCountVo getCount(LibraryWarningLogSelectVo libraryWarningLogSelectVo) throws ParseException;
LibraryWarningLog update(LibraryWarningLog libraryWarningLog);
}
package com.tykj.dev.rfid.service;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.rfid.entity.domin.RfidChangeBill;
import com.tykj.dev.rfid.entity.vo.RfidFormVo;
import javax.transaction.Transactional;
/**
* @author HuangXiahao
* @version V1.0
* @packageName com.tykj.dev.rfid.service
**/
public interface RfidChangeBillService {
RfidChangeBill addEntity(RfidChangeBill libraryWarningLogEntity);
RfidChangeBill getOne(Integer id);
RfidChangeBill updateEntity(RfidChangeBill rfidChangeBill);
}
package com.tykj.dev.rfid.service;
import com.tykj.dev.rfid.entity.domin.RfidChangeLog;
import com.tykj.dev.rfid.entity.vo.RfidChangeLogSelectVo;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @packageName com.tykj.dev.rfid.service
**/
public interface RfidChangeLogService {
RfidChangeLog getOne(Integer id);
List<RfidChangeLog> getList(RfidChangeLogSelectVo rfidChangeLogSelectVo);
RfidChangeLog addEntity(RfidChangeLog rfidChangeLog);
RfidChangeLog updateEntity(RfidChangeLog rfidChangeLog);
}
package com.tykj.dev.rfid.service;
import com.tykj.dev.rfid.entity.vo.RfidCreateVo;
import java.util.List;
/**
* 描述:用于调用RFID打印机打印标签
* @author HuangXiahao
* @version V1.0
* @packageName com.tykj.equipmentrfid.service
**/
public interface RfidService {
/**
* 描述:设置打印机网络端口
* @param ip IP
* @param port 端口号
*/
void setNetWorkConnection(String ip,Integer port) ;
/**
* 描述:自动扫描本机的打印机接口
*/
void scanUsbConnection() ;
/**
* 描述:调用打印机打印内容(如出现打印不对齐的情况请联系管理员)
* @param content 打印内容
* @return
*/
boolean printString(String content) ;
/**
* 描述:生成装备的RFID表面号
* @param list RFID表面号生成类
* @return
*/
List<String> getRfidNumber(List<RfidCreateVo> list);
}
package com.tykj.dev.rfid.service.impl;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLogDetail;
import com.tykj.dev.rfid.repository.LibraryWarningLogDetailDao;
import com.tykj.dev.rfid.service.LibraryWarningLogDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author HuangXiahao
* @version V1.0
* @class LibraryWarningLogDetailServiceImp
* @packageName com.tykj.dev.rfid.service.impl
**/
@Service
public class LibraryWarningLogDetailServiceImp implements LibraryWarningLogDetailService {
@Autowired
LibraryWarningLogDetailDao libraryWarningLogDetailDao;
@Override
public LibraryWarningLogDetail addEntity(LibraryWarningLogDetail libraryWarningLogDetail) {
return libraryWarningLogDetailDao.save(libraryWarningLogDetail);
}
}
package com.tykj.dev.rfid.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLogDetail;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLog;
import com.tykj.dev.rfid.entity.vo.LibraryWarningLogSelectVo;
import com.tykj.dev.rfid.entity.vo.WarningCountVo;
import com.tykj.dev.rfid.entity.vo.WarningDetailListVo;
import com.tykj.dev.rfid.entity.vo.WarningHandleVo;
import com.tykj.dev.rfid.repository.LibraryWarningLogDao;
import com.tykj.dev.rfid.repository.LibraryWarningLogDetailDao;
import com.tykj.dev.rfid.service.LibraryWarningLogService;
import com.tykj.dev.rfid.utils.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.persistence.Transient;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author dengdiyi
*/
@Service
public class LibraryWarningLogServiceImpl implements LibraryWarningLogService {
@Autowired
private LibraryWarningLogDao libraryWarningLogDao;
@Resource
UserUtils userUtils;
@Resource
DeviceLibraryService deviceLibraryService;
@Autowired
LibraryWarningLogDetailDao libraryWarningLogDetailDao;
@Override
public LibraryWarningLog addEntity(LibraryWarningLog libraryWarningLog) {
return libraryWarningLogDao.save(libraryWarningLog);
}
@Override
public Page<LibraryWarningLog> getPage(LibraryWarningLogSelectVo libraryWarningLogSelectVo) throws ParseException {
Specification<LibraryWarningLog> selectSpecification = getSelectSpecification(libraryWarningLogSelectVo);
return libraryWarningLogDao.findAll(selectSpecification,libraryWarningLogSelectVo.getPageable());
}
@Override
public List<WarningDetailListVo> getWarningDetail(Integer warningId,Boolean isHandle) {
List<WarningDetailListVo> warningDetailVos = new ArrayList<>();
PredicateBuilder<LibraryWarningLogDetail> and = Specifications.and();
and.eq("libraryWarningLogId",warningId);
if (isHandle!=null&&isHandle){
and.eq("warningHandle",1);
}
List<LibraryWarningLogDetail> all = libraryWarningLogDetailDao.findAll(and.build());
all.stream().forEach(d->{
WarningDetailListVo detailVo = new WarningDetailListVo();
if (d.getDeviceId()!=null){
DeviceLibrary deviceLibraryEntity = deviceLibraryService.getOne(d.getDeviceId());
BeanUtils.copyProperties(d,detailVo);
detailVo.setDeviceLibraryEntity(deviceLibraryEntity);
}else {
DeviceLibrary deviceLibraryEntity = new DeviceLibrary();
deviceLibraryEntity.setName("未知装备");
deviceLibraryEntity.setModel("未知型号");
deviceLibraryEntity.setRfidCardId("");
deviceLibraryEntity.setRfidSurfaceId("");
deviceLibraryEntity.setType(0);
BeanUtils.copyProperties(d,detailVo);
detailVo.setDeviceLibraryEntity(deviceLibraryEntity);
}
warningDetailVos.add(detailVo);
});
return warningDetailVos;
}
@Override
public Integer updateDetailHandleResult(WarningHandleVo warningHandleVo) {
LibraryWarningLogDetail detailEntity = libraryWarningLogDetailDao.getOne(warningHandleVo.getWarningDetailId());
detailEntity.setHandleResult(warningHandleVo.getHandleResult());
detailEntity.setWarningHandle(1);
LibraryWarningLogDetail save = libraryWarningLogDetailDao.save(detailEntity);
return save.getLibraryWarningLogId();
}
@Override
public LibraryWarningLog getOne(Integer id) {
return libraryWarningLogDao.getOne(id);
}
@Override
public WarningCountVo getCount(LibraryWarningLogSelectVo libraryWarningLogSelectVo) throws ParseException {
//获取时间段告警数量
Long localWarning = libraryWarningLogDao.count(getSelectSpecification(libraryWarningLogSelectVo));
//获取盘点告警数量
libraryWarningLogSelectVo.setWarningType(Arrays.asList(2));
Long inventoryWarning = libraryWarningLogDao.count(getSelectSpecification(libraryWarningLogSelectVo));
//获取出入库告警数量
libraryWarningLogSelectVo.setWarningType(Arrays.asList(0,1));
Long enterOutWarning = libraryWarningLogDao.count(getSelectSpecification(libraryWarningLogSelectVo));
//获取未处理告警数量
libraryWarningLogSelectVo.setWarningType(null);
libraryWarningLogSelectVo.setWarningHandle(0);
Long handleWaring = libraryWarningLogDao.count(getSelectSpecification(libraryWarningLogSelectVo));
return new WarningCountVo(localWarning,inventoryWarning,enterOutWarning,handleWaring);
}
@Override
public LibraryWarningLog update(LibraryWarningLog libraryWarningLog) {
return libraryWarningLogDao.save(libraryWarningLog);
}
private Specification<LibraryWarningLog> getSelectSpecification(LibraryWarningLogSelectVo libraryWarningLogSelectVo) throws ParseException {
PredicateBuilder<LibraryWarningLog> predicateBuilder = Specifications.and();
if (libraryWarningLogSelectVo.getUnit()!=null){
predicateBuilder.eq("unit",libraryWarningLogSelectVo.getUnit());
}else {
predicateBuilder.eq("unit",userUtils.getCurrentUserUnitName());
}
if (libraryWarningLogSelectVo.getInventoryResults()!=null){
predicateBuilder.like("inventoryResults","%"+libraryWarningLogSelectVo.getInventoryResults()+"%");
}
if (libraryWarningLogSelectVo.getStatus()!=null){
predicateBuilder.eq("status",libraryWarningLogSelectVo.getStatus());
}
if (libraryWarningLogSelectVo.getWarningType()!=null){
predicateBuilder.in("warningType",libraryWarningLogSelectVo.getWarningType().toArray());
}
if (libraryWarningLogSelectVo.getContent()!=null){
Class<LibraryWarningLog> libraryWarningLogEntityClass = LibraryWarningLog.class;
Field[] declaredFields = libraryWarningLogEntityClass.getDeclaredFields();
PredicateBuilder<LibraryWarningLog> p = Specifications.or();
for (Field field : declaredFields) {
if (field.getType().equals(String.class)&&field.getAnnotation(Transient.class)==null) {
p.like(field.getName(), "%" + libraryWarningLogSelectVo.getContent() + "%");
}
}
predicateBuilder.predicate(p.build());
}
if (libraryWarningLogSelectVo.getTime()!=null){
switch (libraryWarningLogSelectVo.getTime()){
case 0:
//设置查询条件为本年
predicateBuilder.ge("createTime",DateUtils.getYearStart());
predicateBuilder.le("createTime",DateUtils.getYearEnd());
break;
case 1:
//设置查询条件为本月
predicateBuilder.ge("createTime",DateUtils.getMonthStart());
predicateBuilder.le("createTime",DateUtils.getMonthEnd());
break;
case 2:
//设置查询条件为本周
predicateBuilder.ge("createTime",DateUtils.getWeekStart());
predicateBuilder.le("createTime",DateUtils.getWeekEnd());
break;
case 3:
//设置查询条件为本日
predicateBuilder.like("createTime","%"+DateUtils.getToday()+"%");
break;
default:
break;
};
}
if (libraryWarningLogSelectVo.getStartTime()!=null){
predicateBuilder.ge("createTime",libraryWarningLogSelectVo.getStartTime());
}
if (libraryWarningLogSelectVo.getEndTime()!=null){
predicateBuilder.le("createTime",libraryWarningLogSelectVo.getEndTime());
}
return predicateBuilder.build();
}
}
package com.tykj.dev.rfid.service.impl;
import com.tykj.dev.device.library.service.DeviceLibraryService;
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.vo.FileVo;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.util.AuthenticationUtils;
import com.tykj.dev.misc.utils.ListUtil;
import com.tykj.dev.rfid.entity.domin.RfidChangeBill;
import com.tykj.dev.rfid.entity.domin.RfidChangeLog;
import com.tykj.dev.rfid.entity.enums.RfidChangeStatus;
import com.tykj.dev.rfid.entity.vo.RfidFormVo;
import com.tykj.dev.rfid.repository.RfidChangeBillDao;
import com.tykj.dev.rfid.repository.RfidChangeLogDao;
import com.tykj.dev.rfid.service.RfidChangeBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.ExceptionHandler;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author HuangXiahao
* @version V1.0
* @class RfidChangeBillEntityServiceImpl
* @packageName com.tykj.dev.rfid.service.impl
**/
@Service
public class RfidChangeBillServiceImpl implements RfidChangeBillService {
@Autowired
RfidChangeBillDao rfidChangeBillDao;
@Autowired
RfidChangeLogDao rfidChangeLogDao;
@Override
public RfidChangeBill addEntity(RfidChangeBill libraryWarningLogEntity) {
return rfidChangeBillDao.save(libraryWarningLogEntity);
}
@Override
public RfidChangeBill updateEntity(RfidChangeBill libraryWarningLogEntity) {
return rfidChangeBillDao.save(libraryWarningLogEntity);
}
@Override
public RfidChangeBill getOne(Integer id) {
return rfidChangeBillDao.getOne(id);
}
}
package com.tykj.dev.rfid.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.rfid.entity.domin.RfidChangeLog;
import com.tykj.dev.rfid.entity.vo.RfidChangeLogSelectVo;
import com.tykj.dev.rfid.repository.RfidChangeLogDao;
import com.tykj.dev.rfid.service.RfidChangeLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class RfidChangeLogServiceImpl
* @packageName com.tykj.dev.rfid.service.impl
**/
@Service
public class RfidChangeLogServiceImpl implements RfidChangeLogService {
@Autowired
RfidChangeLogDao rfidChangeLogDao;
@Override
public RfidChangeLog getOne(Integer id) {
return rfidChangeLogDao.getOne(id);
}
@Override
public List<RfidChangeLog> getList(RfidChangeLogSelectVo rfidChangeLogSelectVo) {
return rfidChangeLogDao.findAll(getSelectSpecification(rfidChangeLogSelectVo));
}
@Override
public RfidChangeLog addEntity(RfidChangeLog rfidChangeLog) {
return rfidChangeLogDao.save(rfidChangeLog);
}
@Override
public RfidChangeLog updateEntity(RfidChangeLog rfidChangeLog) {
return rfidChangeLogDao.save(rfidChangeLog);
}
private Specification<RfidChangeLog> getSelectSpecification(RfidChangeLogSelectVo rfidChangeLogSelectVo){
PredicateBuilder<RfidChangeLog> predicateBuilder = Specifications.and();
if (rfidChangeLogSelectVo!=null) {
if(rfidChangeLogSelectVo.getValidTag()!=null){
predicateBuilder.eq("validTag",rfidChangeLogSelectVo.getValidTag());
}
if(rfidChangeLogSelectVo.getBillId()!=null){
predicateBuilder.eq("rfidChangeBillId",rfidChangeLogSelectVo.getBillId());
}
if (rfidChangeLogSelectVo.getDeviceId()!=null){
predicateBuilder.eq("deviceId",rfidChangeLogSelectVo.getDeviceId());
}
}
return predicateBuilder.build();
}
}
package com.tykj.dev.rfid.service.impl;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.ResultUtil;
import com.tykj.dev.rfid.entity.vo.RfidCreateVo;
import com.tykj.dev.rfid.service.RfidService;
import com.zebra.sdk.comm.Connection;
import com.zebra.sdk.comm.ConnectionException;
import com.zebra.sdk.comm.TcpConnection;
import com.zebra.sdk.printer.PrinterLanguage;
import com.zebra.sdk.printer.ZebraPrinter;
import com.zebra.sdk.printer.ZebraPrinterFactory;
import com.zebra.sdk.printer.ZebraPrinterLanguageUnknownException;
import com.zebra.sdk.printer.discovery.DiscoveredUsbPrinter;
import com.zebra.sdk.printer.discovery.UsbDiscoverer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* 描述:用于调用RFID打印机打印标签
*
* @author HuangXiahao
* @version V1.0
**/
@Service
@Slf4j
public class RfidServiceImpl implements RfidService {
@Resource
private DeviceLibraryService deviceLibraryService;
private static final Integer DEFAULT_USB_INDEX = 0;
private static ZebraPrinter printer;
/**
* 描述:设置打印机网络端口
*
* @param ip IP
* @param port 端口号
*/
@Override
public void setNetWorkConnection(String ip, Integer port) {
try {
//根据IP和PORT获取Connection
Connection connection = new TcpConnection(ip, port);
connection.open();
//获取打印机实力
printer = ZebraPrinterFactory.getInstance(connection);
} catch (ConnectionException | ZebraPrinterLanguageUnknownException e) {
throw new ApiException(ResultUtil.failed("未找到对应的端口,请检查网络"));
}
}
/**
* 描述:自动扫描本机的打印机接口
*/
@Override
public void scanUsbConnection() {
try {
//根据IP和PORT获取Connection
DiscoveredUsbPrinter[] zebraUsbPrinters = UsbDiscoverer.getZebraUsbPrinters();
Connection connection = zebraUsbPrinters[DEFAULT_USB_INDEX].getConnection();
//获取打印机实力
printer = ZebraPrinterFactory.getInstance(connection);
} catch (ConnectionException | ZebraPrinterLanguageUnknownException e) {
throw new ApiException(ResultUtil.failed("未找到对应的端口,请检查网络"));
}
}
@Override
public boolean printString(String content) {
try {
Connection connection = new TcpConnection("192.168.0.222", 6101);
connection.open();
printer = ZebraPrinterFactory.getInstance(connection);
String demoFile = createDemoFile(printer.getPrinterControlLanguage(), content, 53, 80);
printer.sendFileContents(demoFile);
} catch (ConnectionException e) {
throw new ApiException(ResultUtil.failed("未找到对应的打印机"));
} catch (ZebraPrinterLanguageUnknownException e) {
throw new ApiException(ResultUtil.failed("打印机内容错误"));
} catch (IOException e) {
throw new ApiException(ResultUtil.failed("生成打印文件失败"));
}
return true;
}
/**
* @param pl 打印机语言
* @param content 打印内容
* @param marginLeft 标签左边距
* @param marginTop 标签顶部边距
* @return 拼接成功的打印机ZPL
* @throws IOException IO错误
*/
private String createDemoFile(PrinterLanguage pl, String content, int marginLeft, int marginTop) throws IOException {
File tmpFile = File.createTempFile("TEST_ZEBRA", "LBL");
FileOutputStream os = new FileOutputStream(tmpFile);
byte[] configLabel = null;
if (pl == PrinterLanguage.ZPL) {
configLabel = ("^XA\n" +
"~TA000\n" +
"~JSN\n" +
"^LT0\n" +
"^MD30\n" +
"^MNW\n" +
"^MTT\n" +
"^PON\n" +
"^PMN\n" +
"^LH0,0\n" +
"^JMA\n" +
"^PR6,6\n" +
"~SD15\n" +
"^JUS\n" +
"^LRN\n" +
"^CI27\n" +
"^PA0,1,1,0\n" +
"^XZ\n" +
"^XA\n" +
"^MMT\n" +
"^PW428\n" +
"^LL264\n" +
"^LS0\n" +
"\n" +
"^LH" + marginLeft + "," + marginTop + "\n" +
"^A0N,60,25\n" +
"^FD" +
content +
"^FS\n" +
"^PQ1,0,1,Y\n" +
"^XZ\n" +
"^XZ").getBytes();
}
os.write(configLabel);
os.flush();
os.close();
return tmpFile.getAbsolutePath();
}
/**
* 描述:生成装备的RFID表面号
*
* @param list RFID表面号生成类
* @return
*/
@Override
public List<String> getRfidNumber(List<RfidCreateVo> list) {
List<String> strings = new ArrayList<>();
//遍历List为每一个创建元素生成对应的RFID表面号
for (RfidCreateVo r : list) {
//如果传入的创建元素中不包含装备ID的话,则生成新的表面号
//否则根据将已经装备的表面号插入LIST
if (r.getDeviceTId() == null) {
strings.add(makeRfidNumber(r.getPartType(), r.getDeviceNumber(), r.getProduceNumber(), r.getDeviceType()));
} else {
DeviceLibrary device = deviceLibraryService.getOne(r.getDeviceTId());
strings.add(device.getRfidSurfaceId());
}
}
return strings;
}
/**
* 描述:生成装备的RFID表面号
*
* @param deviceType 装备类型 共10位
* @param partType 配件类型 主体为0 共1位
* @param deviceNumber 装备序列号 由用户填写
* @param produceNumber 生产序列号 用户填写
* @return 生成的RFID表面号
*/
public String makeRfidNumber(String partType, String deviceNumber, String produceNumber, String deviceType) {
//配件类型的长度只能为1
if (partType.length() > 1) {
throw new IllegalArgumentException("配件类型字段过长");
}
StringBuilder stringBuffer = new StringBuilder();
if (deviceType.length() <= 10) {
stringBuffer.append(deviceType);
for (int i = 0; i < 10 - deviceType.length(); i++) {
stringBuffer.append(" ");
}
} else {
stringBuffer.append(deviceType.substring(deviceType.length() - 10));
}
stringBuffer.append("p");
stringBuffer.append(partType);
if (deviceNumber.length() < 4) {
stringBuffer.append(deviceNumber);
for (int i = 0; i < 4 - deviceNumber.length(); i++) {
stringBuffer.append(" ");
}
} else {
stringBuffer.append(deviceNumber.substring(deviceNumber.length() - 4));
}
if (produceNumber.length() < 4) {
stringBuffer.append(produceNumber);
for (int i = 0; i < 4 - produceNumber.length(); i++) {
stringBuffer.append(" ");
}
} else {
stringBuffer.append(produceNumber.substring(produceNumber.length() - 4));
}
return stringBuffer.toString();
}
}
package com.tykj.dev.rfid.timeTask;
import com.module.interaction.ReaderHelper;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLogDetail;
import com.tykj.dev.rfid.entity.domin.LibraryWarningLog;
import com.tykj.dev.rfid.repository.LibraryWarningLogDetailDao;
import com.tykj.dev.rfid.service.LibraryWarningLogService;
import com.tykj.dev.rfid.service.RfidChangeBillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
* @author HuangXiahao
* @version V1.0
* @class Inventory
* @packageName com.tykj.dev.rfid.timeTask
**/
@Slf4j
@Component
public class InventoryScheduled {
private String cron = "0 0/1 * * * ? ";
private ThreadPoolTaskScheduler threadPoolTaskScheduler;
final RfidChangeBillService rfidChangeBillService;
final LibraryWarningLogService libraryWarningLogService;
final LibraryWarningLogDetailDao libraryWarningLogDetailDao;
@Resource
DeviceLibraryService deviceLibraryService;
public InventoryScheduled(RfidChangeBillService rfidChangeBillService, LibraryWarningLogService libraryWarningLogService, LibraryWarningLogDetailDao libraryWarningLogDetailDao) {
this.rfidChangeBillService = rfidChangeBillService;
this.libraryWarningLogService = libraryWarningLogService;
this.libraryWarningLogDetailDao = libraryWarningLogDetailDao;
threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.initialize();
threadPoolTaskScheduler.schedule(new Inventory(), triggerContext -> new CronTrigger(cron).nextExecutionTime(triggerContext));
}
InventoryThread inventoryThread = new InventoryThread();
public class Inventory implements Runnable {
@Transactional(rollbackOn = Exception.class)
@Override
public void run(){
log.info("定时器执行了");
//将上一个线程设为停止
inventoryThread.setRunFlag(false);
//等待上一个线程彻底停止
try {
inventoryThread.join();
inventoryThread.interrupt();
} catch (InterruptedException e) {
e.printStackTrace();
}
//从线程中取出连接对象
ReaderHelper readerHelper = inventoryThread.getmReaderHelper();
if (readerHelper==null){
//如果连接对象为空则本次盘存无效 报警没有连接到盘点机
log.error("没有连接到天线");
}else { //已经确认在库的装备
//否则从线程中取出本次盘存的数据,用这些数据分析
ArrayList<String> strTids = inventoryThread.getStrTids();
//已经确认不在库的装备
ArrayList<LibraryWarningLogDetail> detailEntitiesOut = new ArrayList<>();
//已经确认正常的装备
ArrayList<LibraryWarningLogDetail> detailEntitiesIn = new ArrayList<>();
//已经确认多出来的装备
ArrayList<LibraryWarningLogDetail> detailEntitiesMore = new ArrayList<>();
//执行数据库操作
DeviceLibrarySelectVo deviceLibrarySelectVo = new DeviceLibrarySelectVo();
deviceLibrarySelectVo.setLifeStatus(Arrays.asList(2));
deviceLibrarySelectVo.setLocationUnit("省机要局");
deviceLibrarySelectVo.setUnitId(1);
List<DeviceLibrary> list = deviceLibraryService.getListWithoutParent(deviceLibrarySelectVo);
//遍历判断结果
LibraryWarningLog libraryWarningLog = new LibraryWarningLog();
libraryWarningLog.setUnit("省机要局");
libraryWarningLog.setStatus("0");
libraryWarningLog.setWarningType(2);
libraryWarningLog.setWarningHandle(0);
libraryWarningLog.setDueQuantity(list.size()+"");
libraryWarningLog = libraryWarningLogService.addEntity(libraryWarningLog);
for (int i = 0; i < list.size(); i++) {
DeviceLibrary deviceLibraryEntity = list.get(i);
//如果装备列表中装备没有被盘存到,则说明这件装备缺失了
if (!strTids.contains(deviceLibraryEntity.getRfidCardId())){
LibraryWarningLogDetail libraryWarningLogDetail = new LibraryWarningLogDetail();
libraryWarningLogDetail.setLibraryWarningLogId(libraryWarningLog.getId());
libraryWarningLogDetail.setDeviceId(deviceLibraryEntity.getId());
libraryWarningLogDetail.setStatus(1);
libraryWarningLogDetail.setWarningHandle(0);
libraryWarningLogDetail.setInventoryResults("缺失");
detailEntitiesOut.add(libraryWarningLogDetailDao.save(libraryWarningLogDetail));
}else {
//如果装备列表中装备被盘存到,则说明这件装备状态正常
LibraryWarningLogDetail libraryWarningLogDetail = new LibraryWarningLogDetail();
libraryWarningLogDetail.setLibraryWarningLogId(libraryWarningLog.getId());
libraryWarningLogDetail.setDeviceId(deviceLibraryEntity.getId());
libraryWarningLogDetail.setStatus(1);
libraryWarningLogDetail.setWarningHandle(0);
libraryWarningLogDetail.setInventoryResults("正常");
detailEntitiesIn.add(libraryWarningLogDetailDao.save(libraryWarningLogDetail));
//从盘存的列表中删除这一件装备
int i1 = strTids.indexOf(deviceLibraryEntity.getRfidCardId());
strTids.remove(i1);
}
}
//盘存列表里多出来的装备就时多出来的
if (strTids.size()>0){
for (int i = 0; i <strTids.size() ; i++) {
DeviceLibrarySelectVo deviceLibrarySelectVo2 = new DeviceLibrarySelectVo();
deviceLibrarySelectVo2.setUnitId(1);
deviceLibrarySelectVo2.setRfidCardId(strTids.get(i));
List<DeviceLibrary> list2 = deviceLibraryService.getListWithoutParent(deviceLibrarySelectVo2);
LibraryWarningLogDetail libraryWarningLogDetail = new LibraryWarningLogDetail();
libraryWarningLogDetail.setLibraryWarningLogId(libraryWarningLog.getId());
libraryWarningLogDetail.setStatus(1);
libraryWarningLogDetail.setWarningHandle(0);
if (list2.size()>0){
log.info("新增了一台未知设备");
libraryWarningLogDetail.setDeviceId(list2.get(0).getId());
libraryWarningLogDetail.setInventoryResults("新增一台未知设备");
}else {
libraryWarningLogDetail.setInventoryResults("新增");
}
detailEntitiesMore.add(libraryWarningLogDetailDao.save(libraryWarningLogDetail));
}
}
log.info("缺失size""+detailEntitiesOut.size());
log.info("新增size""+detailEntitiesMore.size());
if (detailEntitiesOut.size()>0||detailEntitiesMore.size()>0){
String inventoryResult = "";
if (detailEntitiesOut.size()>0){
inventoryResult += "缺失"+detailEntitiesOut.size()+"台";
}
if (detailEntitiesMore.size()>0){
inventoryResult += "新增"+detailEntitiesOut.size()+"台";
}
libraryWarningLog.setInventoryResults(inventoryResult);
libraryWarningLog.setStatus("1");
libraryWarningLog.setCreateTime(new Date());
}else {
libraryWarningLog.setCreateTime(new Date());
libraryWarningLog.setInventoryResults("正常");
}
libraryWarningLog.setActualQuantity(detailEntitiesMore.size()+detailEntitiesIn.size()+detailEntitiesIn.size()+"");
libraryWarningLogService.addEntity(libraryWarningLog);
}
if (inventoryThread.getmConnector()!=null){
inventoryThread.getmConnector().disConnect();
}
//重新开启线程
inventoryThread = new InventoryThread();
inventoryThread.run();
}
}
public String getCron() {
return cron;
}
public void setCron(String cron) {
this.cron = cron;
}
}
package com.tykj.dev.rfid.timeTask;
import cn.pda.serialport.Tools;
import com.module.interaction.ReaderHelper;
import com.rfid.RFIDReaderHelper;
import com.rfid.ReaderConnector;
import com.rfid.rxobserver.RXObserver;
import com.rfid.rxobserver.bean.RXInventoryTag;
import com.rfid.rxobserver.bean.RXOperationTag;
import com.util.StringTool;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.Observer;
/**
* @author HuangXiahao
* @version V1.0
* @class Thread
* @packageName com.tykj.dev.rfid.timeTask
**/
@Slf4j
public class InventoryThread extends Thread{
private final int ANT_COUNT = 1;
private int currentAnt = 0;
ArrayList<String> strEpcs = new ArrayList<>();
ArrayList<String> strTids = new ArrayList<>();
ReaderConnector mConnector = new ReaderConnector();
Boolean runFlag = true;
ReaderHelper mReaderHelper;
Observer mObserver = new RXObserver() {
@Override
protected void onInventoryTag(RXInventoryTag tag) {
//将EPC添加至List中
if (!strEpcs.contains(tag.strEPC)){
strEpcs.add(tag.strEPC);
}
}
@Override
protected void onInventoryTagEnd(RXInventoryTag.RXInventoryTagEnd endTag) {
for (String x:
strEpcs) {
//设置EPC编码
byte[] bytes = StringTool.stringToByteArray(x);
((RFIDReaderHelper) mReaderHelper).setAccessEpcMatch((byte) 0x01, (byte) bytes.length, bytes);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
//读取标签
byte[] pass = Tools.HexString2Bytes("00000000");
int i = ((RFIDReaderHelper) mReaderHelper).readTag((byte) 0xFF, (byte) 0x02, (byte) 0x00, (byte) 0x06, pass);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("现存标签EPC数量:"+strEpcs.size());
System.out.println("现存标签TID数量:"+strTids.size());
//设置天线
if (ANT_COUNT>1){
currentAnt = ++currentAnt%ANT_COUNT;
System.out.println("切换天线至:"+currentAnt);
((RFIDReaderHelper) mReaderHelper).setWorkAntenna((byte) 0x01,(byte)currentAnt);
}
if (runFlag){
((RFIDReaderHelper) mReaderHelper).realTimeInventory((byte) 0xff, (byte) 0x01);
}
}
@Override
protected void onExeCMDStatus(byte cmd, byte status) {
//盘存
((RFIDReaderHelper) mReaderHelper).realTimeInventory((byte) 0xff, (byte) 0x01);
}
@Override
protected void onOperationTag(RXOperationTag tag) {
String tid = tag.strData.replaceAll(" ","");
if (!strTids.contains(tid)){
strTids.add(tid);
}
}
};
@Override
public void run() {
mReaderHelper = mConnector.connectNet("192.168.0.178", 4001);
if (mReaderHelper != null) {
try {
mReaderHelper.registerObserver(mObserver);
((RFIDReaderHelper) mReaderHelper).setWorkAntenna((byte) 0x01,(byte) 0x00);
((RFIDReaderHelper) mReaderHelper).realTimeInventory((byte) 0xff, (byte) 0x01);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
log.error("连接天线失败");
mConnector.disConnect();
}
}
public void setRunFlag(Boolean runFlag) {
this.runFlag = runFlag;
}
public ArrayList<String> getStrTids() {
return strTids;
}
public ReaderHelper getmReaderHelper() {
return mReaderHelper;
}
public ReaderConnector getmConnector() {
return mConnector;
}
}
package com.tykj.dev.rfid.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* 描述:
* @author HuangXiahao
* @version V1.0
* @class DateUtils
* @packageName com.tykj.dev.rfid.utils
**/
public class DateUtils {
public static void main(String[] args) throws ParseException {
Date today = getYearEnd();
System.out.println("1");
}
/**
* 获取今天
* @return String
* */
public static Date getToday() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String format = simpleDateFormat.format(new Date());
return simpleDateFormat.parse(format);
}
/**
* 获取本月开始日期
* @return String
* **/
public static Date getMonthStart() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.add(Calendar.MONTH, 0);
cal.set(Calendar.DAY_OF_MONTH, 1);
Date time=cal.getTime();
String format = simpleDateFormat.format(time);
return simpleDateFormat.parse(format);
}
/**
* 获取本月最后一天
* @return String
* **/
public static Date getMonthEnd() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
Date time=cal.getTime();
String format = simpleDateFormat.format(time)+" 23:59:59";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(format);
}
/**
* 获取本周的第一天
* @return String
* **/
public static Date getWeekStart() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.add(Calendar.WEEK_OF_MONTH, 0);
cal.set(Calendar.DAY_OF_WEEK, 2);
Date time=cal.getTime();
String format = simpleDateFormat.format(time);
return simpleDateFormat.parse(format);
}
/**
* 获取本周的最后一天
* @return String
* **/
public static Date getWeekEnd() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.set(Calendar.DAY_OF_WEEK, cal.getActualMaximum(Calendar.DAY_OF_WEEK));
cal.add(Calendar.DAY_OF_WEEK, 1);
Date time=cal.getTime();
String format = simpleDateFormat.format(time)+" 23:59:59";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(format);
}
/**
* 获取本年的第一天
* @return String
* **/
public static Date getYearStart() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy");
String format = simpleDateFormat.format(new Date())+"-01-01 00:00:00";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(format);
}
/**
* 获取本年的最后一天
* @return String
* **/
public static Date getYearEnd() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MONTH,calendar.getActualMaximum(Calendar.MONTH));
calendar.set(Calendar.DAY_OF_MONTH,calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
Date currYearLast = calendar.getTime();
String format = simpleDateFormat.format(currYearLast)+" 23:59:59";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(format);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论