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

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

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