提交 ece3b0d3 authored 作者: zhoushaopan's avatar zhoushaopan

feat(日常检查模块): 新增流程

新增流程
上级 d59d5c53
...@@ -375,7 +375,13 @@ public enum LogType { ...@@ -375,7 +375,13 @@ public enum LogType {
REPAIR_BACK_21(171,REPAIR.id, ORIGIN_STATUS.id, REPAIR_SEND_UNDER_DRAFT.id, "省直属等待出库"), REPAIR_BACK_21(171,REPAIR.id, ORIGIN_STATUS.id, REPAIR_SEND_UNDER_DRAFT.id, "省直属等待出库"),
ALLOT_BACK_21(172,ALLOT_BACK.id,ORIGIN_STATUS.id,BACK_UNDER_DRAFT.id,"省直属等待出库"), ALLOT_BACK_21(172,ALLOT_BACK.id,ORIGIN_STATUS.id,BACK_UNDER_DRAFT.id,"省直属等待出库"),
READ_SELF(173,READMACHINE_SELFCHECK.id,ORIGIN_STATUS.id,READ_SELF_CHECK.id,"开始进行盘点自查"), READ_SELF(173,READMACHINE_SELFCHECK.id,ORIGIN_STATUS.id,READ_SELF_CHECK.id,"开始进行盘点自查"),
READ_SELF_END(174,READMACHINE_SELFCHECK.id,ORIGIN_STATUS.id,READ_SELF_CHECK_END.id,"盘点自查结束"); READ_SELF_END(174,READMACHINE_SELFCHECK.id,ORIGIN_STATUS.id,READ_SELF_CHECK_END.id,"盘点自查结束"),
DAILY_CHECK_START(175,DAILY_SELF_CHECK.id,ORIGIN_STATUS.id,WAIT_CHECK.id,"发起日常检查"),
DAILY_CHECKED(176,DAILY_SELF_CHECK.id,WAIT_CHECK.id,WAIT_CHECK_RESULT.id,"等待上传校验结果"),
DAILY_CHECK_END(177,DAILY_SELF_CHECK.id,WAIT_CHECK_FILE.id,END.id,"日常检查任务完结"),
DAILY_CHECK_RE(178,DAILY_SELF_CHECK.id,WAIT_CHECK_RESULT.id,WAIT_CHECK_FILE.id,"提交检查结果"),
DAILY_CHECK_RE2(179,DAILY_SELF_CHECK.id,WAIT_CHECK_FILE.id,WAIT_CHECK_FILE.id,"提交检查结果");
public Integer id; public Integer id;
......
...@@ -329,8 +329,16 @@ public enum StatusEnum { ...@@ -329,8 +329,16 @@ public enum StatusEnum {
* 盘存自查状态 * 盘存自查状态
*/ */
READ_SELF_CHECK(3002,"开始进行盘点自查"), READ_SELF_CHECK(3002,"开始进行盘点自查"),
READ_SELF_CHECK_END(3003,"盘点自查结束") READ_SELF_CHECK_END(3003,"盘点自查结束"),
;
/**
* 日常检查
*/
WAIT_CHECK(3004,"待检查"),
WAIT_CHECK_RESULT(3005,"等待上传校验结果"),
WAIT_CHECK_FILE(3006,"等待上传日常检查单")
;
public Integer id; public Integer id;
......
package com.tykj.dev.misc.utils;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
/**
* @author zsp
* @create 2022/4/20 9:32
*/
public class DateUtil {
public static LocalDateTime getLocalDateTime(Date date){
Instant instant = date.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
return instant.atZone(zoneId).toLocalDateTime();
}
public static LocalDate getLocalDate(Date date){
Instant instant = date.toInstant();
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime localDateTime = instant.atZone(zoneId).toLocalDateTime();
return localDateTime.toLocalDate();
}
}
...@@ -8,15 +8,15 @@ import com.tykj.dev.device.selfcheck.service.SelfCheckUnitBillService; ...@@ -8,15 +8,15 @@ import com.tykj.dev.device.selfcheck.service.SelfCheckUnitBillService;
import com.tykj.dev.device.selfcheck.subject.domin.DailyCheckBill; import com.tykj.dev.device.selfcheck.subject.domin.DailyCheckBill;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill; import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckUnitBill; import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckUnitBill;
import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSaveVo;
import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo; import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo;
import com.tykj.dev.device.selfcheck.subject.vo.daily.*;
import com.tykj.dev.device.task.service.TaskService; import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.user.cache.StoreCache; import com.tykj.dev.device.user.cache.StoreCache;
import com.tykj.dev.device.user.cache.UnitsCache; import com.tykj.dev.device.user.cache.UnitsCache;
import com.tykj.dev.device.user.cache.UserCache; import com.tykj.dev.device.user.cache.UserCache;
import com.tykj.dev.device.user.subject.service.PublicService;
import com.tykj.dev.device.user.subject.service.UserPublicService;
import com.tykj.dev.device.user.util.UserUtils; import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.qrcode.vo.TaskData;
import com.tykj.dev.misc.utils.ResultUtil; import com.tykj.dev.misc.utils.ResultUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -26,10 +26,10 @@ import org.springframework.http.ResponseEntity; ...@@ -26,10 +26,10 @@ import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
...@@ -55,9 +55,6 @@ public class DailyCheckController { ...@@ -55,9 +55,6 @@ public class DailyCheckController {
@Resource @Resource
private TaskService taskService; private TaskService taskService;
@Resource
private StoreCache storeCache;
@Resource @Resource
private UserCache userCache; private UserCache userCache;
...@@ -67,15 +64,64 @@ public class DailyCheckController { ...@@ -67,15 +64,64 @@ public class DailyCheckController {
@Resource @Resource
private DeviceLibraryService deviceLibraryService; private DeviceLibraryService deviceLibraryService;
@ApiOperation(value = "发起任务", notes = "发起任务")
@GetMapping(value = "/createBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity createBill(){
DailyCheckBill checkBill = dailyCheckBillService.createBill();
return ResponseEntity.ok(checkBill);
}
@ApiOperation(value = "发起日常检查业务", notes = "发起日常检查业务") @ApiOperation(value = "发起日常检查业务", notes = "发起日常检查业务")
@PostMapping(value = "/addDayBill") @PostMapping(value = "/addDayBill")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity addDayBill(@RequestBody @Validated SelfCheckSaveVo selfCheckSaveVo){ public ResponseEntity addDayBill(@RequestBody @Validated DailyCheckSaveVo dailyCheckSaveVo){
dailyCheckBillService.addDayBill(selfCheckSaveVo); DailyCheckBill dailyCheckBill = dailyCheckBillService.addDayBill(dailyCheckSaveVo);
return ResponseEntity.ok(dailyCheckBill);
}
@ApiOperation(value = "保存", notes = "保存")
@PostMapping(value = "/updateBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity updateBill(@RequestBody DailyCheckUpdateVo dailyCheckUpdateVo){
dailyCheckBillService.updateBill(dailyCheckUpdateVo);
return ResponseEntity.ok("保存成功");
}
@ApiOperation(value = "完结", notes = "完结")
@PostMapping(value = "/endDayBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity endDayBill(@RequestBody @Validated DailyCheckEndVo dailyCheckEndVo){
dailyCheckBillService.endDayBill(dailyCheckEndVo);
return ResponseEntity.ok("发起成功"); return ResponseEntity.ok("发起成功");
} }
@ApiOperation(value = "生成二维码", notes = "生成二维码")
@PostMapping(value = "/createQrcode")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity createQrcode(@RequestBody TaskData taskData){
List<String> qrcode = dailyCheckBillService.createQrcode(taskData);
return ResponseEntity.ok(qrcode);
}
@ApiOperation(value = "解析二维码", notes = "解析二维码")
@PostMapping(value = "/parseQrCode")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity parseQrCode(@RequestBody List<String> strings){
List<DeviceLibrary> deviceLibraries = dailyCheckBillService.parseQrCode(strings);
deviceLibraries.forEach(DeviceLibrary::setConfigName);
return ResponseEntity.ok(deviceLibraries);
}
@ApiOperation(value = "查询详情", notes = "查询详情")
@GetMapping(value = "/selectDetail")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity selectDetail(Integer billId){
Map<String, Object> detail = dailyCheckBillService.selectDetail(billId);
return ResponseEntity.ok(detail);
}
@ApiOperation(value = "保存和更新日常检查的装备列表", notes = "保存和更新日常检查的装备列表") @ApiOperation(value = "保存和更新日常检查的装备列表", notes = "保存和更新日常检查的装备列表")
@PostMapping(value = "/saveDayDevice") @PostMapping(value = "/saveDayDevice")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -86,8 +132,8 @@ public class DailyCheckController { ...@@ -86,8 +132,8 @@ public class DailyCheckController {
@ApiOperation(value = "查询自查任务", notes = "可以通过这个接口查询自查任务") @ApiOperation(value = "查询自查任务", notes = "可以通过这个接口查询自查任务")
@PostMapping(value = "/summary") @PostMapping(value = "/summary")
public ResponseEntity selectSelfExaminationBill(@RequestBody SelfCheckSelectVo selfCheckSelectVo) { public ResponseEntity selectSelfExaminationBill(@RequestBody DailyCheckSelectVo dailyCheckSelectVo) {
Page<DailyCheckBill> page = dailyCheckBillService.getDailyCheckPage(selfCheckSelectVo); Page<DailyCheckBill> page = dailyCheckBillService.getDailyCheckPage(dailyCheckSelectVo);
for (DailyCheckBill dailyCheckBill : page.getContent()) { for (DailyCheckBill dailyCheckBill : page.getContent()) {
if (dailyCheckBill.getCreateUnitId()!=null) { if (dailyCheckBill.getCreateUnitId()!=null) {
dailyCheckBill.setCreateUnit(unitsCache.findById(dailyCheckBill.getId()).getName()); dailyCheckBill.setCreateUnit(unitsCache.findById(dailyCheckBill.getId()).getName());
...@@ -102,15 +148,19 @@ public class DailyCheckController { ...@@ -102,15 +148,19 @@ public class DailyCheckController {
dailyCheckBill.setCreateUser(userCache.findById(dailyCheckBill.getUseraId()).getName()); dailyCheckBill.setCreateUser(userCache.findById(dailyCheckBill.getUseraId()).getName());
} }
if (dailyCheckBill.getId()!=null){ if (dailyCheckBill.getId()!=null){
dailyCheckBill.setTaskId(taskService.get(dailyCheckBill.getId(),4).getId()); dailyCheckBill.setTaskId(taskService.get(dailyCheckBill.getId(),32).getId());
}
if (dailyCheckBill.getStorageLocationId() != null){
dailyCheckBill.setStorageLocationName(storeCache.idToName(dailyCheckBill.getStorageLocationId()));
} }
} }
return ResultUtil.success(page); return ResultUtil.success(page);
} }
@ApiOperation(value = "查询自查任务", notes = "可以通过这个接口查询自查任务")
@GetMapping(value = "/taskId")
public ResponseEntity findByTaskId(Integer taskId) {
Map<String, Object> detail = dailyCheckBillService.selectDetailForTaskId(taskId);
return ResultUtil.success(detail);
}
@ApiOperation(value = "根据单位id查询日常检查选择的设备", notes = "根据单位id查询日常检查选择的设备") @ApiOperation(value = "根据单位id查询日常检查选择的设备", notes = "根据单位id查询日常检查选择的设备")
@GetMapping(value = "/findByUnitId") @GetMapping(value = "/findByUnitId")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -127,9 +177,19 @@ public class DailyCheckController { ...@@ -127,9 +177,19 @@ public class DailyCheckController {
deviceIds.add(i1); deviceIds.add(i1);
} }
List<DeviceLibrary> deviceLibraryList = deviceLibraryService.findAllByIds(deviceIds); List<DeviceLibrary> deviceLibraryList = deviceLibraryService.findAllByIds(deviceIds);
deviceLibraryList.forEach(DeviceLibrary::setConfigName);
checkUnitBill.setDeviceLibraryList(deviceLibraryList); checkUnitBill.setDeviceLibraryList(deviceLibraryList);
} }
return ResultUtil.success(checkUnitBill); return ResultUtil.success(checkUnitBill);
} }
@ApiOperation(value = "是否保存", notes = "是否保存")
@PostMapping(value = "/isSave")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity isSave(@RequestBody SaveDailyTaskVo saveDailyTaskVo) {
dailyCheckBillService.isSave(saveDailyTaskVo);
return ResponseEntity.ok("操作成功");
}
} }
...@@ -1143,98 +1143,98 @@ public class SelfCheckController { ...@@ -1143,98 +1143,98 @@ public class SelfCheckController {
// return ResultUtil.success(selfExaminationBillEntity); // return ResultUtil.success(selfExaminationBillEntity);
// } // }
@ApiOperation(value = "保存和更新日常检查的装备列表", notes = "保存和更新日常检查的装备列表") // @ApiOperation(value = "保存和更新日常检查的装备列表", notes = "保存和更新日常检查的装备列表")
@PostMapping(value = "/saveDayDevice") // @PostMapping(value = "/saveDayDevice")
@Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
public ResponseEntity saveDayDevice(@RequestBody SelfCheckUnitBill selfCheckUnitBill) { // public ResponseEntity saveDayDevice(@RequestBody SelfCheckUnitBill selfCheckUnitBill) {
SelfCheckUnitBill unitBill = service.add(selfCheckUnitBill); // SelfCheckUnitBill unitBill = service.add(selfCheckUnitBill);
return ResultUtil.success(unitBill); // return ResultUtil.success(unitBill);
} // }
//
@ApiOperation(value = "根据单位id查询日常检查选择的设备", notes = "根据单位id查询日常检查选择的设备") // @ApiOperation(value = "根据单位id查询日常检查选择的设备", notes = "根据单位id查询日常检查选择的设备")
@GetMapping(value = "/findByUnitId") // @GetMapping(value = "/findByUnitId")
@Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
public ResponseEntity findByUnitId() { // public ResponseEntity findByUnitId() {
Integer unitId = userUtils.getCurrentUnitId(); // Integer unitId = userUtils.getCurrentUnitId();
SelfCheckUnitBill checkUnitBill = service.findByUnitId(unitId); // SelfCheckUnitBill checkUnitBill = service.findByUnitId(unitId);
if (checkUnitBill != null){ // if (checkUnitBill != null){
//取出设备的id // //取出设备的id
String dayDeviceList = checkUnitBill.getDayDeviceList(); // String dayDeviceList = checkUnitBill.getDayDeviceList();
String[] ids = dayDeviceList.split("x"); // String[] ids = dayDeviceList.split("x");
List<Integer> deviceIds = new ArrayList<>(); // List<Integer> deviceIds = new ArrayList<>();
for (int i = 0; i < ids.length; i++) { // for (int i = 0; i < ids.length; i++) {
int i1 = Integer.parseInt(ids[i]); // int i1 = Integer.parseInt(ids[i]);
deviceIds.add(i1); // deviceIds.add(i1);
} // }
List<DeviceLibrary> deviceLibraryList = deviceLibraryService.findAllByIds(deviceIds); // List<DeviceLibrary> deviceLibraryList = deviceLibraryService.findAllByIds(deviceIds);
checkUnitBill.setDeviceLibraryList(deviceLibraryList); // checkUnitBill.setDeviceLibraryList(deviceLibraryList);
} // }
return ResultUtil.success(checkUnitBill); // return ResultUtil.success(checkUnitBill);
} // }
//
@ApiOperation(value = "生成二维码", notes = "生成二维码") // @ApiOperation(value = "生成二维码", notes = "生成二维码")
@PostMapping(value = "/createCode") // @PostMapping(value = "/createCode")
@Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
public ResponseEntity createCode(@RequestBody TaskData taskData) { // public ResponseEntity createCode(@RequestBody TaskData taskData) {
List<String> qrcode = selfCheckBillService.createQrcode(taskData); // List<String> qrcode = selfCheckBillService.createQrcode(taskData);
return ResultUtil.success(qrcode); // return ResultUtil.success(qrcode);
} // }
//
@ApiOperation(value = "解析二维码", notes = "解析二维码") // @ApiOperation(value = "解析二维码", notes = "解析二维码")
@PostMapping(value = "/parseCode") // @PostMapping(value = "/parseCode")
@Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
public ResponseEntity parseCode(@RequestBody List<String> strings) { // public ResponseEntity parseCode(@RequestBody List<String> strings) {
return ResultUtil.success(selfCheckBillService.parseQrCode(strings)); // return ResultUtil.success(selfCheckBillService.parseQrCode(strings));
} // }
//
@ApiOperation(value = "更新日常检查(日常检查的完结)", notes = "更新日常检查(日常检查的完结)") // @ApiOperation(value = "更新日常检查(日常检查的完结)", notes = "更新日常检查(日常检查的完结)")
@PostMapping(value = "/updateDayCheck") // @PostMapping(value = "/updateDayCheck")
@Transactional(rollbackFor = Exception.class) // @Transactional(rollbackFor = Exception.class)
public ResponseEntity updateDayCheck(@RequestBody DayVO dayVO) { // public ResponseEntity updateDayCheck(@RequestBody DayVO dayVO) {
Integer billId = dayVO.getId(); // Integer billId = dayVO.getId();
SelfCheckBill selfCheckBill = selfCheckBillService.getOne(billId); // SelfCheckBill selfCheckBill = selfCheckBillService.getOne(billId);
BeanUtils.copyProperties(dayVO,selfCheckBill); // BeanUtils.copyProperties(dayVO,selfCheckBill);
Integer currentUserId = userUtils.getCurrentUserId(); // Integer currentUserId = userUtils.getCurrentUserId();
Integer taskId = dayVO.getTaskId(); // Integer taskId = dayVO.getTaskId();
//
if (dayVO.getNewDeviceList() != null) { // if (dayVO.getNewDeviceList() != null) {
//按新增不在系统的装备按rfid卡号拼接保存 // //按新增不在系统的装备按rfid卡号拼接保存
StringBuilder stringBuffer = new StringBuilder(); // StringBuilder stringBuffer = new StringBuilder();
stringBuffer.append("."); // stringBuffer.append(".");
for (String s : dayVO.getNewDeviceList()) { // for (String s : dayVO.getNewDeviceList()) {
stringBuffer.append(s); // stringBuffer.append(s);
stringBuffer.append("."); // stringBuffer.append(".");
} // }
selfCheckBill.setNewDeviceDetail(stringBuffer.toString()); // selfCheckBill.setNewDeviceDetail(stringBuffer.toString());
} // }
//添加日志 // //添加日志
String deviceIdDetail = dayVO.getCheckDetail(); // String deviceIdDetail = dayVO.getCheckDetail();
String[] strings = deviceIdDetail.split("x"); // String[] strings = deviceIdDetail.split("x");
List<FileVo> fileVoList = new ArrayList<>(); // List<FileVo> fileVoList = new ArrayList<>();
if(dayVO.getCheckFiles()!=null&&dayVO.getCheckFiles().size()>0) { // if(dayVO.getCheckFiles()!=null&&dayVO.getCheckFiles().size()>0) {
selfCheckBill.setCheckFiles(FilesUtil.stringFileToList(dayVO.getCheckFiles())); // selfCheckBill.setCheckFiles(FilesUtil.stringFileToList(dayVO.getCheckFiles()));
dayVO.getCheckFiles().forEach(fileRet -> { // dayVO.getCheckFiles().forEach(fileRet -> {
fileVoList.add(new FileVo("日常检查单", fileRet.getName(), fileRet.getPreviewPath())); // fileVoList.add(new FileVo("日常检查单", fileRet.getName(), fileRet.getPreviewPath()));
}); // });
} // }
List<DeviceLogDto> deviceLogDtos = new ArrayList<>(); // List<DeviceLogDto> deviceLogDtos = new ArrayList<>();
for (String s:strings) { // for (String s:strings) {
if (s.length()>=2) { // if (s.length()>=2) {
Integer id = Integer.parseInt(s.substring(0, s.length() - 1)); // Integer id = Integer.parseInt(s.substring(0, s.length() - 1));
DeviceLogDto deviceLogDto = new DeviceLogDto(id,"发起日常检查",fileVoList,currentUserId,dayVO.getTaskId()); // DeviceLogDto deviceLogDto = new DeviceLogDto(id,"发起日常检查",fileVoList,currentUserId,dayVO.getTaskId());
deviceLogDtos.add(deviceLogDto); // deviceLogDtos.add(deviceLogDto);
} // }
} // }
executor.execute(()->deviceLogService.addAllLog(deviceLogDtos)); // executor.execute(()->deviceLogService.addAllLog(deviceLogDtos));
TaskBto taskBto = taskService.get(taskId); // TaskBto taskBto = taskService.get(taskId);
//任务推至完结 // //任务推至完结
TaskBto taskBto1 = taskService.moveToEnd(taskBto); // TaskBto taskBto1 = taskService.moveToEnd(taskBto);
//更新自查单 // //更新自查单
selfCheckBill.setCheckStatus(2); // selfCheckBill.setCheckStatus(2);
selfCheckBill.setTaskId(taskBto1.getId()); // selfCheckBill.setTaskId(taskBto1.getId());
SelfCheckBill save = selfCheckBillDao.save(selfCheckBill); // SelfCheckBill save = selfCheckBillDao.save(selfCheckBill);
return ResultUtil.success(save); // return ResultUtil.success(save);
} // }
// @ApiOperation(value = "查询日常检查的详情", notes = "查询日常检查的详情") // @ApiOperation(value = "查询日常检查的详情", notes = "查询日常检查的详情")
// @GetMapping(value = "/selectDetail") // @GetMapping(value = "/selectDetail")
......
...@@ -5,6 +5,7 @@ import com.tykj.dev.device.selfcheck.subject.domin.DailyCheckBill; ...@@ -5,6 +5,7 @@ import com.tykj.dev.device.selfcheck.subject.domin.DailyCheckBill;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill; import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSaveVo; import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSaveVo;
import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo; import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo;
import com.tykj.dev.device.selfcheck.subject.vo.daily.*;
import com.tykj.dev.misc.qrcode.vo.TaskData; import com.tykj.dev.misc.qrcode.vo.TaskData;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
...@@ -33,12 +34,28 @@ public interface DailyCheckBillService { ...@@ -33,12 +34,28 @@ public interface DailyCheckBillService {
*/ */
DailyCheckBill update(DailyCheckBill dailyCheckBill); DailyCheckBill update(DailyCheckBill dailyCheckBill);
/**
* 生成代办
* @return 实体对象
*/
DailyCheckBill createBill();
/** /**
* 发起日常检查 * 发起日常检查
* @param selfCheckSaveVo 日常检查的vo * @param dailyCheckSaveVo 更新保存列表设备
*/
DailyCheckBill addDayBill(DailyCheckSaveVo dailyCheckSaveVo);
/**
* 暂时保存
* @param dailyCheckUpdateVo
*/
DailyCheckBill updateBill(DailyCheckUpdateVo dailyCheckUpdateVo);
/**
* 完结日常检查
*/ */
void addDayBill(SelfCheckSaveVo selfCheckSaveVo); void endDayBill(DailyCheckEndVo dailyCheckEndVo);
/** /**
* 生成二维码 * 生成二维码
...@@ -60,11 +77,22 @@ public interface DailyCheckBillService { ...@@ -60,11 +77,22 @@ public interface DailyCheckBillService {
*/ */
Map<String,Object> selectDetail(Integer billId); Map<String,Object> selectDetail(Integer billId);
/**
* 根据业务id查询详情
* @param taskId 任务id
* @return 详情
*/
Map<String,Object> selectDetailForTaskId(Integer taskId);
/** /**
* 查询日常检查列表 * 查询日常检查列表
* @param selfCheckSelectVo * @param dailyCheckSelectVo
* @return * @return
*/ */
Page<DailyCheckBill> getDailyCheckPage(SelfCheckSelectVo selfCheckSelectVo); Page<DailyCheckBill> getDailyCheckPage(DailyCheckSelectVo dailyCheckSelectVo);
void isSave(SaveDailyTaskVo saveDailyTaskVo);
void delete(DailyCheckBill dailyCheckBill);
} }
package com.tykj.dev.device.selfcheck.service; package com.tykj.dev.device.selfcheck.service;
import com.tykj.dev.device.selfcheck.subject.domin.HistoryDailyDeviceBill;
import com.tykj.dev.device.selfcheck.subject.domin.HistoryDeviceBill; import com.tykj.dev.device.selfcheck.subject.domin.HistoryDeviceBill;
import java.util.List; import java.util.List;
...@@ -14,7 +15,7 @@ public interface HistoryDailyDeviceBillService { ...@@ -14,7 +15,7 @@ public interface HistoryDailyDeviceBillService {
* 批量保存 * 批量保存
* @param historyDeviceBillList historyDeviceBillList * @param historyDeviceBillList historyDeviceBillList
*/ */
void batchSave(List<HistoryDeviceBill> historyDeviceBillList); void batchSave(List<HistoryDailyDeviceBill> historyDeviceBillList);
/** /**
...@@ -22,5 +23,8 @@ public interface HistoryDailyDeviceBillService { ...@@ -22,5 +23,8 @@ public interface HistoryDailyDeviceBillService {
* @param billId 业务id * @param billId 业务id
* @return 实体对象 * @return 实体对象
*/ */
List<HistoryDeviceBill> selectByBillId(Integer billId); List<HistoryDailyDeviceBill> selectByBillId(Integer billId);
void deleteList(List<HistoryDailyDeviceBill> deviceBillList);
} }
...@@ -2,21 +2,29 @@ package com.tykj.dev.device.selfcheck.service.impl; ...@@ -2,21 +2,29 @@ package com.tykj.dev.device.selfcheck.service.impl;
import com.github.wenhao.jpa.PredicateBuilder; import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications; import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.config.cache.ConfigCache;
import com.tykj.dev.device.file.service.FilesUtil; import com.tykj.dev.device.file.service.FilesUtil;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService; import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.service.DeviceLibraryService; import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.selfcheck.repository.DailyCheckBillDao; import com.tykj.dev.device.selfcheck.repository.DailyCheckBillDao;
import com.tykj.dev.device.selfcheck.service.DailyCheckBillService; import com.tykj.dev.device.selfcheck.service.DailyCheckBillService;
import com.tykj.dev.device.selfcheck.service.HistoryDailyDeviceBillService;
import com.tykj.dev.device.selfcheck.subject.domin.DailyCheckBill; import com.tykj.dev.device.selfcheck.subject.domin.DailyCheckBill;
import com.tykj.dev.device.selfcheck.subject.domin.HistoryDailyDeviceBill;
import com.tykj.dev.device.selfcheck.subject.domin.HistoryDeviceBill;
import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill; import com.tykj.dev.device.selfcheck.subject.domin.SelfCheckBill;
import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSaveVo; import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSaveVo;
import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo; import com.tykj.dev.device.selfcheck.subject.vo.SelfCheckSelectVo;
import com.tykj.dev.device.selfcheck.subject.vo.daily.*;
import com.tykj.dev.device.task.service.TaskLogService; import com.tykj.dev.device.task.service.TaskLogService;
import com.tykj.dev.device.task.service.TaskService; 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.TaskBto;
import com.tykj.dev.device.task.subject.vo.TaskLogUserVo; import com.tykj.dev.device.task.subject.vo.TaskLogUserVo;
import com.tykj.dev.device.task.subject.vo.TaskUserVo; import com.tykj.dev.device.task.subject.vo.TaskUserVo;
import com.tykj.dev.device.user.cache.StoreCache;
import com.tykj.dev.device.user.cache.UserCache;
import com.tykj.dev.device.user.subject.entity.User;
import com.tykj.dev.device.user.util.UserUtils; import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.base.BusinessEnum; import com.tykj.dev.misc.base.BusinessEnum;
import com.tykj.dev.misc.base.StatusEnum; import com.tykj.dev.misc.base.StatusEnum;
...@@ -24,18 +32,23 @@ import com.tykj.dev.misc.exception.ApiException; ...@@ -24,18 +32,23 @@ import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.qrcode.QrCodeBillUtil; import com.tykj.dev.misc.qrcode.QrCodeBillUtil;
import com.tykj.dev.misc.qrcode.vo.DeviceCodeVO; import com.tykj.dev.misc.qrcode.vo.DeviceCodeVO;
import com.tykj.dev.misc.qrcode.vo.TaskData; import com.tykj.dev.misc.qrcode.vo.TaskData;
import com.tykj.dev.misc.utils.DateUtil;
import com.tykj.dev.misc.utils.JacksonUtil; import com.tykj.dev.misc.utils.JacksonUtil;
import com.tykj.dev.misc.utils.SpringUtils;
import com.tykj.dev.misc.utils.TaskDisposeUtil; import com.tykj.dev.misc.utils.TaskDisposeUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
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.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.persistence.Transient; import javax.persistence.Transient;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -57,9 +70,6 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService { ...@@ -57,9 +70,6 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService {
@Resource @Resource
private DeviceLibraryService deviceLibraryService; private DeviceLibraryService deviceLibraryService;
@Resource
private DeviceLibraryCacheService deviceLibraryCacheService;
@Resource @Resource
private TaskService taskService; private TaskService taskService;
...@@ -69,6 +79,13 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService { ...@@ -69,6 +79,13 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService {
@Resource @Resource
private UserUtils userUtils; private UserUtils userUtils;
@Resource
private HistoryDailyDeviceBillService historyDailyDeviceBillService;
@Resource
private UserCache userCache;
@Override @Override
public DailyCheckBill getOne(Integer id) { public DailyCheckBill getOne(Integer id) {
...@@ -81,62 +98,113 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService { ...@@ -81,62 +98,113 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService {
} }
@Override @Override
public void addDayBill(SelfCheckSaveVo selfCheckSaveVo) { public DailyCheckBill createBill() {
//当前登录的用户ID DailyCheckBill dailyCheckBill = new DailyCheckBill();
dailyCheckBill.setCheckStartTime(DateUtil.getLocalDateTime(new Date()));
Integer currentUserId = userUtils.getCurrentUserId(); Integer currentUserId = userUtils.getCurrentUserId();
//当前登录的单位ID
Integer unitId = userUtils.getCurrentUnitId(); Integer unitId = userUtils.getCurrentUnitId();
//当前登录的单位名称
String currentUserUnitName = userUtils.getCurrentUserUnitName(); String currentUserUnitName = userUtils.getCurrentUserUnitName();
//添加账单 dailyCheckBill.setUseraId(currentUserId);
DailyCheckBill checkBill; //设置状态为待检查
TaskBto taskBto; dailyCheckBill.setCheckStatus(0);
if (selfCheckSaveVo.getTaskId()!=null){ dailyCheckBill.setCheckUnitId(unitId);
taskBto = taskService.get(selfCheckSaveVo.getTaskId()); dailyCheckBill.setCheckUnit(currentUserUnitName);
TaskDisposeUtil.isNotSubmit(taskBto.getBillStatus(), StatusEnum.WAIT_SELF_CHECK); dailyCheckBill.setTitle(currentUserUnitName + "发起的日常检查任务");
checkBill = getOne(taskBto.getBillId()); //保存业务
checkBill.setCheckTime(new Date()); DailyCheckBill save = dailyCheckBillDao.save(dailyCheckBill);
BeanUtils.copyProperties(selfCheckSaveVo,checkBill); List<Integer> userIds = new ArrayList<>();
if (selfCheckSaveVo.getUnStockDevices()!=null&&selfCheckSaveVo.getUnStockDevices().size()>0){ userIds.add(currentUserId);
checkBill.setUnStockDetail(JacksonUtil.toJSon(selfCheckSaveVo.getUnStockDevices())); TaskBto taskBto = new TaskBto(StatusEnum.WAIT_CHECK.id, currentUserUnitName + "发起的日常检查任务",
} null, ".", save.getId(), BusinessEnum.DAILY_SELF_CHECK.id,
if (selfCheckSaveVo.getType()==1){ currentUserId, 0, null, userIds);
taskBto.setCustomInfo("扫码"); TaskBto start = taskService.start(taskBto);
//添加涉及人员 log.info("[日常检查模块]:日常检查代办生成");
taskService.addInvolveUser(taskBto,currentUserId); save.setTaskId(start.getId());
}else { return save;
throw new ApiException("type只能为0或1"); }
}
checkBill.setTaskId(selfCheckSaveVo.getTaskId()); @Override
public DailyCheckBill addDayBill(DailyCheckSaveVo dailyCheckSaveVo) {
//当前登录的用户ID
Integer taskId = dailyCheckSaveVo.getTaskId();
//业务id
Integer id = dailyCheckSaveVo.getId();
//任务推进
TaskBto taskBto = taskService.get(taskId);
taskService.moveToSpecial(taskBto,StatusEnum.WAIT_CHECK_RESULT);
//更新列表设备
DailyCheckBill checkBill = getOne(id);
checkBill.setCheckStatus(0);
BeanUtils.copyProperties(dailyCheckSaveVo, checkBill);
DailyCheckBill update = update(checkBill);
log.info("[日常检查模块]:发起日常检查");
return update;
}
@Override
public DailyCheckBill updateBill(DailyCheckUpdateVo dailyCheckUpdateVo) {
TaskBto taskBto = taskService.get(dailyCheckUpdateVo.getTaskId());
taskService.moveToSpecial(taskBto,StatusEnum.WAIT_CHECK_FILE);
Integer id = dailyCheckUpdateVo.getId();
DailyCheckBill checkBill = getOne(id);
BeanUtils.copyProperties(dailyCheckUpdateVo,checkBill);
//处理文件
if(dailyCheckUpdateVo.getCheckFiles()!=null&&dailyCheckUpdateVo.getCheckFiles().size()>0){
checkBill.setCheckFiles(FilesUtil.stringFileToList(dailyCheckUpdateVo.getCheckFiles()));
} }
else { checkBill.setCheckStatus(1);
//发起任务 DailyCheckBill update = update(checkBill);
checkBill = selfCheckSaveVo.toDailyCheckBill(); List<HistoryDailyDeviceBill> historyDailyDeviceBills =
checkBill.setTitle(currentUserUnitName + "发起的日常检查任务"); historyDailyDeviceBillService.selectByBillId(update.getId());
checkBill.setCheckUnit(currentUserUnitName); historyDailyDeviceBillService.deleteList(historyDailyDeviceBills);
checkBill.setCheckUnitId(unitId); //处理存储历史设备数据
//发起任务 List<HistoryDailyDeviceBill> historyDeviceBillList0 = new ArrayList<>();
List<Integer> userIds = new ArrayList<>(); batchSave(dailyCheckUpdateVo.getCheckDeviceList0(),Integer.valueOf("0"),historyDeviceBillList0,update.getId());
userIds.add(currentUserId); List<HistoryDailyDeviceBill> historyDeviceBillList1 = new ArrayList<>();
taskBto = new TaskBto(StatusEnum.SELF_CHECK_CONFIRM.id, currentUserUnitName + "发起的日常检查任务", batchSave(dailyCheckUpdateVo.getCheckDeviceList1(),Integer.valueOf("1"),historyDeviceBillList1,update.getId());
null, ".", checkBill.getId(), BusinessEnum.DAILY_SELF_CHECK.id, return update;
currentUserId, 0, null, userIds); }
TaskBto taskBto1 = new TaskBto();
if (selfCheckSaveVo.getType()==1){ @Override
taskBto.setCustomInfo("扫码"); public void endDayBill(DailyCheckEndVo dailyCheckEndVo) {
taskBto1 = taskService.start(taskBto); Integer taskId = dailyCheckEndVo.getTaskId();
//未检查 TaskBto taskBto = taskService.get(taskId);
checkBill.setCheckStatus(3); //如果是直接提交
checkBill.setTaskId(taskBto1.getId()); if (StatusEnum.WAIT_CHECK_RESULT.id.equals(taskBto.getBillStatus())){
} //推进一步
taskService.moveToSpecial(taskBto,StatusEnum.WAIT_CHECK_FILE);
}
//任务完结
taskService.moveToEnd(taskBto);
Integer id = dailyCheckEndVo.getId();
//处理业务
DailyCheckBill checkBill = getOne(id);
BeanUtils.copyProperties(dailyCheckEndVo,checkBill);
//处理文件
if(dailyCheckEndVo.getCheckFiles()!=null&&dailyCheckEndVo.getCheckFiles().size()>0){
checkBill.setCheckFiles(FilesUtil.stringFileToList(dailyCheckEndVo.getCheckFiles()));
}
//更新
//正常完成 超时完成
LocalDate startTime = checkBill.getCheckStartTime().toLocalDate();
LocalDateTime endTime = DateUtil.getLocalDateTime(new Date());
checkBill.setCheckEndTime(endTime);
if (!startTime.equals(endTime.toLocalDate())){
//说明是超时完成
checkBill.setCheckStatus(3);
}else {
checkBill.setCheckStatus(2);
} }
//日常检查设备 DailyCheckBill update = update(checkBill);
String dayCheckDetail = selfCheckSaveVo.getDayCheckDetail(); List<HistoryDailyDeviceBill> historyDailyDeviceBills =
checkBill.setDayCheckDetail(dayCheckDetail); historyDailyDeviceBillService.selectByBillId(update.getId());
checkBill.setUseraId(currentUserId); historyDailyDeviceBillService.deleteList(historyDailyDeviceBills);
checkBill.setCreateUnitId(unitId); //处理存储历史设备数据
update(checkBill); List<HistoryDailyDeviceBill> historyDeviceBillList0 = new ArrayList<>();
log.info("[自查模块]:发起日常检查"); batchSave(dailyCheckEndVo.getCheckDeviceList0(),Integer.valueOf("0"),historyDeviceBillList0,update.getId());
List<HistoryDailyDeviceBill> historyDeviceBillList1 = new ArrayList<>();
batchSave(dailyCheckEndVo.getCheckDeviceList1(),Integer.valueOf("1"),historyDeviceBillList1,update.getId());
} }
@Override @Override
...@@ -190,68 +258,36 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService { ...@@ -190,68 +258,36 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService {
@Override @Override
public Map<String, Object> selectDetail(Integer billId) { public Map<String, Object> selectDetail(Integer billId) {
Map<Integer, DeviceLibrary> deviceLibraryMap =
deviceLibraryCacheService.getAllDeviceLibraryList().stream().collect(Collectors.toMap(DeviceLibrary::getId,
Function.identity()));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
//根据billid查询实体 //根据billid查询实体
DailyCheckBill checkBill = getOne(billId); DailyCheckBill checkBill = getOne(billId);
//日常设备信息 //日常设备信息
if (checkBill.getDayCheckDetail() != null) { if (checkBill.getCheckDetail() != null) {
String dayDeviceList = checkBill.getDayCheckDetail(); String dayDeviceList = checkBill.getCheckDetail();
String[] ids = dayDeviceList.split("x"); String[] ids = dayDeviceList.split(",");
List<Integer> deviceIds = new ArrayList<>(); List<Integer> deviceIds = new ArrayList<>();
for (int i = 0; i < ids.length; i++) { for (int i = 0; i < ids.length; i++) {
int i1 = Integer.parseInt(ids[i]); int i1 = Integer.parseInt(ids[i]);
deviceIds.add(i1); deviceIds.add(i1);
} }
List<DeviceLibrary> deviceLibraryList = deviceLibraryService.findAllByIds(deviceIds); List<DeviceLibrary> deviceLibraryList = deviceLibraryService.findAllByIds(deviceIds);
deviceLibraryList.forEach(DeviceLibrary::setConfigName);
checkBill.setDayDeviceLibraries(deviceLibraryList); checkBill.setDayDeviceLibraries(deviceLibraryList);
} }
//设备信息 List<HistoryDailyDeviceBill> historyDailyDeviceBills = historyDailyDeviceBillService.selectByBillId(billId);
List<DeviceLibrary> deviceLibraries = new ArrayList<>(); checkBill.setHistoryDailyDeviceBills(historyDailyDeviceBills);
String checkDetail = checkBill.getCheckDetail();
if (checkDetail != null) {
String[] split = checkDetail.split("x");
//添加自查装备
for (String s : split) {
if (s.length() >= 2) {
Integer i = Integer.parseInt(s.substring(0, s.length() - 1));
Integer checkResult = Integer.parseInt(s.substring(s.length() - 1));
DeviceLibrary deviceLibraryEntity = deviceLibraryMap.get(i);
deviceLibraryEntity.setCheckResult(checkResult);
deviceLibraries.add(deviceLibraryEntity);
}
}
}
checkBill.setInDeviceLibraries(deviceLibraries);
//新增的
String newDeviceDetail = checkBill.getNewDeviceDetail();
List<DeviceLibrary> newDeviceList = new ArrayList<>();
if (newDeviceDetail != null) {
//分隔字符获得rfid卡号
String[] split2 = newDeviceDetail.split("\\.");
newDeviceList = new ArrayList<>();
for (String rfid : split2) {
if (rfid.length() > 0) {
DeviceLibrary d = new DeviceLibrary();
d.setCheckResult(2);
d.setSeqNumber("-");
d.setName("-");
d.setType(0);
d.setRfidSurfaceId("-");
d.setProdNumber("-");
d.setRfidCardId(rfid);
newDeviceList.add(d);
}
}
}
checkBill.setNewDeviceLibraries(newDeviceList);
//处理文件 //处理文件
if (checkBill.getCheckFiles() != null && checkBill.getCheckFiles().length() >0){ if (checkBill.getCheckFiles() != null && checkBill.getCheckFiles().length() >0){
checkBill.setCheckFileList(FilesUtil.stringFileToList(checkBill.getCheckFiles())); checkBill.setCheckFileList(FilesUtil.stringFileToList(checkBill.getCheckFiles()));
} }
//处理A B名称
if (checkBill.getUseraId() != null){
checkBill.setCheckUser(userCache.findById(checkBill.getUseraId()).getName());
}
if (checkBill.getUserbId() != null){
checkBill.setConfirmUser(userCache.findById(checkBill.getUserbId()).getName());
}
map.put("checkBill", checkBill); map.put("checkBill", checkBill);
//根据业务id查询任务日志 //根据业务id查询任务日志
TaskBto taskBto = taskService.get(billId, BusinessEnum.DAILY_SELF_CHECK.id); TaskBto taskBto = taskService.get(billId, BusinessEnum.DAILY_SELF_CHECK.id);
...@@ -264,54 +300,76 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService { ...@@ -264,54 +300,76 @@ public class DailyCheckBillServiceImpl implements DailyCheckBillService {
} }
@Override @Override
public Page<DailyCheckBill> getDailyCheckPage(SelfCheckSelectVo selfCheckSelectVo) { public Map<String, Object> selectDetailForTaskId(Integer taskId) {
return dailyCheckBillDao.findAll(getSelectSpecification(selfCheckSelectVo), Integer billId = taskService.get(taskId).getBillId();
selfCheckSelectVo.getPageable()); Map<String, Object> detail = selectDetail(billId);
return detail;
} }
private Specification<DailyCheckBill> getSelectSpecification(SelfCheckSelectVo selfCheckSelectVo) { @Override
public Page<DailyCheckBill> getDailyCheckPage(DailyCheckSelectVo dailyCheckSelectVo) {
return dailyCheckBillDao.findAll(getSelectSpecification(dailyCheckSelectVo),
dailyCheckSelectVo.getPageable());
}
@Override
public void isSave(SaveDailyTaskVo saveDailyTaskVo) {
//保存自查任务
if (saveDailyTaskVo.getIsSave() == 0){
DailyCheckSaveVo dailyCheckSaveVo = saveDailyTaskVo.getDailyCheckSaveVo();
this.addDayBill(dailyCheckSaveVo);
}else {
//删除task
TaskBto taskBto = taskService.get(saveDailyTaskVo.getTaskId());
//将任务进封存
taskService.moveToArchive(taskBto);
//将业务删除
DailyCheckBill checkBill = getOne(saveDailyTaskVo.getDailyCheckId());
delete(checkBill);
}
}
@Override
public void delete(DailyCheckBill dailyCheckBill) {
dailyCheckBillDao.delete(dailyCheckBill);
}
private Specification<DailyCheckBill> getSelectSpecification(DailyCheckSelectVo dailyCheckSelectVo) {
PredicateBuilder<DailyCheckBill> predicateBuilder = Specifications.and(); PredicateBuilder<DailyCheckBill> predicateBuilder = Specifications.and();
predicateBuilder.eq("checkUnitId", userUtils.getCurrentUnitId()); predicateBuilder.eq("checkUnitId", userUtils.getCurrentUnitId());
if (selfCheckSelectVo != null) { if (dailyCheckSelectVo != null) {
if (selfCheckSelectVo.getCheckStatus() != null) { if (dailyCheckSelectVo.getCheckStatus() != null) {
predicateBuilder.eq("checkStatus", selfCheckSelectVo.getCheckStatus()); predicateBuilder.eq("checkStatus", dailyCheckSelectVo.getCheckStatus());
}
if (selfCheckSelectVo.getSelfExaminationUnit() != null) {
predicateBuilder.eq("checkUnit", selfCheckSelectVo.getSelfExaminationUnit());
} }
if (selfCheckSelectVo.getCheckUserId() != null) { if (dailyCheckSelectVo.getCheckUserId() != null) {
predicateBuilder.eq("useraId", selfCheckSelectVo.getCheckUserId()); predicateBuilder.eq("useraId", dailyCheckSelectVo.getCheckUserId());
}
if (selfCheckSelectVo.getConfirmUserId() != null) {
predicateBuilder.eq("userbId", selfCheckSelectVo.getConfirmUserId());
}
if (selfCheckSelectVo.getSelfExaminationCycle() != null) {
predicateBuilder.eq("cycle", selfCheckSelectVo.getSelfExaminationCycle());
}
if (selfCheckSelectVo.getCreateUnitId() != null) {
predicateBuilder.eq("createUnitId", selfCheckSelectVo.getCreateUnitId());
}
if (selfCheckSelectVo.getCreateUserId() != null) {
predicateBuilder.eq("createUserId", selfCheckSelectVo.getCreateUserId());
}
if (selfCheckSelectVo.getContent() != null) {
Class<SelfCheckBill> selfExaminationBillEntityClass = SelfCheckBill.class;
Field[] declaredFields = selfExaminationBillEntityClass.getDeclaredFields();
PredicateBuilder<SelfCheckBill> p = Specifications.or();
for (Field field : declaredFields) {
if (field.getType().equals(String.class) && field.getAnnotation(Transient.class) == null) {
p.like(field.getName(), "%" + selfCheckSelectVo.getContent() + "%");
}
}
predicateBuilder.predicate(p.build());
}
if (selfCheckSelectVo.getStartTime() != null) {
predicateBuilder.gt("createTime", selfCheckSelectVo.getStartTime());
}
if (selfCheckSelectVo.getEndTime() != null) {
predicateBuilder.lt("createTime", selfCheckSelectVo.getEndTime());
} }
} }
return predicateBuilder.build(); return predicateBuilder.build();
} }
private void batchSave(List<DeviceLibrary> deviceLibraries,Integer integer,
List<HistoryDailyDeviceBill> historyDeviceBillList,Integer billId){
for (DeviceLibrary deviceLibrary : deviceLibraries) {
HistoryDailyDeviceBill historyDailyDeviceBill = new HistoryDailyDeviceBill();
historyDailyDeviceBill.setBillId(billId);
historyDailyDeviceBill.setModel(deviceLibrary.getModel());
historyDailyDeviceBill.setName(deviceLibrary.getName());
historyDailyDeviceBill.setDeviceId(deviceLibrary.getId());
historyDailyDeviceBill.setRfidCardId(deviceLibrary.getRfidCardId());
historyDailyDeviceBill.setLocationUnit(deviceLibrary.getLocationUnit());
historyDailyDeviceBill.setOwnUnit(deviceLibrary.getOwnUnit());
historyDailyDeviceBill.setCheckResult(integer);
historyDailyDeviceBill.setSeqNumber(deviceLibrary.getSeqNumber());
historyDailyDeviceBill.setTypeName(deviceLibrary.getTypeName());
historyDailyDeviceBill.setInvisibleRangeName(deviceLibrary.getInvisibleRangeName());
historyDailyDeviceBill.setSecretLevelName(deviceLibrary.getSecretLevelName());
historyDeviceBillList.add(historyDailyDeviceBill);
}
historyDailyDeviceBillService.batchSave(historyDeviceBillList);
}
} }
package com.tykj.dev.device.selfcheck.service.impl; package com.tykj.dev.device.selfcheck.service.impl;
import com.tykj.dev.device.selfcheck.repository.HistoryDailyDeviceBillDao;
import com.tykj.dev.device.selfcheck.service.HistoryDailyDeviceBillService; import com.tykj.dev.device.selfcheck.service.HistoryDailyDeviceBillService;
import com.tykj.dev.device.selfcheck.subject.domin.HistoryDailyDeviceBill;
import com.tykj.dev.device.selfcheck.subject.domin.HistoryDeviceBill; import com.tykj.dev.device.selfcheck.subject.domin.HistoryDeviceBill;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
/** /**
...@@ -12,13 +15,23 @@ import java.util.List; ...@@ -12,13 +15,23 @@ import java.util.List;
*/ */
@Service @Service
public class HistoryDailyDeviceBillServiceImpl implements HistoryDailyDeviceBillService { public class HistoryDailyDeviceBillServiceImpl implements HistoryDailyDeviceBillService {
@Resource
private HistoryDailyDeviceBillDao historyDailyDeviceBillDao;
@Override @Override
public void batchSave(List<HistoryDeviceBill> historyDeviceBillList) { public void batchSave(List<HistoryDailyDeviceBill> historyDeviceBillList) {
historyDailyDeviceBillDao.saveAll(historyDeviceBillList);
}
@Override
public List<HistoryDailyDeviceBill> selectByBillId(Integer billId) {
return historyDailyDeviceBillDao.findAllByBillId(billId);
} }
@Override @Override
public List<HistoryDeviceBill> selectByBillId(Integer billId) { public void deleteList(List<HistoryDailyDeviceBill> deviceBillList) {
return null; historyDailyDeviceBillDao.deleteAll(deviceBillList);
} }
} }
package com.tykj.dev.device.selfcheck.subject.domin; package com.tykj.dev.device.selfcheck.subject.domin;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.device.file.entity.FileRet; import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary; import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -12,8 +13,9 @@ import org.springframework.data.annotation.CreatedDate; ...@@ -12,8 +13,9 @@ 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.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -57,8 +59,20 @@ public class DailyCheckBill { ...@@ -57,8 +59,20 @@ public class DailyCheckBill {
/** /**
* 自查时间 * 自查时间
*/ */
@ApiModelProperty(value = "自查时间") @ApiModelProperty(value = "自查时间(创建任务的时间)")
private Date checkTime; @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
private LocalDateTime checkStartTime;
@ApiModelProperty(value = "完成的时间(上传单据的时间)")
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss")
private LocalDateTime checkEndTime;
@ApiModelProperty(value = "扫码完成时间")
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime scanCodeTime;
/** /**
* 自查单位 * 自查单位
*/ */
...@@ -82,20 +96,26 @@ public class DailyCheckBill { ...@@ -82,20 +96,26 @@ public class DailyCheckBill {
*/ */
@ApiModelProperty(value = "自查结果") @ApiModelProperty(value = "自查结果")
private String checkResult; private String checkResult;
/**
* 自查详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增
*/
@Column(name = "check_detail",columnDefinition = "TEXT") @Column(name = "check_detail",columnDefinition = "TEXT")
@ApiModelProperty(value = "自查详情(装备主键id+核对结果(0缺失1无误2新增,字符x作为分隔符)),例如10x21x32,意为主键id为1的装备缺失,为2的无误,为3的新增") @ApiModelProperty(value = "设备id 1,2,3")
private String checkDetail; private String checkDetail;
@Column(name = "check_detail0",columnDefinition = "TEXT")
@ApiModelProperty(value = "0 代表缺失")
private String checkDetail0;
@Column(name = "check_detail1",columnDefinition = "TEXT")
@ApiModelProperty(value = "1 代表无误")
private String checkDetail1;
@Column(name = "un_stock_detail",columnDefinition = "TEXT") @Column(name = "un_stock_detail",columnDefinition = "TEXT")
@ApiModelProperty(value = "非在库装备转JSon") @ApiModelProperty(value = "非在库装备转JSon")
private String unStockDetail; private String unStockDetail;
/** /**
* 自查状态(0:待审核,1:审核失败,2:自查完成,3:未检) * 自查状态(0:待审核,1:审核失败,2:自查完成,3:未检)
*/ */
@ApiModelProperty(value = "自查状态(0:待审核,1:审核失败,2:自查完成,3:未检)") @ApiModelProperty(value = "自查状态(0:待检查,1:未完成,2:已完成,3:超时完成)")
private Integer checkStatus; private Integer checkStatus;
/** /**
* 创建用户id * 创建用户id
...@@ -131,33 +151,13 @@ public class DailyCheckBill { ...@@ -131,33 +151,13 @@ public class DailyCheckBill {
*/ */
@ApiModelProperty(value = "删除标记(0:未删除,1:已删除)") @ApiModelProperty(value = "删除标记(0:未删除,1:已删除)")
private Integer deleteTag = 0; private Integer deleteTag = 0;
/**
* 自查未入库新增装备详情(RFID卡号以.为分隔符)
*/
@Column(name = "new_device_detail",columnDefinition = "TEXT")
@ApiModelProperty(value = "自查未入库新增装备详情(RFID卡号以.为分隔符)")
private String newDeviceDetail;
@ApiModelProperty(value = "手持终端信息") @ApiModelProperty(value = "手持终端信息")
private String handheldTerminalInformation; private String handheldTerminalInformation;
@ApiModelProperty(value = "装备存放位置Id",notes = "默认是库房, null代表是所有库房") @Column(name = "remake",columnDefinition = "TEXT")
private Integer storageLocationId; @ApiModelProperty(value = "备注说明")
private String remake;
@ApiModelProperty(value = "是否是日常检查",notes = "0代表 常规检查, 1代表 日常检查")
private Integer isDayCheck = 0;
// @ApiModelProperty(value = "生成二维码的地址")
// @Column(name = "qr_code_path",columnDefinition = "TEXT")
// private String qrcodePath ;
@ApiModelProperty(value = "日常检查装备的集合",example = "id 以x进行分割 id")
@Column(name = "day_check_detail",columnDefinition = "TEXT")
private String dayCheckDetail;
@ApiModelProperty(value = "装备存放位置Id",notes = "默认是库房, null代表是所有库房")
@Transient
private String storageLocationName;
@ApiModelProperty(value = "检查人") @ApiModelProperty(value = "检查人")
@Transient @Transient
...@@ -196,10 +196,7 @@ public class DailyCheckBill { ...@@ -196,10 +196,7 @@ public class DailyCheckBill {
private List<DeviceLibrary> dayDeviceLibraries; private List<DeviceLibrary> dayDeviceLibraries;
@Transient @Transient
@ApiModelProperty("日常检查设备信息列表") @ApiModelProperty("0和1")
private List<DeviceLibrary> inDeviceLibraries; private List<HistoryDailyDeviceBill> historyDailyDeviceBills;
@Transient
@ApiModelProperty("日常检查的设备新增设备列表")
private List<DeviceLibrary> newDeviceLibraries;
} }
...@@ -65,11 +65,20 @@ public class HistoryDailyDeviceBill { ...@@ -65,11 +65,20 @@ public class HistoryDailyDeviceBill {
@ApiModelProperty(value = "所属单位") @ApiModelProperty(value = "所属单位")
private String ownUnit; private String ownUnit;
@ApiModelProperty(value = "密级")
private String secretLevelName;
@ApiModelProperty(value = "可见范围")
private String invisibleRangeName;
@ApiModelProperty(value = "形态")
private String typeName;
/** /**
* 设备的状态 * 设备的状态
*/ */
@ApiModelProperty(value = "设备的状态",example = "0 缺失 1 正常 2 新增") @ApiModelProperty(value = "设备的状态",example = "0 缺失 1 正常 2 新增")
private Integer deviceStatus; private Integer checkResult;
@ApiModelProperty(value = "业务id") @ApiModelProperty(value = "业务id")
private Integer billId; private Integer billId;
......
...@@ -97,17 +97,4 @@ public class SelfCheckSaveVo { ...@@ -97,17 +97,4 @@ public class SelfCheckSaveVo {
return selfExaminationBillEntity; return selfExaminationBillEntity;
} }
public DailyCheckBill toDailyCheckBill() {
DailyCheckBill dailyCheckBill = new DailyCheckBill();
BeanUtils.copyProperties(this, dailyCheckBill);
dailyCheckBill.setCheckTime(new Date());
dailyCheckBill.setCheckStatus(0);
if(this.checkFiles!=null&&this.checkFiles.size()>0){
dailyCheckBill.setCheckFiles(FilesUtil.stringFileToList(this.checkFiles));
}
if (this.unStockDevices!=null&&this.unStockDevices.size()>0){
dailyCheckBill.setUnStockDetail(JacksonUtil.toJSon(this.unStockDevices));
}
return dailyCheckBill;
}
} }
package com.tykj.dev.device.selfcheck.subject.vo.daily;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Repository;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author zsp
*/
@Data
@ApiModel("日常检查更新列表类vo")
@Repository
public class DailyCheckEndVo {
@ApiModelProperty(name = "主键id")
private Integer id;
@Min(value = 1,message = "taskId不能小于1")
@ApiModelProperty(name = "任务id", example = "1")
private Integer taskId;
@NotNull(message = "userbId不能为空")
@Min(value = 1,message = "userbId不能小于1")
@ApiModelProperty(name = "审核人ID", example = "1")
private Integer userbId;
@NotNull(message = "checkingCount不能为空")
@Min(value = 0,message = "checkingCount不能小于0")
@ApiModelProperty(name = "应查数量", example = "1")
private Integer checkingCount;
@NotNull(message = "checkedCount不能为空")
@Min(value = 0,message = "checkedCount不能小于0")
@ApiModelProperty(name = "实查数量", example = "1")
private Integer checkedCount;
@NotNull(message = "checkResult不能为空")
@ApiModelProperty(name = "自查结果", example = "通过")
private String checkResult;
@ApiModelProperty(name = "自查详情 1 正常")
private List<DeviceLibrary> checkDeviceList1;
@ApiModelProperty(name = "自查详情 0 缺失")
private List<DeviceLibrary> checkDeviceList0;
@ApiModelProperty(value = "检查附件名")
private List<FileRet> checkFiles;
@ApiModelProperty(value = "手持终端信息")
private String handheldTerminalInformation;
@ApiModelProperty(value = "备注说明")
private String remake;
@ApiModelProperty(value = "设备id 1,2,3")
private String checkDetail;
@ApiModelProperty(value = "扫码完成时间")
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime scanCodeTime;
}
package com.tykj.dev.device.selfcheck.subject.vo.daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @author zsp
*/
@Data
@ApiModel("日常检查保存列表类vo")
public class DailyCheckSaveVo {
@ApiModelProperty(name = "主键id")
private Integer id;
@Min(value = 1,message = "taskId不能小于1")
@ApiModelProperty(name = "任务id", example = "1")
private Integer taskId;
@NotNull(message = "checkingCount不能为空")
@Min(value = 0,message = "checkingCount不能小于0")
@ApiModelProperty(name = "应查数量", example = "1")
private Integer checkingCount;
@ApiModelProperty(value = "日常检查装备详情(设备id 格式:1,2,3)")
private String checkDetail;
@ApiModelProperty(value = "手持终端信息")
private String handheldTerminalInformation;
}
package com.tykj.dev.device.selfcheck.subject.vo.daily;
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 zsp
*/
@Data
@ApiModel("日常检查单查询类")
public class DailyCheckSelectVo extends CustomPage {
@ApiModelProperty(value = "检查人的id", example = "检查人的id")
public Integer checkUserId;
@ApiModelProperty(value = "检查状态", example = "2")
public Integer checkStatus;
}
package com.tykj.dev.device.selfcheck.subject.vo.daily;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.device.file.entity.FileRet;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Repository;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author zsp
*/
@Data
@ApiModel("日常检查暂时保存类vo")
@Repository
public class DailyCheckUpdateVo {
@ApiModelProperty(name = "主键id")
private Integer id;
@NotNull
@Min(value = 1,message = "taskId不能小于1")
@ApiModelProperty(name = "任务id", example = "1")
private Integer taskId;
@ApiModelProperty(name = "审核人ID", example = "1")
private Integer userbId;
@NotNull(message = "checkingCount不能为空")
@Min(value = 0,message = "checkingCount不能小于0")
@ApiModelProperty(name = "应查数量", example = "1")
private Integer checkingCount;
@NotNull(message = "checkedCount不能为空")
@Min(value = 0,message = "checkedCount不能小于0")
@ApiModelProperty(name = "实查数量", example = "1")
private Integer checkedCount;
@NotNull(message = "checkResult不能为空")
@ApiModelProperty(name = "自查结果", example = "通过")
private String checkResult;
@ApiModelProperty(name = "自查详情 1 正常")
private List<DeviceLibrary> checkDeviceList1;
@ApiModelProperty(name = "自查详情 0 缺失")
private List<DeviceLibrary> checkDeviceList0;
@ApiModelProperty(value = "检查附件名")
private List<FileRet> checkFiles;
@ApiModelProperty(value = "手持终端信息")
private String handheldTerminalInformation;
@ApiModelProperty(value = "设备id 1,2,3")
private String checkDetail;
@ApiModelProperty(value = "扫码完成时间")
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime scanCodeTime;
}
package com.tykj.dev.device.selfcheck.subject.vo.daily;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* DATE:2021-7-14
* Author:zsp
* @author zsp
*/
@Data
@ApiModel("是否保存日常检查任务")
public class SaveDailyTaskVo {
@ApiModelProperty(value = "是否保存",notes = "0 是保存,1是不保存")
private Integer isSave;
@ApiModelProperty("任务id")
private Integer taskId;
@ApiModelProperty("日常检查id")
private Integer dailyCheckId;
@ApiModelProperty("更新日常检查的vo")
private DailyCheckSaveVo dailyCheckSaveVo;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论