初始代码
This commit is contained in:
23
yunzhupaas-pcm/yunzhupaas-pcm-controller/pom.xml
Normal file
23
yunzhupaas-pcm/yunzhupaas-pcm-controller/pom.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yunzhupaas-pcm</artifactId>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>yunzhupaas-pcm-controller</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-pcm-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,314 @@
|
||||
package com.yunzhupaas.base.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.yunzhupaas.base.ActionResult;
|
||||
import com.yunzhupaas.base.UserInfo;
|
||||
import com.yunzhupaas.exception.DataException;
|
||||
import com.yunzhupaas.permission.entity.UserEntity;
|
||||
import com.yunzhupaas.constant.MsgCode;
|
||||
import com.yunzhupaas.base.service.*;
|
||||
import com.yunzhupaas.base.entity.*;
|
||||
import com.yunzhupaas.util.*;
|
||||
import com.yunzhupaas.base.model.pcmcontract.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.*;
|
||||
import com.yunzhupaas.model.ExcelModel;
|
||||
import com.yunzhupaas.excel.ExcelExportStyler;
|
||||
import com.yunzhupaas.excel.ExcelHelper;
|
||||
import com.yunzhupaas.base.vo.PageListVO;
|
||||
import com.yunzhupaas.base.vo.PaginationVO;
|
||||
import com.yunzhupaas.base.vo.DownloadVO;
|
||||
import com.yunzhupaas.config.ConfigValueUtil;
|
||||
import com.yunzhupaas.base.entity.ProvinceEntity;
|
||||
import java.io.IOException;
|
||||
import java.util.stream.Collectors;
|
||||
import com.yunzhupaas.flowable.entity.TaskEntity;
|
||||
import com.yunzhupaas.exception.WorkFlowException;
|
||||
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
|
||||
import com.yunzhupaas.base.util.FormExecelUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* pcm_contract
|
||||
* @版本: V5.2.7
|
||||
* @版权: Copyright @ 2025 深圳市乐程软件有限公司版权所有
|
||||
* @作者: 深圳市乐程软件有限公司
|
||||
* @日期: 2026-03-31
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Tag(name = "pcm_contract" , description = "bcm")
|
||||
@RequestMapping("/api/bcm/PcmContract")
|
||||
public class PcmContractController {
|
||||
|
||||
@Autowired
|
||||
private GeneraterSwapUtil generaterSwapUtil;
|
||||
|
||||
@Autowired
|
||||
private UserProvider userProvider;
|
||||
|
||||
@Autowired
|
||||
private PcmContractService pcmContractService;
|
||||
|
||||
@Autowired
|
||||
private Pcm_contract_itemService pcm_contract_itemService;
|
||||
@Autowired
|
||||
private Pcm_payment_planService pcm_payment_planService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param pcmContractPagination
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取列表")
|
||||
@PostMapping("/getList")
|
||||
public ActionResult list(@RequestBody PcmContractPagination pcmContractPagination)throws Exception{
|
||||
List<PcmContractEntity> list= pcmContractService.getList(pcmContractPagination);
|
||||
List<Map<String, Object>> realList=new ArrayList<>();
|
||||
for (PcmContractEntity entity : list) {
|
||||
Map<String, Object> pcmContractMap=JsonUtil.entityToMap(entity);
|
||||
pcmContractMap.put("id", pcmContractMap.get("contract_id"));
|
||||
//副表数据
|
||||
//子表数据
|
||||
List<Pcm_contract_itemEntity> pcm_contract_itemList = entity.getPcm_contract_item();
|
||||
pcmContractMap.put("tableFieldc5c2d3",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(pcm_contract_itemList)));
|
||||
pcmContractMap.put("pcm_contract_itemList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(pcm_contract_itemList)));
|
||||
List<Pcm_payment_planEntity> pcm_payment_planList = entity.getPcm_payment_plan();
|
||||
pcmContractMap.put("tableField9213ba",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(pcm_payment_planList)));
|
||||
pcmContractMap.put("pcm_payment_planList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(pcm_payment_planList)));
|
||||
realList.add(pcmContractMap);
|
||||
}
|
||||
//数据转换
|
||||
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
|
||||
realList = generaterSwapUtil.swapDataList(realList, PcmContractConstant.getFormData(), PcmContractConstant.getColumnData(), pcmContractPagination.getModuleId(),isPc?false:false);
|
||||
|
||||
//返回对象
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(realList);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(pcmContractPagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param pcmContractForm
|
||||
* @return
|
||||
*/
|
||||
@PostMapping()
|
||||
@Operation(summary = "创建")
|
||||
public ActionResult create(@RequestBody @Valid PcmContractForm pcmContractForm) {
|
||||
String b = pcmContractService.checkForm(pcmContractForm,0);
|
||||
if (StringUtil.isNotEmpty(b)){
|
||||
return ActionResult.fail(b );
|
||||
}
|
||||
try{
|
||||
pcmContractService.saveOrUpdate(pcmContractForm, null ,true);
|
||||
}catch(Exception e){
|
||||
log.error("【合同管理主表创建接口异常】参数:{}", pcmContractForm, e);
|
||||
return ActionResult.fail(MsgCode.FA028.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@DeleteMapping("/{id}")
|
||||
@Transactional
|
||||
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
|
||||
PcmContractEntity entity= pcmContractService.getInfo(id);
|
||||
if(entity!=null){
|
||||
//主表数据删除
|
||||
pcmContractService.delete(entity);
|
||||
QueryWrapper<Pcm_contract_itemEntity> queryWrapperPcm_contract_item=new QueryWrapper<>();
|
||||
queryWrapperPcm_contract_item.lambda().eq(Pcm_contract_itemEntity::getContractId,entity.getContractId());
|
||||
//子表数据删除
|
||||
pcm_contract_itemService.remove(queryWrapperPcm_contract_item);
|
||||
QueryWrapper<Pcm_payment_planEntity> queryWrapperPcm_payment_plan=new QueryWrapper<>();
|
||||
queryWrapperPcm_payment_plan.lambda().eq(Pcm_payment_planEntity::getContractId,entity.getContractId());
|
||||
//子表数据删除
|
||||
pcm_payment_planService.remove(queryWrapperPcm_payment_plan);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
/**
|
||||
* 批量删除
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/batchRemove")
|
||||
@Transactional
|
||||
@Operation(summary = "批量删除")
|
||||
public ActionResult batchRemove(@RequestBody Object obj){
|
||||
Map<String, Object> objectMap = JsonUtil.entityToMap(obj);
|
||||
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
|
||||
String errInfo = "";
|
||||
List<String> successList = new ArrayList<>();
|
||||
for (String allId : idList){
|
||||
try {
|
||||
this.delete(allId,false);
|
||||
successList.add(allId);
|
||||
} catch (Exception e) {
|
||||
errInfo = e.getMessage();
|
||||
}
|
||||
}
|
||||
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
|
||||
return ActionResult.fail(errInfo);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
/**
|
||||
* 编辑
|
||||
* @param id
|
||||
* @param pcmContractForm
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "更新")
|
||||
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid PcmContractForm pcmContractForm,
|
||||
@RequestParam(value = "isImport", required = false) boolean isImport){
|
||||
PcmContractEntity entity= pcmContractService.getInfo(id);
|
||||
if(entity!=null){
|
||||
pcmContractForm.setContractId(String.valueOf(entity.getContractId()));
|
||||
|
||||
if (!isImport) {
|
||||
String b = pcmContractService.checkForm(pcmContractForm,1);
|
||||
if (StringUtil.isNotEmpty(b)){
|
||||
return ActionResult.fail(b );
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
pcmContractService.saveOrUpdate(pcmContractForm,id,false);
|
||||
}catch (DataException e1){
|
||||
return ActionResult.fail(e1.getMessage());
|
||||
}catch(Exception e){
|
||||
log.error("【合同管理主表编辑接口异常】参数:{}", pcmContractForm, e);
|
||||
return ActionResult.fail(MsgCode.FA029.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}else{
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 表单信息(详情页)
|
||||
* 详情页面使用-转换数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "表单信息(详情页)")
|
||||
@GetMapping("/detail/{id}")
|
||||
public ActionResult detailInfo(@PathVariable("id") String id){
|
||||
PcmContractEntity entity= pcmContractService.getInfo(id);
|
||||
if(entity==null){
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
Map<String, Object> pcmContractMap=JsonUtil.entityToMap(entity);
|
||||
pcmContractMap.put("id", pcmContractMap.get("contract_id"));
|
||||
//副表数据
|
||||
//子表数据
|
||||
List<Pcm_contract_itemEntity> pcm_contract_itemList = entity.getPcm_contract_item();
|
||||
// 按 resources_type 分组,直接得到 Map<类型, 列表>
|
||||
Map<String, List<Pcm_contract_itemEntity>> groupMap = pcm_contract_itemList.stream()
|
||||
.collect(Collectors.groupingBy(Pcm_contract_itemEntity::getResourcesType));
|
||||
|
||||
// 取出对应分组
|
||||
List<Pcm_contract_itemEntity> rgList = groupMap.getOrDefault("RG", new ArrayList<>());
|
||||
List<Pcm_contract_itemEntity> clList = groupMap.getOrDefault("CL", new ArrayList<>());
|
||||
List<Pcm_contract_itemEntity> zlList = groupMap.getOrDefault("ZL", new ArrayList<>());
|
||||
List<Pcm_contract_itemEntity> fyList = groupMap.getOrDefault("GCL", new ArrayList<>());
|
||||
for (Pcm_contract_itemEntity pcm_contract_itemEntity : clList) {
|
||||
pcm_contract_itemEntity.setResourcesName(pcmContractService.selectByFEnCode(pcm_contract_itemEntity.getResourcesName()));
|
||||
|
||||
}
|
||||
for (Pcm_contract_itemEntity pcm_contract_itemEntity : zlList) {
|
||||
pcm_contract_itemEntity.setResourcesName(pcmContractService.selectByFEnCode(pcm_contract_itemEntity.getResourcesName()));
|
||||
|
||||
}
|
||||
pcmContractMap.put("tableFieldc5c2d3",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(rgList)));
|
||||
pcmContractMap.put("pcm_contract_itemList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(rgList)));
|
||||
pcmContractMap.put("tableFieldc5c2d4",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(clList)));
|
||||
pcmContractMap.put("cg_pcm_contract_itemList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(clList)));
|
||||
pcmContractMap.put("tableFieldc5c2d5",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(zlList)));
|
||||
pcmContractMap.put("zd_pcm_contract_itemList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(zlList)));
|
||||
pcmContractMap.put("tableFieldc5c2d6",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(fyList)));
|
||||
pcmContractMap.put("gcl_pcm_contract_itemList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(fyList)));
|
||||
List<Pcm_payment_planEntity> pcm_payment_planList = entity.getPcm_payment_plan();
|
||||
pcmContractMap.put("tableField9213ba",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(pcm_payment_planList)));
|
||||
pcmContractMap.put("pcm_payment_planList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(pcm_payment_planList)));
|
||||
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
|
||||
pcmContractMap = generaterSwapUtil.swapDataDetail(pcmContractMap,PcmContractConstant.getFormData(),"808334712857693445",isPc?false:false);
|
||||
//子表数据
|
||||
pcmContractMap.put("pcm_contract_itemList",pcmContractMap.get("tableFieldc5c2d3"));
|
||||
pcmContractMap.put("cg_pcm_contract_itemList",pcmContractMap.get("tableFieldc5c2d4"));
|
||||
pcmContractMap.put("zd_pcm_contract_itemList",pcmContractMap.get("tableFieldc5c2d5"));
|
||||
pcmContractMap.put("gcl_pcm_contract_itemList",pcmContractMap.get("tableFieldc5c2d6"));
|
||||
pcmContractMap.put("pcm_payment_planList",pcmContractMap.get("tableField9213ba"));
|
||||
|
||||
//获取附件数据
|
||||
List<PcmDocument> pcmDocuments= pcmContractService.getFjxxList(entity.getContractId());
|
||||
pcmContractMap.put("pcmDocument",pcmDocuments);
|
||||
return ActionResult.success(pcmContractMap);
|
||||
}
|
||||
/**
|
||||
* 获取详情(编辑页)
|
||||
* 编辑页面使用-不转换数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "信息")
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult info(@PathVariable("id") String id){
|
||||
PcmContractEntity entity= pcmContractService.getInfo(id);
|
||||
if(entity==null){
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
|
||||
Map<String, Object> pcmContractMap=JsonUtil.entityToMap(entity);
|
||||
pcmContractMap.put("id", pcmContractMap.get("contract_id"));
|
||||
//获取附件数据
|
||||
List<PcmDocument> pcmDocuments= pcmContractService.getFjxxList(entity.getContractId());
|
||||
|
||||
//副表数据
|
||||
//子表数据
|
||||
List<Pcm_contract_itemEntity> pcm_contract_itemList = entity.getPcm_contract_item();
|
||||
// 按 resources_type 分组,直接得到 Map<类型, 列表>
|
||||
Map<String, List<Pcm_contract_itemEntity>> groupMap = pcm_contract_itemList.stream()
|
||||
.collect(Collectors.groupingBy(Pcm_contract_itemEntity::getResourcesType));
|
||||
|
||||
// 取出对应分组
|
||||
List<Pcm_contract_itemEntity> rgList = groupMap.getOrDefault("RG", new ArrayList<>());
|
||||
List<Pcm_contract_itemEntity> clList = groupMap.getOrDefault("CL", new ArrayList<>());
|
||||
List<Pcm_contract_itemEntity> zlList = groupMap.getOrDefault("ZL", new ArrayList<>());
|
||||
List<Pcm_contract_itemEntity> fyList = groupMap.getOrDefault("GCL", new ArrayList<>());
|
||||
pcmContractMap.put("tableFieldc5c2d3",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(rgList)));
|
||||
pcmContractMap.put("pcm_contract_itemList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(rgList)));
|
||||
pcmContractMap.put("tableFieldc5c2d4",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(clList)));
|
||||
pcmContractMap.put("cg_pcm_contract_itemList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(clList)));
|
||||
pcmContractMap.put("tableFieldc5c2d5",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(zlList)));
|
||||
pcmContractMap.put("zd_pcm_contract_itemList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(zlList)));
|
||||
pcmContractMap.put("tableFieldc5c2d6",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(fyList)));
|
||||
pcmContractMap.put("gcl_pcm_contract_itemList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(fyList)));
|
||||
List<Pcm_payment_planEntity> pcm_payment_planList = entity.getPcm_payment_plan();
|
||||
pcmContractMap.put("tableField9213ba",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(pcm_payment_planList)));
|
||||
pcmContractMap.put("pcm_payment_planList",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(pcm_payment_planList)));
|
||||
pcmContractMap = generaterSwapUtil.swapDataForm(pcmContractMap,PcmContractConstant.getFormData(),PcmContractConstant.TABLEFIELDKEY,PcmContractConstant.TABLERENAMES);
|
||||
pcmContractMap.put("pcmDocument",pcmDocuments);
|
||||
return ActionResult.success(pcmContractMap);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user