提交 fcc5c9ae authored 作者: zjm's avatar zjm

添加托管业务以及应急业务代码12-05-zjm

上级 7e48dbf1
......@@ -115,12 +115,12 @@ public class EmergencyBill extends BaseEntity {
@Transient
@ApiModelProperty(value = "文件对象集合")
@ApiModelProperty(value = "文件对象集合(添加时查询使用)")
private List<FileRet> fileRets;
@Transient
@ApiModelProperty(value = "单据数据集合")
@ApiModelProperty(value = "单据数据集合(添加时查询使用)")
private List<EmergencyLibraryVo> emergencyLibraryList = new ArrayList<>();
......
package com.tykj.dev.device.emergency.service;
import com.alibaba.fastjson.JSON;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.device.emergency.dao.EmergencyBillDao;
import com.tykj.dev.device.emergency.dao.EmergencyLibraryDao;
......@@ -16,9 +18,11 @@ import com.tykj.dev.device.library.subject.Dto.DeviceLogDto;
import com.tykj.dev.device.library.subject.domin.DeviceLog;
import com.tykj.dev.device.library.subject.vo.ScriptSaveVo;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
import com.tykj.dev.misc.base.StatusEnum;
import com.tykj.dev.misc.exception.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -115,7 +119,7 @@ public class EmergencyBillServiceImpl implements EmergencyBillService{
@Override
public Page<EmergencyBill> selectPage(EmergencySelectVo emergencySelectVo) {
Page<EmergencyBill> all = emergencyBillDao.findAll(emergencySelectVo.getPageable());
Page<EmergencyBill> all = emergencyBillDao.findAll(getEmergencyBillSpecification(emergencySelectVo),emergencySelectVo.getPageable());
all.forEach(
emergencyBill -> {
emergencyBill.setFileRets(FilesUtil.stringFileToList(emergencyBill.getFiles()));
......@@ -125,6 +129,8 @@ public class EmergencyBillServiceImpl implements EmergencyBillService{
return all;
}
@Override
public List<UserWorkload> queryTimeUserWorkload(LocalDateTime sTime, LocalDateTime eTime) {
List<EmergencyBill> allByInitiateTimeBetween = emergencyBillDao.findAllByInitiateTimeBetweenAndStatus(sTime, eTime,2);
......@@ -171,6 +177,19 @@ public class EmergencyBillServiceImpl implements EmergencyBillService{
}
private Specification<EmergencyBill> getEmergencyBillSpecification(EmergencySelectVo emergencySelectVo) {
PredicateBuilder<EmergencyBill> predicateBuilder = Specifications.and();
if (emergencySelectVo.getStartTime() != null) {
predicateBuilder.gt("initiateTime", emergencySelectVo.getStartTime());
}
if (emergencySelectVo.getEndTime() != null) {
predicateBuilder.lt("initiateTime", emergencySelectVo.getEndTime());
}
return predicateBuilder.build();
}
public static void main(String[] args) {
Duration duration = Duration.between(LocalDateTime.now()
.withHour(0)
......
......@@ -11,13 +11,11 @@ import com.tykj.dev.device.matching.service.TrusteeshipBillService;
import com.tykj.dev.device.matching.subject.domin.ExternalUnitEquip;
import com.tykj.dev.device.matching.subject.domin.TrusteeshipBill;
import com.tykj.dev.device.matching.subject.domin.TrusteeshipEquip;
import com.tykj.dev.device.matching.subject.vo.ExternalSelectVo;
import com.tykj.dev.device.matching.subject.vo.ExternalUpdataVo;
import com.tykj.dev.device.matching.subject.vo.TrusteeshipBillSelectVo;
import com.tykj.dev.device.matching.subject.vo.TrusteeshipEquipSelectVo;
import com.tykj.dev.device.matching.subject.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -46,7 +44,7 @@ public class TrusteeshipBillController {
@ApiOperation(value = "登记入库", notes = "登记信息")
@PostMapping("/saveInitTrusteeshipBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity saveInitTrusteeshipBill(@RequestBody TrusteeshipBill trusteeshipBill) {
public ResponseEntity<TrusteeshipBill> saveInitTrusteeshipBill(@RequestBody TrusteeshipBill trusteeshipBill) {
return ResponseEntity.ok(trusteeshipBillService.saveInitTrusteeshipBill(trusteeshipBill));
}
......@@ -54,7 +52,7 @@ public class TrusteeshipBillController {
@ApiOperation(value = "退回登记", notes = "登记信息")
@PostMapping("/saveSendBackTrusteeshipBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity saveSendBackTrusteeshipBill(@RequestBody TrusteeshipBill trusteeshipBill) {
public ResponseEntity<TrusteeshipBill> saveSendBackTrusteeshipBill(@RequestBody TrusteeshipBill trusteeshipBill) {
return ResponseEntity.ok(trusteeshipBillService.saveSendBackTrusteeshipBill(trusteeshipBill));
}
......@@ -63,7 +61,7 @@ public class TrusteeshipBillController {
@ApiOperation(value = "根据相关条件查询业务列表", notes = "托管")
@PostMapping("/queryTrusteeshipBillSelectVo")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity queryTrusteeshipBillSelectVo(@RequestBody TrusteeshipBillSelectVo trusteeshipBillSelectVo) {
public ResponseEntity<Page<TrusteeshipBill>> queryTrusteeshipBillSelectVo(@RequestBody TrusteeshipBillSelectVo trusteeshipBillSelectVo) {
return ResponseEntity.ok(trusteeshipBillService.queryTrusteeshipBillSelectVo(trusteeshipBillSelectVo));
}
......@@ -73,7 +71,7 @@ public class TrusteeshipBillController {
@ApiOperation(value = "根据相关条件查询托管设备列表", notes = "托管")
@PostMapping("/queryTrusteeshipEquipSelectVo")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity queryTrusteeshipEquipSelectVo(@RequestBody TrusteeshipEquipSelectVo trusteeshipEquipSelectVo) {
public ResponseEntity<TrusteeshipEquipPageVo> queryTrusteeshipEquipSelectVo(@RequestBody TrusteeshipEquipSelectVo trusteeshipEquipSelectVo) {
return ResponseEntity.ok(trusteeshipBillService.queryTrusteeshipEquipSelectVo(trusteeshipEquipSelectVo));
}
......@@ -114,5 +112,12 @@ public class TrusteeshipBillController {
}
@ApiOperation(value = "根据需要查询是否存在", notes = "登记信息")
@GetMapping("/selectNum/{num}")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity queryById(@PathVariable String num) {
return ResponseEntity.ok(trusteeshipBillService.queryNum(num));
}
}
......@@ -15,4 +15,6 @@ public interface TrusteeshipEquipDao extends JpaRepository<TrusteeshipEquip,Inte
@Modifying
@Query(value = "update TrusteeshipEquip d set d.state = ?2 where d.id in ?1")
int updateIdsToStatus(List<Integer> ids, Integer status);
boolean existsByNum(String num);
}
......@@ -3,6 +3,7 @@ package com.tykj.dev.device.matching.service;
import com.tykj.dev.device.matching.subject.domin.TrusteeshipBill;
import com.tykj.dev.device.matching.subject.domin.TrusteeshipEquip;
import com.tykj.dev.device.matching.subject.vo.TrusteeshipBillSelectVo;
import com.tykj.dev.device.matching.subject.vo.TrusteeshipEquipPageVo;
import com.tykj.dev.device.matching.subject.vo.TrusteeshipEquipSelectVo;
import org.springframework.data.domain.Page;
......@@ -25,7 +26,7 @@ public interface TrusteeshipBillService {
/**
* 分页查询代管装备列表数据
*/
Page<TrusteeshipEquip> queryTrusteeshipEquipSelectVo(TrusteeshipEquipSelectVo trusteeshipEquipSelectVo);
TrusteeshipEquipPageVo queryTrusteeshipEquipSelectVo(TrusteeshipEquipSelectVo trusteeshipEquipSelectVo);
boolean queryNum(String num);
}
......@@ -12,14 +12,19 @@ import com.tykj.dev.device.matching.subject.domin.TrusteeshipBill;
import com.tykj.dev.device.matching.subject.domin.TrusteeshipEquip;
import com.tykj.dev.device.matching.subject.vo.ExternalSelectVo;
import com.tykj.dev.device.matching.subject.vo.TrusteeshipBillSelectVo;
import com.tykj.dev.device.matching.subject.vo.TrusteeshipEquipPageVo;
import com.tykj.dev.device.matching.subject.vo.TrusteeshipEquipSelectVo;
import com.tykj.dev.misc.base.StatusEnum;
import com.tykj.dev.misc.utils.PageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
......@@ -49,7 +54,7 @@ public class TrusteeshipBillServiceImpl implements TrusteeshipBillService {
trusteeshipBill.setTrusteeshipEquipJson(JSON.toJSONString(trusteeshipBill.getTrusteeshipEquips()));
trusteeshipBill.setFiles(FilesUtil.stringFileToList(trusteeshipBill.getFileRets()));
trusteeshipBill.setCount(trusteeshipBill.getTrusteeshipEquips().size());
trusteeshipEquipDao.updateIdsToStatus(trusteeshipBill.getTrusteeshipEquips().stream().map(TrusteeshipEquip::getId).collect(Collectors.toList()), 2);
trusteeshipEquipDao.updateIdsToStatus(trusteeshipBill.getTrusteeshipEquips().stream().map(TrusteeshipEquip::getId).collect(Collectors.toList()), 1);
return trusteeshipBillDao.save(trusteeshipBill);
}
......@@ -64,9 +69,25 @@ public class TrusteeshipBillServiceImpl implements TrusteeshipBillService {
}
@Override
public Page<TrusteeshipEquip> queryTrusteeshipEquipSelectVo(TrusteeshipEquipSelectVo trusteeshipEquipSelectVo) {
public TrusteeshipEquipPageVo queryTrusteeshipEquipSelectVo(TrusteeshipEquipSelectVo trusteeshipEquipSelectVo) {
return trusteeshipEquipDao.findAll(getPredicateBuilder(trusteeshipEquipSelectVo).build(),trusteeshipEquipSelectVo.getPageable());
Map<String,List<String>> map=new HashMap<>();
List<TrusteeshipEquip> all = trusteeshipEquipDao.findAll(getPredicateBuilder(trusteeshipEquipSelectVo).build());
map.put("model",all.stream().map(TrusteeshipEquip::getModel).distinct().collect(Collectors.toList()));
map.put("name",all.stream().map(TrusteeshipEquip::getName).distinct().collect(Collectors.toList()));
map.put("form",all.stream().map(TrusteeshipEquip::getForm).distinct().collect(Collectors.toList()));
map.put("unitName",all.stream().map(TrusteeshipEquip::getUnitName).distinct().collect(Collectors.toList()));
Page<TrusteeshipEquip> perPage = PageUtil.getPerPage(trusteeshipEquipSelectVo.getPage(), trusteeshipEquipSelectVo.getSize(), all, trusteeshipEquipSelectVo.getPageable());
return new TrusteeshipEquipPageVo(perPage,map);
}
@Override
public boolean queryNum(String num) {
return trusteeshipEquipDao.existsByNum(num);
}
......@@ -79,6 +100,13 @@ public class TrusteeshipBillServiceImpl implements TrusteeshipBillService {
}
if (trusteeshipBillSelectVo.getStartTime() != null) {
predicateBuilder.gt("createTime", trusteeshipBillSelectVo.getStartTime());
}
if (trusteeshipBillSelectVo.getEndTime() != null) {
predicateBuilder.lt("createTime", trusteeshipBillSelectVo.getEndTime());
}
}
return predicateBuilder;
}
......@@ -113,4 +141,6 @@ public class TrusteeshipBillServiceImpl implements TrusteeshipBillService {
}
}
package com.tykj.dev.device.matching.subject.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.tykj.dev.misc.base.CustomPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -7,6 +8,8 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
......@@ -15,4 +18,12 @@ public class TrusteeshipBillSelectVo extends CustomPage {
@ApiModelProperty(value = "1.入库 2退回")
private Integer type;
@ApiModelProperty(name = "开始清退的年份 默认各式 2020-01-01 00:00:00")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime startTime;
@ApiModelProperty(name = "开始清退的年份 默认各式 2020-01-01 00:00:00")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime endTime;
}
package com.tykj.dev.device.matching.subject.vo;
import com.tykj.dev.device.matching.subject.domin.ExternalUnitEquip;
import com.tykj.dev.device.matching.subject.domin.TrusteeshipEquip;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.domain.Page;
import java.util.List;
import java.util.Map;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TrusteeshipEquipPageVo {
@ApiModelProperty(value = "分页内容")
private Page<TrusteeshipEquip> trusteeshipEquips;
@ApiModelProperty(value = "条件内容")
private Map<String,List<String>> map;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论