提交 7d1f8491 authored 作者: zjm's avatar zjm

Dev to master

上级 1856d396
...@@ -112,8 +112,8 @@ public class DeviceApplyController { ...@@ -112,8 +112,8 @@ public class DeviceApplyController {
@Autowired @Autowired
private PackingController packingController; private PackingController packingController;
@Autowired // @Autowired
private DeviceLibraryDao deviceLibraryDao; // private DeviceLibraryDao deviceLibraryDao;
@ApiOperation(value = "发起装备申请", notes = "可以通过这个接口发起装备申请") @ApiOperation(value = "发起装备申请", notes = "可以通过这个接口发起装备申请")
@PostMapping("/addDeviceApplyBill") @PostMapping("/addDeviceApplyBill")
...@@ -500,7 +500,8 @@ public class DeviceApplyController { ...@@ -500,7 +500,8 @@ public class DeviceApplyController {
seqs.addAll(DeviceSeqUtil.selectDeviceSeqs(r.getSeqInterval())); seqs.addAll(DeviceSeqUtil.selectDeviceSeqs(r.getSeqInterval()));
} }
} }
deviceLibraryDao.upDateSeqNumbersApplyTaskId(taskBto.getId(), seqs); // deviceLibraryDao.upDateSeqNumbersApplyTaskId(taskBto.getId(), seqs);
deviceLibraryService.upDateSeqNumbersApplyTaskId(taskBto.getId(),seqs);
} }
} }
return ResponseEntity.ok("ok"); return ResponseEntity.ok("ok");
......
package com.tykj.dev.config;
import java.lang.annotation.*;
/**
* UpdateCache注解
*
* @author zsp
*/
@Target({ElementType.METHOD,ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface UpdateCache {
String type() default "";
}
package com.tykj.dev.device.confirmcheck.common;
import com.tykj.dev.device.confirmcheck.entity.vo.LinkVo;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
* CcDataCache. 核查模块自用缓存
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/23 at 5:32 下午
*/
@Data
public class CcDataCache {
public static Map<Integer, LinkVo> linkVoCache = new HashMap<>();
}
package com.tykj.dev.device.confirmcheck.common;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import java.util.HashMap;
/**
* CcInitRunner.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/23 at 5:30 下午
*/
@Order(99)
public class CcInitRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
//初始化Map 从DB里面拿数据
CcDataCache.linkVoCache = new HashMap<>(32);
}
}
package com.tykj.dev.device.confirmcheck.entity.domain;
import com.tykj.dev.device.confirmcheck.entity.vo.DeviceCheckLinkVo;
import com.tykj.dev.device.confirmcheck.entity.vo.LinkVo;
import com.tykj.dev.device.confirmcheck.utils.MapperHelper;
import com.tykj.dev.misc.base.BaseEntity;
import com.tykj.dev.misc.utils.JacksonUtil;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.modelmapper.ModelMapper;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.time.LocalDateTime;
/**
* DeviceCheckLink.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/23 at 5:40 下午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@SQLDelete(sql = "update device_check_link set delete_tag = 1 where id = ?")
@ApiModel("核查检查列表的缓存表")
@NoArgsConstructor
@Table(name = "device_check_link")
public class DeviceCheckLink extends BaseEntity {
private Integer statId;
@Column(name = "link_text", columnDefinition = "TEXT")
private String linkText;
public DeviceCheckLinkVo toVo() {
ModelMapper mapper = MapperHelper.getMapper();
DeviceCheckLinkVo dcLinkVo = mapper.map(this, DeviceCheckLinkVo.class);
LinkVo linkVo = JacksonUtil.readValue(linkText, LinkVo.class);
dcLinkVo.setLinkVo(linkVo);
return dcLinkVo;
}
public DeviceCheckLink(Integer statId , String linkText) {
this.statId = statId;
this.linkText = linkText;
}
public DeviceCheckLink(Integer id, Integer createUserId, Integer updateUserId, LocalDateTime createTime, LocalDateTime updateTime, Integer deleteTag, Integer statId, String linkText) {
super(id, createUserId, updateUserId, createTime, updateTime, deleteTag);
this.statId = statId;
this.linkText = linkText;
}
}
package com.tykj.dev.device.confirmcheck.entity.vo;
import com.alibaba.fastjson.JSON;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckLink;
import com.tykj.dev.device.confirmcheck.utils.MapperHelper;
import com.tykj.dev.misc.base.BaseVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.modelmapper.ModelMapper;
import java.time.LocalDateTime;
/**
* DeviceCheckLinkVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/24 at 10:58 上午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class DeviceCheckLinkVo extends BaseVo {
private Integer statId;
private LinkVo linkVo;
public DeviceCheckLinkVo(Integer statId, LinkVo linkVo) {
this.statId = statId;
this.linkVo = linkVo;
}
public DeviceCheckLinkVo(Integer id, Integer createUserId, Integer updateUserId, LocalDateTime createTime, LocalDateTime updateTime, Integer deleteTag, Integer statId, LinkVo linkVo) {
super(id, createUserId, updateUserId, createTime, updateTime, deleteTag);
this.statId = statId;
this.linkVo = linkVo;
}
public DeviceCheckLink toDo() {
ModelMapper mapper = MapperHelper.getMapper();
DeviceCheckLink dcLink = mapper.map(this, DeviceCheckLink.class);
String linkText = JSON.toJSONStringWithDateFormat(this.linkVo, "yyyy-MM-dd HH:mm:ss");
dcLink.setLinkText(linkText);
return dcLink;
}
}
package com.tykj.dev.device.confirmcheck.entity.vo; package com.tykj.dev.device.confirmcheck.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
...@@ -25,11 +31,19 @@ public class LinkVo { ...@@ -25,11 +31,19 @@ public class LinkVo {
*/ */
private int type; private int type;
/**
* 是否终结 true = 已终结 ,false = 未终结
*/
private boolean isShutDown;
/** /**
* 核查/检查总标题 * 核查/检查总标题
*/ */
private String title; private String title;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate endTime; private LocalDate endTime;
/** /**
...@@ -48,4 +62,13 @@ public class LinkVo { ...@@ -48,4 +62,13 @@ public class LinkVo {
this.type = type; this.type = type;
this.endTime = endTime; this.endTime = endTime;
} }
// public LinkVo(int type, String title, String endTime, List<LinkCheckDetail> lcDetail, List<LinkExamDetail> leDetail, int detailId) {
// this.type = type;
// this.title = title;
// this.endTime = LocalDate.parse(endTime);
// this.lcDetail = lcDetail;
// this.leDetail = leDetail;
// this.detailId = detailId;
// }
} }
package com.tykj.dev.device.confirmcheck.repository;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckLink;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import java.util.Optional;
/**
* DeviceCheckLinkDao.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/24 at 11:05 上午
*/
@Repository
public interface DeviceCheckLinkDao extends JpaRepository<DeviceCheckLink, Integer>, JpaSpecificationExecutor<DeviceCheckLink> {
Optional<DeviceCheckLink> findByStatId(Integer statId);
}
...@@ -42,6 +42,7 @@ import java.util.*; ...@@ -42,6 +42,7 @@ import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.tykj.dev.misc.base.StatusEnum.*;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap; import static java.util.stream.Collectors.toMap;
...@@ -143,16 +144,6 @@ public class ObjTransUtil { ...@@ -143,16 +144,6 @@ public class ObjTransUtil {
List<Task> childTask = taskDao.findAllByParentTaskId(fatherTaskId); List<Task> childTask = taskDao.findAllByParentTaskId(fatherTaskId);
boolean flag = false; boolean flag = false;
boolean confirmTaskisDone = false;
for (Task task : childTask) {
if (task.getTitle().contains("统计数据确认任务")) {
if (task.getBillStatus() != 9999) {
flag = true;
} else {
confirmTaskisDone = true;
}
}
}
// 3/3 -> 统计待确认 -> 省统计任务待完结 // 3/3 -> 统计待确认 -> 省统计任务待完结
...@@ -164,27 +155,24 @@ public class ObjTransUtil { ...@@ -164,27 +155,24 @@ public class ObjTransUtil {
long total = childTask.size(); long total = childTask.size();
long done = childTask.stream() long done = childTask.stream()
.filter(task -> task.getBillStatus().equals(9999)) .filter(task -> task.getBillStatus().equals(END.id) || task.getBillStatus().equals(CHECK_SHUT_DOWN.id))
.count(); .count();
//如果是检查统计的话那么还要看一下他的父节点是不是已经完成了 //如果是检查统计的话那么还要看一下他的父节点是不是已经完成了
String completion; String completion;
if (done == total) { if (done == total) {
if (stat.getCheckType() == CheckType.CT_EXAM && !fatherTask.getBillStatus().equals(9999)) { boolean examFinish = fatherTask.getBillStatus().equals(END.id) || fatherTask.getBillStatus().equals(CHECK_SHUT_DOWN.id);
if (stat.getCheckType() == CheckType.CT_EXAM && !examFinish) {
completion = "核查完成待办结"; completion = "核查完成待办结";
} else { } else {
if (flag) { if (flag) {
completion = "核查完成待确认"; completion = "核查完成待确认";
} else { } else {
// confirmTaskidDone 为true 代表此时等待最后的father任务 为false代表 flag = false 且isDone为false 代表整个节点里没有确认节点直接完结 // confirmTaskidDone 为true 代表此时等待最后的father任务 为false代表 flag = false 且isDone为false 代表整个节点里没有确认节点直接完结
if (confirmTaskisDone) { if (fatherTask.getBillStatus().equals(END.id) || fatherTask.getBillStatus().equals(CHECK_SHUT_DOWN.id)) {
if (fatherTask.getBillStatus() == 9999) {
completion = "核查完成";
} else {
completion = "核查完成待办结";
}
} else {
completion = "核查完成"; completion = "核查完成";
} else {
completion = "核查完成待办结";
} }
} }
} }
......
...@@ -867,7 +867,7 @@ public class DeviceLibraryController { ...@@ -867,7 +867,7 @@ public class DeviceLibraryController {
@ApiOperation(value = "修改装备的存放位置") @ApiOperation(value = "修改装备的存放位置")
@PostMapping("/updateDeviceLibraryLocation") @PostMapping("/updateDeviceLibraryLocation")
@CacheEvict(value = "devicesLibraryList",key = "'device'",allEntries = true) // @CacheEvict(value = "devicesLibraryList",key = "'device'",allEntries = true)
public void updateDeviceLibraryLocation(@RequestBody DeviceStorageLocation deviceStorageLocation){ public void updateDeviceLibraryLocation(@RequestBody DeviceStorageLocation deviceStorageLocation){
DeviceLibrary deviceLibrary = deviceLibraryService.getOne(deviceStorageLocation.getDevId()); DeviceLibrary deviceLibrary = deviceLibraryService.getOne(deviceStorageLocation.getDevId());
//添加修改存放装备位置 //添加修改存放装备位置
...@@ -875,12 +875,12 @@ public class DeviceLibraryController { ...@@ -875,12 +875,12 @@ public class DeviceLibraryController {
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceStorageLocation.getDevId(), "将存放位置改为"+deviceStorageLocation.getStorageLocation(), null,null,null); DeviceLogDto deviceLogDto = new DeviceLogDto(deviceStorageLocation.getDevId(), "将存放位置改为"+deviceStorageLocation.getStorageLocation(), null,null,null);
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
deviceLibraryService.update(deviceLibrary); deviceLibraryService.update(deviceLibrary);
//异步去查询数据库 // //异步去查询数据库
executor.execute( // executor.execute(
()->{ // ()->{
cacheLibraryService.getAllDeviceLibraryList(); // cacheLibraryService.getAllDeviceLibraryList();
} // }
); // );
} }
@ApiOperation("根据装备id修改装备的序列号") @ApiOperation("根据装备id修改装备的序列号")
...@@ -944,6 +944,29 @@ public class DeviceLibraryController { ...@@ -944,6 +944,29 @@ public class DeviceLibraryController {
return deviceNewVoList; return deviceNewVoList;
} }
@ApiOperation(value = "查询可进行绑定的装备", notes = "查询可进行绑定的装备")
@GetMapping("/selectBindingDevice")
public List<DeviceLibrary> selectBindingDevice(){
List<DeviceLibrary> deviceLibraries = cacheLibraryService.getAllDeviceLibraryList().stream()
.filter(deviceLibrary -> deviceLibrary.getPartParentId() == null).collect(Collectors.toList());
// cacheLibraryService.asyncUpdateCache();
return deviceLibraries;
}
@ApiOperation(value = "解除装备绑定", notes = "解除装备绑定")
@GetMapping("/relieveDevice/{deviceId}")
public ResponseEntity relieveDevice(@PathVariable("deviceId") Integer deviceId){
deviceLibraryService.relieveDevice(deviceId);
return ResponseEntity.ok("解除成功");
}
@ApiOperation(value = "进行装备绑定", notes = "进行装备绑定")
@PostMapping("/bindingDevice")
public ResponseEntity bindingDevice(BindingDeviceVo bindingDeviceVo){
deviceLibraryService.bindingDevice(bindingDeviceVo);
return ResponseEntity.ok("绑定成功");
}
/** /**
* 测试 * 测试
*/ */
......
...@@ -191,5 +191,22 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>, ...@@ -191,5 +191,22 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
int updateMatchingRange2(Integer matchingRange,@Param("deviceIds") List<Integer> deviceIds); int updateMatchingRange2(Integer matchingRange,@Param("deviceIds") List<Integer> deviceIds);
List<DeviceLibrary> findByModelAndIsPart(String model,Integer isPart); List<DeviceLibrary> findByModelAndIsPart(String model,Integer isPart);
List<DeviceLibrary> findAllByPartParentId(Integer partParentId);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.model = :newModel,o.packingId = :packingId where o.id in :deviceIds")
int updateModelAndPackingId(
@Param("newModel") String newModel,
@Param("packingId") Integer packingId,
@Param("deviceIds") List<Integer> deviceIds);
@Transactional
@Modifying
@Query("update DeviceLibrary o set o.packingId = :packingId where o.id in :deviceIds")
int updatePackingId(
@Param("packingId") Integer packingId,
@Param("deviceIds") List<Integer> deviceIds);
} }
...@@ -26,4 +26,6 @@ public interface DeviceLibraryCacheService { ...@@ -26,4 +26,6 @@ public interface DeviceLibraryCacheService {
void deletAllDeviceLibraryList(); void deletAllDeviceLibraryList();
void asyncUpdateCache();
} }
package com.tykj.dev.device.library.service; package com.tykj.dev.device.library.service;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.BindingDeviceVo;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo; import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo; import com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -206,11 +208,6 @@ public interface DeviceLibraryService { ...@@ -206,11 +208,6 @@ public interface DeviceLibraryService {
*/ */
DeviceLibrary findBySeqNumber(String seqNumber); DeviceLibrary findBySeqNumber(String seqNumber);
// /**
// *
// */
// List<DeviceLibrary> findByIds2(List<Integer> ids);
/** /**
* 得到所有的装备 * 得到所有的装备
*/ */
...@@ -245,7 +242,8 @@ public interface DeviceLibraryService { ...@@ -245,7 +242,8 @@ public interface DeviceLibraryService {
void updateDevicesOwnUnit(List<Integer> deviceIds); void updateDevicesOwnUnit(List<Integer> deviceIds);
/** /**
* @param * @param localUnit 所在单位
* @param deviceIds 装备id的集合
*/ */
void updateLocalAndOwn(String localUnit,List<Integer> deviceIds); void updateLocalAndOwn(String localUnit,List<Integer> deviceIds);
...@@ -254,6 +252,9 @@ public interface DeviceLibraryService { ...@@ -254,6 +252,9 @@ public interface DeviceLibraryService {
*/ */
int getMaxSeqNumber(String model); int getMaxSeqNumber(String model);
List<DeviceLibrary> findAllDeviceLibraryList();
List<String> getMaxPartSeqNumber(String model,Integer isPart); List<String> getMaxPartSeqNumber(String model,Integer isPart);
...@@ -264,6 +265,173 @@ public interface DeviceLibraryService { ...@@ -264,6 +265,173 @@ public interface DeviceLibraryService {
*/ */
List<DeviceLibrary> findDevicesByPacking(Integer packing); List<DeviceLibrary> findDevicesByPacking(Integer packing);
/**
* 更新配用范围
* @param libraries 装备的集合
*/
void updateMatchingRange(List<DeviceLibrary> libraries); void updateMatchingRange(List<DeviceLibrary> libraries);
/**
* 装备的解除
* @param deviceId 装备id
*/
void relieveDevice(int deviceId);
/**
* 装备的绑定
* @param
*/
void bindingDevice(BindingDeviceVo bindingDeviceVo);
/**
* 以下接口都为缓存做铺垫
*/
/**
* 更新设备序列号
* @param taskId 任务id
* @param seqNumbers 序列号的集合
*/
void upDateSeqNumbersApplyTaskId(Integer taskId,List<String> seqNumbers);
List<DeviceLibrary> findAllByOwnUnit(String ownUnit);
List<DeviceLibrary> getAllByRfidCardId(String rfidCardId);
/**
* 根据装备id的集合更新装备的生命状态
* @param lifeStatus 生命状态
* @param idList 装备id的集合
* @return
*/
int upDateLeftStatus(Integer lifeStatus,@Param("idList") List<Integer> idList);
/**
* 根据装备id的集合更新装备的生命状态
* @param lifeStatus 生命状态
* @param seqNumbers 装备序列号的集合
* @return 影响行数
*/
int upDateSeqNumbersLeftStatus(Integer lifeStatus,@Param("seqNumbers") List<String> seqNumbers);
/**
* 根据装备id的集合更新装备的生命状态和lock
* @param lifeStatus 生命状态
* @param lock 是否解锁
* @param idList 装备id的集合
* @return 影响行数
*/
int upDateLeftStatusAndLockStatus(Integer lifeStatus,Integer lock,@Param("idList") List<Integer> idList);
/**
* 根据装备id的集合更新lock
* @param lock 解锁
* @param idList 装备id的集合
* @return 影响行数
*/
int upDateLockStatus(Integer lock,@Param("idList") List<Integer> idList);
/**
* 根据装备id的集合更新生命状态和单位名称
* @param lifeStatus
* @param unitName
* @param lock
* @param idList
* @return 影响行数
*/
int upDateLeftStatusAndUnitNameAndLockStatus(Integer lifeStatus,String unitName,Integer lock,@Param("idList") List<Integer> idList);
/**
* 根据装备的序列号的集合更新生命状态和单位名称和锁
* @param lifeStatus 生命状态
* @param unitName 单位名称
* @param lock 锁
* @param seqNumbers 装备序列号的集合
* @return 影响行数
*/
int upDateSeqNumbersLeftStatusAndUnitNameAndLockStatus(Integer lifeStatus,String unitName,Integer lock,@Param("seqNumbers") List<String> seqNumbers);
/**
* 根据装备id的集合更新生命状态和所属单位
* @param lifeStatus 生命状态
* @param unitName 所属单位
* @param idList 装备id的集合
* @return 影响行数
*/
int upDateLeftStatusAndOwnUnitName(Integer lifeStatus,String unitName,@Param("idList") List<Integer> idList);
/**
* 根据装备id的集合更新RFID表面号
* @param idList 装备id的集合
* @return 影响行数
*/
int upDateRfidSurfaceIdAsSeqNumber(@Param("idList") List<Integer> idList);
/**
* 根据列装id更新名称
* @param name 名称
* @param packingId 列装id
* @return 影响行数
*/
int upDateName(String name,Integer packingId);
/**
* 根据列装id更新配用范围
* @param matchingRange 配用范围
* @param packingId 列装id
* @return 影响函数
*/
int upDateMatchingRange(Integer matchingRange,Integer packingId);
/**
* 根据装备id更新生命状态
* @param lifeStatus 生命状态
* @param id 装备id
* @return
*/
int batchUpdate(Integer lifeStatus,Integer id);
/**
* 根据装备id更新生命状态
* @param lifeStatus 生命状态
* @param ids 装备id的集合
* @return
*/
int batchUpdate2(Integer lifeStatus,List<Integer> ids);
/**
* 根据列装id更新配用范围
* @param matchingRange 配用范围
* @param packingId 列装id
* @return 影响行数
*/
int updateMatchingRange(Integer matchingRange,Integer packingId);
/**
* 根据列装id更新配用范围
* @param matchingRange 配用范围
* @param deviceIds 装备id的集合
* @return 影响行数
*/
int updateMatchingRange2(Integer matchingRange,@Param("deviceIds") List<Integer> deviceIds);
/**
* 更新型号和列装id
* @param newModel 新的型号
* @param packingId 列装id
* @param deviceIds 装备id集合
* @return 影响行数
*/
int updateModelAndPackingId(String newModel,Integer packingId,List<Integer> deviceIds);
/**
* 根据装备id的集合更新列装id
* @param packingId 列装id
* @param deviceIds 装备id的集合
* @return 影响行数
*/
int updatePackingId(Integer packingId,List<Integer> deviceIds);
/**
* 查询所有装备
*/
List<DeviceLibrary> findAllDevices();
} }
...@@ -3,7 +3,9 @@ package com.tykj.dev.device.library.service.impl; ...@@ -3,7 +3,9 @@ package com.tykj.dev.device.library.service.impl;
import com.tykj.dev.device.library.repository.DeviceLibraryDao; import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService; import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.CachePut;
...@@ -13,6 +15,7 @@ import org.springframework.stereotype.Service; ...@@ -13,6 +15,7 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Executor;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -22,21 +25,26 @@ import java.util.stream.Collectors; ...@@ -22,21 +25,26 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
@CacheConfig(cacheNames = "devicesLibraryList") @CacheConfig(cacheNames = "devicesLibraryList")
@Slf4j
public class CacheLibraryServiceImpl implements DeviceLibraryCacheService { public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
@Autowired @Autowired
private DeviceLibraryDao deviceLibraryDao; private DeviceLibraryDao deviceLibraryDao;
@Autowired
@Qualifier("taskExecutor")
private Executor executor;
// @Autowired // @Autowired
// private ConcurrentMapCacheManager mapCacheManager; // private ConcurrentMapCacheManager mapCacheManager;
@Autowired @Autowired
private DeviceLibraryCacheService deviceLibraryCacheService; private DeviceLibraryCacheService deviceLibraryCacheService;
@Override @Override
@Cacheable(key = "'device'") @Cacheable(key = "'device'")
public List<DeviceLibrary> getAllDeviceLibraryList() { public List<DeviceLibrary> getAllDeviceLibraryList() {
long l = System.currentTimeMillis(); long start = System.currentTimeMillis();
List<DeviceLibrary> all = deviceLibraryDao.findAll(); List<DeviceLibrary> all = deviceLibraryDao.findAll();
System.out.println("缓存时间"+(System.currentTimeMillis()-l)); log.info("缓存时间:{}", System.currentTimeMillis() - start);
return all; return all;
} }
...@@ -64,4 +72,14 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService { ...@@ -64,4 +72,14 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
// List<DeviceLibrary> all = deviceLibraryDao.findAll(); // List<DeviceLibrary> all = deviceLibraryDao.findAll();
// System.out.println("更新缓存时间"+(System.currentTimeMillis()-l)); // System.out.println("更新缓存时间"+(System.currentTimeMillis()-l));
} }
@Override
@CacheEvict(key = "'device'",allEntries=true)
public void asyncUpdateCache() {
executor.execute(()->{
deviceLibraryCacheService.getAllDeviceLibraryList();
});
}
} }
package com.tykj.dev.device.library.subject.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("装备绑定的vo")
public class BindingDeviceVo {
@ApiModelProperty(value = "要绑定的装备id")
private Integer originDeviceId;
@ApiModelProperty(value = "需要绑定到的装备id")
private Integer toDeviceId;
}
...@@ -9,6 +9,7 @@ import org.springframework.data.annotation.CreatedDate; ...@@ -9,6 +9,7 @@ import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*; import javax.persistence.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -52,12 +53,14 @@ public class BaseEntity { ...@@ -52,12 +53,14 @@ public class BaseEntity {
* 创建时间 * 创建时间
*/ */
@CreatedDate @CreatedDate
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime; private LocalDateTime createTime;
/** /**
* 更新时间 * 更新时间
*/ */
@LastModifiedDate @LastModifiedDate
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime; private LocalDateTime updateTime;
/** /**
......
package com.tykj.dev.misc.base;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
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.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import java.time.LocalDateTime;
/**
* BaseVo.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2021/9/24 at 11:02 上午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseVo {
/**
* 主键id
*/
private Integer id;
/**
* 创建用户id
*/
private Integer createUserId;
/**
* 更新用户id
*/
private Integer updateUserId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
/**
* 删除标记(0:未删除,1:已删除)
*/
private Integer deleteTag = 0;
}
...@@ -65,6 +65,9 @@ public enum StatusEnum { ...@@ -65,6 +65,9 @@ public enum StatusEnum {
CHECK_DETAIL_CITY_0(160, "等待专管员A处理"), CHECK_DETAIL_CITY_0(160, "等待专管员A处理"),
CHECK_DETAIL_CITY_1(161, "等待专管员B处理"), CHECK_DETAIL_CITY_1(161, "等待专管员B处理"),
// 核查任务终止状态
CHECK_SHUT_DOWN(20001,"任务终止"),
/** /**
* 清退任务 * 清退任务
*/ */
......
...@@ -1237,7 +1237,10 @@ public class TaskServiceImpl implements TaskService { ...@@ -1237,7 +1237,10 @@ public class TaskServiceImpl implements TaskService {
// .map(Task::parse2Bto) // .map(Task::parse2Bto)
// .collect(Collectors.toList()); // .collect(Collectors.toList());
List<TaskBto> taskBtos = taskDao.findAll().stream() List<TaskBto> taskBtos = taskDao.findAll().stream()
.filter(task -> (!task.getBillStatus().equals(StatusEnum.END.id)) && (!task.getBillStatus().equals(StatusEnum.ARCHIVE.id)) && (!task.getBillStatus().equals(StatusEnum.REVOKEALLOTTASK.id))) .filter(task -> (!task.getBillStatus().equals(StatusEnum.END.id))
&& (!task.getBillStatus().equals(StatusEnum.ARCHIVE.id))
&& (!task.getBillStatus().equals(StatusEnum.REVOKEALLOTTASK.id))
&& (!task.getBillStatus().equals(StatusEnum.CHECK_SHUT_DOWN.id)))
.map(Task::parse2Bto) .map(Task::parse2Bto)
.collect(Collectors.toList()); .collect(Collectors.toList());
//查询待办 //查询待办
...@@ -1460,7 +1463,8 @@ public class TaskServiceImpl implements TaskService { ...@@ -1460,7 +1463,8 @@ public class TaskServiceImpl implements TaskService {
predicateBuilder.lt("createTime", taskSelectVo.getEndTime()); predicateBuilder.lt("createTime", taskSelectVo.getEndTime());
} }
if (taskSelectVo.getSelectNum() == 4) { if (taskSelectVo.getSelectNum() == 4) {
predicateBuilder.eq("billStatus", StatusEnum.END.id); // predicateBuilder.eq("billStatus", StatusEnum.END.id);
predicateBuilder.in("billStatus", StatusEnum.END.id,StatusEnum.CHECK_SHUT_DOWN.id);
} }
if (taskSelectVo.getSelectNum() == 5) { if (taskSelectVo.getSelectNum() == 5) {
predicateBuilder.eq("billStatus", StatusEnum.ARCHIVE.id); predicateBuilder.eq("billStatus", StatusEnum.ARCHIVE.id);
......
package com.tykj.dev.union;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.subject.vo.FileVo;
import com.tykj.dev.device.matching.service.MatchingDeviceBillService;
import com.tykj.dev.device.matching.subject.domin.MatchingDeviceBill;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 增强更新缓存aop
*
* @author zsp
*/
@Slf4j
@Aspect
@Component
public class UpdateCacheAspect {
/**
* 业务新状态
*/
@Autowired
private DeviceLibraryCacheService deviceLibraryCacheService;
/**
* 更新缓存定义切入点
*/
@Pointcut("@annotation(com.tykj.dev.config.UpdateCache)")
public void operationLog() {
}
/**
* 新增结果返回后触发
*/
@AfterReturning(pointcut = "operationLog()")
public void doAfterReturning(JoinPoint point) {
log.info("开始更新缓存");
deviceLibraryCacheService.asyncUpdateCache();
}
}
...@@ -48,4 +48,6 @@ public interface UnitsDao extends JpaRepository<Units, Integer>, JpaSpecificatio ...@@ -48,4 +48,6 @@ public interface UnitsDao extends JpaRepository<Units, Integer>, JpaSpecificatio
List<Units> findAllByType(Integer type); List<Units> findAllByType(Integer type);
List<Units> findByTypeAndEscrow(int type, int escrow);
} }
...@@ -95,6 +95,9 @@ public class Units { ...@@ -95,6 +95,9 @@ public class Units {
@ApiModelProperty(value = "装备配用范围的指定") @ApiModelProperty(value = "装备配用范围的指定")
private Integer packingMatchingRange; private Integer packingMatchingRange;
@ApiModelProperty(value = "是否代管")
private Integer escrow;
/** /**
* 区域对象 * 区域对象
*/ */
...@@ -113,6 +116,7 @@ public class Units { ...@@ -113,6 +116,7 @@ public class Units {
null, null,
null, null,
null, null,
null,
null null
); );
} }
...@@ -130,4 +134,18 @@ public class Units { ...@@ -130,4 +134,18 @@ public class Units {
public LeftNavigation toLeftNavigation(){ public LeftNavigation toLeftNavigation(){
return new LeftNavigation(unitId,name,null, UUID.randomUUID().toString(),2,showOrder,null); return new LeftNavigation(unitId,name,null, UUID.randomUUID().toString(),2,showOrder,null);
} }
/**
* @return true = 是代管单位,false = 不是代管单位
*/
public boolean isEscrow(){
return escrow == 1;
}
/**
* @return true = 不是代管单位,false = 是代管单位
*/
public boolean isNotEscrow(){
return escrow == 0;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论