提交 64c506e5 authored 作者: Matrix's avatar Matrix

[核查模块] 重构1.0

上级 d60337ae
......@@ -11,5 +11,19 @@
<artifactId>device-confitmcheck</artifactId>
<dependencies>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-task</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.tykj.dev</groupId>
<artifactId>device-library</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.tykj.dev.device.confirmcheck.common;
import lombok.AllArgsConstructor;
/**
* AreaLevel.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/16 at 7:03 下午
*/
@AllArgsConstructor
public enum AreaLevel {
PROVINCE(1, "省级"),
CITY(2, "市级"),
COUNTY(3, "县级");
public int id;
public String name;
}
package com.tykj.dev.device.confirmcheck.entity.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
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 org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.util.Date;
/**
* entity class for device_check_bill
* 装备核查账单
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_check_bill set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("装备核查账单")
@Table(name = "device_check_bill", schema = "device_check_bill")
@NoArgsConstructor
public class DeviceCheckBillEntity {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", columnDefinition = "not null int(11) 主键id")
@ApiModelProperty(name = "主键id")
private Integer id;
/**
* 检查组成员1(省A岗)id
*/
@Column(name = "userA_id", columnDefinition = "not null int(11) 检查组成员1(省A岗)id")
@ApiModelProperty(value = "检查组成员1(省A岗)id")
private Integer userAId;
/**
* 检查组成员2(省A岗)id
*/
@Column(name = "userB_id", columnDefinition = "not null int(11) 检查组成员2(省A岗)id")
@ApiModelProperty(value = "检查组成员2(省A岗)id")
private Integer userBId;
/**
* 核查状态(0:决算待审核,1:决算审核失败,2:决算中,3:决算完成)
*/
@Column(name = "check_status", columnDefinition = "not null int(11) 核查状态(0:决算待审核,1:决算审核失败,2:决算中,3:决算完成)")
@ApiModelProperty(value = "核查状态(0:决算待审核,1:决算审核失败,2:决算中,3:决算完成)")
private Integer checkStatus;
/**
* 核查单位主键id(x作为分隔符),例如1x2,意为单位id为1和2的装备核查
*/
@Column(name = "check_detail", columnDefinition = "not null text 核查单位主键id(x作为分隔符),例如1x2,意为单位id为1和2的装备核查")
@ApiModelProperty(value = "核查单位主键id(x作为分隔符),例如1x2,意为单位id为1和2的装备核查")
private String checkDetail;
/**
* 核查标题
*/
@Column(name = "check_title", columnDefinition = "not null varchar(32) 核查标题")
@ApiModelProperty(value = "核查标题")
private String checkTitle;
/**
* 备注
*/
@Column(name = "remark", columnDefinition = "not null varchar(255) 备注")
@ApiModelProperty(value = "备注")
private String remark;
/**
* 创建用户id
*/
@CreatedBy
@Column(name = "create_user_id", columnDefinition = "not null int(11) 创建用户id")
@ApiModelProperty(value = "创建用户id")
private Integer createUserId;
/**
* 创建时间
*/
@CreatedDate
@Column(name = "create_time", columnDefinition = "not null datetime 创建时间")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新用户id
*/
@LastModifiedBy
@Column(name = "update_user_id", columnDefinition = "not null int(11) 更新用户id")
@ApiModelProperty(value = "更新用户id")
private Integer updateUserId;
/**
* 更新时间
*/
@LastModifiedDate
@Column(name = "update_time", columnDefinition = "not null datetime 更新时间")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@Column(name = "delete_tag", columnDefinition = "not null int(11) 删除标记(0:未删除,1:已删除)")
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
public DeviceCheckBillEntity(Integer userAId, Integer userBId, Integer checkStatus, String checkDetail, String checkTitle, Date completeTime, String remark) {
this.userAId = userAId;
this.userBId = userBId;
this.checkStatus = checkStatus;
this.checkDetail = checkDetail;
this.checkTitle = checkTitle;
this.remark = remark;
}
}
package com.tykj.dev.device.confirmcheck.entity.domain;
import com.tykj.dev.device.confirmcheck.entity.vo.CheckDeviceStatVo;
import com.tykj.dev.device.confirmcheck.entity.vo.CheckStatVo;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.JacksonUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
import org.modelmapper.ModelMapper;
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.Arrays;
import java.util.Date;
/**
* DeviceCheckStat.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/15 at 7:09 下午
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@SQLDelete(sql = "update device_check_stat set delete_tag = 1 where id = ?")
@Where(clause = "delete_tag = 0")
@ApiModel("装备核查统计")
@Table(name = "device_check_stat", schema = "device_check_stat")
@NoArgsConstructor
public class DeviceCheckStat {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 父标题
*/
private String title;
/**
* 子标题
*/
private String subtitle;
/**
* 开始时间
*/
private Date startTime;
/**
* 结束时间
*/
private Date endTime;
/**
* 统计信息以JSON形式存储
*/
private String statInfo;
/**
* 创建用户id
*/
@CreatedBy
@Column(name = "create_user_id", columnDefinition = "not null int(11) 创建用户id")
@ApiModelProperty(value = "创建用户id")
private Integer createUserId;
/**
* 创建时间
*/
@CreatedDate
@Column(name = "create_time", columnDefinition = "not null datetime 创建时间")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新用户id
*/
@LastModifiedBy
@Column(name = "update_user_id", columnDefinition = "not null int(11) 更新用户id")
@ApiModelProperty(value = "更新用户id")
private Integer updateUserId;
/**
* 更新时间
*/
@LastModifiedDate
@Column(name = "update_time", columnDefinition = "not null datetime 更新时间")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
@Column(name = "delete_tag", columnDefinition = "not null int(11) 删除标记(0:未删除,1:已删除)")
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0;
public DeviceCheckStat(String title, String subtitle, Date startTime, Date endTime, String statInfo) {
this.title = title;
this.subtitle = subtitle;
this.startTime = startTime;
this.endTime = endTime;
this.statInfo = statInfo;
}
/**
* Do类转化为Vo类
*/
public CheckStatVo toVo() {
ModelMapper mapper = BeanHelper.getUserMapper();
//复制基本信息
CheckStatVo initialStat = mapper.map(this, CheckStatVo.class);
//解析JSON并赋值
CheckDeviceStatVo[] checkDeviceStatVos = JacksonUtil.readValue(this.statInfo, CheckDeviceStatVo[].class);
initialStat.setDeviceStatVoList(Arrays.asList(checkDeviceStatVos));
return initialStat;
}
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* CheckAreaStatVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/15 at 7:20 下午
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class CheckAreaStatVo {
/**
* 地区名
*/
private String areaName;
/**
* 实查数量
*/
private int actualCount;
/**
* 应查数量
*/
private int supposeCount;
/**
* 完成进度 0-待办 , 1-进行中, 2-已完成
*/
private int comProgress;
/**
* 完成情况 0-无误 1-有异常
*/
private int comSituation;
/**
* 该地区对应的统计账单id
*/
private int areaStatId;
/**
* 该地区对应的详情账单id
*/
private int areaDetailId;
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* CheckBillVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/17 at 6:20 下午
*/
@Data
@ApiModel("核查发起对象")
public class CheckBillVo {
@ApiModelProperty(name = "业务标题", example = "浙江省手动核查测试")
@JSONField(name = "title")
private String checkTitle;
@ApiModelProperty(name = "核查组成员A id", example = "1")
private Integer userAId;
@ApiModelProperty(name = "核查组成员B id", example = "2")
private Integer userBId;
@ApiModelProperty(name = "发起单位id", example = "1")
private Integer unitId;
@ApiModelProperty(name = "要核查的区域id数组", example = "[\"2\"]")
private List<Integer> areaRange;
@ApiModelProperty(name = "备注", example = "这是一段测试数据")
private String remark;
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* CheckDetailVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/17 at 8:46 下午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CheckDetailVo {
/**
* 主键id
*/
@ApiModelProperty(name = "主键id")
private Integer id;
/**
* 核查账单id
*/
@ApiModelProperty(value = "核查账单id")
private Integer finalCheckId;
/**
* 检查组成员1(省A岗) 名称
*/
@ApiModelProperty(value = "检查组成员1(省A岗)名称")
private String checkUserAName;
/**
* 检查组成员2(省A岗) 名称
*/
@ApiModelProperty(value = "检查组成员2(省A岗)名称")
private String checkUserBName;
/**
* 本级经办人名称(A岗)
*/
@ApiModelProperty(value = "本级经办人名称(A岗)")
private String userAName;
/**
* 本级审核人名称(B岗)
*/
@ApiModelProperty(value = "本级审核人名称(B岗)")
private String userBName;
/**
* 检查组成员1(省A岗)id
*/
@ApiModelProperty(value = "检查组成员1(省A岗)id")
private Integer checkUserAId;
/**
* 检查组成员2(省A岗)id
*/
@ApiModelProperty(value = "检查组成员2(省A岗)id")
private Integer checkUserBId;
/**
* 本级经办人id(A岗)
*/
@ApiModelProperty(value = "本级经办人id(A岗)")
private Integer userAId;
/**
* 本级审核人id(B岗)
*/
@ApiModelProperty(value = "本级审核人id(B岗)")
private Integer userBId;
/**
* 核查时间
*/
@ApiModelProperty(value = "核查时间")
private Date checkTime;
/**
* 核查单位
*/
@ApiModelProperty(value = "核查单位")
private String checkUnit;
/**
* 应查数量
*/
@ApiModelProperty(value = "应查数量")
private Integer checkingCount;
/**
* 实查数量
*/
@ApiModelProperty(value = "实查数量")
private Integer checkedCount;
/**
* 核查结果
*/
@ApiModelProperty(value = "核查结果")
private String checkResult;
@ApiModelProperty(value = "在库装备列表")
private List<DeviceInLibVo> devInLibrary;
@ApiModelProperty(value = "非在库装备列表")
private List<DeviceNotInLibVo> devNotInLibrary;
/**
* 核查状态(0:待核查,1:审核失败,2:核查完成)
*/
@ApiModelProperty(value = "核查状态(0:待核查,1:审核失败,2:核查完成)")
private Integer checkStatus;
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
/**
* CheckDeviceStatVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/15 at 7:18 下午
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@Slf4j
public class CheckDeviceStatVo {
/**
* 装备型号
*/
private String deviceModel;
/**
* 装备名称
*/
private String deviceName;
/**
* 装备总数
*/
private int deviceCount;
/**
* 核查该型号装备的各地区统计情况
*/
private List<CheckAreaStatVo> areaStatList;
/**
* other的model一定要与本deviceModel相同
*/
public void add(CheckDeviceStatVo other) {
if (!deviceModel.equals(other.getDeviceModel())) {
log.warn("[核查] 合并统计的数据发现装备不统一的情况");
return;
}
deviceCount += other.getDeviceCount();
for (CheckAreaStatVo otherArea : other.getAreaStatList()) {
if (deviceModel.equals(other.getDeviceModel())) {
for (CheckAreaStatVo statVo : areaStatList) {
if (statVo.getAreaName().equals(otherArea.getAreaName())) {
statVo.setAreaName(otherArea.getAreaName());
statVo.setAreaStatId(otherArea.getAreaStatId());
statVo.setAreaDetailId(otherArea.getAreaDetailId());
statVo.setActualCount(statVo.getActualCount() + otherArea.getActualCount());
statVo.setSupposeCount(statVo.getSupposeCount() + otherArea.getSupposeCount());
statVo.setComProgress(otherArea.getComProgress());
statVo.setComSituation(otherArea.getComSituation());
}
}
}
}
}
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat;
import com.tykj.dev.misc.base.BeanHelper;
import com.tykj.dev.misc.utils.JacksonUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* DeviceCheckStatVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/15 at 7:13 下午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CheckStatVo {
/**
* 主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
/**
* 父标题
*/
private String title;
/**
* 子标题
*/
private String subtitle;
/**
* 开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**
* 结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
private Date createTime;
private Date updateTime;
private Integer createUserId;
private Integer updateUserId;
/**
* 核查装备详情
*/
private List<CheckDeviceStatVo> deviceStatVoList;
public CheckStatVo(Integer id, String title, String subtitle, Date startTime, Date endTime, List<CheckDeviceStatVo> deviceStatVoList) {
this.id = id;
this.title = title;
this.subtitle = subtitle;
this.startTime = startTime;
this.endTime = endTime;
this.deviceStatVoList = deviceStatVoList;
}
public static CheckStatVo empty() {
List<CheckDeviceStatVo> emptyList = new ArrayList<>();
return new CheckStatVo(0, "无指定数据", "无指定数据", null, null, emptyList);
}
/**
* Vo转Do
*/
public DeviceCheckStat toDo() {
ModelMapper mapper = BeanHelper.getUserMapper();
//复制基本信息
DeviceCheckStat initialStat = mapper.map(this, DeviceCheckStat.class);
//数据转JSON并赋值
String jsonString = JacksonUtil.toJSon(this.deviceStatVoList);
initialStat.setStatInfo(jsonString);
return initialStat;
}
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* DevLibVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/19 at 4:56 下午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DevLibVo {
private List<DeviceInLibVo> devInLibrary;
private List<DeviceNotInLibVo> devNotInLibrary;
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* DeviceInLibVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/18 at 4:41 下午
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class DeviceInLibVo {
private int id;
private String model;
private String name;
private String seqNumber;
private String prodNumber;
private String rfidSurfaceId;
private String rfidCardId;
private int proofResult;
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* DeviceNotInLibVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/18 at 4:41 下午
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class DeviceNotInLibVo {
private int id;
private String model;
private String name;
private String seqNumber;
private String prodNumber;
private String rfidSurfaceId;
private String rfidCardId;
private String locationUnit;
private String ownUnit;
private int status;
}
package com.tykj.dev.device.confirmcheck.repository;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckBillEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author dengdiyi
*/
public interface DeviceCheckBillDao extends JpaRepository<DeviceCheckBillEntity, Integer>, JpaSpecificationExecutor<DeviceCheckBillEntity> {
}
package com.tykj.dev.device.confirmcheck.repository;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetailEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
/**
* @author dengdiyi
*/
@Transactional
public interface DeviceCheckDetailDao extends JpaRepository<DeviceCheckDetailEntity, Integer>, JpaSpecificationExecutor<DeviceCheckDetailEntity> {
/**
* 根据id更新checkDetail
*
* @param id detail id
* @param checkDetail 要更新的检查结果
*/
@Modifying
@Query("update DeviceCheckDetailEntity o set o.checkDetail=?2,o.checkResult = ?3,o.userAId =?4,o.userBId=?5 where o.id=?1")
void updateCheckDetail(Integer id, String checkDetail, String checkResult, int userAId, int userBId);
@Modifying
@Query("update DeviceCheckDetailEntity o set o.checkStatus=?2 where o.id=?1")
int updateCheckStatus(int id, int checkStatus);
/**
* 更新 checkUserAId 与 checkUserBId
*
* @param id detailId
* @param checkUserAId 核查组成员A
* @param checkUserBId 核查组成员B
*/
@Modifying
@Query("update DeviceCheckDetailEntity o set o.checkUserAId =?2,o.checkUserBId=?3 where o.id =?1")
void updateCheckUser(int id, int checkUserAId, int checkUserBId);
}
package com.tykj.dev.device.confirmcheck.repository;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckStat;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* DeviceCheckStatRepo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/16 at 5:26 下午
*/
@Repository
public interface DeviceCheckStatRepo extends JpaRepository<DeviceCheckStat, Integer> {
}
package com.tykj.dev.device.confirmcheck.utils;
import com.tykj.dev.device.task.subject.bto.TaskBto;
/**
* ObjConsUtil.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/9/2 at 2:02 下午
*/
public class ObjConsUtil {
public static TaskBto newTaskBto(Integer status,
String title,
Integer parentTaskId,
String nodeIdDetail,
Integer billId,
Integer ownUnit
) {
TaskBto taskBto = new TaskBto();
taskBto.setBillStatus(status);
taskBto.setTitle(title);
taskBto.setParentTaskId(parentTaskId);
taskBto.setNodeIdDetail(nodeIdDetail);
taskBto.setBillId(billId);
taskBto.setOwnUnit(ownUnit);
return taskBto;
}
}
package com.tykj.dev.device.confirmcheck.utils;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckBillEntity;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetailEntity;
import com.tykj.dev.device.confirmcheck.entity.vo.CheckBillVo;
import com.tykj.dev.device.confirmcheck.entity.vo.CheckDetailVo;
import com.tykj.dev.device.confirmcheck.entity.vo.DeviceInLibVo;
import com.tykj.dev.device.confirmcheck.entity.vo.DeviceNotInLibVo;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.user.subject.dao.AreaDao;
import com.tykj.dev.device.user.subject.dao.UnitsDao;
import com.tykj.dev.device.user.subject.dao.UserDao;
import com.tykj.dev.misc.base.BeanHelper;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* ObjTransUtil.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/17 at 8:45 下午
*/
@Component
public class ObjTransUtil {
@Autowired
private UserDao userRepo;
@Autowired
private DeviceLibraryDao deviceRepo;
@Autowired
private AreaDao areaRepo;
@Autowired
private UnitsDao unitRepo;
public DeviceCheckBillEntity checkBillVo2Do(CheckBillVo vo) {
ModelMapper modelMapper = BeanHelper.getUserMapper();
DeviceCheckBillEntity billDo = modelMapper.map(vo, DeviceCheckBillEntity.class);
billDo.setCheckStatus(0);
//areas -> unitIds -> unitStrings
String unitString = vo.getAreaRange().stream()
.flatMap(id -> unitRepo.findAllByAreaId(id).stream())
.map(units -> units.getUnitId().toString())
.collect(Collectors.joining("x"));
billDo.setCheckDetail(unitString);
return billDo;
}
public DeviceCheckDetailEntity checkDetailVo2Do(CheckDetailVo detailVo) {
ModelMapper modelMapper = BeanHelper.getUserMapper();
DeviceCheckDetailEntity detailDo = modelMapper.map(detailVo, DeviceCheckDetailEntity.class);
//将inLib与notInLib 的集合 转化为压缩字符串
String checkDetailString = devLib2String(detailVo.getDevInLibrary(), detailVo.getDevNotInLibrary());
detailDo.setCheckDetail(checkDetailString);
return detailDo;
}
public String devLib2String(List<DeviceInLibVo> inLibrary, List<DeviceNotInLibVo> notInLibrary) {
String inLibString = inLibrary.stream()
.map(lib -> String.format("%d-%d", lib.getId(), lib.getProofResult()))
.collect(Collectors.joining(","));
String notInLibString = notInLibrary.stream()
.map(lib -> String.format("%d-%d", lib.getId(), 3))
.collect(Collectors.joining(","));
//不为空则拼接
String checkDetailString = inLibString;
if (!CollectionUtils.isEmpty(notInLibrary)) {
checkDetailString = checkDetailString + notInLibString;
}
return checkDetailString;
}
public CheckDetailVo CheckDetailDo2Vo(DeviceCheckDetailEntity detailDo) {
//查询人物id
Integer checkUserAId = detailDo.getCheckUserAId();
Integer checkUserBId = detailDo.getCheckUserBId();
Integer userAId = detailDo.getUserAId();
Integer userBId = detailDo.getUserBId();
String checkUserAName = userRepo.findById(checkUserAId).orElse(null).getName();
String checkUserBName = userRepo.findById(checkUserBId).orElse(null).getName();
String userAName = "";
String userBName = "";
if (userAId != null && userAId != 0) {
userAName = userRepo.findById(userAId).orElse(null).getName();
}
if (userBId != null && userBId != 0) {
userBName = userRepo.findById(userBId).orElse(null).getName();
}
//解析核查详情 -> 获取id与核查结果
List<DeviceInLibVo> inLibVoList = new ArrayList<>();
List<DeviceNotInLibVo> notInLibVoList = new ArrayList<>();
String checkDetail = detailDo.getCheckDetail();
String[] detailArray = checkDetail.split(",");
for (String detail : detailArray) {
String[] array = detail.split("-");
Integer deviceId = Integer.valueOf(array[0]);
int proofResult = Integer.parseInt(array[1]);
DeviceLibrary device = deviceRepo.findById(deviceId).orElse(null);
//依据proofResult 判断是否是在库装备
if (proofResult == 3) {
// 非在库装备
notInLibVoList.add(toCheckNotInLibVo(device));
} else {
// 在库装备
inLibVoList.add(toCheckInLibVo(device, proofResult));
}
}
// detailDo -> detailVo
ModelMapper modelMapper = BeanHelper.getUserMapper();
CheckDetailVo detailVo = modelMapper.map(detailDo, CheckDetailVo.class);
detailVo.setCheckUserAName(checkUserAName);
detailVo.setCheckUserBName(checkUserBName);
detailVo.setUserAName(userAName);
detailVo.setUserBName(userBName);
detailVo.setDevInLibrary(inLibVoList);
detailVo.setDevNotInLibrary(notInLibVoList);
return detailVo;
}
public DeviceInLibVo toCheckInLibVo(DeviceLibrary device, int proofResult) {
return new DeviceInLibVo(
device.getId(),
device.getModel(),
device.getName(),
device.getSeqNumber(),
device.getProdNumber(),
device.getRfidSurfaceId(),
device.getRfidCardId(),
proofResult
);
}
public DeviceNotInLibVo toCheckNotInLibVo(DeviceLibrary device) {
return new DeviceNotInLibVo(
device.getId(),
device.getModel(),
device.getName(),
device.getSeqNumber(),
device.getProdNumber(),
device.getRfidSurfaceId(),
device.getRfidCardId(),
device.getLocationUnit(),
device.getOwnUnit(),
device.getLifeStatus()
);
}
}
......@@ -199,4 +199,5 @@ public class DeviceLibrary {
public void addChildNode(DeviceLibrary deviceLibraryEntity) {
childs.add(deviceLibraryEntity);
}
}
......@@ -3,6 +3,7 @@ package com.tykj.dev.device.task.repository;
import com.tykj.dev.device.task.subject.domin.Task;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
......@@ -12,27 +13,38 @@ import java.util.List;
public interface TaskDao extends JpaRepository<Task, Integer>, JpaSpecificationExecutor<Task> {
/**
* @param billId 账单id
* @param billId 账单id
* @param businessType 业务类型
* 根据账单Id和业务类型查询task
* 根据账单Id和业务类型查询task
*/
Task findByBillIdAndBusinessType(Integer billId, Integer businessType);
/**
* 根据账单id、业务类型、任务状态查询task
* @param billId 账单id
*
* @param billId 账单id
* @param businessType 业务类型
* @param billStatus 任务状态
* @param billStatus 任务状态
*/
List<Task> findAllByBillIdAndBusinessTypeAndBillStatus(Integer billId,Integer businessType,Integer billStatus);
List<Task> findAllByBillIdAndBusinessTypeAndBillStatus(Integer billId, Integer businessType, Integer billStatus);
/**
* 根据账单id、业务类型、以及父id为null
* @param billId 账单ID
*
* @param billId 账单ID
* @param businessType 业务类型
*/
Task findAllByParentTaskIdIsNullAndBillIdAndBusinessType(Integer billId,Integer businessType);
Task findAllByParentTaskIdIsNullAndBillIdAndBusinessType(Integer billId, Integer businessType);
List<Task> findAllByParentTaskId(Integer parentTaskId);
@Query("select o.billId from Task o where o.id=?1")
Integer findBillIdByTaskId(int taskId);
@Query("select o.billId from Task o where o.id=?1 and o.businessType=?2")
Integer findBillId(int id, int businessType);
@Query("select o.billId from Task o where o.parentTaskId = ?1 and o. businessType = ?2")
Integer findBillIdByParentId(int parentTaskId, int businessType);
}
......@@ -106,8 +106,18 @@ public interface TaskService {
/**
* @param taskBto 任务bto
* @param userId 新增涉及用户id
* 不指定用户的任务被用户接取之后新增涉及用户
* @param userId 新增涉及用户id
* 不指定用户的任务被用户接取之后新增涉及用户
*/
TaskBto addInvolveUser(TaskBto taskBto,Integer userId);
TaskBto addInvolveUser(TaskBto taskBto, Integer userId);
/**
* 判断该根任务节点下的所有task是否都处于完结状态
*
* @param rootId task的根节点id
* @return Task Tree 是否已经结束
*/
boolean TaskTreeIsOver(int rootId);
}
......@@ -12,10 +12,8 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -75,13 +73,40 @@ public class TaskBto {
@ApiModelProperty(value = "工作涉及人员id")
private List<Integer> involveUserIdList;
public TaskBto(Integer billStatus, String title, Integer parentTaskId, String nodeIdDetail, Integer billId, Integer businessType, Integer ownUnit, Integer currentPoint, String customInfo, List<Integer> involveUserIdList) {
this.billStatus = billStatus;
this.title = title;
this.parentTaskId = parentTaskId;
this.nodeIdDetail = nodeIdDetail;
this.billId = billId;
this.businessType = businessType;
this.ownUnit = ownUnit;
this.currentPoint = currentPoint;
this.customInfo = customInfo;
this.involveUserIdList = involveUserIdList;
}
public TaskBto(Integer status, String title, Integer parentTaskId, String nodeIdDetail, Integer businessType, Integer billId, Integer ownUnit, int startUserId) {
this.billStatus = status;
this.title = title;
this.parentTaskId = parentTaskId;
this.nodeIdDetail = nodeIdDetail;
this.businessType = businessType;
this.billId = billId;
this.ownUnit = ownUnit;
List<Integer> involveUserIdList = new ArrayList<>();
involveUserIdList.add(startUserId);
this.involveUserIdList = involveUserIdList;
}
/**
* bto类转化为do类
*/
public Task toDo(){
public Task toDo() {
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
Task task = modelMapper.map(this,Task.class);
Task task = modelMapper.map(this, Task.class);
//set组合字段
task.setInvolveUsers(StringSplitUtil.idListToString(this.involveUserIdList));
task.setUserReadDetail(StringSplitUtil.idListToString(this.userReadDetailList));
......@@ -89,16 +114,14 @@ public class TaskBto {
return task;
}
/**
* bto类转化为vo类
*/
public TaskUserVo toVo(){
public TaskUserVo toVo() {
UserPublicService userPublicService = SpringUtils.getBean("userPublicServiceImpl");
//复制相同属性
ModelMapper modelMapper = BeanHelper.getUserMapper();
TaskUserVo taskUserVo = modelMapper.map(this,TaskUserVo.class);
TaskUserVo taskUserVo = modelMapper.map(this, TaskUserVo.class);
//set vo字段
if (userPublicService != null) {
taskUserVo.setStartUnit(userPublicService.findUnitsNameByUserId(this.createUserId));
......@@ -107,16 +130,17 @@ public class TaskBto {
return taskUserVo;
}
public TaskBto(Integer billStatus, String title, Integer parentTaskId, String nodeIdDetail, Integer billId, Integer businessType, Integer ownUnit, Integer currentPoint, String customInfo, List<Integer> involveUserIdList) {
this.billStatus = billStatus;
this.title = title;
this.parentTaskId = parentTaskId;
this.nodeIdDetail = nodeIdDetail;
this.billId = billId;
this.businessType = businessType;
this.ownUnit = ownUnit;
this.currentPoint = currentPoint;
this.customInfo = customInfo;
this.involveUserIdList = involveUserIdList;
/**
* @return 最后一个参与该任务的人员id, 用于任务状态变化时人员不变的情况
*/
public Integer getLastUserId() {
return involveUserIdList.get(involveUserIdList.size() - 1);
}
/**
* @return 第一个参与该任务的人员id, 用于任务状态变化时需要返回初始状态的情况
*/
public Integer getFirstUserId() {
return involveUserIdList.get(0);
}
}
......@@ -26,25 +26,38 @@ public enum StatusEnum {
CREATE_DESTROY_BUSINESS(8110,"标签制作业务开始"),
DESTROY_BUSINESS_NEED_CONFIRM(8111,"等待审核"),
DESTROY_BUSINESS_CONFIRM_FINISH_SUCCESS(8112,"审核成功"),
DESTROY_BUSINESS_CONFIRM_FINISH_FAILED(8113,"审核失败"),
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,"审核失败"),
CREATE_RETIRED_BUSINESS(8120, "标签制作业务开始"),
RETIRED_BUSINESS_NEED_CONFIRM(8121, "等待审核"),
RETIRED_BUSINESS_CONFIRM_FINISH_SUCCESS(8122, "审核成功"),
RETIRED_BUSINESS_CONFIRM_FINISH_FAILED(8123, "审核失败"),
/**
* 核查任务
*/
//以下为stat状态
CHECK_STAT_0(100, "省级统计数据收集中"),
CHECK_STAT_1(101, "省级统计数据等待确认"),
//以下为detail状态
CHECK_DETAIL_0(120, "等待专管员A处理"),
CHECK_DETAIL_1(121, "等待专管员B处理"),
CHECK_DETAIL_2(122, "等待核查员A处理"),
CHECK_DETAIL_3(123, "等待核查员B处理"),
/**
* 业务完结
*/
END(9999,"业务完结"),
END(9999, "业务完结"),
TRAIN1000(1000,"报名中"),
TRAIN1000(1000, "报名中"),
TRAIN1001(1001,"报名确认"),
TRAIN1001(1001, "报名确认"),
TRAIN1002(1002,"待报名"),
......
......@@ -95,13 +95,33 @@ public class Task {
@ApiModelProperty(value = "工作涉及人员id(x作为分隔符),例如x1x2x,意为id为1,2的用户参与了该任务")
private String involveUsers;
public Task(String title, Integer parentTaskId, String nodeIdDetail, Integer businessType, Integer billId, Integer ownUnit) {
this.title = title;
this.parentTaskId = parentTaskId;
this.nodeIdDetail = nodeIdDetail;
this.businessType = businessType;
this.billId = billId;
this.ownUnit = ownUnit;
}
public Task(Integer status, String title, Integer parentTaskId, String nodeIdDetail, Integer businessType, Integer billId, Integer ownUnit) {
this.billStatus = status;
this.title = title;
this.parentTaskId = parentTaskId;
this.nodeIdDetail = nodeIdDetail;
this.businessType = businessType;
this.billId = billId;
this.ownUnit = ownUnit;
this.currentPoint = 0;
}
/**
* do类转化为bto类
*/
public TaskBto parse2Bto(){
public TaskBto parse2Bto() {
//modelMap复制
ModelMapper mapper = BeanHelper.getUserMapper();
TaskBto taskBto = mapper.map(this,TaskBto.class);
TaskBto taskBto = mapper.map(this, TaskBto.class);
//解析组合字段并添加
taskBto.setInvolveUserIdList(StringSplitUtil.userIdSplit(this.involveUsers));
taskBto.setTopFlagDetailList(StringSplitUtil.userIdSplit(this.topFlagDetail));
......
......@@ -3,6 +3,7 @@ package com.tykj.dev.device.user.subject.dao;
import com.tykj.dev.device.user.subject.entity.Area;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -22,4 +23,7 @@ public interface AreaDao extends JpaRepository<Area, Integer>, JpaSpecificationE
List<Area> findAreasByType(Integer type);
@Query("select o.name from Area o where o.id=?1")
String findNameById(int id);
}
......@@ -3,6 +3,7 @@ package com.tykj.dev.device.user.subject.dao;
import com.tykj.dev.device.user.subject.entity.Units;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -19,11 +20,17 @@ public interface UnitsDao extends JpaRepository<Units, Integer>, JpaSpecificatio
List<Units> findByAreaIdIn(List<Integer> areaIds);
List<Units> findAllByAreaIdIn(List<Integer> ids);
List<Units> findAllByAreaIdIn(List<Integer> ids);
List<Units> findByAreaId(Integer area);
List<Units> findByAreaId(Integer area);
List<Units> findByIdDel(Integer idDel);
List<Units> findByIdDel(Integer idDel);
@Query("select o.areaId from Units o where o.name = ?1")
int findAreaIdByName(String unitName);
@Query("select o.areaId from Units o where o.unitId=?1")
int findAreaId(int id);
}
......@@ -3,6 +3,8 @@ package com.tykj.dev.misc.utils;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
......@@ -15,18 +17,19 @@ import java.util.Date;
public class TimestampUtil {
/**
*
* 获取当前系统时间,并返回时间戳
*
* @return 时间戳
*/
public static Timestamp getCurrentTimestamp(){
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());
......@@ -35,77 +38,107 @@ public class TimestampUtil {
/**
* 获取本月开始日期
*
* @return String
* **/
**/
public static Date getMonthStart() throws ParseException {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, 0);
cal.set(Calendar.DAY_OF_MONTH, 1);
Date time=cal.getTime();
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();
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";
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();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.WEEK_OF_MONTH, 0);
cal.set(Calendar.DAY_OF_WEEK, 2);
Date time=cal.getTime();
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();
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";
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";
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));
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";
String format = simpleDateFormat.format(currYearLast) + " 23:59:59";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(format);
}
/**
* 默认将时分秒设置为00:00:00
*/
public static Date localDateToDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
public static LocalDate dateToLocalDate(Date date) {
return date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
}
/**
* @return 当前时间的Date类型
*/
public static Date getNowDate() {
return Date.from(LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toInstant());
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论