This commit is contained in:
张秉卓
2026-03-10 18:04:42 +08:00
parent b831fc8762
commit f22f8001b9
10 changed files with 1057 additions and 0 deletions

View File

@ -0,0 +1,165 @@
package com.xjrsoft.module.contract.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.google.api.client.util.Lists;
import com.pictc.datalog.DataOperationContent;
import com.pictc.datalog.DataOperationListener;
import com.pictc.enums.BusinessCode;
import com.pictc.enums.ExceptionCommonCode;
import com.pictc.jdbc.JdbcTools;
import com.pictc.jdbc.model.JdbcParam;
import com.pictc.utils.StringUtils;
import com.xjrsoft.common.exception.BusinessException;
import com.xjrsoft.common.model.result.R;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.utils.VoToColumnUtil;
import com.xjrsoft.module.contract.dto.LngContractPageDto;
import com.xjrsoft.module.contract.dto.UpdateLngContractPLDto;
import com.xjrsoft.module.contract.entity.LngContract;
import com.xjrsoft.module.contract.service.IContractPurLngService;
import com.xjrsoft.module.contract.vo.LngContractPageVo;
import com.xjrsoft.module.datalog.service.DatalogService;
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* @title: 国内LNG采购合同
* @Author 管理员
* @Date: 2026-03-10
* @Version 1.0
*/
@RestController
@RequestMapping("/contract" + "/contractPurLng")
@Api(value = "/contract" + "/contractPurLng",tags = "国内LNG采购合同代码")
@AllArgsConstructor
public class ContractPurLngController {
private final IContractPurLngService contractPurLngService;
private final DatalogService dataService;
@GetMapping(value = "/page")
@ApiOperation(value="LngContract列表(分页)")
@SaCheckPermission("contractPurLng:list")
public R page(@Valid LngContractPageDto dto){
LambdaQueryWrapper<LngContract> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper
.eq(ObjectUtil.isNotNull(dto.getId()),LngContract::getId,dto.getId())
.like(StrUtil.isNotBlank(dto.getKNo()),LngContract::getKNo,dto.getKNo())
.like(StrUtil.isNotBlank(dto.getKName()),LngContract::getKName,dto.getKName())
.like(StrUtil.isNotBlank(dto.getCpName()),LngContract::getCpName,dto.getCpName())
.eq(ObjectUtil.isNotNull(dto.getComId()),LngContract::getComId,dto.getComId())
.like(StrUtil.isNotBlank(dto.getApproCode()),LngContract::getApproCode,dto.getApproCode())
.orderByDesc(LngContract::getId)
.select(LngContract.class,x -> VoToColumnUtil.fieldsToColumns(LngContractPageVo.class).contains(x.getProperty()));
IPage<LngContract> page = contractPurLngService.page(ConventPage.getPage(dto), queryWrapper);
PageOutput<LngContractPageVo> pageOutput = ConventPage.getPageOutput(page, LngContractPageVo.class);
return R.ok(pageOutput);
}
@GetMapping(value = "/info")
@ApiOperation(value="根据id查询LngContract信息")
@SaCheckPermission("contractPurLng:detail")
public R info(@RequestParam Long id){
return R.ok(contractPurLngService.getInfoById(id));
}
@GetMapping(value = "/datalog")
@ApiOperation(value="根据id查询LngContract数据详细日志")
@SaCheckPermission("contractPurLng:datalog")
public R datalog(@RequestParam Long id){
List<DataChangeLogVo> logs = dataService.findLogsByEntityId(UpdateLngContractPLDto.class,id);
return R.ok(logs);
}
@PostMapping
@ApiOperation(value = "新增LngContract")
@SaCheckPermission("contractPurLng:add")
public R add(@Valid @RequestBody UpdateLngContractPLDto dto){
UpdateLngContractPLDto res = dataService.insert(dto, new DataOperationListener<UpdateLngContractPLDto>() {
@Override
public UpdateLngContractPLDto before(DataOperationContent<UpdateLngContractPLDto> content) {
return null;
}
@Override
public UpdateLngContractPLDto after(DataOperationContent<UpdateLngContractPLDto> content) {
execAfter(content.getTableName(), content.getIdValue(), "I");
return content.getObj();
}
});
return R.ok(res);
}
private void execAfter(String table, Long id, String sign) {
String sql = StringUtils.format("{? = call pc_{0}.f_save(?, ?)}", table);
List<JdbcParam> params = Lists.newArrayList();
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
params.add(outParam);
params.add(JdbcParam.ofLong(id));
params.add(JdbcParam.ofString(sign));
JdbcTools.call(sql,params);
String error = outParam.getStringValue();
if (StringUtils.isNotEmpty(error)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_SAVE_EXEC_ERROR, error));
}
}
@PutMapping
@ApiOperation(value = "修改LngContract")
@SaCheckPermission("contractPurLng:edit")
public R update(@Valid @RequestBody UpdateLngContractPLDto dto){
return R.ok(dataService.updateById(dto, new DataOperationListener<UpdateLngContractPLDto>() {
@Override
public UpdateLngContractPLDto before(DataOperationContent<UpdateLngContractPLDto> content) {
return null;
}
@Override
public UpdateLngContractPLDto after(DataOperationContent<UpdateLngContractPLDto> content) {
execAfter(content.getTableName(), content.getIdValue(), "U");
return content.getObj();
}
}));
}
@DeleteMapping
@ApiOperation(value = "删除")
@SaCheckPermission("contractPurLng:delete")
public R delete(@Valid @RequestBody List<Long> ids){
return R.ok(dataService.deleteByIds(UpdateLngContractPLDto.class, ids, new DataOperationListener<UpdateLngContractPLDto>() {
@Override
public UpdateLngContractPLDto before(DataOperationContent<UpdateLngContractPLDto> content) {
String sql = StringUtils.format("{? = call pc_{0}.f_before_delete(?)}", content.getTableName());
List<JdbcParam> params = Lists.newArrayList();
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
params.add(outParam);
params.add(JdbcParam.ofLong(content.getIdValue()));
JdbcTools.call(sql,params);
String error = outParam.getStringValue();
if (StringUtils.isNotEmpty(error)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
}
return content.getObj();
}
@Override
public UpdateLngContractPLDto after(DataOperationContent<UpdateLngContractPLDto> content) {
return null;
}
}));
}
}

View File

@ -0,0 +1,113 @@
package com.xjrsoft.module.contract.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @title: 国内LNG采购合同
* @Author 管理员
* @Date: 2026-03-10
* @Version 1.0
*/
@Data
@TableName("lng_contract_pur_lng")
@ApiModel(value = "国内LNG采购合同对象", description = "国内LNG采购合同")
public class LngContractPurLng implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ApiModelProperty("主键")
@TableId
private Long id;
/**
* 合同-档案主键
*/
@ApiModelProperty("合同-档案主键")
private Long kId;
/**
* 长协/现货/年度合同(长协/现货/年度……)
*/
@ApiModelProperty("长协/现货/年度合同(长协/现货/年度……)")
private String longSpotCode;
/**
* 定价机制(固定价/公式价/对标价/无)
*/
@ApiModelProperty("定价机制(固定价/公式价/对标价/无)")
private String prcTypeCode;
/**
* 计量单位(隐藏)
*/
@ApiModelProperty("计量单位(隐藏)")
private String uomCode;
/**
* 备注
*/
@ApiModelProperty("备注")
private String note;
/**
* 创建人id
*/
@ApiModelProperty("创建人id")
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED)
private Long createUserId;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED)
private LocalDateTime createDate;
/**
* 修改人id
*/
@ApiModelProperty("修改人id")
@TableField(fill = FieldFill.UPDATE, updateStrategy = FieldStrategy.IGNORED)
private Long modifyUserId;
/**
* 修改时间
*/
@ApiModelProperty("修改时间")
@TableField(fill = FieldFill.UPDATE, updateStrategy = FieldStrategy.IGNORED)
private LocalDateTime modifyDate;
/**
* 租户id
*/
@ApiModelProperty("租户id")
@TableField(updateStrategy = FieldStrategy.IGNORED)
private Long tenantId;
/**
* 部门id
*/
@ApiModelProperty("部门id")
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED)
private Long deptId;
/**
* 数据权限id
*/
@ApiModelProperty("数据权限id")
@TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.IGNORED)
private Long ruleUserId;
}

View File

@ -0,0 +1,17 @@
package com.xjrsoft.module.contract.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.module.contract.entity.LngContractPurLng;
import org.apache.ibatis.annotations.Mapper;
/**
* @title: mapper
* @Author 管理员
* @Date: 2026-03-10
* @Version 1.0
*/
@Mapper
public interface LngContractPurLngMapper extends MPJBaseMapper<LngContractPurLng>, BaseMapper<LngContractPurLng> {
}

View File

@ -0,0 +1,19 @@
package com.xjrsoft.module.contract.service;
import com.github.yulichang.base.MPJBaseService;
import com.github.yulichang.extension.mapping.base.MPJDeepService;
import com.github.yulichang.extension.mapping.base.MPJRelationService;
import com.xjrsoft.module.contract.entity.LngContract;
import com.xjrsoft.module.contract.vo.LngContractPLVo;
/**
* @title: service
* @Author 管理员
* @Date: 2026-03-10
* @Version 1.0
*/
public interface IContractPurLngService extends MPJBaseService<LngContract>, MPJDeepService<LngContract>, MPJRelationService<LngContract> {
LngContractPLVo getInfoById(Long id);
}

View File

@ -0,0 +1,88 @@
package com.xjrsoft.module.contract.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.google.common.collect.Lists;
import com.pictc.enums.BusinessCode;
import com.xjrsoft.common.exception.BusinessException;
import com.xjrsoft.module.contract.entity.*;
import com.xjrsoft.module.contract.mapper.*;
import com.xjrsoft.module.contract.service.IContractPurLngService;
import com.xjrsoft.module.contract.vo.LngContractFactVo;
import com.xjrsoft.module.contract.vo.LngContractPLVo;
import com.xjrsoft.module.contract.vo.LngContractPurLngVo;
import com.xjrsoft.module.sales.vo.LngApproVo;
import com.xjrsoft.module.system.client.IFileClient;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @title: service
* @Author 管理员
* @Date: 2026-03-10
* @Version 1.0
*/
@Service
@AllArgsConstructor
public class ContractPurLngServiceImpl extends MPJBaseServiceImpl<LngContractMapper, LngContract> implements IContractPurLngService {
private final LngContractPurLngMapper lngContractPurLngMapper;
private final LngContractFactMapper lngContractFactMapper;
private final LngContractFactRelMapper lngContractFactRelMapper;
private final LngContractApproRelMapper lngContractApproRelMapper;
private final IFileClient fileClient;
@Override
public LngContractPLVo getInfoById(Long id) {
LngContract lngContract = this.getById(id);
if(lngContract == null) {
throw new BusinessException(BusinessCode.of(10500,"找不到此数据"));
}
LngContractPLVo vo = BeanUtil.toBean(lngContract, LngContractPLVo.class);
List<LngContractPurLng> lngContractPurLngList = lngContractPurLngMapper.selectList(
new LambdaQueryWrapper<LngContractPurLng>()
.eq(LngContractPurLng::getKId, lngContract.getId()));
if (CollectionUtils.isNotEmpty(lngContractPurLngList)) {
vo.setLngContractPurLngList(BeanUtil.copyToList(lngContractPurLngList,
LngContractPurLngVo.class));
}
List<LngContractFactRel> lngContractFactRelList = lngContractFactRelMapper.selectList(
new LambdaQueryWrapper<LngContractFactRel>()
.eq(LngContractFactRel::getKId, lngContract.getId()));
if (CollectionUtils.isNotEmpty(lngContractFactRelList)) {
List<LngContractFactVo> lngContractFactVoList = Lists.newArrayList();
lngContractFactRelList.forEach(x -> {
LngContractFact lngContractFact = lngContractFactMapper.selectById(x.getKFactId());
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_contract_fact",
"lngFileUploadList", lngContractFact.getId());
LngContractFactVo lngContractFactVo = BeanUtil.toBean(lngContractFact, LngContractFactVo.class);
lngContractFactVo.setLngFileUploadList(fileList);
lngContractFactVoList.add(lngContractFactVo);
});
vo.setLngContractFactList(lngContractFactVoList);
}
List<LngContractApproRel> lngContractApproRelList = lngContractApproRelMapper.selectList(
new LambdaQueryWrapper<LngContractApproRel>()
.eq(LngContractApproRel::getTableId, lngContract.getId()));
if (CollectionUtils.isNotEmpty(lngContractApproRelList)) {
List<LngApproVo> approVoList = Lists.newArrayList();
lngContractApproRelList.forEach(x -> {
LngApproVo approVo = lngContractFactMapper.getLngApproVo(x.getApproId());
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_appro",
"lngFileUploadList", approVo.getId());
approVo.setLngFileUploadList(fileList);
approVoList.add(approVo);
});
vo.setLngApproVoList(approVoList);
}
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_contract",
"lngFileUploadList", vo.getId());
vo.setLngFileUploadList(fileList);
return vo;
}
}