|
|
|
package com.ruoyi.tc.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
import com.ruoyi.tc.entity.*;
|
|
|
|
import com.ruoyi.tc.entity.po.*;
|
|
|
|
import com.ruoyi.tc.entity.request.Acomma;
|
|
|
|
import com.ruoyi.tc.entity.request.AssetAppPageRequest;
|
|
|
|
import com.ruoyi.tc.entity.request.AssetAuditPageRequest;
|
|
|
|
import com.ruoyi.tc.entity.request.AssetAuditRequest;
|
|
|
|
import com.ruoyi.tc.service.AssetAppCpService;
|
|
|
|
import com.ruoyi.tc.service.AssetAppJyService;
|
|
|
|
import com.ruoyi.tc.service.AssetAppService;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.validation.Valid;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import static com.ruoyi.common.core.domain.AjaxResult.success;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 资产移动应用程序表(asset_app)表控制层
|
|
|
|
*
|
|
|
|
* @author makejava
|
|
|
|
* @since 2024-11-28 17:13:05
|
|
|
|
*/
|
|
|
|
@Api(tags = "资产移动应用程序表控制层")
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/tc/assetApp")
|
|
|
|
public class AssetAppController extends BaseController {
|
|
|
|
/**
|
|
|
|
* 服务对象
|
|
|
|
*/
|
|
|
|
@Resource
|
|
|
|
private AssetAppService assetAppService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
private AssetAppJyService assetAppJyService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页查询
|
|
|
|
*
|
|
|
|
* @param req 分页对象
|
|
|
|
* @return 查询结果
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "分页查询")
|
|
|
|
@GetMapping
|
|
|
|
public AjaxResult queryByPage(AssetAppPageRequest req) {
|
|
|
|
Page<AssetApp> page = new Page<>();
|
|
|
|
page.setCurrent(req.getCurrent());
|
|
|
|
page.setSize(req.getSize());
|
|
|
|
try {
|
|
|
|
if (!SecurityUtils.getLoginUser().getUser().isAdmin() && !SecurityUtils.hasRole("common")) {
|
|
|
|
req.setDwmc(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new ServiceException("获取用户信息异常");
|
|
|
|
}
|
|
|
|
return success(assetAppService.page(page, req));
|
|
|
|
}
|
|
|
|
//=================================================
|
|
|
|
/**
|
|
|
|
* 单位自编辑进行校验
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "单位自编辑进行校验")
|
|
|
|
@PreAuthorize("@ss.hasAnyRoles('unit')")
|
|
|
|
@PostMapping("/unitEdit")
|
|
|
|
public AjaxResult unitEdit(@RequestBody @Valid AssetAppJyPo assetAppJyPo) {
|
|
|
|
AssetAppJyPo one = assetAppJyService.lambdaQuery().eq(AssetAppJyPo::getAppName,assetAppJyPo.getAppName())
|
|
|
|
.eq(AssetAppJyPo::getSsdw,assetAppJyPo.getSsdw()).isNull(AssetAppJyPo::getTaskId).one();
|
|
|
|
assetAppJyPo.setAuditState("1");
|
|
|
|
assetAppJyPo.setAuditYy(null);
|
|
|
|
if (one != null) {
|
|
|
|
assetAppJyPo.setAppId(one.getAppId());
|
|
|
|
assetAppJyPo.setAssetId(one.getAssetId());
|
|
|
|
assetAppJyService.updateById(assetAppJyPo);
|
|
|
|
} else {
|
|
|
|
assetAppJyPo.setAssetId(assetAppService.lambdaQuery().eq(AssetApp::getAppName,assetAppJyPo.getAppName())
|
|
|
|
.eq(AssetApp::getSsdw,assetAppJyPo.getSsdw()).one().getId());
|
|
|
|
assetAppJyService.save(assetAppJyPo);
|
|
|
|
}
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 分页查询管理端或者单位端审核列表
|
|
|
|
*
|
|
|
|
* @param as 查询实体
|
|
|
|
* @return 所有数据
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "分页查询管理端或者单位端审核列表", response = AssetAppJyPo.class)
|
|
|
|
@GetMapping("/getAuditList")
|
|
|
|
public AjaxResult getAuditList(AssetAuditPageRequest as) {
|
|
|
|
Page<AssetAppJyPo> page = new Page<>();
|
|
|
|
page.setSize(as.getSize());
|
|
|
|
page.setCurrent(as.getCurrent());
|
|
|
|
try {
|
|
|
|
if (!SecurityUtils.getLoginUser().getUser().isAdmin() && !SecurityUtils.hasRole("common")) {
|
|
|
|
as.setDwmc(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new ServiceException("获取用户信息异常");
|
|
|
|
}
|
|
|
|
return success(assetAppJyService.getAuditList(page, as));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查看中间数据详情
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "单位端查看中间数据详情", response = AssetAppJyPo.class)
|
|
|
|
@GetMapping("/lookInfo/{id}")
|
|
|
|
public AjaxResult lookInfo(@PathVariable Long id) {
|
|
|
|
return success(assetAppJyService.getById(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 管理端审核
|
|
|
|
*
|
|
|
|
* @param as 查询实体
|
|
|
|
* @return 所有数据
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasAnyRoles('admin,common')")
|
|
|
|
@ApiOperation(value = "管理端审核")
|
|
|
|
@PostMapping("/audit")
|
|
|
|
public AjaxResult audit(@Valid @RequestBody AssetAuditRequest as) {
|
|
|
|
AssetAppJyPo ass = new AssetAppJyPo();
|
|
|
|
BeanUtil.copyProperties(as, ass);
|
|
|
|
ass.setAppId(as.getCurrentId());
|
|
|
|
assetAppJyService.updateById(ass);
|
|
|
|
//通过数据同步
|
|
|
|
if ("2".equals(as.getAuditState())) {
|
|
|
|
AssetAppJyPo byId = assetAppJyService.getById(as.getCurrentId());
|
|
|
|
AssetApp aa = new AssetApp();
|
|
|
|
BeanUtil.copyProperties(byId, aa);
|
|
|
|
aa.setId(byId.getAssetId());
|
|
|
|
//修改主表
|
|
|
|
assetAppService.updateById(aa);
|
|
|
|
}
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
//=================================================
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过主键查询单条app数据
|
|
|
|
*
|
|
|
|
* @param id 主键
|
|
|
|
* @return 单条数据
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "通过主键查询单条app数据")
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
public AjaxResult queryById(@PathVariable("id") Long id) {
|
|
|
|
return success(assetAppService.getById(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增数据
|
|
|
|
*
|
|
|
|
* @param assetApp 实体
|
|
|
|
* @return 新增结果
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "新增数据")
|
|
|
|
@PostMapping
|
|
|
|
@Log(title = "新增app数据", businessType = BusinessType.INSERT)
|
|
|
|
public AjaxResult add(@RequestBody AssetApp assetApp) {
|
|
|
|
|
|
|
|
return success(assetAppService.add(assetApp));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 编辑数据
|
|
|
|
*
|
|
|
|
* @param assetApp 实体
|
|
|
|
* @return 编辑结果
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "编辑数据")
|
|
|
|
@Log(title = "编辑app数据", businessType = BusinessType.UPDATE)
|
|
|
|
@PutMapping
|
|
|
|
public AjaxResult edit(@RequestBody AssetApp assetApp) {
|
|
|
|
return success(assetAppService.edit(assetApp));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除数据
|
|
|
|
*
|
|
|
|
* @param id 主键
|
|
|
|
* @return 删除是否成功
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "删除数据")
|
|
|
|
@Log(title = "删除app数据", businessType = BusinessType.DELETE)
|
|
|
|
@DeleteMapping("/delete/{id}")
|
|
|
|
public AjaxResult deleteById(@PathVariable Long id) {
|
|
|
|
assetAppService.deleteById(id);
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 下载资产导入模板
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "下载App导入模板")
|
|
|
|
@PostMapping("/importTemplate")
|
|
|
|
public void importTemplate(HttpServletResponse response) {
|
|
|
|
ExcelUtil<AssetApp> util = new ExcelUtil<>(AssetApp.class);
|
|
|
|
util.importTemplateExcel(response, "App导入模板");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* app导出
|
|
|
|
*/
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@ApiOperation(value = "app导出")
|
|
|
|
@Log(title = "app导出", businessType = BusinessType.EXPORT)
|
|
|
|
@PostMapping("/export")
|
|
|
|
public void export(HttpServletResponse response, AssetAppPageRequest unit) {
|
|
|
|
List<AssetApp> list = assetAppService.getAllList(unit);
|
|
|
|
ExcelUtil<AssetApp> util = new ExcelUtil<>(AssetApp.class);
|
|
|
|
util.exportExcel(response, list, "app数据");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* app导入
|
|
|
|
*/
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@ApiOperation(value = "app导入")
|
|
|
|
@Log(title = "app导入", businessType = BusinessType.IMPORT)
|
|
|
|
@PostMapping("/importData")
|
|
|
|
public AjaxResult importData(MultipartFile file) throws Exception {
|
|
|
|
ExcelUtil<AssetApp> util = new ExcelUtil<>(AssetApp.class);
|
|
|
|
List<AssetApp> list = util.importExcel(file.getInputStream());
|
|
|
|
if (list != null) {
|
|
|
|
list.forEach(x->{
|
|
|
|
AssetApp one = assetAppService.lambdaQuery().eq(AssetApp::getSsdw, x.getSsdw())
|
|
|
|
.eq(AssetApp::getAppName, x.getAppName()).one();
|
|
|
|
if(one!=null){
|
|
|
|
x.setId(one.getId());
|
|
|
|
assetAppService.edit(x);
|
|
|
|
}else {
|
|
|
|
assetAppService.add(x);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
throw new ServiceException("app导入数据不能为空!");
|
|
|
|
}
|
|
|
|
return AjaxResult.success("导入成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|