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

更新

上级 e328acba
......@@ -119,10 +119,12 @@ public class AllotBillSelectController {
if (allotBillEntity.getReceiveUserbId() !=null){
allotBillEntity.setReceiveUserB(userService.getOne(allotBillEntity.getReceiveUserbId()).getName());
}
//转换文件
allotBillEntity.setSendFileList(FilesUtil.stringFileToList(allotBillEntity.getSendFiles()));
allotBillEntity.setReceiveFileList(FilesUtil.stringFileToList(allotBillEntity.getReceiveFiles()));
allotBillEntity.setReplyFileList(FilesUtil.stringFileToList(allotBillEntity.getReplyFiles()));
allotBillEntity.setApplyFileList(FilesUtil.stringFileToList(allotBillEntity.getApplyFiles()));
//转换单据
if (allotBillEntity.getScriptJson()!=null){
allotBillEntity.setScripts(JacksonUtil.readValue(allotBillEntity.getScriptJson(),new TypeReference<List<ScriptSaveVo>>() {}));
}
......
package com.tykj.dev.device.allot.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.allot.service.AllotBillService;
import com.tykj.dev.device.allot.subject.vo.AllotBillSaveVo;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.user.util.UserUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -28,21 +23,6 @@ import java.util.List;
@Slf4j
public class BatchAllotController {
@Autowired
private AllotBillService allotBillService;
@Autowired
private UserUtils userUtils;
@Autowired
private TaskService taskService;
@Autowired
private DeviceLibraryService deviceLibraryService;
@Autowired
private DeviceLogService deviceLogService;
@Autowired
private AllotBillController allotBillController;
......
......@@ -12,6 +12,9 @@ import java.util.List;
*/
public interface AllotBillService {
/**
* 新增配发单
*/
AllotBill addEntity(AllotBill allotBillEntity);
/**
......@@ -19,13 +22,33 @@ public interface AllotBillService {
*/
void sendHash(List<AllotBill> allotBills);
/**
* 更新账单
*/
AllotBill update(AllotBill allotBillEntity);
/**
* @param allotBillSelectVo 查询vo
* @param pageable 分页
* @return 配发单分页
*/
Page<AllotBill> getPage(AllotBillSelectVo allotBillSelectVo, Pageable pageable);
/**
* @param allotBillSelectVo 查询vo
* @return 配发单集合
*/
List<AllotBill> getList(AllotBillSelectVo allotBillSelectVo);
/**
* @param id 账单id
* 根据id获取配发单
*/
AllotBill getOne(Integer id);
/**
* @param id 账单id
* 根据id删除配发单
*/
void delete(Integer id);
}
......@@ -48,13 +48,17 @@ public class AllotBackBillServiceImpl implements AllotBackBillService {
@Override
public AllotBackBill addEntity(AllotBackBill allotBackBill) {
AllotBackBill allotBackBill1 = allotBackBillDao.save(allotBackBill);
//异步上链
CompletableFuture.runAsync(()->{
//延迟2s防止同时写入
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//获取最新数据
AllotBackBill allotBackBill2 = getOne(allotBackBill1.getId());
//上链获得recordId并存入表中
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(allotBackBill2));
String recordId = bcText.getData().getRecordID();
allotBackBill2.setRecordId(recordId);
......@@ -80,8 +84,8 @@ public class AllotBackBillServiceImpl implements AllotBackBillService {
@Override
public AllotBackBill update(AllotBackBill allotBackBill) {
AllotBackBill allotBackBill1 = allotBackBillDao.save(allotBackBill);
//根据recordId追加上链
CompletableFuture.runAsync(()->blockChainUtil.appendHash(JacksonUtil.toJSon(allotBackBill),allotBackBill.getRecordId()),TaskBeanConfig.getThreadPoolTaskScheduler());
// blockChainUtil.appendHash(JacksonUtil.toJSon(allotBackBill),allotBackBill.getRecordId());
return allotBackBill1;
}
......@@ -98,6 +102,7 @@ public class AllotBackBillServiceImpl implements AllotBackBillService {
@Override
public Page<AllotBackBill> getPage(AllotBillSelectVo allotBillSelectVo, Pageable pageable) {
Page<AllotBackBill> page = allotBackBillDao.findAll(getSelectSpecification(allotBillSelectVo), pageable);
//id转换为人名
for (AllotBackBill a : page.getContent()) {
if (a.getSendUseraId()!=null) {
a.setSenderUserA(userPublicService.getOne(a.getSendUseraId()).getName());
......@@ -115,8 +120,13 @@ public class AllotBackBillServiceImpl implements AllotBackBillService {
return page;
}
/**
* @param allotBillSelectVo 查询vo
* 查询统一筛选器
*/
private Specification<AllotBackBill> getSelectSpecification(AllotBillSelectVo allotBillSelectVo) {
PredicateBuilder<AllotBackBill> predicateBuilder = Specifications.and();
//或预言器,判断当前单位是不是发件或收件单位
PredicateBuilder<AllotBackBill> predicateBuilder1 = Specifications.or();
predicateBuilder1.eq("sendUnit", userUtils.getCurrentUserUnitName());
predicateBuilder1.eq("receiveUnit", userUtils.getCurrentUserUnitName());
......
......@@ -46,13 +46,17 @@ public class AllotBillServiceImpl implements AllotBillService {
@Override
public AllotBill addEntity(AllotBill allotBillEntity) {
AllotBill allotBill = allotBillDao.save(allotBillEntity);
//异步上链
CompletableFuture.runAsync(() ->{
//延迟2s防止同时写入
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//获取最新数据
AllotBill allotBill1 = getOne(allotBill.getId());
//上链获得recordId并存入表中
BcHash bcText = blockChainUtil.sendHash(1000, JacksonUtil.toJSon(allotBill1));
String recordId = bcText.getData().getRecordID();
allotBill1.setRecordId(recordId);
......@@ -77,7 +81,9 @@ public class AllotBillServiceImpl implements AllotBillService {
@Override
public AllotBill update(AllotBill allotBillEntity) {
//save
AllotBill allotBill = allotBillDao.save(allotBillEntity);
//根据recordId追加上链
CompletableFuture.runAsync(() -> blockChainUtil.appendHash(JacksonUtil.toJSon(allotBill), allotBill.getRecordId()),TaskBeanConfig.getThreadPoolTaskScheduler());
return allotBill;
}
......@@ -85,6 +91,7 @@ public class AllotBillServiceImpl implements AllotBillService {
@Override
public Page<AllotBill> getPage(AllotBillSelectVo allotBillSelectVo, Pageable pageable) {
Page<AllotBill> page = allotBillDao.findAll(getSelectSpecification(allotBillSelectVo), pageable);
//id转换为人名
for (AllotBill a : page.getContent()) {
if (a.getSendUseraId()!=null) {
a.setSenderUserA(userPublicService.getOne(a.getSendUseraId()).getName());
......@@ -118,8 +125,13 @@ public class AllotBillServiceImpl implements AllotBillService {
allotBillDao.deleteById(id);
}
/**
* @param allotBillSelectVo 查询vo
* 查询统一筛选器
*/
private Specification<AllotBill> getSelectSpecification(AllotBillSelectVo allotBillSelectVo) {
PredicateBuilder<AllotBill> predicateBuilder = Specifications.and();
//或预言器,判断当前单位是不是发件或收件单位
PredicateBuilder<AllotBill> predicateBuilder1 = Specifications.or();
predicateBuilder1.eq("sendUnit", userUtils.getCurrentUserUnitName());
predicateBuilder1.eq("receiveUnit", userUtils.getCurrentUserUnitName());
......
......@@ -171,36 +171,47 @@ public class AllotBackBill {
@ApiModelProperty(value = "区块链记录id")
private String recordId;
@ApiModelProperty(value = "批复文号文件")
@Column(name = "reply_files",columnDefinition = "TEXT")
private String replyFiles;
@ApiModelProperty(value = "发件方回执单")
@Column(name = "send_files",columnDefinition = "TEXT")
private String sendFiles;
@ApiModelProperty(value = "收件方签收单")
@Column(name = "receive_files",columnDefinition = "TEXT")
private String receiveFiles;
@ApiModelProperty(value = "申请文号文件")
@Column(name = "apply_files",columnDefinition = "TEXT")
private String applyFiles;
@ApiModelProperty(value = "单据集合json")
@Column(name = "script_json",columnDefinition = "TEXT")
private String scriptJson;
@ApiModelProperty(value = "单据集合")
@Transient
private List<ScriptSaveVo> scripts = new ArrayList<>();
@ApiModelProperty(value = "批复文号文件集合")
@Transient
private List<FileRet> replyFileList = new ArrayList<>();
@ApiModelProperty(value = "发件方回执单集合")
@Transient
private List<FileRet> sendFileList = new ArrayList<>();
@ApiModelProperty(value = "申请文号文件集合")
@Transient
private List<FileRet> applyFileList = new ArrayList<>();
@ApiModelProperty(value = "收件方签收单集合")
@Transient
private List<FileRet> receiveFileList = new ArrayList<>();
@ApiModelProperty(value = "装备集合")
@Transient
private List<DeviceLibrary> deviceLibraries;
}
......@@ -159,12 +159,15 @@ public class PackingController {
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity addPack(@RequestBody @Validated AddPack addPack){
if (packingLibraryService.nameIsExist(addPack.getModel(),addPack.getName())){
Map<String,Object> map = new HashMap<>();
map.put("error","型号"+addPack.getModel()+"下名称为"+addPack.getName()+"的装备已存在");
return ResponseEntity.ok(map);
if (!packingLibraryService.hasSamePack(addPack.getPartParentId(),addPack.getType(),addPack.getStyle(),addPack.getName(),addPack.getSecretLevel(),addPack.getInvisibleRange())) {
if (packingLibraryService.nameIsExist(addPack.getModel(), addPack.getName())) {
Map<String, Object> map = new HashMap<>();
map.put("error", "型号" + addPack.getModel() + "下名称为" + addPack.getName() + "的装备已存在");
return ResponseEntity.ok(map);
}
}
if (packingLibraryService.matchingRangeIsExist(addPack.getPartParentId(),addPack.getMatchingRange(),addPack.getType(),addPack.getStyle(),addPack.getName(),addPack.getSecretLevel(),addPack.getInvisibleRange())){
Boolean matchingRangeIsExist = packingLibraryService.matchingRangeIsExist(addPack.getPartParentId(),addPack.getMatchingRange(),addPack.getType(),addPack.getStyle(),addPack.getName(),addPack.getSecretLevel(),addPack.getInvisibleRange());
if (matchingRangeIsExist){
Map<String,Object> map = new HashMap<>();
map.put("error","型号"+addPack.getModel()+"下配用范围为"+configCache.getMatchingRangeMap().get(addPack.getMatchingRange())+"的该装备已存在");
return ResponseEntity.ok(map);
......
......@@ -164,4 +164,9 @@ public interface PackingLibraryService {
*/
List<PackingLibrary> splitTree(List<PackingLibrary> packingLibraries);
/**
* 判断是否有相同名称的列装装备,如果相同则可以进行新增
*/
Boolean hasSamePack(Integer parentId,Integer type,Integer style,String name,Integer secretLevel,Integer invisibleRange);
}
......@@ -615,6 +615,22 @@ public class PackingLibraryServiceImpl implements PackingLibraryService {
return resultList;
}
/**
* 判断是否有相同名称的列装装备,如果相同则可以进行新增
*/
@Override
public Boolean hasSamePack(Integer parentId, Integer type, Integer style, String name, Integer secretLevel, Integer invisibleRange) {
PredicateBuilder<PackingLibrary> predicateBuilder = Specifications.and();
predicateBuilder.eq("isRoot", 0);
predicateBuilder.eq("partParentId", parentId);
predicateBuilder.eq("type",type);
predicateBuilder.eq("style",style);
predicateBuilder.eq("name",name);
predicateBuilder.eq("secretLevel",secretLevel);
predicateBuilder.eq("invisibleRange",invisibleRange);
return packingLibraryDao.findAll(predicateBuilder.build()).size()>0;
}
private Specification<PackingLibrary> getSelectSpecification(PackingLibrarySelectVo packingLibrarySelectVo) {
PredicateBuilder<PackingLibrary> predicateBuilder = Specifications.and();
Integer level = userUtils.getCurrentUnitLevel();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论