提交 debb315a authored 作者: 邓砥奕's avatar 邓砥奕

更新

上级 a8ee7c2f
......@@ -24,6 +24,7 @@ public interface DeviceApplyBillService {
/**
* @param scriptSaveVos 退役/报废/销毁装备单据详情
* 更新装备对应申请任务的已完成数量
*/
void updateCompleteNum(Integer applyType , List<ScriptSaveVo> scriptSaveVos);
......
......@@ -110,39 +110,55 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
@Override
public void updateCompleteNum(Integer applyType,List<ScriptSaveVo> scriptSaveVos) {
//筛选出所有申请完成后待执行的任务
Map<Integer, Task> taskMap = taskDao.findAllByBusinessTypeAndBillStatus(9, StatusEnum.WAIT_CONFIRM_APPLY_DEVICE.id).stream().collect(Collectors.toMap(Task::getId, Function.identity()));
//所有申请单Id的map
Map<Integer, DeviceApplyBill> billMap = deviceApplyBillDao.findAll().stream().collect(Collectors.toMap(DeviceApplyBill::getId,Function.identity()));
//所有装备序列号map
Map<String, DeviceLibrary> seqMap = deviceLibraryService.getAllDeviceSeqMap();
//根据序列号区间找到所有装备
List<DeviceLibrary> deviceLibraries = new ArrayList<>();
for (ScriptSaveVo s:scriptSaveVos) {
if (s.getSeqNumber()!=null){
DeviceSeqUtil.selectDeviceSeqs(s.getSeqNumber()).forEach(s1 -> deviceLibraries.add(seqMap.get(s1)));
}
}
//taskId为主键,对应装备集合为值的map
Map<Integer,List<DeviceLibrary>> taskIdMap= deviceLibraries.stream().filter(deviceLibrary -> deviceLibrary.getApplyTaskId()!=null).collect(groupingBy(DeviceLibrary::getApplyTaskId));
//根据taskIdMap遍历
for (Integer taskId:taskIdMap.keySet()) {
//将该task涉及装备按列装id分组
Map<Integer,List<DeviceLibrary>> map = taskIdMap.get(taskId).stream().collect(groupingBy(DeviceLibrary::getPackingId));
TaskBto taskBto = taskMap.get(taskId).parse2Bto();
DeviceApplyBill deviceApplyBill = billMap.get(taskBto.getBillId());
//该任务是否完成
Boolean isComplete = true;
if (deviceApplyBill.getReplyVos()!=null&&!"".equals(deviceApplyBill.getReplyVos())) {
//转换json
List<ReplyVo> replyVos = JacksonUtil.readValue(deviceApplyBill.getReplyVos(), new TypeReference<List<ReplyVo>>() {
});
//存放未完成数量装备
List<DeviceLibrary> deviceLibraryList = new ArrayList<>();
if (replyVos != null) {
for(ReplyVo r:replyVos){
if (map.get(r.getId())!=null){
//完成数量增加
r.setCompleteCount(r.getCompleteCount()+map.get(r.getId()).size());
//如果完成数量不等于申请数量
if (!r.getCompleteCount().equals(r.getNum())){
isComplete = false;
List<String> seqs = DeviceSeqUtil.selectDeviceSeqs(r.getSeqInterval());
//移除已完成数量装备序列号
seqs.removeAll(map.get(r.getId()).stream().map(DeviceLibrary::getSeqNumber).collect(Collectors.toList()));
//将未完成的装备添加到集合
seqs.forEach(s -> deviceLibraryList.add(seqMap.get(s)));
}
}
}
if (!isComplete){
//存放所有未完成装备生命状态
Set<Integer> lifeStatus = deviceLibraryList.stream().map(DeviceLibrary::getLifeStatus).collect(Collectors.toSet());
//存放所有完成的状态
Set<Integer> integers = new HashSet<>();
integers.add(11);
if (applyType==2) {
......@@ -160,11 +176,14 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
integers.add(10);
integers.add(20);
}
//判断剩下未完成的装备是否生命状态算完成
if (integers.containsAll(lifeStatus)){
isComplete = true;
}
}
//如果已完成
if (isComplete){
//业务办结
taskService.addInvolveUser(taskBto,userUtils.getCurrentUserId());
taskService.moveToEnd(taskBto);
//发送阅知信息
......@@ -176,6 +195,7 @@ public class DeviceApplyBillServiceImpl implements DeviceApplyBillService {
messageBto.setBusinessType(taskBto.getBusinessType());
messageService.add(messageBto);
}
//更新账单replyVos
deviceApplyBill.setReplyVos(JacksonUtil.toJSon(replyVos));
update(deviceApplyBill);
}
......
......@@ -137,19 +137,23 @@ public class DeviceApplyBill {
@ApiModelProperty(value = "区块链记录id")
private String recordId;
@ApiModelProperty(value = "申请单")
@Column(name = "apply_files",columnDefinition = "TEXT")
private String applyFiles;
@ApiModelProperty(value = "批复单")
@Column(name = "back_files",columnDefinition = "TEXT")
private String backFiles;
@ApiModelProperty(value = "批复文号文件")
@Column(name = "apply_num_files",columnDefinition = "TEXT")
private String applyNumFiles;
@ApiModelProperty(value = "批复文号文件")
@Column(name = "reply_files",columnDefinition = "TEXT")
private String replyFiles;
@ApiModelProperty(value = "记录完成数量和未完成数量")
@Column(name = "reply_vos",columnDefinition = "TEXT")
private String replyVos;
......@@ -168,6 +172,7 @@ public class DeviceApplyBill {
@Transient
private List<ReplyVo> replyVoList = new ArrayList<>();
@ApiModelProperty(value = "申请装备序列号信息vo")
@Transient
private List<ApplyBillDetailVo> applyBillDetailVos = new ArrayList<>();
}
......@@ -53,5 +53,6 @@ public class DeviceApplyAllotSaveVo {
@ApiModelProperty(value = "左签章Id")
private String leftSignatureId;
@ApiModelProperty(value = "单据保存vo")
private List<ScriptSaveVo> scriptSaveVos;
}
......@@ -70,14 +70,20 @@ public class DeviceApplySaveVo {
@ApiModelProperty(value = "申请类型(1:装备申请,2:退役申请,3:报废申请,4:销毁申请)")
private Integer applyType;
/**
* 转实体
*/
public DeviceApplyBill toDo() {
ModelMapper mapper = BeanHelper.getUserMapper();
DeviceApplyBill deviceApplyBillEntity = mapper.map(this, DeviceApplyBill.class);
deviceApplyBillEntity.setApplyStatus(0);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("x");
//申请详情
if (this.storageBillDetailVoList!=null&&this.storageBillDetailVoList.size() > 0) {
//分解父子结构
List<ApplyBillDetailVo> applyBillDetailVos = GetTreeUtils.splitTree(storageBillDetailVoList,ApplyBillDetailVo::getChilds,ApplyBillDetailVo::setChildNull);
//拼接列装id和申请数量字符串
for (ApplyBillDetailVo s : applyBillDetailVos) {
stringBuffer.append(s.getPackingId()).append("x");
if (s.getStorageCount()!=null) {
......@@ -87,7 +93,9 @@ public class DeviceApplySaveVo {
stringBuffer.append(0).append("x");
}
}
//转为json存储
deviceApplyBillEntity.setApplyStat(JacksonUtil.toJSon(applyBillDetailVos));
//如果不是装备申请,添加replyVo
if (this.applyType!=1){
List<ReplyVo> replyVos = new ArrayList<>();
for (ApplyBillDetailVo applyBillDetailVo : applyBillDetailVos){
......@@ -97,10 +105,13 @@ public class DeviceApplySaveVo {
replyVo.setSeqInterval(applyBillDetailVo.getSeqInterval());
replyVos.add(replyVo);
}
//转为json存储
deviceApplyBillEntity.setReplyVos(JacksonUtil.toJSon(replyVos));
}
}
//set组合字符串
deviceApplyBillEntity.setApplyDetail(stringBuffer.toString());
//单据转换
if(this.applyFiles!=null&&this.applyFiles.size()>0){
deviceApplyBillEntity.setApplyFiles(FilesUtil.stringFileToList(this.applyFiles));
}
......
......@@ -322,6 +322,14 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
deviceStatisticsVo.setRetiredNum(retiredNum);
deviceStatisticsVo.setUseNum(useNum);
deviceStatisticsVo.setOtherNum(num-allotNum-inLibraryNum-repairNum-destoryNum-scrappedNum-retiredNum-useNum);
deviceIds.removeAll(allotIds);
deviceIds.removeAll(destoryIds);
deviceIds.removeAll(inLibraryIds);
deviceIds.removeAll(repairIds);
deviceIds.removeAll(retiredIds);
deviceIds.removeAll(scrappedIds);
deviceIds.removeAll(useIds);
deviceStatisticsVo.setOtherNumIds(deviceIds);
deviceStatisticsVo.setSeqs(StringSplitUtil.stringListToString(DeviceSeqUtil.getContinuousSeqs(devSeqs)));
deviceStatisticsVos.add(deviceStatisticsVo);
}
......
......@@ -50,6 +50,9 @@ public class DeviceStatisticsVo {
@ApiModelProperty(value = "其他数量", example = "10")
private Integer otherNum;
@ApiModelProperty(value = "其他数量id", example = "10")
private List<Integer> otherNumIds = new ArrayList<>();
@ApiModelProperty(value = "该型号所有装备Id列表")
private List<Integer> deviceIds = new ArrayList<>();
......
......@@ -5,6 +5,7 @@ import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.subject.domin.DeviceLibrary;
import com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo;
import com.tykj.dev.device.library.subject.vo.DeviceLogUserVo;
import com.tykj.dev.device.packing.repository.PackingLibraryDao;
import com.tykj.dev.device.packing.repository.PackingLogDao;
......@@ -36,6 +37,8 @@ import javax.validation.constraints.Min;
import java.util.*;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.groupingBy;
@RestController
@Api(tags = "列装管理模块", description = "列装管理接口")
@AutoDocument
......@@ -287,29 +290,48 @@ public class PackingController {
return ResponseEntity.ok(allotSeqs1);
}
@ApiOperation(value = "配发设置区间")
@PostMapping("/setAllotSeqs/{id}/{num}/{seq}")
public ResponseEntity setAllotSeqs(@PathVariable("id") int id,@PathVariable("num") int num,@PathVariable("seq") String seq){
List<DeviceLibrary> deviceLibraries = packingLibraryService.getAllotDevSeqs(id);
List<String> existSeqs = deviceLibraries.stream().map(DeviceLibrary::getSeqNumber).collect(Collectors.toList());
List<String> inputSeqs = DeviceSeqUtil.selectDeviceSeqs(seq);
if (existSeqs.containsAll(inputSeqs)){
if (inputSeqs.size()!=num){
return ResponseEntity.ok("序列号区间装备数量为"+inputSeqs.size()+",与填写数量不符");
}
else {
List<Integer> ids = deviceLibraries.stream().filter(deviceLibrary -> inputSeqs.contains(deviceLibrary.getSeqNumber())).map(DeviceLibrary::getId).collect(Collectors.toList());
return ResponseEntity.ok(ids);
}
@ApiOperation(value = "获取批量配发最大数量")
@PostMapping("/getMaxAllotNum")
public ResponseEntity getMaxAllotNum(@RequestBody List<Integer> ids){
//输出集合
List<AllotMaxNum> allotMaxNums = new ArrayList<>();
//筛选出当前单位在库的装备
DeviceLibrarySelectVo deviceLibrarySelectVo = new DeviceLibrarySelectVo();
deviceLibrarySelectVo.setLifeStatus(Collections.singletonList(2));
List<DeviceLibrary> deviceLibraries = deviceLibraryService.getList(deviceLibrarySelectVo);
//转为列装id的map
Map<Integer,List<DeviceLibrary>> map = deviceLibraries.stream().collect(groupingBy(DeviceLibrary::getPackingId));
ids.forEach(integer -> {
//创建返回对象
AllotMaxNum allotMaxNum = new AllotMaxNum();
allotMaxNum.setId(integer);
//map里value的集合大小为最大可配发数量
allotMaxNum.setMaxNum(map.get(integer).size());
allotMaxNums.add(allotMaxNum);
});
return ResponseEntity.ok(allotMaxNums);
}
@ApiOperation(value = "批量配发设置区间")
@PostMapping("/getAllotSeqs/{id}/{num}")
public ResponseEntity getAllotSeqs(@PathVariable("id") int id,@PathVariable("num") int num,@RequestBody List<Integer> existIds){
//获取可配发装备,排除已经生成了序列号在批量配发中的装备,按序列号排序
List<DeviceLibrary> deviceLibraries = packingLibraryService.getAllotDevSeqs(id).stream()
.filter(deviceLibrary -> !existIds.contains(deviceLibrary.getId()))
.sorted(Comparator.comparing(DeviceLibrary::getSeqNumber))
.collect(Collectors.toList());
if (deviceLibraries.size()<num){
return ResponseEntity.ok(ResultUtil.success("该装备最大可配发数量为"+deviceLibraries.size()+"小于填写数量"));
}
else {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("序列号");
inputSeqs.removeAll(existSeqs);
inputSeqs.forEach(s -> stringBuffer.append(s).append(","));
stringBuffer.deleteCharAt(stringBuffer.length()-1);
stringBuffer.append("不存在");
return ResponseEntity.ok(stringBuffer.toString());
//获取前num个装备
List<DeviceLibrary> deviceLibraryList = deviceLibraries.subList(0,num);
List<Integer> ids = deviceLibraryList.stream().map(DeviceLibrary::getId).collect(Collectors.toList());
List<String> seqs = deviceLibraryList.stream().map(DeviceLibrary::getSeqNumber).collect(Collectors.toList());
Map<String,Object> map = new HashMap<>();
map.put("ids",ids);
map.put("seqs",StringSplitUtil.stringListToString(DeviceSeqUtil.getContinuousSeqs(seqs)));
return ResponseEntity.ok(map);
}
}
......
......@@ -529,6 +529,7 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
public List<DeviceLibrary> getAllotDevSeqs(Integer packingId) {
PredicateBuilder<DeviceLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("ownUnit", userUtils.getCurrentUserUnitName());
predicateBuilder.eq("locationUnit", userUtils.getCurrentUserUnitName());
predicateBuilder.eq("lifeStatus", 2);
predicateBuilder.eq("packingId", packingId);
return deviceLibraryDao.findAll(predicateBuilder.build());
......
package com.tykj.dev.device.packing.subject.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.springframework.stereotype.Repository;
/**
* @author dengdiyi
*/
@Repository
@Data
@ApiModel("最大配发数量返回类")
public class AllotMaxNum {
//列装id
private Integer id;
//最大可配发的在库数量
private Integer maxNum;
}
......@@ -238,12 +238,15 @@ public class RepairBackBill {
@ApiModelProperty(value = "区块链记录id")
private String recordId;
@ApiModelProperty(value = "发件方上传单据")
@Column(name = "send_files",columnDefinition = "TEXT")
private String sendFiles;
@ApiModelProperty(value = "收件方上传单据")
@Column(name = "receive_files",columnDefinition = "TEXT")
private String receiveFiles;
@ApiModelProperty(value = "单据json")
@Column(name = "script_json",columnDefinition = "TEXT")
private String scriptJson;
......
......@@ -57,7 +57,7 @@ public class RepairBill {
/**
* 维修状态
*/
@ApiModelProperty(value = "维修状态")
@ApiModelProperty(value = "维修状态(0.草稿,1.发起审核失败,2.运输中,3.维修方审核失败,4.维修中,5.维修完成,6:维修方接收待审核)")
private Integer repairStatus;
/**
* 创建用户id
......
......@@ -149,12 +149,16 @@ public class RepairDetail {
@ApiModelProperty(value = "维修记录信息")
private String record3;
@ApiModelProperty(value = "领取单id")
private Integer repairBackBillId;
@ApiModelProperty(value = "形态")
@Transient
private String typeName;
/**
* set 中文名称
*/
public RepairDetail setConfigName(){
ConfigCache configCache = SpringUtils.getBean("initConfigCache");
if (configCache != null) {
......
......@@ -230,12 +230,15 @@ public class RepairSendBill {
@ApiModelProperty(value = "区块链记录id")
private String recordId;
@ApiModelProperty(value = "发件方上传单据")
@Column(name = "send_files",columnDefinition = "TEXT")
private String sendFiles;
@ApiModelProperty(value = "收件方上传单据")
@Column(name = "receive_files",columnDefinition = "TEXT")
private String receiveFiles;
@ApiModelProperty(value = "单据json")
@Column(name = "script_json",columnDefinition = "TEXT")
private String scriptJson;
......
......@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("配发审核类")
@ApiModel("上传签发人类")
public class AgentBackVo {
private Integer id;
......
......@@ -95,5 +95,6 @@ public class RepairBillSaveVo {
@ApiModelProperty(value = "发送方附件")
private List<FileRet> sendFileList;
@ApiModelProperty(value = "单据保存vo")
private List<ScriptSaveVo> scriptSaveVos;
}
......@@ -76,5 +76,6 @@ public class RepairReceiveVo {
@ApiModelProperty(value = "收件单位签章id")
private String rightSignatureId;
@ApiModelProperty(value = "单据保存vo")
private List<ScriptSaveVo> scriptSaveVos;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论