|
|
|
@ -48,7 +48,7 @@ import java.util.*;
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
|
@Tag(name = "Contract", description = "example")
|
|
|
|
|
@Tag(name = "Contract" , description = "example")
|
|
|
|
|
@RequestMapping("/api/example/Contract")
|
|
|
|
|
public class ContractController {
|
|
|
|
|
|
|
|
|
@ -76,9 +76,9 @@ public class ContractController {
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "获取列表")
|
|
|
|
|
@PostMapping("/getList")
|
|
|
|
|
public ActionResult list(@RequestBody ContractPagination contractPagination) throws IOException {
|
|
|
|
|
List<ContractEntity> list = contractService.getList(contractPagination);
|
|
|
|
|
List<Map<String, Object>> realList = new ArrayList<>();
|
|
|
|
|
public ActionResult list(@RequestBody ContractPagination contractPagination)throws IOException{
|
|
|
|
|
List<ContractEntity> list= contractService.getList(contractPagination);
|
|
|
|
|
List<Map<String, Object>> realList=new ArrayList<>();
|
|
|
|
|
for (ContractEntity entity : list) {
|
|
|
|
|
Map<String, Object> contractMap = JsonUtil.entityToMap(entity);
|
|
|
|
|
contractMap.put("id", contractMap.get("id"));
|
|
|
|
@ -89,7 +89,7 @@ public class ContractController {
|
|
|
|
|
realList.add(contractMap);
|
|
|
|
|
}
|
|
|
|
|
//数据转换
|
|
|
|
|
realList = generaterSwapUtil.swapDataList(realList, ContractConstant.getFormData(), ContractConstant.getColumnData(), contractPagination.getModuleId(), false);
|
|
|
|
|
realList = generaterSwapUtil.swapDataList(realList, ContractConstant.getFormData(), ContractConstant.getColumnData(), contractPagination.getModuleId(),false);
|
|
|
|
|
|
|
|
|
|
//返回对象
|
|
|
|
|
PageListVO vo = new PageListVO();
|
|
|
|
@ -98,7 +98,6 @@ public class ContractController {
|
|
|
|
|
vo.setPagination(page);
|
|
|
|
|
return ActionResult.success(vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建
|
|
|
|
|
*
|
|
|
|
@ -108,18 +107,17 @@ public class ContractController {
|
|
|
|
|
@PostMapping()
|
|
|
|
|
@Operation(summary = "创建")
|
|
|
|
|
public ActionResult create(@RequestBody @Valid ContractForm contractForm) {
|
|
|
|
|
String b = contractService.checkForm(contractForm, 0);
|
|
|
|
|
if (StringUtil.isNotEmpty(b)) {
|
|
|
|
|
return ActionResult.fail(b);
|
|
|
|
|
String b = contractService.checkForm(contractForm,0);
|
|
|
|
|
if (StringUtil.isNotEmpty(b)){
|
|
|
|
|
return ActionResult.fail(b );
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
contractService.saveOrUpdate(contractForm, null, true);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
try{
|
|
|
|
|
contractService.saveOrUpdate(contractForm, null ,true);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
return ActionResult.fail("新增数据失败");
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success("创建成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出Excel
|
|
|
|
|
*
|
|
|
|
@ -128,11 +126,11 @@ public class ContractController {
|
|
|
|
|
@Operation(summary = "导出Excel")
|
|
|
|
|
@PostMapping("/Actions/Export")
|
|
|
|
|
public ActionResult Export(@RequestBody ContractPagination contractPagination) throws IOException {
|
|
|
|
|
if (StringUtil.isEmpty(contractPagination.getSelectKey())) {
|
|
|
|
|
if (StringUtil.isEmpty(contractPagination.getSelectKey())){
|
|
|
|
|
return ActionResult.fail("请选择导出字段");
|
|
|
|
|
}
|
|
|
|
|
List<ContractEntity> list = contractService.getList(contractPagination);
|
|
|
|
|
List<Map<String, Object>> realList = new ArrayList<>();
|
|
|
|
|
List<ContractEntity> list= contractService.getList(contractPagination);
|
|
|
|
|
List<Map<String, Object>> realList=new ArrayList<>();
|
|
|
|
|
for (ContractEntity entity : list) {
|
|
|
|
|
Map<String, Object> contractMap = JsonUtil.entityToMap(entity);
|
|
|
|
|
contractMap.put("id", contractMap.get("id"));
|
|
|
|
@ -143,98 +141,98 @@ public class ContractController {
|
|
|
|
|
realList.add(contractMap);
|
|
|
|
|
}
|
|
|
|
|
//数据转换
|
|
|
|
|
realList = generaterSwapUtil.swapDataList(realList, ContractConstant.getFormData(), ContractConstant.getColumnData(), contractPagination.getModuleId(), false);
|
|
|
|
|
String[] keys = !StringUtil.isEmpty(contractPagination.getSelectKey()) ? contractPagination.getSelectKey() : new String[0];
|
|
|
|
|
UserInfo userInfo = userProvider.get();
|
|
|
|
|
DownloadVO vo = this.creatModelExcel(configValueUtil.getTemporaryFilePath(), realList, keys, userInfo);
|
|
|
|
|
realList = generaterSwapUtil.swapDataList(realList, ContractConstant.getFormData(), ContractConstant.getColumnData(), contractPagination.getModuleId(),false);
|
|
|
|
|
String[]keys=!StringUtil.isEmpty(contractPagination.getSelectKey())?contractPagination.getSelectKey():new String[0];
|
|
|
|
|
UserInfo userInfo=userProvider.get();
|
|
|
|
|
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo);
|
|
|
|
|
return ActionResult.success(vo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导出表格方法
|
|
|
|
|
*/
|
|
|
|
|
public DownloadVO creatModelExcel(String path, List<Map<String, Object>> list, String[] keys, UserInfo userInfo) {
|
|
|
|
|
DownloadVO vo = DownloadVO.builder().build();
|
|
|
|
|
List<ExcelExportEntity> entitys = new ArrayList<>();
|
|
|
|
|
if (keys.length > 0) {
|
|
|
|
|
ExcelExportEntity tableField130ExcelEntity = new ExcelExportEntity("空间列表", "tableField130");
|
|
|
|
|
public DownloadVO creatModelExcel(String path,List<Map<String, Object>>list,String[]keys,UserInfo userInfo){
|
|
|
|
|
DownloadVO vo=DownloadVO.builder().build();
|
|
|
|
|
List<ExcelExportEntity> entitys=new ArrayList<>();
|
|
|
|
|
if(keys.length>0){
|
|
|
|
|
ExcelExportEntity tableField130ExcelEntity = new ExcelExportEntity("空间列表","tableField130");
|
|
|
|
|
List<ExcelExportEntity> tableField130List = new ArrayList<>();
|
|
|
|
|
for (String key : keys) {
|
|
|
|
|
switch (key) {
|
|
|
|
|
case "contractNumber":
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同编号", "contractNumber"));
|
|
|
|
|
for(String key:keys){
|
|
|
|
|
switch(key){
|
|
|
|
|
case "contractNumber" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同编号" ,"contractNumber"));
|
|
|
|
|
break;
|
|
|
|
|
case "contractName":
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同名称", "contractName"));
|
|
|
|
|
case "contractName" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同名称" ,"contractName"));
|
|
|
|
|
break;
|
|
|
|
|
case "pricingMethod":
|
|
|
|
|
entitys.add(new ExcelExportEntity("计价方式", "pricingMethod"));
|
|
|
|
|
case "pricingMethod" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("计价方式" ,"pricingMethod"));
|
|
|
|
|
break;
|
|
|
|
|
case "signingDate":
|
|
|
|
|
entitys.add(new ExcelExportEntity("签订日期", "signingDate"));
|
|
|
|
|
case "signingDate" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("签订日期" ,"signingDate"));
|
|
|
|
|
break;
|
|
|
|
|
case "parkId":
|
|
|
|
|
entitys.add(new ExcelExportEntity("园区名称", "parkId"));
|
|
|
|
|
case "parkId" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("园区名称" ,"parkId"));
|
|
|
|
|
break;
|
|
|
|
|
case "merchantId":
|
|
|
|
|
entitys.add(new ExcelExportEntity("商户名称", "merchantId"));
|
|
|
|
|
case "merchantId" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("商户名称" ,"merchantId"));
|
|
|
|
|
break;
|
|
|
|
|
case "totalRentalPrice":
|
|
|
|
|
entitys.add(new ExcelExportEntity("租金总价", "totalRentalPrice"));
|
|
|
|
|
case "totalRentalPrice" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("租金总价" ,"totalRentalPrice"));
|
|
|
|
|
break;
|
|
|
|
|
case "totalDeposit":
|
|
|
|
|
entitys.add(new ExcelExportEntity("押金总计", "totalDeposit"));
|
|
|
|
|
case "totalDeposit" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("押金总计" ,"totalDeposit"));
|
|
|
|
|
break;
|
|
|
|
|
case "payDeposit":
|
|
|
|
|
entitys.add(new ExcelExportEntity("支付方式", "payDeposit"));
|
|
|
|
|
case "payDeposit" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("支付方式" ,"payDeposit"));
|
|
|
|
|
break;
|
|
|
|
|
case "returnDeposit":
|
|
|
|
|
entitys.add(new ExcelExportEntity("退还方式", "returnDeposit"));
|
|
|
|
|
case "returnDeposit" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("退还方式" ,"returnDeposit"));
|
|
|
|
|
break;
|
|
|
|
|
case "startTime":
|
|
|
|
|
entitys.add(new ExcelExportEntity("开始时间", "startTime"));
|
|
|
|
|
case "startTime" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("开始时间" ,"startTime"));
|
|
|
|
|
break;
|
|
|
|
|
case "endTime":
|
|
|
|
|
entitys.add(new ExcelExportEntity("结束时间", "endTime"));
|
|
|
|
|
case "endTime" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("结束时间" ,"endTime"));
|
|
|
|
|
break;
|
|
|
|
|
case "leaseTerm":
|
|
|
|
|
entitys.add(new ExcelExportEntity("租期", "leaseTerm"));
|
|
|
|
|
case "leaseTerm" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("租期" ,"leaseTerm"));
|
|
|
|
|
break;
|
|
|
|
|
case "contacts":
|
|
|
|
|
entitys.add(new ExcelExportEntity("联系人", "contacts"));
|
|
|
|
|
case "contacts" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("联系人" ,"contacts"));
|
|
|
|
|
break;
|
|
|
|
|
case "contactsPhone":
|
|
|
|
|
entitys.add(new ExcelExportEntity("联系电话", "contactsPhone"));
|
|
|
|
|
case "contactsPhone" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("联系电话" ,"contactsPhone"));
|
|
|
|
|
break;
|
|
|
|
|
case "contractStatus":
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同状态", "contractStatus"));
|
|
|
|
|
case "contractStatus" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同状态" ,"contractStatus"));
|
|
|
|
|
break;
|
|
|
|
|
case "creationTime":
|
|
|
|
|
entitys.add(new ExcelExportEntity("创建时间", "creationTime"));
|
|
|
|
|
case "creationTime" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("创建时间" ,"creationTime"));
|
|
|
|
|
break;
|
|
|
|
|
case "contractExplain":
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同说明", "contractExplain"));
|
|
|
|
|
case "contractExplain" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同说明" ,"contractExplain"));
|
|
|
|
|
break;
|
|
|
|
|
case "contractEnclosure":
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同附件", "contractEnclosure"));
|
|
|
|
|
case "contractEnclosure" :
|
|
|
|
|
entitys.add(new ExcelExportEntity("合同附件" ,"contractEnclosure"));
|
|
|
|
|
break;
|
|
|
|
|
case "tableField130-contractLineNumber":
|
|
|
|
|
tableField130List.add(new ExcelExportEntity("合同行号", "contractLineNumber"));
|
|
|
|
|
tableField130List.add(new ExcelExportEntity("合同行号" ,"contractLineNumber"));
|
|
|
|
|
break;
|
|
|
|
|
case "tableField130-spaceId":
|
|
|
|
|
tableField130List.add(new ExcelExportEntity("空间名称", "spaceId"));
|
|
|
|
|
tableField130List.add(new ExcelExportEntity("空间名称" ,"spaceId"));
|
|
|
|
|
break;
|
|
|
|
|
case "tableField130-spaceArea":
|
|
|
|
|
tableField130List.add(new ExcelExportEntity("空间面积", "spaceArea"));
|
|
|
|
|
tableField130List.add(new ExcelExportEntity("空间面积" ,"spaceArea"));
|
|
|
|
|
break;
|
|
|
|
|
case "tableField130-totalRentalPrice":
|
|
|
|
|
tableField130List.add(new ExcelExportEntity("租金总价", "totalRentalPrice"));
|
|
|
|
|
tableField130List.add(new ExcelExportEntity("租金总价" ,"totalRentalPrice"));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (tableField130List.size() > 0) {
|
|
|
|
|
if(tableField130List.size() > 0){
|
|
|
|
|
tableField130ExcelEntity.setList(tableField130List);
|
|
|
|
|
entitys.add(tableField130ExcelEntity);
|
|
|
|
|
}
|
|
|
|
@ -242,10 +240,10 @@ public class ContractController {
|
|
|
|
|
|
|
|
|
|
ExportParams exportParams = new ExportParams(null, "表单信息");
|
|
|
|
|
exportParams.setType(ExcelType.XSSF);
|
|
|
|
|
try {
|
|
|
|
|
try{
|
|
|
|
|
@Cleanup Workbook workbook = new HSSFWorkbook();
|
|
|
|
|
if (entitys.size() > 0) {
|
|
|
|
|
if (list.size() == 0) {
|
|
|
|
|
if (entitys.size()>0){
|
|
|
|
|
if (list.size()==0){
|
|
|
|
|
list.add(new HashMap<>());
|
|
|
|
|
}
|
|
|
|
|
//去除空数据
|
|
|
|
@ -255,8 +253,8 @@ public class ContractController {
|
|
|
|
|
for (String key : keys) {
|
|
|
|
|
//子表
|
|
|
|
|
if (key.toLowerCase().startsWith("tablefield")) {
|
|
|
|
|
String tableField = key.substring(0, key.indexOf("-"));
|
|
|
|
|
String field = key.substring(key.indexOf("-") + 1);
|
|
|
|
|
String tableField = key.substring(0, key.indexOf("-" ));
|
|
|
|
|
String field = key.substring(key.indexOf("-" ) + 1);
|
|
|
|
|
Object o = map.get(tableField);
|
|
|
|
|
if (o != null) {
|
|
|
|
|
List<Map<String, Object>> childList = (List<Map<String, Object>>) o;
|
|
|
|
@ -299,72 +297,66 @@ public class ContractController {
|
|
|
|
|
}
|
|
|
|
|
return vo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param contractForm
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping("/{id}")
|
|
|
|
|
@Operation(summary = "更新")
|
|
|
|
|
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid ContractForm contractForm,
|
|
|
|
|
@RequestParam(value = "isImport", required = false) boolean isImport) {
|
|
|
|
|
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid ContractForm contractForm,
|
|
|
|
|
@RequestParam(value = "isImport", required = false) boolean isImport){
|
|
|
|
|
contractForm.setId(id);
|
|
|
|
|
if (!isImport) {
|
|
|
|
|
String b = contractService.checkForm(contractForm, 1);
|
|
|
|
|
if (StringUtil.isNotEmpty(b)) {
|
|
|
|
|
return ActionResult.fail(b);
|
|
|
|
|
String b = contractService.checkForm(contractForm,1);
|
|
|
|
|
if (StringUtil.isNotEmpty(b)){
|
|
|
|
|
return ActionResult.fail(b );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ContractEntity entity = contractService.getInfo(id);
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
try {
|
|
|
|
|
contractService.saveOrUpdate(contractForm, id, false);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
ContractEntity entity= contractService.getInfo(id);
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
try{
|
|
|
|
|
contractService.saveOrUpdate(contractForm,id,false);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
return ActionResult.fail("修改数据失败");
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success("更新成功");
|
|
|
|
|
} else {
|
|
|
|
|
}else{
|
|
|
|
|
return ActionResult.fail("更新失败,数据不存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "删除")
|
|
|
|
|
@DeleteMapping("/{id}")
|
|
|
|
|
@Transactional
|
|
|
|
|
public ActionResult delete(@PathVariable("id") String id) {
|
|
|
|
|
ContractEntity entity = contractService.getInfo(id);
|
|
|
|
|
if (entity != null) {
|
|
|
|
|
public ActionResult delete(@PathVariable("id") String id){
|
|
|
|
|
ContractEntity entity= contractService.getInfo(id);
|
|
|
|
|
if(entity!=null){
|
|
|
|
|
//假删除
|
|
|
|
|
entity.setDeleteMark(1);
|
|
|
|
|
contractService.update(id, entity);
|
|
|
|
|
}
|
|
|
|
|
return ActionResult.success("删除成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 表单信息(详情页)
|
|
|
|
|
* 详情页面使用-转换数据
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "表单信息(详情页)")
|
|
|
|
|
@GetMapping("/detail/{id}")
|
|
|
|
|
public ActionResult detailInfo(@PathVariable("id") String id) {
|
|
|
|
|
ContractEntity entity = contractService.getInfo(id);
|
|
|
|
|
if (entity == null) {
|
|
|
|
|
public ActionResult detailInfo(@PathVariable("id") String id){
|
|
|
|
|
ContractEntity entity= contractService.getInfo(id);
|
|
|
|
|
if(entity==null){
|
|
|
|
|
return ActionResult.fail("表单数据不存在!");
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> contractMap = JsonUtil.entityToMap(entity);
|
|
|
|
|
Map<String, Object> contractMap=JsonUtil.entityToMap(entity);
|
|
|
|
|
contractMap.put("id", contractMap.get("id"));
|
|
|
|
|
//副表数据
|
|
|
|
|
//子表数据
|
|
|
|
@ -373,22 +365,20 @@ public class ContractController {
|
|
|
|
|
contractMap = generaterSwapUtil.swapDataDetail(contractMap, ContractConstant.getFormData(), "582839350958489605", false);
|
|
|
|
|
return ActionResult.success(contractMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取详情(编辑页)
|
|
|
|
|
* 编辑页面使用-不转换数据
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Operation(summary = "信息")
|
|
|
|
|
@GetMapping("/{id}")
|
|
|
|
|
public ActionResult info(@PathVariable("id") String id) {
|
|
|
|
|
ContractEntity entity = contractService.getInfo(id);
|
|
|
|
|
if (entity == null) {
|
|
|
|
|
public ActionResult info(@PathVariable("id") String id){
|
|
|
|
|
ContractEntity entity= contractService.getInfo(id);
|
|
|
|
|
if(entity==null){
|
|
|
|
|
return ActionResult.fail("表单数据不存在!");
|
|
|
|
|
}
|
|
|
|
|
Map<String, Object> contractMap = JsonUtil.entityToMap(entity);
|
|
|
|
|
Map<String, Object> contractMap=JsonUtil.entityToMap(entity);
|
|
|
|
|
contractMap.put("id", contractMap.get("id"));
|
|
|
|
|
//副表数据
|
|
|
|
|
//子表数据
|
|
|
|
|