You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

365 lines
13 KiB

package com.ruoyi.tc.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.tc.entity.AssetCurrent;
import com.ruoyi.tc.entity.AssetLc;
import com.ruoyi.tc.entity.AssetTask;
import com.ruoyi.tc.entity.po.*;
import com.ruoyi.tc.entity.request.AssestTaskXqRequest;
import com.ruoyi.tc.entity.request.AssetCurrentShRequest;
import com.ruoyi.tc.entity.request.AssetTaskPageRequest;
import com.ruoyi.tc.entity.request.AssetdwHcRequest;
import com.ruoyi.tc.entity.response.AssestTaskXqresponse;
import com.ruoyi.tc.entity.response.AssetTaskIdResponse;
import com.ruoyi.tc.entity.response.AssetdwHcResponse;
import com.ruoyi.tc.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.time.LocalDateTime;
/**
* (AssetTask)
*
* @author makejava
* @since 2024-11-18 13:22:58
*/
@Api(tags = "任务主表")
@RestController
@RequestMapping("/unit/assetTask")
public class AssetTaskController extends BaseController {
/**
*
*/
@Resource
private AssetTaskService assetTaskService;
@Resource
private AssetCurrentCpService assetCurrentCpService;
@Resource
private AssetBusinessFormCpService assetBusinessFormCpService;
@Resource
private AssetBasicNetworkCpService assetBasicNetworkCpService;
@Resource
private AssetSupplyChainCpService assetSupplyChainCpService;
@Resource
private UnitOtherConcatCpService unitOtherConcatCpService;
@Resource
private AssetCurrentJyService assetCurrentJyService;
@Resource
private AssetBusinessFormJyService assetBusinessFormJyService;
@Resource
private AssetSupplyChainJyService assetSupplyChainJyService;
@Resource
AssetBasicNetworkJyService assetBasicNetworkJyService;
@Resource
private UnitOtherConcatJyservice unitOtherConcatJyservice;
@Resource
private AssetLcService assetLcService;
/**
*
*
* @param assetTask
* @param pageRequest
* @return
*/
@ApiOperation(value = "分页查询", response = AssetTask.class)
@GetMapping("/page")
public AjaxResult queryByPage(Page<AssetTask> assetTask, AssetTaskPageRequest pageRequest) {
return AjaxResult.success(this.assetTaskService.queryByPage(assetTask, pageRequest));
}
/**
*
*
* @param id
* @return
*/
@ApiOperation(value = "通过主键查询单条数据", response = AssetTaskIdResponse.class)
@GetMapping("{id}")
public AjaxResult queryById(@PathVariable("id") Integer id) {
return AjaxResult.success(this.assetTaskService.queryById(id));
}
/**
*
*
* @param assetTask
* @return
*/
@ApiOperation(value = "新增数据")
@PostMapping("/add")
@Transactional(rollbackFor = Exception.class)
public AjaxResult add(@RequestBody @Valid AssetTask assetTask) {
assetTask.setTaskTime(LocalDateTime.now());
this.assetTaskService.insert(assetTask);
return AjaxResult.success();
}
/**
*
*
* @param assetTask
* @return
*/
@ApiOperation(value = "编辑数据")
@PostMapping("/edit")
public AjaxResult edit(@RequestBody @Valid AssetTask assetTask) {
return AjaxResult.success(this.assetTaskService.update(assetTask));
}
/**
*
*
* @param id
* @return
*/
@ApiOperation(value = "删除数据")
@PostMapping("/deleteById/{id}")
public AjaxResult deleteById(@PathVariable("id") Integer id) {
return AjaxResult.success(this.assetTaskService.deleteById(id));
}
/**
*
*
* @param taskId id
* @param assetId id
* @return
*/
@ApiOperation(value = "任务审核详情信息", response = AssetCurrent.class)
@GetMapping("/taskSh")
public AjaxResult taskSh(@RequestParam("taskId") int taskId, @RequestParam("assetId") int assetId) {
return AjaxResult.success(assetTaskService.taskSh(taskId, assetId));
}
/**
*
*
* @param page
* @param pageRequest
* @return
*/
@ApiOperation(value = "资产核查信息", response = AssestTaskXqresponse.class)
@GetMapping("/zcHc")
public AjaxResult zcHc(Page<AssestTaskXqresponse> page, AssestTaskXqRequest pageRequest) {
return AjaxResult.success(assetTaskService.zcHc(page, pageRequest));
}
/**
*
*
* @param assetCurrent
* @return
*/
@ApiOperation(value = "单位端暂存报废")
@PostMapping("/zc")
@Transactional(rollbackFor = Exception.class)
public AjaxResult zcHc(@RequestBody AssetCurrentCpPo assetCurrent) {
//根据资产id和任务id删除五张表数据
assetCurrentCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
assetBusinessFormCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
assetSupplyChainCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
unitOtherConcatCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
assetBasicNetworkCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
if (StringUtils.isBlank(assetCurrent.getBfyy())) {
//待审批
assetCurrent.setStatus(0);
} else {
//已报废
assetCurrent.setStatus(5);
assetCurrent.setXtzt("5");
}
StringBuilder a = new StringBuilder();
if (!assetCurrent.getGlymList().isEmpty()) {
assetCurrent.getGlymList().forEach(x -> {
a.append(x);
a.append(",");
});
}
assetCurrent.setGlym(a.toString());
StringBuilder b = new StringBuilder();
if (!assetCurrent.getGlIpList().isEmpty()) {
assetCurrent.getGlymList().forEach(x -> {
b.append(x);
b.append(",");
});
}
assetCurrent.setGlIp(b.toString());
// assetCurrent.setCurrentId(null);
assetCurrentCpService.save(assetCurrent);
//新增新监管业务形态
if (assetCurrent.getXjgywxt() != null) {
assetCurrent.getXjgywxt().setAssetId(assetCurrent.getId());
assetCurrent.getXjgywxt().setTaskId(assetCurrent.getTaskId());
assetBusinessFormCpService.save(assetCurrent.getXjgywxt());
}
if (!assetCurrent.getGylxxList().isEmpty()) {
for (AssetSupplyChainCpPo items : assetCurrent.getGylxxList()) {
items.setAssetId(assetCurrent.getId());
items.setTaskId(assetCurrent.getTaskId());
}
//新增供应链
assetSupplyChainCpService.saveBatch(assetCurrent.getGylxxList());
}
if (!assetCurrent.getJcwlList().isEmpty()) {
for (AssetBasicNetworkCpPo items : assetCurrent.getJcwlList()) {
items.setAssetId(assetCurrent.getId());
items.setTaskId(assetCurrent.getTaskId());
}
//新增基础网络
assetBasicNetworkCpService.saveBatch(assetCurrent.getJcwlList());
}
if (!assetCurrent.getOtherConcat().isEmpty()) {
for (UnitOtherConcatCpPo items : assetCurrent.getOtherConcat()) {
items.setAssetId(assetCurrent.getId());
items.setTaskId(assetCurrent.getTaskId());
}
//新增其他联系人
unitOtherConcatCpService.saveBatch(assetCurrent.getOtherConcat());
}
return success();
}
/**
*
*
* @param assetCurrent
* @return
*/
@ApiOperation(value = "单位端校验提交")
@PostMapping("/jyTj")
@Transactional(rollbackFor = Exception.class)
public AjaxResult tj(@RequestBody AssetCurrentJyPo assetCurrent) {
//根据资产id和任务id删除五张表数据
assetCurrentCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
assetBusinessFormCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
assetSupplyChainCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
unitOtherConcatCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
assetBasicNetworkCpService.deletByAssetIdandTaskId(assetCurrent.getId(), assetCurrent.getTaskId());
//新增流程节点时间
AssetLc assetLc = new AssetLc();
assetLc.setTaskId(assetCurrent.getTaskId());
assetLc.setAssetName(assetCurrent.getXtmc());
//当审核状态为审核不通过 单位端重新提交
// if (assetCurrent.getStatus().equals(4)) {
// assetLc.setTaskId(assetCurrent.getTaskId());
// assetLc.setXfTime(LocalDateTime.now());
// assetLc.setAssetName("单位重新核查提交时间" + assetCurrent.getXtmc());
// assetLcService.insert(assetLc);
// }
StringBuilder a = new StringBuilder();
if (!assetCurrent.getGlymList().isEmpty()) {
assetCurrent.getGlymList().forEach(x -> {
a.append(x);
a.append(",");
});
}
assetCurrent.setGlym(a.toString());
StringBuilder b = new StringBuilder();
if (!assetCurrent.getGlIpList().isEmpty()) {
assetCurrent.getGlymList().forEach(x -> {
b.append(x);
b.append(",");
});
}
assetCurrent.setGlIp(b.toString());
assetCurrent.setStatus(1);
//当审核状态为带待核查
if (assetCurrent.getStatus().equals(1)) {
assetLc.setXfTime(LocalDateTime.now());
assetLc.setTaskId(assetCurrent.getTaskId());
assetLc.setAssetName("单位核查完成提交" + assetCurrent.getXtmc());
assetLcService.insert(assetLc);
}
assetCurrentJyService.save(assetCurrent);
//新增新监管业务形态
if (assetCurrent.getXjgywxt() != null) {
assetCurrent.getXjgywxt().setAssetId(assetCurrent.getId());
assetCurrent.getXjgywxt().setTaskId(assetCurrent.getTaskId());
assetBusinessFormJyService.save(assetCurrent.getXjgywxt());
}
if (!assetCurrent.getGylxxList().isEmpty()) {
for (AssetSupplyChainJyPo items : assetCurrent.getGylxxList()) {
items.setAssetId(assetCurrent.getId());
items.setTaskId(assetCurrent.getTaskId());
}
//新增供应链
assetSupplyChainJyService.saveBatch(assetCurrent.getGylxxList());
}
if (!assetCurrent.getJcwlList().isEmpty()) {
for (AssetBasicNetworkJyPo items : assetCurrent.getJcwlList()) {
items.setAssetId(assetCurrent.getId());
items.setTaskId(assetCurrent.getTaskId());
}
//新增基础网络
assetBasicNetworkJyService.saveBatch(assetCurrent.getJcwlList());
}
if (!assetCurrent.getOtherConcat().isEmpty()) {
for (UnitOtherConcatJyPo items : assetCurrent.getOtherConcat()) {
items.setAssetId(assetCurrent.getId());
items.setTaskId(assetCurrent.getTaskId());
}
//新增其他联系人
unitOtherConcatJyservice.saveBatch(assetCurrent.getOtherConcat());
}
return success();
}
/**
*
*
* @param req
* @return
*/
@ApiOperation(value = "管理端审核")
@PostMapping("/sh")
public AjaxResult sh(@RequestBody AssetCurrentShRequest req) {
return AjaxResult.success(assetTaskService.sh(req));
}
/**
* -
*
* @param req
* @return
*/
@ApiOperation(value = "管理端-单位核查情况", response = AssetdwHcResponse.class)
@GetMapping("/dwHc")
public AjaxResult dwHc(Page<AssetdwHcResponse> assetdwHcResponsePage, AssetdwHcRequest req) {
return AjaxResult.success(assetTaskService.dwHc(assetdwHcResponsePage, req));
}
}