This commit is contained in:
张秉卓
2026-01-09 18:06:12 +08:00
13 changed files with 320 additions and 28 deletions

View File

@ -1,6 +1,10 @@
package com.xjrsoft.module.contract.controller;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import javax.validation.Valid;
@ -26,8 +30,12 @@ import com.xjrsoft.common.model.result.R;
import com.xjrsoft.module.contract.dto.LngContractPageDto;
import com.xjrsoft.module.contract.dto.UpdateLngContractPurDto;
import com.xjrsoft.module.contract.dto.UpdateLngContractPurPngPointDto;
import com.xjrsoft.module.contract.dto.UpdateLngContractPurPngPointSalesDto;
import com.xjrsoft.module.contract.dto.UpdateLngContractSalesPngPointDto;
import com.xjrsoft.module.contract.service.IContractPurPngService;
import com.xjrsoft.module.contract.vo.LngContractPurPngPointSalesVo;
import com.xjrsoft.module.contract.vo.LngContractPurPngPointVo;
import com.xjrsoft.module.contract.vo.LngContractPurVo;
import com.xjrsoft.module.datalog.service.DatalogService;
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
@ -105,22 +113,61 @@ public class ContractPurPngController {
boolean res = dataService.updateById(dto, new DataOperationListener<UpdateLngContractPurDto>() {
@Override
public UpdateLngContractPurDto before(DataOperationContent<UpdateLngContractPurDto> content) {
List<UpdateLngContractPurPngPointDto> list = dto.getLngContractPurPngPointList();
LngContractPurVo old = contractPurPngService.getInfoById(dto.getId());
List<LngContractPurPngPointVo> oldPpList = old.getLngContractPurPngPointList();
List<Long> oldPpIdList = Lists.newArrayList();
List<Long> oldSalesIdList = Lists.newArrayList();
for(LngContractPurPngPointVo pp:oldPpList) {
oldPpIdList.add(pp.getId());
if(pp.getLngContractPurPngPointSalesList() != null) {
for(LngContractPurPngPointSalesVo sales:pp.getLngContractPurPngPointSalesList()) {
oldSalesIdList.add(sales.getId());
}
}
}
List<UpdateLngContractPurPngPointDto> list = dto.getLngContractPurPngPointList();
List<Long> newPpIdList = Lists.newArrayList();
List<Long> newSalesIdList = Lists.newArrayList();
for (UpdateLngContractPurPngPointDto dto : list) {
if (dto.getHasDel()) {
String sql = StringUtils.format("{? = call pc_{0}.f before_delete_point(?)}",
"pc_lng_contract_pur_png");
List<JdbcParam> params = Lists.newArrayList();
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
params.add(outParam);
params.add(JdbcParam.ofLong(dto.getId()));
JdbcTools.call(sql,params);
String error = outParam.getStringValue();
if (StringUtils.isNotEmpty(error)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
}
if(dto.getId() != null) {
newPpIdList.add(dto.getId());
}
if(dto.getLngContractPurPngPointSalesList() != null) {
for(UpdateLngContractPurPngPointSalesDto sales:dto.getLngContractPurPngPointSalesList()) {
newSalesIdList.add(sales.getId());
}
}
}
for(Long sid:oldPpIdList) {
if(!newPpIdList.contains(sid)) {
String sql = StringUtils.format("{? = call pc_{0}.f_before_delete_point(?)}",
"lng_contract_pur_png");
List<JdbcParam> params = Lists.newArrayList();
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
params.add(outParam);
params.add(JdbcParam.ofLong(dto.getId()));
JdbcTools.call(sql,params);
String error = outParam.getStringValue();
if (StringUtils.isNotEmpty(error)) {
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_DELETE_EXEC_ERROR, error));
}
}
}
for(Long sid:oldSalesIdList) {
if(!newSalesIdList.contains(sid)) {
String sql = StringUtils.format("{? = call pc_{0}.f_before_delete_point_sales(?)}",
"lng_contract_pur_png");
List<JdbcParam> params = Lists.newArrayList();
JdbcParam outParam = JdbcParam.ofString(null).setOut(true);
params.add(outParam);
params.add(JdbcParam.ofLong(dto.getId()));
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();
}

View File

@ -56,11 +56,14 @@ public class LngContractPurPngPoint implements Serializable {
* 上载点编码
*/
@ApiModelProperty("上载点编码")
private String pointUpCode;
@TableField(exist = false)
private String pointUpName;
@TableField(exist = false)
private String pointDelyName;
/**
* 自主托运(Y-是N-否)
*/

View File

@ -68,6 +68,13 @@ public class LngContractPurPngPointSales implements Serializable {
*/
@ApiModelProperty("交割点编码")
private String pointDelyCode;
/**
* 交割点编码
*/
@ApiModelProperty("交割点名称")
@TableField(exist = false)
private String pointDelyName;
/**
* 备注

View File

@ -1,11 +1,14 @@
package com.xjrsoft.module.contract.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.xjrsoft.module.contract.entity.LngContractPurPngPoint;
import com.xjrsoft.module.contract.entity.LngContractPurPngQty;
import org.apache.ibatis.annotations.Mapper;
/**
* @title: mapper
@ -16,4 +19,18 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface LngContractPurPngPointMapper extends MPJBaseMapper<LngContractPurPngPoint> , BaseMapper<LngContractPurPngPoint>{
@Select("SELECT p.full_name " +
" FROM lng_b_station_png p" +
" WHERE p.code = #{code}")
String getLngStationPngNameByCode(@Param("code") String code);
/**
@Select("SELECT GROUP_CONCAT(p.full_name SEPARATOR ',') as fullNames " +
"FROM lng_b_station_png p " +
"WHERE p.code IN " +
"<foreach collection='codes' item='code' open='(' separator=',' close='')>" +
"#{code}" +
"</foreach>")
String getLngStationPngNameByCodes(@Param("codes") List<String> codes);
**/
}

View File

@ -1,7 +1,9 @@
package com.xjrsoft.module.contract.service.impl;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -9,21 +11,30 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.google.common.collect.Lists;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.module.contract.dto.LngContractPageDto;
import com.xjrsoft.module.contract.entity.LngContractFact;
import com.xjrsoft.module.contract.entity.LngContractPur;
import com.xjrsoft.module.contract.entity.LngContractPurPngPoint;
import com.xjrsoft.module.contract.entity.LngContractPurPngPointSales;
import com.xjrsoft.module.contract.mapper.LngContractFactMapper;
import com.xjrsoft.module.contract.mapper.LngContractPurMapper;
import com.xjrsoft.module.contract.mapper.LngContractPurPngPointMapper;
import com.xjrsoft.module.contract.mapper.LngContractPurPngPointSalesMapper;
import com.xjrsoft.module.contract.service.IContractPurPngService;
import com.xjrsoft.module.contract.vo.LngContractApproRelVo;
import com.xjrsoft.module.contract.vo.LngContractFactRelVo;
import com.xjrsoft.module.contract.vo.LngContractPageVo;
import com.xjrsoft.module.contract.vo.LngContractPurVo;
import com.xjrsoft.module.sales.entity.LngAppro;
import com.xjrsoft.module.sales.mapper.LngApproMapper;
import com.xjrsoft.module.system.client.IFileClient;
import com.xjrsoft.module.system.vo.LngFileUploadVo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import lombok.AllArgsConstructor;
/**
@ -40,6 +51,16 @@ public class ContractPurPngServiceImpl extends MPJBaseServiceImpl<LngContractPur
private final LngContractPurPngPointSalesMapper lngContractPurPngPointSalesMapper;
//private final LngContractApproRelMapper lngContractApproRelMapper;
//private final LngContractFactRelMapper lngContractFactRelMapper;
private final LngContractPurPngPointMapper lngContractPurPngPointMapper;
private final LngContractFactMapper lngContractFactMapper;
private final LngApproMapper lngApproMapper;
@Override
public PageOutput<LngContractPageVo> queryPage(LngContractPageDto dto) {
QueryWrapper<LngContractPur> queryWrapper = new QueryWrapper<>();
@ -63,13 +84,63 @@ public class ContractPurPngServiceImpl extends MPJBaseServiceImpl<LngContractPur
}
if(lngContractPur.getLngContractPurPngPointList() != null) {
for(LngContractPurPngPoint pp:lngContractPur.getLngContractPurPngPointList()) {
String fullName = lngContractPurPngPointMapper.getLngStationPngNameByCode(pp.getPointUpCode());
pp.setPointUpName(fullName);
List<LngContractPurPngPointSales> list = lngContractPurPngPointSalesMapper.selectList(new LambdaQueryWrapper<LngContractPurPngPointSales>()
.eq(LngContractPurPngPointSales::getKpppId, pp.getId()));
pp.setLngContractPurPngPointSalesList(list);
List<String> names = Lists.newArrayList();
for(LngContractPurPngPointSales ps:list) {
String delyName = lngContractPurPngPointMapper.getLngStationPngNameByCode(ps.getPointDelyCode());
ps.setPointDelyName(delyName);
names.add(delyName);
}
if(CollectionUtil.isNotEmpty(names)) {
pp.setPointDelyName(names.stream().collect(Collectors.joining(",")));
}
}
}
LngContractPurVo vo = BeanUtil.toBean(lngContractPur, LngContractPurVo.class);
List<LngContractFactRelVo> lngContractFactRelList = vo.getLngContractFactRelList();
if (CollectionUtils.isNotEmpty(lngContractFactRelList)) {
lngContractFactRelList.forEach(x -> {
LngContractFact lngContractFact = lngContractFactMapper.selectById(x.getKFactId());
if(lngContractFact != null) {
x.setComId(lngContractFact.getComId());
x.setKName(lngContractFact.getKName());
x.setKNo(lngContractFact.getKNo());
x.setEmpId(lngContractFact.getEmpId());
x.setTel(lngContractFact.getTel());
x.setKTypeCode1(lngContractFact.getKTypeCode1());
x.setRelTypeCode(lngContractFact.getRelTypeCode());
}
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_contract_fact",
"lngFileUploadList", lngContractFact.getId());
x.setLngFileUploadList(fileList);
});
}
List<LngContractApproRelVo> lngContractApproRelList = vo.getLngContractApproRelList();
if (CollectionUtils.isNotEmpty(lngContractApproRelList)) {
lngContractApproRelList.forEach(x -> {
LngAppro appro = lngApproMapper.selectById(x.getApproId());
if(appro != null) {
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_appro",
"lngFileUploadList", appro.getId());
x.setLngFileUploadList(fileList);
x.setBDeptId(appro.getBDeptId());
x.setCode(appro.getCode());
x.setTypeCode(x.getTypeCode());
x.setEmpId(x.getEmpId());
x.setDateAppro(appro.getDateAppro());
x.setTitle(appro.getTitle());
}
});
}
List<LngFileUploadVo> fileList = fileClient.getTableFiles("lng_contract", "lngFileUploadList", vo.getId());
vo.setLngFileUploadList(fileList);

View File

@ -110,8 +110,7 @@ public class CustomerController {
String code = codeRuleClient.genEncode(CUSTOMER_CODE);
dto.setCuCode("C"+code);
//UpdateLngCustomerDto obj = dataService.insert(dto);
//return R.ok(obj);
return R.ok(dataService.insert(dto,new DataOperationListener<UpdateLngCustomerDto>() {
@Override