|
|
|
@ -147,6 +147,53 @@ public class AssetCurrentController extends BaseController {
|
|
|
|
|
@PreAuthorize("@ss.hasAnyRoles('admin,common')")
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public AjaxResult insert(@RequestBody @Valid AssetCurrent assetCurrent) {
|
|
|
|
|
if (assetCurrent.getXzType() == 1) {
|
|
|
|
|
List<Unit> list = unitService.lambdaQuery().eq(Unit::getNickName, assetCurrent.getDwmc()).eq(Unit::getDelFlag, 0).list();
|
|
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
|
|
throw new ServiceException("请选择已有单位!");
|
|
|
|
|
}
|
|
|
|
|
List<AssetCurrent> list1 = assetCurrentService.lambdaQuery().eq(AssetCurrent::getXtmc, assetCurrent.getXtmc()).eq(AssetCurrent::getDwmc, assetCurrent.getDwmc()).list();
|
|
|
|
|
if (list1 != null && !list1.isEmpty()) {
|
|
|
|
|
throw new ServiceException("不允许新增重复资产!");
|
|
|
|
|
}
|
|
|
|
|
//获取新增资产id
|
|
|
|
|
Long id = assetCurrent.getId();
|
|
|
|
|
//新增资产复制主表
|
|
|
|
|
AssetCurrentCpPo assetCurrentCpPo = new AssetCurrentCpPo();
|
|
|
|
|
BeanUtil.copyProperties(assetCurrent, assetCurrentCpPo);
|
|
|
|
|
assetCurrentCpPo.setAuditState("1");
|
|
|
|
|
assetCurrentCpPo.setXzType(1);
|
|
|
|
|
assetCurrentCpService.save(assetCurrentCpPo);
|
|
|
|
|
//新增新监管业务形态
|
|
|
|
|
//根据资产id查询新监管业务形态主表id
|
|
|
|
|
if (assetCurrent.getXjgywxt() != null) {
|
|
|
|
|
assetCurrentCpPo.getXjgywxt().setAssetId(id);
|
|
|
|
|
assetBusinessFormCpService.save(assetCurrentCpPo.getXjgywxt());
|
|
|
|
|
}
|
|
|
|
|
if (assetCurrent.getGylxxList() != null) {
|
|
|
|
|
for (AssetSupplyChainCpPo items : assetCurrentCpPo.getGylxxList()) {
|
|
|
|
|
items.setAssetId(id);
|
|
|
|
|
}
|
|
|
|
|
//新增供应链
|
|
|
|
|
assetSupplyChainCpService.saveBatch(assetCurrentCpPo.getGylxxList());
|
|
|
|
|
}
|
|
|
|
|
if (assetCurrent.getJcwlList() != null) {
|
|
|
|
|
for (AssetBasicNetworkCpPo items : assetCurrentCpPo.getJcwlList()) {
|
|
|
|
|
items.setAssetId(assetCurrent.getId());
|
|
|
|
|
}
|
|
|
|
|
//新增基础网络
|
|
|
|
|
assetBasicNetworkCpService.saveBatch(assetCurrentCpPo.getJcwlList());
|
|
|
|
|
}
|
|
|
|
|
if (assetCurrent.getOtherConcat() != null) {
|
|
|
|
|
for (UnitOtherConcatCpPo items : assetCurrentCpPo.getOtherConcat()) {
|
|
|
|
|
items.setAssetId(assetCurrent.getId());
|
|
|
|
|
}
|
|
|
|
|
//新增其他联系人
|
|
|
|
|
unitOtherConcatCpService.saveBatch(assetCurrentCpPo.getOtherConcat());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Unit> list = unitService.lambdaQuery().eq(Unit::getNickName, assetCurrent.getDwmc()).eq(Unit::getDelFlag, 0).list();
|
|
|
|
|
if (list == null || list.isEmpty()) {
|
|
|
|
@ -269,6 +316,7 @@ public class AssetCurrentController extends BaseController {
|
|
|
|
|
unitOtherConcatCpService.saveBatch(assetCurrentCpPo.getOtherConcat());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -458,13 +506,31 @@ public class AssetCurrentController extends BaseController {
|
|
|
|
|
BeanUtil.copyProperties(as, ass);
|
|
|
|
|
assetCurrentCpService.updateById(ass);
|
|
|
|
|
//通过数据同步
|
|
|
|
|
if ("2".equals(as.getAuditState())) {
|
|
|
|
|
if ("2".equals(as.getAuditState()) && as.getXzType() != 1) {
|
|
|
|
|
AssetCurrentCpPo byId = assetCurrentCpService.getById(as.getCurrentId());
|
|
|
|
|
AssetCurrent assetCurrent = new AssetCurrent();
|
|
|
|
|
BeanUtil.copyProperties(byId, assetCurrent);
|
|
|
|
|
//修改主表
|
|
|
|
|
assetCurrentService.updateById(assetCurrent);
|
|
|
|
|
//删除副表数据然后再添加
|
|
|
|
|
Result result = getResult(assetCurrent, byId);
|
|
|
|
|
//如果有任务也修改任务这边
|
|
|
|
|
taskTb(byId, result.list, result.list1, result.list2, result.list3);
|
|
|
|
|
} else {
|
|
|
|
|
AssetCurrentCpPo byId = assetCurrentCpService.getById(as.getCurrentId());
|
|
|
|
|
AssetCurrent assetCurrent = new AssetCurrent();
|
|
|
|
|
BeanUtil.copyProperties(byId, assetCurrent);
|
|
|
|
|
//修改主表
|
|
|
|
|
assetCurrentService.save(assetCurrent);
|
|
|
|
|
//删除副表数据然后再添加
|
|
|
|
|
Result result = getResult(assetCurrent, byId);
|
|
|
|
|
//如果有任务也修改任务这边
|
|
|
|
|
taskTb(byId, result.list, result.list1, result.list2, result.list3);
|
|
|
|
|
}
|
|
|
|
|
return success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Result getResult(AssetCurrent assetCurrent, AssetCurrentCpPo byId) {
|
|
|
|
|
assetSupplyChainService.deleteByAssetIds(assetCurrent.getId());
|
|
|
|
|
assetBasicNetworkService.deleteByAssetIds(assetCurrent.getId());
|
|
|
|
|
assetBusinessFormService.deleteByAssetIds(assetCurrent.getId());
|
|
|
|
@ -497,7 +563,25 @@ public class AssetCurrentController extends BaseController {
|
|
|
|
|
BeanUtil.copyProperties(x, a4);
|
|
|
|
|
unitOtherConcatService.save(a4);
|
|
|
|
|
});
|
|
|
|
|
//如果有任务也修改任务这边
|
|
|
|
|
Result result = new Result(list, list1, list2, list3);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class Result {
|
|
|
|
|
public final List<AssetSupplyChainCpPo> list;
|
|
|
|
|
public final List<AssetBasicNetworkCpPo> list1;
|
|
|
|
|
public final List<AssetBusinessFormCpPo> list2;
|
|
|
|
|
public final List<UnitOtherConcatCpPo> list3;
|
|
|
|
|
|
|
|
|
|
public Result(List<AssetSupplyChainCpPo> list, List<AssetBasicNetworkCpPo> list1, List<AssetBusinessFormCpPo> list2, List<UnitOtherConcatCpPo> list3) {
|
|
|
|
|
this.list = list;
|
|
|
|
|
this.list1 = list1;
|
|
|
|
|
this.list2 = list2;
|
|
|
|
|
this.list3 = list3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void taskTb(AssetCurrentCpPo byId, List<AssetSupplyChainCpPo> list, List<AssetBasicNetworkCpPo> list1, List<AssetBusinessFormCpPo> list2, List<UnitOtherConcatCpPo> list3) {
|
|
|
|
|
AssetCurrentCpPo one = assetCurrentCpService.lambdaQuery().isNotNull(AssetCurrentCpPo::getTaskId).ne(AssetCurrentCpPo::getStatus, 5).eq(AssetCurrentCpPo::getId, byId.getId()).one();
|
|
|
|
|
if (one != null) {
|
|
|
|
|
Integer taskId = one.getTaskId();
|
|
|
|
@ -545,7 +629,19 @@ public class AssetCurrentController extends BaseController {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success();
|
|
|
|
|
|
|
|
|
|
private static class deleteFb {
|
|
|
|
|
public final List<AssetSupplyChainCpPo> list;
|
|
|
|
|
public final List<AssetBasicNetworkCpPo> list1;
|
|
|
|
|
public final List<AssetBusinessFormCpPo> list2;
|
|
|
|
|
public final List<UnitOtherConcatCpPo> list3;
|
|
|
|
|
|
|
|
|
|
public deleteFb(List<AssetSupplyChainCpPo> list, List<AssetBasicNetworkCpPo> list1, List<AssetBusinessFormCpPo> list2, List<UnitOtherConcatCpPo> list3) {
|
|
|
|
|
this.list = list;
|
|
|
|
|
this.list1 = list1;
|
|
|
|
|
this.list2 = list2;
|
|
|
|
|
this.list3 = list3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//=================================================
|
|
|
|
|
|
|
|
|
|