|
@@ -0,0 +1,177 @@
|
|
|
|
|
+package com.qdport.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.qdport.entity.PolicyShare;
|
|
|
|
|
+import com.qdport.entity.PolicyTodo;
|
|
|
|
|
+import com.qdport.enums.QDPortEnum;
|
|
|
|
|
+import com.qdport.query.PolicyShareQuery;
|
|
|
|
|
+import com.qdport.service.PolicyFileService;
|
|
|
|
|
+import com.qdport.service.PolicyShareService;
|
|
|
|
|
+import com.qdport.service.PolicyTodoService;
|
|
|
|
|
+import com.qdport.service.impl.PolicySystemService;
|
|
|
|
|
+import com.qdport.util.StringUtil;
|
|
|
|
|
+import com.qdport.vo.PolicyFileVO;
|
|
|
|
|
+import com.qdport.vo.PolicyShareVO;
|
|
|
|
|
+import com.qdport.wrapper.PolicyShareWrapper;
|
|
|
|
|
+import com.qdport.modules.system.entity.SysUser;
|
|
|
|
|
+import com.qdport.modules.system.service.TSysUserService;
|
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
|
|
+import com.qdport.core.tool.api.R;
|
|
|
|
|
+import com.qdport.core.tool.utils.Func;
|
|
|
|
|
+import com.qdport.core.boot.ctrl.QdportController;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 政策共享
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author yuheng
|
|
|
|
|
+ * @since 1.0.0 2024-09-30
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("qdport-zcgx/share")
|
|
|
|
|
+@Api(value = "政策共享", tags = "政策共享")
|
|
|
|
|
+@AllArgsConstructor
|
|
|
|
|
+public class PolicyShareController extends QdportController {
|
|
|
|
|
+ private final PolicyShareService policyShareService;
|
|
|
|
|
+ private final TSysUserService sysUserService;
|
|
|
|
|
+ private final PolicySystemService policySystemService;
|
|
|
|
|
+ private final PolicyFileService policyFileService;
|
|
|
|
|
+ private final PolicyTodoService policyTodoService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分页
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("page")
|
|
|
|
|
+ @ApiOperation(value = "分页", notes = "分页")
|
|
|
|
|
+ public R<IPage<PolicyShareVO>> page(@Valid PolicyShareQuery query) {
|
|
|
|
|
+ IPage<PolicyShareVO> page = policyShareService.page(query);
|
|
|
|
|
+ List<PolicyShareVO> records = page.getRecords();
|
|
|
|
|
+ for (PolicyShareVO model : records) {
|
|
|
|
|
+ SysUser createUser = sysUserService.getById(model.getCreateId());
|
|
|
|
|
+ Map<String, String> resultMap = policySystemService.getDeptNameAndCompanyName(createUser.getDeptId());
|
|
|
|
|
+ model.setDeptName(resultMap.get("deptName"));
|
|
|
|
|
+ model.setCompanyName(resultMap.get("companyName"));
|
|
|
|
|
+
|
|
|
|
|
+ List<PolicyFileVO> fileList = policyFileService.getFileList(model.getId().toString(), QDPortEnum.POLICY_FILE_REFTYPE_POLICY_SHARE.getValue());
|
|
|
|
|
+ model.setFileList(fileList);
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.data(page);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 详情
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("{id}")
|
|
|
|
|
+ @ApiOperation(value = "详情", notes = "id")
|
|
|
|
|
+ public R<PolicyShareVO> get(@PathVariable("id") Long id) {
|
|
|
|
|
+ PolicyShare entity = policyShareService.getById(id);
|
|
|
|
|
+ PolicyShareVO vo = PolicyShareWrapper.build().entityVO(entity);
|
|
|
|
|
+
|
|
|
|
|
+ SysUser createUser = sysUserService.getById(entity.getCreateId());
|
|
|
|
|
+ Map<String, String> resultMap = policySystemService.getDeptNameAndCompanyName(createUser.getDeptId());
|
|
|
|
|
+ vo.setDeptName(resultMap.get("deptName"));
|
|
|
|
|
+ vo.setCompanyName(resultMap.get("companyName"));
|
|
|
|
|
+
|
|
|
|
|
+ List<PolicyFileVO> fileList = policyFileService.getFileList(entity.getId().toString(), QDPortEnum.POLICY_FILE_REFTYPE_POLICY_SHARE.getValue());
|
|
|
|
|
+
|
|
|
|
|
+ vo.setFileList(fileList);
|
|
|
|
|
+ return R.data(vo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/save")
|
|
|
|
|
+ @ApiOperation(value = "新增", notes = "传入PolicyShare")
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public R save(@RequestBody PolicyShareVO vo) {
|
|
|
|
|
+ vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_ACTIVE.getValue());
|
|
|
|
|
+ policyShareService.save(vo);
|
|
|
|
|
+ return R.success("保存成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/saveApprove")
|
|
|
|
|
+ @ApiOperation(value = "新增并且提交", notes = "传入PolicyShare")
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public R saveApprove(@RequestBody PolicyShareVO vo) {
|
|
|
|
|
+ if (StringUtil.isEmpty(vo.getId())) {
|
|
|
|
|
+ vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_APPROVE.getValue());
|
|
|
|
|
+ policyShareService.save(vo);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_APPROVE.getValue());
|
|
|
|
|
+ policyShareService.update(vo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ policyTodoService.save(vo);
|
|
|
|
|
+ return R.success("新增并且提交成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/update")
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public R update(@RequestBody @Valid PolicyShareVO vo) {
|
|
|
|
|
+ policyShareService.update(vo);
|
|
|
|
|
+ return R.success("更新成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/withdraw")
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public R withdraw(@RequestBody @Valid PolicyShareVO vo) {
|
|
|
|
|
+ vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_ACTIVE.getValue());
|
|
|
|
|
+ policyShareService.updateById(vo);
|
|
|
|
|
+
|
|
|
|
|
+ QueryWrapper<PolicyTodo> todoQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ todoQueryWrapper.eq("REF_ID", vo.getId());
|
|
|
|
|
+ todoQueryWrapper.eq("REF_TYPE", QDPortEnum.POLICY_TODO_REFTYPE_POLICY_SHARE.getValue());
|
|
|
|
|
+ todoQueryWrapper.eq("TODO_USER_ID",1 );
|
|
|
|
|
+ todoQueryWrapper.eq("TODO_TYPE",QDPortEnum.POLICY_TODO_TYPE_APPROVE.getValue() );
|
|
|
|
|
+ todoQueryWrapper.eq("STATUS",QDPortEnum.POLICY_TODO_STATUS_ACTIVE.getValue() );
|
|
|
|
|
+ PolicyTodo todo = new PolicyTodo();
|
|
|
|
|
+ todo.setStatus(QDPortEnum.POLICY_TODO_STATUS_CANCEL.getValue());
|
|
|
|
|
+ policyTodoService.update(todo, todoQueryWrapper);
|
|
|
|
|
+ return R.success("撤回成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/approve")
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public R approve(@RequestBody @Valid PolicyShareVO vo) {
|
|
|
|
|
+ vo.setStatus(QDPortEnum.POLICY_SHARE_STATUS_DONE.getValue());
|
|
|
|
|
+ policyShareService.updateById(vo);
|
|
|
|
|
+
|
|
|
|
|
+ QueryWrapper<PolicyTodo> todoQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ todoQueryWrapper.eq("REF_ID", vo.getId());
|
|
|
|
|
+ todoQueryWrapper.eq("REF_TYPE", QDPortEnum.POLICY_TODO_REFTYPE_POLICY_SHARE.getValue());
|
|
|
|
|
+ todoQueryWrapper.eq("TODO_USER_ID", 1);
|
|
|
|
|
+ todoQueryWrapper.eq("TODO_TYPE", QDPortEnum.POLICY_TODO_TYPE_APPROVE.getValue());
|
|
|
|
|
+ todoQueryWrapper.eq("STATUS", QDPortEnum.POLICY_TODO_STATUS_ACTIVE.getValue());
|
|
|
|
|
+ PolicyTodo todo = new PolicyTodo();
|
|
|
|
|
+ todo.setStatus(QDPortEnum.POLICY_TODO_STATUS_DONE.getValue());
|
|
|
|
|
+ policyTodoService.update(todo, todoQueryWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ return R.success("更新成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/remove")
|
|
|
|
|
+ @ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public R delete(@ApiParam(value = "主键集合", required = true) @RequestParam(name = "ids") String ids) {
|
|
|
|
|
+ List<Long> idList = Func.toLongList(ids);
|
|
|
|
|
+ policyShareService.delete(idList);
|
|
|
|
|
+ return R.success("删除成功");
|
|
|
|
|
+ }
|
|
|
|
|
+}
|