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, 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 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); } 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 ) @PostMapping("/dwHc") public AjaxResult dwHc(Page assetdwHcResponsePage, AssetdwHcRequest req) { return AjaxResult.success(assetTaskService.dwHc(assetdwHcResponsePage,req)); } }