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

[修改bug]修改报废、更新列装库等bug、添加事务

上级 f5bee343
......@@ -27,6 +27,7 @@ public class SystemVariableServiceImpl implements SystemVariableService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public SystemVariable setVaule(String name,String vaule) {
SystemVariable systemVariable = systemVariableDao.findByName(name);
systemVariable.setVaule(vaule);
......
......@@ -53,4 +53,5 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
@Query("select o from DeviceLibrary o where o.ownUnit= :unitName and o.createTime >= :startTime and o.createTime <= :endTime")
List<DeviceLibrary> findAllByUnitBetweenTime(String unitName, Date startTime, Date endTime);
List<DeviceLibrary> getAllByPackingId(Integer packingId);
}
......@@ -29,6 +29,10 @@
<groupId>com.tykj.dev</groupId>
<artifactId>config</artifactId>
</dependency>
<dependency>
<groupId>com.tykj</groupId>
<artifactId>dev-library</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.tykj.dev.device.packing.controller;
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.packing.service.PackingLibraryService;
import com.tykj.dev.device.packing.subject.domin.PackingLibrary;
import com.tykj.dev.device.packing.subject.vo.PackingEditVo;
......@@ -17,6 +20,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -31,6 +35,12 @@ public class PackingLibraryController {
@Autowired
PackingLibraryService packingLibraryService;
@Autowired
DeviceLibraryDao deviceLibraryDao;
@Autowired
DeviceLibraryService deviceLibraryService;
@ApiOperation(value = "列装库分页查询", notes = "可以通过这个接口进行列装查询")
@PostMapping("/serve/summary")
public ResponseEntity getPage(@RequestBody PackingLibrarySelectVo packingLibrarySelectVo) {
......@@ -71,6 +81,11 @@ public class PackingLibraryController {
PackingLibrary packingLibraryEntity = packingLibraryService.getOne(packingEditVo.getPackingId());
//获取配件列装
List<PackingLibrary> packingLibraries = packingLibraryService.selectAllPart(packingEditVo.getPackingId());
//获取该列装所有装备
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.getAllByPackingId(packingEditVo.getPackingId());
//获取所有列装配件装备
List<DeviceLibrary> deviceLibraryList = new ArrayList<>();
packingLibraries.forEach(packingLibrary -> deviceLibraryList.addAll(deviceLibraryDao.getAllByPackingId(packingLibrary.getId())));
PackingLibraryUpdateVo p = packingEditVo.getUpdateVoList();
if (p.getApplyType() != null) {
packingLibraryEntity.setApplyType(p.getApplyType());
......@@ -99,16 +114,22 @@ public class PackingLibraryController {
if (p.getInvisibleRange() != null) {
packingLibraryEntity.setInvisibleRange(p.getInvisibleRange());
packingLibraries.forEach(packingLibrary -> packingLibrary.setInvisibleRange(p.getInvisibleRange()));
deviceLibraries.forEach(deviceLibrary -> deviceLibrary.setInvisibleRange(p.getInvisibleRange()));
deviceLibraryList.forEach(deviceLibrary -> deviceLibrary.setInvisibleRange(p.getInvisibleRange()));
}
if (p.getMatchingRange() != null) {
packingLibraryEntity.setMatchingRange(p.getMatchingRange());
packingLibraries.forEach(packingLibrary -> packingLibrary.setMatchingRange(p.getMatchingRange()));
deviceLibraries.forEach(deviceLibrary -> deviceLibrary.setMatchingRange(p.getMatchingRange()));
deviceLibraryList.forEach(deviceLibrary -> deviceLibrary.setMatchingRange(p.getMatchingRange()));
}
if (p.getModel() != null) {
packingLibraryEntity.setModel(p.getModel());
deviceLibraries.forEach(deviceLibrary -> deviceLibrary.setModel(p.getModel()));
}
if (p.getName() != null) {
packingLibraryEntity.setName(p.getName());
deviceLibraries.forEach(deviceLibrary -> deviceLibrary.setName(p.getName()));
}
if (p.getNature() != null) {
packingLibraryEntity.setNature(p.getNature());
......@@ -125,6 +146,8 @@ public class PackingLibraryController {
if (p.getSecretLevel() != null) {
packingLibraryEntity.setSecretLevel(p.getSecretLevel());
packingLibraries.forEach(packingLibrary -> packingLibrary.setSecretLevel(p.getSecretLevel()));
deviceLibraries.forEach(deviceLibrary -> deviceLibrary.setSecretLevel(p.getSecretLevel()));
deviceLibraryList.forEach(deviceLibrary -> deviceLibrary.setSecretLevel(p.getSecretLevel()));
}
if (p.getStatus() != null) {
packingLibraryEntity.setStatus(p.getStatus());
......@@ -132,24 +155,33 @@ public class PackingLibraryController {
}
if (p.getType() != null) {
packingLibraryEntity.setType(p.getType());
deviceLibraries.forEach(deviceLibrary -> deviceLibrary.setType(p.getType()));
}
packingLibraryService.update(packingLibraryEntity);
packingLibraries.forEach(packingLibrary -> packingLibraryService.update(packingLibrary));
deviceLibraries.forEach(deviceLibrary -> deviceLibraryService.update(deviceLibrary));
deviceLibraryList.forEach(deviceLibrary -> deviceLibraryService.update(deviceLibrary));
}
//更新配件信息
if (packingEditVo.getPartUpdateVoList()!=null){
packingEditVo.getPartUpdateVoList().forEach(packingLibraryUpdateVo -> {
if (packingLibraryUpdateVo.getPackingId() > 0){
PackingLibrary packingLibrary = packingLibraryService.getOne(packingLibraryUpdateVo.getPackingId());
//获取该配件所有装备
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.getAllByPackingId(packingLibraryUpdateVo.getPackingId());
if (packingLibraryUpdateVo.getModel()!=null){
packingLibrary.setModel(packingLibraryUpdateVo.getModel());
deviceLibraries.forEach(deviceLibrary -> deviceLibrary.setModel(packingLibraryUpdateVo.getModel()));
}
if (packingLibraryUpdateVo.getName()!=null){
packingLibrary.setName(packingLibraryUpdateVo.getName());
deviceLibraries.forEach(deviceLibrary -> deviceLibrary.setName(packingLibraryUpdateVo.getName()));
}
if (packingLibraryUpdateVo.getType()!=null){
packingLibrary.setType(packingLibraryUpdateVo.getType());
deviceLibraries.forEach(deviceLibrary -> deviceLibrary.setType(packingLibraryUpdateVo.getType()));
}
deviceLibraries.forEach(deviceLibrary -> deviceLibraryService.update(deviceLibrary));
packingLibraryService.update(packingLibrary);
}
});
......
......@@ -12,6 +12,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.*;
......@@ -54,6 +55,7 @@ public class DeviceScrapController {
@ApiOperation(value = "提交报废单", notes = "提交报废单")
@PostMapping(value = "/form")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity commitScrap(@RequestBody ScrapSaveVo scrapSaveVo) {
//转实体类
ScrapBill scrapBill = scrapSaveVo.toDo();
......@@ -66,7 +68,7 @@ public class DeviceScrapController {
//计算所有不同的名称
Set<String> names = scrapSaveVo.getDeviceIds().stream().map(integer -> deviceLibraryService.getOne(integer).getName()).collect(Collectors.toSet());
StringBuffer stringBuffer2 = new StringBuffer();
models.forEach(s -> stringBuffer2.append(s).append(","));
names.forEach(s -> stringBuffer2.append(s).append(","));
stringBuffer2.deleteCharAt(stringBuffer2.length() - 1);
scrapBill.setNames(stringBuffer2.toString());
ScrapBill scrapBill1 = scrapBillService.add(scrapBill);
......
......@@ -21,6 +21,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
......@@ -96,6 +97,7 @@ public class SelfCheckSchedulerTask {
public class SelfCheckTask implements Runnable{
@Override
@Transactional(rollbackFor = Exception.class)
public void run() {
if (unitsDao != null && taskService!=null && selfCheckBillService!=null) {
List<Units> unitsList = unitsDao.findAll();
......
......@@ -40,6 +40,7 @@ import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.config.Task;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Field;
......@@ -132,6 +133,7 @@ public class SelfCheckController {
@ApiOperation(value = "设置自查周期", notes = "可以通过这个接口设置自查周期")
@PostMapping(value = "/set/cycle/{type}")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity setCycle(@PathVariable("type") int type){
if (selfCheckSchedulerTask!=null) {
switch (type) {
......@@ -253,6 +255,7 @@ public class SelfCheckController {
@ApiOperation(value = "发起自查业务", notes = "可以通过这个接口发起自查业务")
@PostMapping(value = "/addBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity addSelfExaminationBill(@RequestBody SelfCheckSaveVo selfCheckSaveVo) {
//添加账单
SelfCheckBill selfExaminationBillEntity;
......@@ -319,6 +322,7 @@ public class SelfCheckController {
@ApiOperation(value = "自查审核", notes = "可以通过这个接口自查审核")
@PatchMapping(value = "/selfExaminationConfirm")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity selfExaminationConfirm(@RequestBody SelfCheckConfirmVo selfCheckConfirmVo) {
TaskBto taskBto = taskService.get(selfCheckConfirmVo.getTaskId());
SelfCheckBill selfExaminationBillEntity = selfExaminationBillService.getOne(taskBto.getBillId());
......
......@@ -30,6 +30,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
......@@ -111,6 +112,7 @@ public class StorageBillController {
@ApiOperation(value = "添加入库单", notes = "可以通过这个接口发起入库业务")
@PostMapping(value = "/addStorageBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity addStorageBill(@RequestBody StorageBillSaveVo storageBillSaveVo) {
//1.存入库单
Integer userId = userUtils.getCurrentUserId();
......@@ -172,6 +174,7 @@ public class StorageBillController {
@ApiOperation(value = "入库审核", notes = "可以通过这个接口入库审核")
@PostMapping(value = "/confirmStorageBill")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity confirmStorageBill(@RequestBody StorageBillConfirmVo storageBillConfirmVo) {
TaskBto taskBto = taskService.get(storageBillConfirmVo.getTaskId());
//1.审核成功,入库任务结束,发起新的确认任务,改变装备状态
......
......@@ -17,6 +17,7 @@ import org.springframework.beans.BeanUtils;
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.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
......@@ -50,6 +51,7 @@ public class DeviceUseReportController {
@ApiOperation(value = "生成装备使用报告", notes = "可以通过这个接口生成装备使用报告")
@PostMapping("/create")
@Transactional(rollbackFor = Exception.class)
public ResponseEntity createDeviceUseReport(@RequestBody DeviceUseReportCreateVo deviceUseReportCreateVo) {
return ResultUtil.success(deviceUseReportService.createReport(deviceUseReportCreateVo));
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论