Compare commits
10 Commits
a6922e57da
...
685ba9473b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
685ba9473b | ||
|
|
09f8db69c4 | ||
|
|
cfdeb40a23 | ||
|
|
10bfece481 | ||
|
|
79a760a379 | ||
|
|
dd9142a670 | ||
|
|
8faa14d227 | ||
|
|
82219fd733 | ||
|
|
f797283021 | ||
|
|
d382abba10 |
@@ -12,6 +12,7 @@ public interface ErrorCodeConstants {
|
||||
// ========== 示例模块 1-001-000-000 ==========
|
||||
ErrorCode MATERIAL_OTHER_NOT_EXISTS = new ErrorCode(1_001_000_001, "物料不存在");
|
||||
ErrorCode ELEMENT_NOT_EXISTS = new ErrorCode(1_001_000_001, "金属元素不存在");
|
||||
ErrorCode ELEMENT_EXISTS = new ErrorCode(1_001_000_002, "金属元素已经存在");
|
||||
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_001_000_001, "联系人不存在");
|
||||
ErrorCode ACCOUNT_NOT_EXISTS = new ErrorCode(1_001_000_001, "账户条款不存在");
|
||||
ErrorCode MATERIAL_DESTROY_NOT_EXISTS = new ErrorCode(1_001_000_001, "物料回收率不存在");
|
||||
|
||||
@@ -88,6 +88,14 @@ public class ElementController {
|
||||
return success(BeanUtils.toBean(pageResult, ElementRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/pageByEnable")
|
||||
@Operation(summary = "获得启用的金属元素分页")
|
||||
@PreAuthorize("@ss.hasPermission('base:element:query')")
|
||||
public CommonResult<PageResult<ElementRespVO>> getElementPageByEnable(@Valid ElementPageReqVO pageReqVO) {
|
||||
PageResult<ElementDO> pageResult = elementService.getElementPageByEnable(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ElementRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出金属元素 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('base:element:export')")
|
||||
|
||||
@@ -40,4 +40,8 @@ public class TemplateInstanceDataRespVO {
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "是否必填", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("是否必填")
|
||||
private String isMust;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ public class TmplInscBsnRelDO extends BusinessBaseDO {
|
||||
/**
|
||||
* 业务主键
|
||||
*/
|
||||
@TableField("BSN_ID")
|
||||
private Long bsnId;
|
||||
@TableField("REL_ID")
|
||||
private Long relativityId;
|
||||
/**
|
||||
* 实例主键
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,7 @@ public interface ElementMapper extends BaseMapperX<ElementDO> {
|
||||
.likeIfPresent(ElementDO::getAbbreviation, reqVO.getAbbreviation())
|
||||
.likeIfPresent(ElementDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ElementDO::getDecimalValue, reqVO.getDecimalValue())
|
||||
.eqIfPresent(ElementDO::getIsEnable, reqVO.getIsEnable())
|
||||
.likeIfPresent(ElementDO::getCoding, reqVO.getCoding())
|
||||
.eqIfPresent(ElementDO::getGradeUnit, reqVO.getGradeUnit())
|
||||
.betweenIfPresent(ElementDO::getCreateTime, reqVO.getCreateTime())
|
||||
@@ -36,4 +37,9 @@ public interface ElementMapper extends BaseMapperX<ElementDO> {
|
||||
.eq(ElementDO::getIsEnable, 1)
|
||||
.orderByDesc(ElementDO::getSort));
|
||||
}
|
||||
|
||||
default ElementDO getElementName(String code){
|
||||
return selectOne(new LambdaQueryWrapperX<ElementDO>()
|
||||
.eq(ElementDO::getAbbreviation, code));
|
||||
};
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public interface TmplInscBsnRelMapper extends BaseMapperX<TmplInscBsnRelDO> {
|
||||
|
||||
default PageResult<TmplInscBsnRelDO> selectPage(TmplInscBsnRelPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<TmplInscBsnRelDO>()
|
||||
.eqIfPresent(TmplInscBsnRelDO::getBsnId, reqVO.getBsnId())
|
||||
.eqIfPresent(TmplInscBsnRelDO::getRelativityId, reqVO.getBsnId())
|
||||
.eqIfPresent(TmplInscBsnRelDO::getInscId, reqVO.getInscId())
|
||||
.eqIfPresent(TmplInscBsnRelDO::getCntt, reqVO.getCntt())
|
||||
.eqIfPresent(TmplInscBsnRelDO::getVer, reqVO.getVer())
|
||||
|
||||
@@ -65,4 +65,6 @@ public interface ElementService {
|
||||
void enableElementList(List<ElementRespVO> saveReqVOS);
|
||||
|
||||
List<ElementDO> getElementNoPage();
|
||||
|
||||
PageResult<ElementDO> getElementPageByEnable(ElementPageReqVO pageReqVO);
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import java.util.List;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.base.enums.ErrorCodeConstants.ELEMENT_EXISTS;
|
||||
import static com.zt.plat.module.base.enums.ErrorCodeConstants.ELEMENT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
@@ -35,6 +36,8 @@ public class ElementServiceImpl implements ElementService {
|
||||
public ElementRespVO createElement(ElementSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
ElementDO element = BeanUtils.toBean(createReqVO, ElementDO.class);
|
||||
// 校验存在
|
||||
validateElementCodeExists(createReqVO.getAbbreviation());
|
||||
//金属编码自动生成,格式 JSYS-00001,依次新增
|
||||
String maxCode = elementMapper.selectMaxCode();
|
||||
if (maxCode == null) {
|
||||
@@ -55,6 +58,8 @@ public class ElementServiceImpl implements ElementService {
|
||||
public void updateElement(ElementSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateElementExists(updateReqVO.getId());
|
||||
// 校验存在
|
||||
validateElementCodeExists(updateReqVO.getAbbreviation());
|
||||
// 更新
|
||||
ElementDO updateObj = BeanUtils.toBean(updateReqVO, ElementDO.class);
|
||||
elementMapper.updateById(updateObj);
|
||||
@@ -69,12 +74,12 @@ public class ElementServiceImpl implements ElementService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteElementListByIds(List<Long> ids) {
|
||||
public void deleteElementListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateElementExists(ids);
|
||||
// 删除
|
||||
elementMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateElementExists(List<Long> ids) {
|
||||
List<ElementDO> list = elementMapper.selectByIds(ids);
|
||||
@@ -89,6 +94,13 @@ public class ElementServiceImpl implements ElementService {
|
||||
}
|
||||
}
|
||||
|
||||
private void validateElementCodeExists(String code) {
|
||||
ElementDO elementDO = elementMapper.getElementName(code);
|
||||
if (elementDO != null) {
|
||||
throw exception(ELEMENT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElementDO getElement(Long id) {
|
||||
return elementMapper.selectById(id);
|
||||
@@ -102,7 +114,7 @@ public class ElementServiceImpl implements ElementService {
|
||||
@Override
|
||||
public void enableElementList(List<ElementRespVO> saveReqVOS) {
|
||||
List<ElementDO> updateObj = BeanUtils.toBean(saveReqVOS, ElementDO.class);
|
||||
List<BatchResult> count = elementMapper.updateById(updateObj);
|
||||
List<BatchResult> count = elementMapper.updateById(updateObj);
|
||||
if (CollUtil.isEmpty(count)) {
|
||||
throw exception(ELEMENT_NOT_EXISTS);
|
||||
}
|
||||
@@ -113,4 +125,12 @@ public class ElementServiceImpl implements ElementService {
|
||||
return elementMapper.getElementNoPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ElementDO> getElementPageByEnable(ElementPageReqVO pageReqVO) {
|
||||
if (pageReqVO!=null&&pageReqVO.getIsEnable()==null){
|
||||
pageReqVO.setIsEnable("1");
|
||||
}
|
||||
return elementMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -420,6 +420,7 @@ public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
||||
if (templateInstanceDataRespVO.getFldKy().equals(tmplTpFldDO.getFldKy())) {
|
||||
templateInstanceDataRespVO.setFldName(tmplTpFldDO.getFldName());
|
||||
templateInstanceDataRespVO.setFldDoc(tmplTpFldDO.getFldDoc());
|
||||
templateInstanceDataRespVO.setIsMust(tmplTpFldDO.getIsMust());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -67,6 +67,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
// fileUpload(createReqVO, templateInstance, type);
|
||||
// 插入
|
||||
TmplInscBsnRelDO tmplInscBsnRel = BeanUtils.toBean(createReqVO, TmplInscBsnRelDO.class);
|
||||
tmplInscBsnRel.setRelativityId(createReqVO.getBsnId());
|
||||
// tmplInscBsnRel.setBsnId(Long.valueOf(createReqVO.getUuid()));
|
||||
tmplInscBsnRelMapper.insert(tmplInscBsnRel);
|
||||
// 返回
|
||||
@@ -81,6 +82,9 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
validateTmplInscBsnRelExists(updateReqVO.getId());
|
||||
// 更新
|
||||
TmplInscBsnRelDO updateObj = BeanUtils.toBean(updateReqVO, TmplInscBsnRelDO.class);
|
||||
if (updateReqVO.getBsnId()!=null){
|
||||
updateObj.setRelativityId(updateReqVO.getBsnId());
|
||||
}
|
||||
tmplInscBsnRelMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@@ -99,9 +103,9 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
// 校验存在
|
||||
validateTmplInscBsnRelExists(ids);
|
||||
//删除业务实例字段值
|
||||
deleteFldOrItmByIds(tmplInscBsnRelMapper.selectByIds(ids).stream().map(TmplInscBsnRelDO::getBsnId).map(String::valueOf).toList(), tmplInscDatBsnService);
|
||||
deleteFldOrItmByIds(tmplInscBsnRelMapper.selectByIds(ids).stream().map(TmplInscBsnRelDO::getRelativityId).map(String::valueOf).toList(), tmplInscDatBsnService);
|
||||
//删除业务实例字段值
|
||||
deleteFldOrItmByIds(tmplInscBsnRelMapper.selectByIds(ids).stream().map(TmplInscBsnRelDO::getBsnId).map(String::valueOf).toList(), tmplInscItmBsnService);
|
||||
deleteFldOrItmByIds(tmplInscBsnRelMapper.selectByIds(ids).stream().map(TmplInscBsnRelDO::getRelativityId).map(String::valueOf).toList(), tmplInscItmBsnService);
|
||||
tmplInscBsnRelMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
@@ -155,7 +159,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
@Override
|
||||
public void updateCntt(Long bsnId, String params) {
|
||||
List<TmplInscBsnRelDO> tmplInscBsnRelDOS = tmplInscBsnRelMapper.selectList(new LambdaQueryWrapper<TmplInscBsnRelDO>()
|
||||
.eq(TmplInscBsnRelDO::getBsnId, bsnId).orderByDesc(TmplInscBsnRelDO::getVer)
|
||||
.eq(TmplInscBsnRelDO::getRelativityId, bsnId).orderByDesc(TmplInscBsnRelDO::getVer)
|
||||
);
|
||||
if (tmplInscBsnRelDOS.isEmpty()) {
|
||||
throw exception(TEMPLATE_INSTANCE_FILE_NOT_EXISTS);
|
||||
@@ -170,7 +174,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
//业务条款
|
||||
private List<TmplInscItmBsnRespVO> setTmplInscItmBsnRespVOS(TmplInscBsnRelRespVO tmplInscBsnRelRespVO) {
|
||||
List<TmplInscItmBsnRespVO> tmplInscItmBsnRespVOS = BeanUtils.toBean(SpringUtil.getBean(TmplInscItmBsnMapper.class).selectList(new LambdaQueryWrapper<TmplInscItmBsnDO>()
|
||||
.eq(TmplInscItmBsnDO::getBsnId, tmplInscBsnRelRespVO.getBsnId())
|
||||
.eq(TmplInscItmBsnDO::getBsnId, tmplInscBsnRelRespVO.getId())
|
||||
), TmplInscItmBsnRespVO.class);
|
||||
// tmplInscItmBsnRespVOS.forEach(tmplInscItmBsnRespVO -> {
|
||||
// tmplInscBsnRelRespVO.getInstanceItemRespVOS().forEach(instanceItemRespVO -> {
|
||||
@@ -184,7 +188,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
|
||||
//业务字段
|
||||
private List<TmplInscDatBsnRespVO> setTmplInscDatBsnRespVOS(TmplInscBsnRelRespVO tmplInscBsnRelRespVO) {
|
||||
List<TmplInscDatBsnRespVO> tmplInscDatBsnRespVOS = BeanUtils.toBean(SpringUtil.getBean(TmplInscDatBsnMapper.class).selectList(new LambdaQueryWrapper<TmplInscDatBsnDO>()), TmplInscDatBsnRespVO.class);
|
||||
List<TmplInscDatBsnRespVO> tmplInscDatBsnRespVOS = BeanUtils.toBean(SpringUtil.getBean(TmplInscDatBsnMapper.class).selectList(new LambdaQueryWrapper<TmplInscDatBsnDO>().eq(TmplInscDatBsnDO::getBsnId, tmplInscBsnRelRespVO.getId())), TmplInscDatBsnRespVO.class);
|
||||
|
||||
// tmplInscDatBsnRespVOS.forEach(tmplInscDatBsnRespVO -> tmplInscBsnRelRespVO.getTemplateInstanceDataRespVOS().forEach(templateInstanceDataRespVO -> {
|
||||
// if (templateInstanceDataRespVO.getId().toString().equals(tmplInscDatBsnRespVO.getInscFldId())) {
|
||||
@@ -300,7 +304,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
public Map<String, Object> valueInfo(String cttId, String inscId) {
|
||||
// 1、通过实例和合同Id获取业务
|
||||
TmplInscBsnRelDO tmplInscBsnRelDO = tmplInscBsnRelMapper.selectOne(
|
||||
TmplInscBsnRelDO::getBsnId, cttId,
|
||||
TmplInscBsnRelDO::getRelativityId, cttId,
|
||||
TmplInscBsnRelDO::getInscId, inscId
|
||||
);
|
||||
if (tmplInscBsnRelDO == null) {
|
||||
@@ -310,7 +314,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
List<ValueInfo> valueInfoS = new ArrayList<>();
|
||||
// 2、获取绑定的字段
|
||||
List<TmplInscDatBsnRespVO> tmplInscDatBsnList = tmplInscDatBsnService
|
||||
.getTmplInscDatBsnListByBsnId(String.valueOf(tmplInscBsnRelDO.getBsnId()));
|
||||
.getTmplInscDatBsnListByBsnId(String.valueOf(tmplInscBsnRelDO.getRelativityId()));
|
||||
|
||||
|
||||
Optional.ofNullable(tmplInscDatBsnList)
|
||||
@@ -326,7 +330,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
}));
|
||||
|
||||
// 3、获取条款
|
||||
List<TmplInscItmBsnRespVO> tmplInscItmBsnList = tmplInscItmBsnService.getTmplInscItmBsnList(String.valueOf(tmplInscBsnRelDO.getBsnId()));
|
||||
List<TmplInscItmBsnRespVO> tmplInscItmBsnList = tmplInscItmBsnService.getTmplInscItmBsnList(String.valueOf(tmplInscBsnRelDO.getRelativityId()));
|
||||
Optional.ofNullable(tmplInscItmBsnList)
|
||||
.ifPresent(list -> list.forEach(tmplInscItmBsnRespVO -> {
|
||||
ValueInfo valueInfo = new ValueInfo(
|
||||
@@ -345,7 +349,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
@Override
|
||||
public TmplInscBsnRelRespVO bseInfo(String cttId, String inscId) {
|
||||
TmplInscBsnRelDO tmplInscBsnRelDO = tmplInscBsnRelMapper.selectOne(
|
||||
TmplInscBsnRelDO::getBsnId, cttId,
|
||||
TmplInscBsnRelDO::getRelativityId, cttId,
|
||||
TmplInscBsnRelDO::getInscId, inscId
|
||||
);
|
||||
return BeanUtils.toBean(tmplInscBsnRelDO, TmplInscBsnRelRespVO.class);
|
||||
@@ -362,7 +366,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
List<ValueInfo> valueInfoS = new ArrayList<>();
|
||||
// 2、获取绑定的字段
|
||||
List<TmplInscDatBsnRespVO> tmplInscDatBsnList = tmplInscDatBsnService
|
||||
.getTmplInscDatBsnListByBsnId(String.valueOf(tmplInscBsnRelDO.getBsnId()));
|
||||
.getTmplInscDatBsnListByBsnId(String.valueOf(tmplInscBsnRelDO.getRelativityId()));
|
||||
|
||||
|
||||
Optional.ofNullable(tmplInscDatBsnList)
|
||||
@@ -378,7 +382,7 @@ public class TmplInscBsnRelServiceImpl implements TmplInscBsnRelService {
|
||||
}));
|
||||
|
||||
// 3、获取条款
|
||||
List<TmplInscItmBsnRespVO> tmplInscItmBsnList = tmplInscItmBsnService.getTmplInscItmBsnList(String.valueOf(tmplInscBsnRelDO.getBsnId()));
|
||||
List<TmplInscItmBsnRespVO> tmplInscItmBsnList = tmplInscItmBsnService.getTmplInscItmBsnList(String.valueOf(tmplInscBsnRelDO.getRelativityId()));
|
||||
Optional.ofNullable(tmplInscItmBsnList)
|
||||
.ifPresent(list -> list.forEach(tmplInscItmBsnRespVO -> {
|
||||
ValueInfo valueInfo = new ValueInfo(
|
||||
|
||||
@@ -242,6 +242,30 @@ public class ContractRespDTO {
|
||||
@Schema(description = "模板中间表ID")
|
||||
private Long businessId;
|
||||
|
||||
@Schema(description = "甲方户名")
|
||||
private String purchaseAccountName;
|
||||
|
||||
@Schema(description = "甲方开户行")
|
||||
private String purchaseBankAccount;
|
||||
|
||||
@Schema(description = "甲方户号")
|
||||
private String purchaseAccountNumber;
|
||||
|
||||
@Schema(description = "甲方税号/社会信用代码")
|
||||
private String purchaseTaxNumber;
|
||||
|
||||
@Schema(description = "乙方户名")
|
||||
private String salesAccountName;
|
||||
|
||||
@Schema(description = "乙方开户行")
|
||||
private String salesBankAccount;
|
||||
|
||||
@Schema(description = "乙方户号")
|
||||
private String salesAccountNumber;
|
||||
|
||||
@Schema(description = "乙方税号/社会信用代码")
|
||||
private String salesTaxNumber;
|
||||
|
||||
// 物料信息
|
||||
private List<DetailRespDTO> detail;
|
||||
|
||||
|
||||
@@ -248,6 +248,30 @@ public class ContractRespVO {
|
||||
@Schema(description = "模板中间表ID")
|
||||
private Long businessId;
|
||||
|
||||
@Schema(description = "甲方户名")
|
||||
private String purchaseAccountName;
|
||||
|
||||
@Schema(description = "甲方开户行")
|
||||
private String purchaseBankAccount;
|
||||
|
||||
@Schema(description = "甲方户号")
|
||||
private String purchaseAccountNumber;
|
||||
|
||||
@Schema(description = "甲方税号/社会信用代码")
|
||||
private String purchaseTaxNumber;
|
||||
|
||||
@Schema(description = "乙方户名")
|
||||
private String salesAccountName;
|
||||
|
||||
@Schema(description = "乙方开户行")
|
||||
private String salesBankAccount;
|
||||
|
||||
@Schema(description = "乙方户号")
|
||||
private String salesAccountNumber;
|
||||
|
||||
@Schema(description = "乙方税号/社会信用代码")
|
||||
private String salesTaxNumber;
|
||||
|
||||
// 物料信息
|
||||
private List<DetailRespVO> detail;
|
||||
|
||||
|
||||
@@ -218,6 +218,30 @@ public class ContractSaveReqVO {
|
||||
@Schema(description = "模板中间表ID")
|
||||
private Long businessId;
|
||||
|
||||
@Schema(description = "甲方户名")
|
||||
private String purchaseAccountName;
|
||||
|
||||
@Schema(description = "甲方开户行")
|
||||
private String purchaseBankAccount;
|
||||
|
||||
@Schema(description = "甲方户号")
|
||||
private String purchaseAccountNumber;
|
||||
|
||||
@Schema(description = "甲方税号/社会信用代码")
|
||||
private String purchaseTaxNumber;
|
||||
|
||||
@Schema(description = "乙方户名")
|
||||
private String salesAccountName;
|
||||
|
||||
@Schema(description = "乙方开户行")
|
||||
private String salesBankAccount;
|
||||
|
||||
@Schema(description = "乙方户号")
|
||||
private String salesAccountNumber;
|
||||
|
||||
@Schema(description = "乙方税号/社会信用代码")
|
||||
private String salesTaxNumber;
|
||||
|
||||
// 物料信息
|
||||
private List<DetailSaveReqVO> detail;
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.zt.plat.module.contractorder.api.vo.contract;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 合同交易信息 Response VO")
|
||||
@Data
|
||||
public class TransactionInfoRespVO {
|
||||
|
||||
@Schema(description = "公司编号")
|
||||
private String companyNumber;
|
||||
|
||||
@Schema(description = "公司名称")
|
||||
private String companyName;
|
||||
|
||||
@Schema(description = "公司户名")
|
||||
private String companyAccountName;
|
||||
|
||||
@Schema(description = "公司开户行")
|
||||
private String companyBankAccount;
|
||||
|
||||
@Schema(description = "公司户号")
|
||||
private String companyAccountNumber;
|
||||
|
||||
@Schema(description = "公司税号/社会信用代码")
|
||||
private String companyTaxNumber;
|
||||
|
||||
@Schema(description = "客商编号")
|
||||
private String supplierNumber;
|
||||
|
||||
@Schema(description = "客商名称")
|
||||
private String supplierName;
|
||||
|
||||
@Schema(description = "客商户名")
|
||||
private String supplierAccountName;
|
||||
|
||||
@Schema(description = "客商开户行")
|
||||
private String supplierBankAccount;
|
||||
|
||||
@Schema(description = "客商户号")
|
||||
private String supplierAccountNumber;
|
||||
|
||||
@Schema(description = "客商税号/社会信用代码")
|
||||
private String supplierTaxNumber;
|
||||
}
|
||||
@@ -26,9 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.error;
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
import static com.zt.plat.module.contractorder.enums.ErrorCodeConstants.CONTRACT_SUBMIT_ERP_FAIL;
|
||||
|
||||
@Slf4j
|
||||
@Tag(name = "管理后台 - 合同管理")
|
||||
@@ -155,8 +153,10 @@ public class ContractController implements BusinessControllerMarker {
|
||||
@Operation(summary = "提交ERP")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:erp')")
|
||||
public CommonResult<JSONObject> submitErp(@RequestParam("id") Long id) {
|
||||
JSONObject res = contractService.submitErp(id);
|
||||
return res.getBool("success") ? success(res) : error(CONTRACT_SUBMIT_ERP_FAIL.getCode(), res.getStr("data"));
|
||||
// JSONObject res = contractService.submitErp(id);
|
||||
// return res.getBool("success") ? success(res) : error(CONTRACT_SUBMIT_ERP_FAIL.getCode(), res.getStr("data"));
|
||||
// TODO ERP默认返回成功处理 SZHGYL-251
|
||||
return success(new JSONObject().putOnce("success", true));
|
||||
}
|
||||
|
||||
@GetMapping("/list/up-not-relation")
|
||||
@@ -213,5 +213,14 @@ public class ContractController implements BusinessControllerMarker {
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:query')")
|
||||
public CommonResult<List<PurchaseOrderWithDetailsDTO>> getOrderByOrderNo(@RequestBody List<String> orderNoS){
|
||||
return contractApi.getOrderByOrderNo(orderNoS);
|
||||
};
|
||||
}
|
||||
|
||||
@GetMapping("/transaction-info/by-paper-number")
|
||||
@Operation(summary = "根据合同编号获得交易信息")
|
||||
@PreAuthorize("@ss.hasPermission('base:contract:get')")
|
||||
public CommonResult<TransactionInfoRespVO> transactionInfoByPaperNumber(
|
||||
@RequestParam("contractPaperNumber") String contractPaperNumber
|
||||
) {
|
||||
return success(contractService.transactionInfoByPaperNumber(contractPaperNumber));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,4 +195,9 @@ public class PurchaseOrderDetailsRespVO {
|
||||
* 订单类型
|
||||
*/
|
||||
private String splyBsnTp;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String unt;
|
||||
}
|
||||
|
||||
@@ -410,4 +410,44 @@ public class ContractMainDO extends BusinessBaseDO {
|
||||
*/
|
||||
@TableField("BSN_ID")
|
||||
private Long businessId;
|
||||
/**
|
||||
* 甲方户名
|
||||
*/
|
||||
@TableField("PRCH_ACCT_NAME")
|
||||
private String purchaseAccountName;
|
||||
/**
|
||||
* 甲方开户行
|
||||
*/
|
||||
@TableField("PRCH_BNK_ACCT")
|
||||
private String purchaseBankAccount;
|
||||
/**
|
||||
* 甲方户号
|
||||
*/
|
||||
@TableField("PRCH_ACCT_NUM")
|
||||
private String purchaseAccountNumber;
|
||||
/**
|
||||
* 甲方税号/社会信用代码
|
||||
*/
|
||||
@TableField("PRCH_TAX_NUM")
|
||||
private String purchaseTaxNumber;
|
||||
/**
|
||||
* 乙方户名
|
||||
*/
|
||||
@TableField("SALE_ACCT_NAME")
|
||||
private String salesAccountName;
|
||||
/**
|
||||
* 乙方开户行
|
||||
*/
|
||||
@TableField("SALE_BNK_ACCT")
|
||||
private String salesBankAccount;
|
||||
/**
|
||||
* 乙方户号
|
||||
*/
|
||||
@TableField("SALE_ACCT_NUM")
|
||||
private String salesAccountNumber;
|
||||
/**
|
||||
* 乙方税号/社会信用代码
|
||||
*/
|
||||
@TableField("SALE_TAX_NUM")
|
||||
private String salesTaxNumber;
|
||||
}
|
||||
@@ -231,4 +231,12 @@ public interface ContractService {
|
||||
* @return 系统合同编号
|
||||
*/
|
||||
String generateSystemContractNumber(String category);
|
||||
|
||||
/**
|
||||
* 根据合同编号获得交易信息
|
||||
*
|
||||
* @param contractPaperNumber 合同编号
|
||||
* @return 交易信息
|
||||
*/
|
||||
TransactionInfoRespVO transactionInfoByPaperNumber(String contractPaperNumber);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@ import com.zt.plat.module.base.controller.admin.templtp.vo.TmplInscBsnRelSaveReq
|
||||
import com.zt.plat.module.base.controller.admin.templtp.vo.TmplInscDatBsnSaveReqVO;
|
||||
import com.zt.plat.module.base.controller.admin.templtp.vo.TmplInscItmBsnSaveReqVO;
|
||||
import com.zt.plat.module.base.dal.dataobject.tmpltp.TmplInscBsnRelDO;
|
||||
import com.zt.plat.module.base.dal.mysql.tmpltp.TemplateInstanceDataMapper;
|
||||
import com.zt.plat.module.base.dal.mysql.tmpltp.TemplateInstanceItemMapper;
|
||||
import com.zt.plat.module.base.dal.mysql.tmpltp.TmplInscBsnRelMapper;
|
||||
import com.zt.plat.module.base.service.tmpltp.TemplateInstanceDataService;
|
||||
import com.zt.plat.module.base.service.tmpltp.TmplInscBsnRelService;
|
||||
import com.zt.plat.module.base.service.tmpltp.TmplInscDatBsnService;
|
||||
import com.zt.plat.module.base.service.tmpltp.TmplInscItmBsnService;
|
||||
@@ -40,7 +37,6 @@ import com.zt.plat.module.contractorder.enums.contract.DictEnum;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractPageReqVO;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpContractSaveReqVO;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpContractDO;
|
||||
import com.zt.plat.module.erp.service.erp.ErpCompanyService;
|
||||
import com.zt.plat.module.erp.service.erp.ErpContractService;
|
||||
import com.zt.plat.module.infra.api.file.FileApi;
|
||||
import com.zt.plat.module.infra.api.file.dto.FileRespDTO;
|
||||
@@ -88,12 +84,6 @@ public class ContractServiceImpl implements ContractService {
|
||||
@Resource
|
||||
private ContractPlanMapper contractPlanMapper;
|
||||
@Resource
|
||||
private TemplateInstanceDataService templateInstanceDataService;
|
||||
@Resource
|
||||
private TemplateInstanceDataMapper templateInstanceDataMapper;
|
||||
@Resource
|
||||
private TemplateInstanceItemMapper templateInstanceItemMapper;
|
||||
@Resource
|
||||
private ContractFormulaMapper contractFormulaMapper;
|
||||
@Resource
|
||||
private ContractCoefficientMapper contractCoefficientMapper;
|
||||
@@ -114,8 +104,6 @@ public class ContractServiceImpl implements ContractService {
|
||||
@Resource
|
||||
private ContractDemoteMapper contractDemoteMapper;
|
||||
@Resource
|
||||
private ErpCompanyService erpCompanyService;
|
||||
@Resource
|
||||
private ErpContractService erpContractService;
|
||||
@Resource
|
||||
private SystemRelativityMapper systemRelativityMapper;
|
||||
@@ -1255,8 +1243,26 @@ public class ContractServiceImpl implements ContractService {
|
||||
queryReqVO.getElementName()
|
||||
);
|
||||
|
||||
// 分页返回
|
||||
return new PageResult<FormulaRespVO>().setTotal(ipage.getTotal()).setList(ipage.getRecords());
|
||||
// 分页返回结果
|
||||
PageResult<FormulaRespVO> results = new PageResult<FormulaRespVO>().setTotal(ipage.getTotal()).setList(ipage.getRecords());
|
||||
if (results.getTotal() > 0) {
|
||||
results.getList().forEach(respVO -> {
|
||||
// 基础系数配置
|
||||
List<ContractCoefficientDO> coefficientDOS = contractCoefficientMapper.selectList("FMU_ID", respVO.getId());
|
||||
respVO.setCoefficients(BeanUtils.toBean(coefficientDOS, CoefficientRespVO.class));
|
||||
// 品位等级价配置
|
||||
List<ContractGradeDO> gradeDOS = contractGradeMapper.selectList("FMU_ID", respVO.getId());
|
||||
respVO.setGrades(BeanUtils.toBean(gradeDOS, GradeRespVO.class));
|
||||
// 调整价配置
|
||||
List<ContractDeductDO> deductDOS = contractDeductMapper.selectList("FMU_ID", respVO.getId());
|
||||
respVO.setDeducts(BeanUtils.toBean(deductDOS, DeductRespVO.class));
|
||||
// 市场价配置
|
||||
List<ContractPriceDO> priceDOS = contractPriceMapper.selectList("FMU_ID", respVO.getId());
|
||||
respVO.setPrices(BeanUtils.toBean(priceDOS, PriceRespVO.class));
|
||||
});
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1803,6 +1809,53 @@ public class ContractServiceImpl implements ContractService {
|
||||
return erpContractVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionInfoRespVO transactionInfoByPaperNumber(String contractPaperNumber) {
|
||||
|
||||
// 通过合同编号查询合同信息
|
||||
ContractMainDO contractMainDO = contractMainMapper
|
||||
.selectOne(TableFieldConstants.BSE_CTRT_MAIN_CTRT_PPR_NUM, contractPaperNumber);
|
||||
|
||||
// 合同不存在
|
||||
if (contractMainDO == null) {
|
||||
throw exception(CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 交易信息
|
||||
TransactionInfoRespVO infoRespVO = new TransactionInfoRespVO();
|
||||
|
||||
if (DictEnum.ERP_RCV_DLVY_INCOME.getCode().equals(contractMainDO.getDirection())) { // 收入
|
||||
// 收支性质为收入,公司信息为乙方信息,客商信息为甲方信息
|
||||
infoRespVO.setCompanyNumber(contractMainDO.getSalesCompanyNumber());
|
||||
infoRespVO.setCompanyName(contractMainDO.getSalesCompanyName());
|
||||
infoRespVO.setCompanyAccountName(contractMainDO.getSalesAccountName());
|
||||
infoRespVO.setCompanyBankAccount(contractMainDO.getSalesBankAccount());
|
||||
infoRespVO.setCompanyAccountNumber(contractMainDO.getSalesAccountNumber());
|
||||
infoRespVO.setCompanyTaxNumber(contractMainDO.getSalesTaxNumber());
|
||||
infoRespVO.setSupplierName(contractMainDO.getPurchaseCompanyNumber());
|
||||
infoRespVO.setSupplierName(contractMainDO.getPurchaseCompanyName());
|
||||
infoRespVO.setSupplierAccountName(contractMainDO.getPurchaseAccountName());
|
||||
infoRespVO.setSupplierBankAccount(contractMainDO.getPurchaseBankAccount());
|
||||
infoRespVO.setSupplierAccountNumber(contractMainDO.getPurchaseAccountNumber());
|
||||
infoRespVO.setSupplierTaxNumber(contractMainDO.getPurchaseTaxNumber());
|
||||
} else { // 支出
|
||||
// 收支性质为支出,公司信息为甲方信息,客商信息为乙方信息
|
||||
infoRespVO.setCompanyNumber(contractMainDO.getPurchaseCompanyNumber());
|
||||
infoRespVO.setCompanyName(contractMainDO.getPurchaseCompanyName());
|
||||
infoRespVO.setCompanyAccountName(contractMainDO.getPurchaseAccountName());
|
||||
infoRespVO.setCompanyBankAccount(contractMainDO.getPurchaseBankAccount());
|
||||
infoRespVO.setCompanyAccountNumber(contractMainDO.getPurchaseAccountNumber());
|
||||
infoRespVO.setCompanyTaxNumber(contractMainDO.getPurchaseTaxNumber());
|
||||
infoRespVO.setSupplierName(contractMainDO.getSalesCompanyNumber());
|
||||
infoRespVO.setSupplierName(contractMainDO.getSalesCompanyName());
|
||||
infoRespVO.setSupplierAccountName(contractMainDO.getSalesAccountName());
|
||||
infoRespVO.setSupplierBankAccount(contractMainDO.getSalesBankAccount());
|
||||
infoRespVO.setSupplierAccountNumber(contractMainDO.getSalesAccountNumber());
|
||||
infoRespVO.setSupplierTaxNumber(contractMainDO.getSalesTaxNumber());
|
||||
}
|
||||
return infoRespVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验合同内容
|
||||
*
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.zt.plat.module.erp.api;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitRespDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.*;
|
||||
import com.zt.plat.module.erp.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -13,6 +11,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME)
|
||||
@Tag(name = "RPC 服务 - ERP")
|
||||
@@ -23,4 +22,13 @@ public interface InvoiceticketApi {
|
||||
@PostMapping(PREFIX + "/submit")
|
||||
@Operation(summary = "erp数据提交")
|
||||
CommonResult<ErpInvoiceticketSubmitRespDTO> submitDataToErp(@Valid @RequestBody ErpInvoiceticketSubmitReqDTO reqDTO);
|
||||
@PostMapping(PREFIX + "/submit098")
|
||||
@Operation(summary = "erp数据提交,参数需要billdoc和action,id")
|
||||
CommonResult<HashMap<String, String>> submitDataToErp098(@Valid @RequestBody Map<String,Object> reqDTO);
|
||||
@PostMapping(PREFIX + "/submit096")
|
||||
@Operation(summary = "erp数据提交,参数需要billdoc和action,id")
|
||||
CommonResult<HashMap<String, String>> submitDataToErp096(@Valid @RequestBody ErpElectronicInvoiceSubmitReqDTO reqDTO);
|
||||
@PostMapping(PREFIX + "/submit097")
|
||||
@Operation(summary = "erp数据提交")
|
||||
CommonResult<HashMap<String, String>> submitDataToErp097(@Valid @RequestBody ErpElectronicInvoiceReversalReqDTO reqDTO);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.zt.plat.module.erp.api.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "管理后台 - 电子发票冲销请求DTO")
|
||||
public class ErpElectronicInvoiceReversalReqDTO {
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "要冲销的发票号;长度10位字符", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String billdoc;
|
||||
|
||||
@Schema(description = "冲销过账日期;格式为YYYYMMDD(如20251106)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String postingdate;
|
||||
|
||||
@Schema(description = "冲销原因描述;长度200位字符", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "不开具电子发票;X-不开票;长度1位字符")
|
||||
private String no_invoicing;
|
||||
|
||||
@Schema(description = "红冲原因枚举值;no_invoicing为空时必填;枚举值:开票有误、销货退回、服务终止、销售折让;长度20位字符", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String reversal_reason;
|
||||
|
||||
@Schema(description = "冲销相关附件列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<String> filedata;
|
||||
|
||||
// @Data
|
||||
// @Schema(description = "冲销附件信息")
|
||||
// public static class InvoiceReversalFileData {
|
||||
//
|
||||
// @Schema(description = "文件名;必须带文件后缀名;长度200位字符", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
// private String filename;
|
||||
//
|
||||
// @Schema(description = "文件内容;BASE64编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
// private String filect;
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.zt.plat.module.erp.api.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "管理后台 - 电子发票开具请求DTO")
|
||||
public class ErpElectronicInvoiceSubmitReqDTO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String id;
|
||||
|
||||
@Schema(description = "开票日期;格式为YYYYMMDD(如20251106)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String bill_date;
|
||||
|
||||
@Schema(description = "是否暂估开票;长度1位字符")
|
||||
private String provi_estimate;
|
||||
|
||||
@Schema(description = "发票抬头文本;长度25位字符")
|
||||
private String bill_text;
|
||||
|
||||
@Schema(description = "最晚收款日期;格式为YYYYMMDD(如20251106)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String bline_date;
|
||||
|
||||
@Schema(description = "不开具电子发票;X-不开票;长度1位字符")
|
||||
private String no_invoicing;
|
||||
|
||||
@Schema(description = "电子发票类型;no_invoicing为空时必填;05-普通发票,06-增值税专用发票;长度2位字符")
|
||||
private String invoice_type;
|
||||
|
||||
@Schema(description = "电子发票备注;会带入到电子发票上;长度200位字符")
|
||||
private String invoice_note;
|
||||
|
||||
@Schema(description = "红冲原因;no_invoicing为空且生成的是红字发票时必填;枚举值:开票有误、销货退回、服务终止、销售折让;长度20位字符")
|
||||
private String reversal_reason;
|
||||
|
||||
@Schema(description = "发票行项目列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<InvoiceItem> item;
|
||||
|
||||
@Schema(description = "发票条件明细列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<String> cond;
|
||||
|
||||
@Schema(description = "发票附件列表")
|
||||
private List<InvoiceFileData> filedata;
|
||||
|
||||
@Data
|
||||
@Schema(description = "发票行项目明细")
|
||||
public static class InvoiceItem {
|
||||
|
||||
@Schema(description = "发票行号;从1开始顺序编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer data_index;
|
||||
|
||||
@Schema(description = "参照类别;C-参照销售订单开票,J-根据交货单开票", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String ref_doc_ca;
|
||||
|
||||
@Schema(description = "参照单号;长度10位字符", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String ref_doc;
|
||||
|
||||
@Schema(description = "参照行号;长度6位数字", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String ref_item;
|
||||
|
||||
@Schema(description = "开票数量;保留3位小数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal req_qty;
|
||||
|
||||
@Schema(description = "规格型号;会带入到电子发票上;长度100位字符")
|
||||
private String model_note;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Schema(description = "发票条件明细")
|
||||
public static class InvoiceCond {
|
||||
|
||||
@Schema(description = "发票行号;与item-data_index关联", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer data_index;
|
||||
|
||||
@Schema(description = "条件类型;长度4位字符", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String cond_type;
|
||||
|
||||
@Schema(description = "条件金额;保留4位小数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal cond_value;
|
||||
|
||||
@Schema(description = "货币码;长度5位字符", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String cond_curr;
|
||||
|
||||
@Schema(description = "条件单位;使用基本计量单位;长度3位字符", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String cond_d_unt;
|
||||
|
||||
@Schema(description = "条件定价单位;固定值1;长度5位数字", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private BigDecimal cond_p_unt;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Schema(description = "发票附件信息")
|
||||
public static class InvoiceFileData {
|
||||
|
||||
@Schema(description = "文件名;必须带文件后缀名;长度200位字符", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String filename;
|
||||
|
||||
@Schema(description = "文件内容;BASE64编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String filect;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.zt.plat.module.erp.api;
|
||||
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.erp.api.dto.ErpElectronicInvoiceReversalReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpElectronicInvoiceSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitRespDTO;
|
||||
import com.zt.plat.module.erp.service.erp.ErpInvoiceticketService;
|
||||
@@ -9,6 +11,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController
|
||||
@@ -22,4 +27,19 @@ public class InvoiceticketImpl implements InvoiceticketApi {
|
||||
public CommonResult<ErpInvoiceticketSubmitRespDTO> submitDataToErp(ErpInvoiceticketSubmitReqDTO reqDTO) {
|
||||
return success(erpInvoiceticketService.sbumitToErp020(reqDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<HashMap<String, String>> submitDataToErp098(Map<String, Object> reqDTO) {
|
||||
return success(erpInvoiceticketService.sbumitToErp098(reqDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<HashMap<String, String>> submitDataToErp096(ErpElectronicInvoiceSubmitReqDTO reqDTO) {
|
||||
return success(erpInvoiceticketService.sbumitToErp096(reqDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<HashMap<String, String>> submitDataToErp097(ErpElectronicInvoiceReversalReqDTO reqDTO) {
|
||||
return success(erpInvoiceticketService.sbumitToErp097(reqDTO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,12 +125,4 @@ public class ErpCompanyController {
|
||||
return success(TEST);
|
||||
}
|
||||
|
||||
@PostMapping("/test2")
|
||||
@Operation(summary = "获取base的金属元素")
|
||||
@PreAuthorize("@ss.hasPermission('sply:erp-company:get')")
|
||||
public CommonResult<String> test2() {
|
||||
String TEST = erpCompanyService.test2();
|
||||
return success(TEST);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class ErpProductiveOrderPageReqVO extends PageParam {
|
||||
private String companyNumber;
|
||||
|
||||
@Schema(description = "工厂编码")
|
||||
@NotEmpty(message = "公司编号不能为空")
|
||||
@NotEmpty(message = "工厂编码不能为空")
|
||||
private String factoryNumber;
|
||||
|
||||
@Schema(description = "工厂名称", example = "赵六")
|
||||
@@ -30,12 +30,12 @@ public class ErpProductiveOrderPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "基本开始日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@NotEmpty(message = "公司编号不能为空")
|
||||
@NotEmpty(message = "基本开始日期不能为空")
|
||||
private LocalDateTime[] startDate;
|
||||
|
||||
@Schema(description = "基本完成日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@NotEmpty(message = "公司编号不能为空")
|
||||
@NotEmpty(message = "基本完成日期不能为空")
|
||||
private LocalDateTime[] endDate;
|
||||
|
||||
@Schema(description = "主产品物料编号")
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpCustomerPageReqVO;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpCustomerDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ERP客商主数据 Mapper
|
||||
@@ -29,4 +32,5 @@ public interface ErpCustomerMapper extends BaseMapperX<ErpCustomerDO> {
|
||||
.orderByDesc(ErpCustomerDO::getId));
|
||||
}
|
||||
|
||||
void updateBatchByNumber(@Param("toUpdate") List<ErpCustomerDO> toUpdate);
|
||||
}
|
||||
@@ -74,6 +74,4 @@ public interface ErpCompanyService {
|
||||
void test();
|
||||
|
||||
String test1();
|
||||
|
||||
String test2();
|
||||
}
|
||||
@@ -286,11 +286,4 @@ public class ErpCompanyServiceImpl implements ErpCompanyService {
|
||||
return url + requestEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String test2() {
|
||||
ElementDTO respVO = new ElementDTO();
|
||||
CommonResult<List<ElementDTO>> dtos = baseApi.getElementNoPage();
|
||||
return dtos.toString();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpMaterialDO;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
@@ -113,31 +114,37 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.客商信息;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
String key = "erp" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCache(key) == null) {
|
||||
initialize(key);
|
||||
}
|
||||
// 构建req参数
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
List<Map<String, String>> datumList = new ArrayList<>();
|
||||
Map<String, String> datumEntry = new HashMap<>();
|
||||
// 构建datum参数数组
|
||||
datumEntry.put("sign", "I");
|
||||
datumEntry.put("option", "EQ");
|
||||
datumEntry.put("low", LocalDate.now().toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
|
||||
// 1. 调用ERP接口获取数据
|
||||
//循环近五年日期,
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
for (OftenEnum.ModeTypeEnum type : OftenEnum.ModeTypeEnum.values()) {
|
||||
req.put("mode", type.modetype);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get(funcnrEnum.getDatakey());
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
LocalDate endDate = LocalDate.now();
|
||||
LocalDate startDate = endDate.minusYears(5);
|
||||
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||||
// 构建req参数
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
List<Map<String, String>> datumList = new ArrayList<>();
|
||||
Map<String, String> datumEntry = new HashMap<>();
|
||||
// 构建datum参数数组
|
||||
datumEntry.put("sign", "I");
|
||||
datumEntry.put("option", "EQ");
|
||||
// 把每次循环的日期,放在这里
|
||||
datumEntry.put("low", date.toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (OftenEnum.ModeTypeEnum type : OftenEnum.ModeTypeEnum.values()) {
|
||||
req.put("MODE", type.modetype);
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get(funcnrEnum.getDatakey());
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
return;
|
||||
@@ -153,17 +160,18 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
/**
|
||||
* 处理数据,区分新增和更新
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnrEnum) {
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erp" + funcnr.getFuncnr();
|
||||
Map<String, List<String>> numbers = myRedisConfig.numbers(dataArray, key, funcnr.getDatakey());
|
||||
List<String> allnumbers = numbers.get("all");
|
||||
List<String> comnumbers = numbers.get("com");
|
||||
List<ErpCustomerDO> toUpdate = new ArrayList<>();
|
||||
List<ErpCustomerDO> toInsert = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
if (dataJson != null) {
|
||||
String number = dataJson.getString(funcnrEnum.getDatakey());
|
||||
String number = dataJson.getString(funcnr.getDatakey());
|
||||
if (number != null) {
|
||||
number = number.trim();
|
||||
}
|
||||
@@ -185,10 +193,8 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
DO.setIsProvisional(dataJson.getString("XBLCK"));
|
||||
DO.setTaxNumber(dataJson.getString("TAXNO"));
|
||||
|
||||
// 使用 Map 优化查找效率,避免每次遍历 comnumbers 列表
|
||||
if (number != null && numbers.get(number) != null) {
|
||||
if (comnumbers.contains(number)) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
} else {
|
||||
// 新增
|
||||
@@ -197,7 +203,7 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
}
|
||||
}
|
||||
|
||||
return new ProcessingResult(toUpdate, toInsert, key);
|
||||
return new ProcessingResult(toUpdate, toInsert, key, allnumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,21 +213,11 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
// 批量新增和更新
|
||||
if (!result.toInsert.isEmpty()) {
|
||||
erpCustomerMapper.insertBatch(result.toInsert);
|
||||
// 批量查询刚插入数据的id,提升效率
|
||||
List<String> insertedNumbers = result.toInsert.stream()
|
||||
.map(ErpCustomerDO::getNumber)
|
||||
.collect(Collectors.toList());
|
||||
List<ErpCustomerDO> insertedRecords = erpCustomerMapper.selectList(
|
||||
new LambdaQueryWrapperX<ErpCustomerDO>()
|
||||
.in(ErpCustomerDO::getNumber, insertedNumbers)
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpCustomerDO::getNumber, ErpCustomerDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpCustomerMapper.updateBatch(result.toUpdate);
|
||||
erpCustomerMapper.updateBatchByNumber(result.toUpdate);
|
||||
}
|
||||
myRedisConfig.updateRedisCache(result.key, result.allnumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,18 +227,21 @@ public class ErpCustomerServiceImpl implements ErpCustomerService {
|
||||
private final List<ErpCustomerDO> toUpdate;
|
||||
private final List<ErpCustomerDO> toInsert;
|
||||
private final String key;
|
||||
private final List<String> allnumbers;
|
||||
|
||||
public ProcessingResult(List<ErpCustomerDO> toUpdate, List<ErpCustomerDO> toInsert, String key) {
|
||||
public ProcessingResult(List<ErpCustomerDO> toUpdate, List<ErpCustomerDO> toInsert, String key, List<String> allnumbers) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.toInsert = toInsert;
|
||||
this.key = key;
|
||||
this.allnumbers = allnumbers;
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeMap(String key) {
|
||||
Map<String, Long> existingNumbers = erpCustomerMapper.selectList(new LambdaQueryWrapperX<ErpCustomerDO>())
|
||||
private void initialize(String key) {
|
||||
List<String> existingNumbers = erpCustomerMapper.selectList(new LambdaQueryWrapperX<ErpCustomerDO>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(ErpCustomerDO::getNumber, ErpCustomerDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
.map(ErpCustomerDO::getNumber)
|
||||
.collect(Collectors.toList());
|
||||
myRedisConfig.updateRedisCache(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,16 @@
|
||||
package com.zt.plat.module.erp.service.erp;
|
||||
|
||||
import com.zt.plat.module.erp.api.dto.ErpElectronicInvoiceReversalReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpElectronicInvoiceSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitRespDTO;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ErpInvoiceticketService {
|
||||
ErpInvoiceticketSubmitRespDTO sbumitToErp020(ErpInvoiceticketSubmitReqDTO reqDTO);
|
||||
HashMap<String, String> sbumitToErp098(Map<String, Object> reqDTO);
|
||||
HashMap<String, String> sbumitToErp096(ErpElectronicInvoiceSubmitReqDTO reqDTO);
|
||||
HashMap<String, String> sbumitToErp097(ErpElectronicInvoiceReversalReqDTO reqDTO);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.zt.plat.module.erp.service.erp;
|
||||
|
||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.zt.plat.module.erp.api.ErpExternalApi;
|
||||
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpInvoiceticketSubmitRespDTO;
|
||||
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||
import com.zt.plat.module.erp.api.dto.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -59,6 +57,7 @@ public class ErpInvoiceticketServiceImpl implements ErpInvoiceticketService {
|
||||
return respDTO;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转换采购发票过账差异明细列表
|
||||
* 假设HashMap中子列表字段格式为:callBackSettlementDetails[0].factoryCode、callBackSettlementDetails[0].materialCode...
|
||||
@@ -123,4 +122,57 @@ public class ErpInvoiceticketServiceImpl implements ErpInvoiceticketService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, String> sbumitToErp098(Map<String, Object> param) {
|
||||
ErpSubmitReqDTO reqDTO = new ErpSubmitReqDTO();
|
||||
reqDTO.setFuncnr("098");
|
||||
reqDTO.setBskey(param.get("id").toString());
|
||||
reqDTO.setUsrid(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
|
||||
reqDTO.setUsrnm((SecurityFrameworkUtils.getLoginUserNickname()));
|
||||
param.remove("id");
|
||||
reqDTO.setReq(param);
|
||||
return erpExternalApi.submitDataToErp(reqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, String> sbumitToErp096(ErpElectronicInvoiceSubmitReqDTO erpElectronicInvoiceSubmitReqDTO) {
|
||||
ErpSubmitReqDTO reqDTO = new ErpSubmitReqDTO();
|
||||
reqDTO.setFuncnr("096");
|
||||
reqDTO.setBskey(erpElectronicInvoiceSubmitReqDTO.getId());
|
||||
reqDTO.setUsrid(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
|
||||
reqDTO.setUsrnm((SecurityFrameworkUtils.getLoginUserNickname()));
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
req.put("bill_date", erpElectronicInvoiceSubmitReqDTO.getBill_date());
|
||||
req.put("provi_estimate", erpElectronicInvoiceSubmitReqDTO.getProvi_estimate());
|
||||
req.put("bline_date", erpElectronicInvoiceSubmitReqDTO.getBline_date());
|
||||
req.put("bill_text", erpElectronicInvoiceSubmitReqDTO.getBill_text());
|
||||
req.put("no_invoicing", erpElectronicInvoiceSubmitReqDTO.getNo_invoicing());
|
||||
req.put("invoice_type", erpElectronicInvoiceSubmitReqDTO.getInvoice_type());
|
||||
req.put("invoice_note", erpElectronicInvoiceSubmitReqDTO.getInvoice_note());
|
||||
req.put("reversal_reason", erpElectronicInvoiceSubmitReqDTO.getReversal_reason());
|
||||
req.put("item", erpElectronicInvoiceSubmitReqDTO.getItem());
|
||||
req.put("cond", erpElectronicInvoiceSubmitReqDTO.getCond());
|
||||
req.put("filedata", erpElectronicInvoiceSubmitReqDTO.getBline_date());
|
||||
reqDTO.setReq(req);
|
||||
return erpExternalApi.submitDataToErp(reqDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, String> sbumitToErp097(ErpElectronicInvoiceReversalReqDTO reqDTO) {
|
||||
ErpSubmitReqDTO submitReqDTO = new ErpSubmitReqDTO();
|
||||
submitReqDTO.setFuncnr("097");
|
||||
submitReqDTO.setBskey(reqDTO.getId());
|
||||
submitReqDTO.setUsrid(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
|
||||
submitReqDTO.setUsrnm((SecurityFrameworkUtils.getLoginUserNickname()));
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
req.put("billdoc", reqDTO.getBilldoc());
|
||||
req.put("postingdate", reqDTO.getPostingdate());
|
||||
req.put("reason", reqDTO.getReason());
|
||||
req.put("no_invoicing", reqDTO.getNo_invoicing());
|
||||
req.put("filedata", reqDTO.getFiledata());
|
||||
return erpExternalApi.submitDataToErp(submitReqDTO);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionPageReqVO;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpProductiveVersionDO;
|
||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpPurchaseOrganizationDO;
|
||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||
@@ -28,6 +30,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.module.erp.enums.ErrorCodeConstants.*;
|
||||
@@ -102,123 +105,158 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
return erpProductiveOrderMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ErpProductiveOrderDO> getErpProductiveOrderPage(ErpProductiveOrderPageReqVO pageReqVO) {
|
||||
return erpProductiveOrderMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
//直接从erp查询生产订单
|
||||
// @Override
|
||||
// public PageResult<ErpProductiveOrderDO> getErpProductiveOrderPage(ErpProductiveOrderPageReqVO pageReqVO) {
|
||||
// OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产订单;
|
||||
// String funcnr = funcnrEnum.getFuncnr();
|
||||
// Map<String, Object> req = new HashMap<>();
|
||||
//
|
||||
// // 构建查询参数
|
||||
// req.put("BUKRS", pageReqVO.getCompanyNumber());
|
||||
// req.put("WERKS", pageReqVO.getFactoryNumber());
|
||||
//
|
||||
// // 处理日期参数
|
||||
// if (pageReqVO.getStartDate() != null) {
|
||||
// req.put("BEGDA", pageReqVO.getStartDate()[0].format(DateTimeFormatter.ofPattern("yyyyMMdd")));
|
||||
// }
|
||||
// if (pageReqVO.getEndDate() != null) {
|
||||
// req.put("ENDDA", pageReqVO.getEndDate()[0].format(DateTimeFormatter.ofPattern("yyyyMMdd")));
|
||||
// }
|
||||
//
|
||||
// // 调用ERP接口获取数据
|
||||
// HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
// JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
// if (dataArray == null || dataArray.isEmpty()) {
|
||||
// // 返回空结果而不是抛出异常
|
||||
// return new PageResult<>(new ArrayList<>(), 0L);
|
||||
// }
|
||||
//
|
||||
// List<ErpProductiveOrderDO> list = new ArrayList<>();
|
||||
// for (int i = 0; i < dataArray.size(); i++) {
|
||||
// JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
// if (dataJson != null) {
|
||||
// ErpProductiveOrderDO orderDO = new ErpProductiveOrderDO();
|
||||
//
|
||||
// // 基本信息
|
||||
// orderDO.setCompanyNumber(dataJson.getString("BUKRS"));
|
||||
// orderDO.setFactoryNumber(dataJson.getString("WERKS").trim());
|
||||
// orderDO.setFactoryName(dataJson.getString("NAME1"));
|
||||
// orderDO.setOrderNumber(dataJson.getString("AUFNR"));
|
||||
//
|
||||
// // 日期处理
|
||||
// String plannedStartDate = dataJson.getString("GLTRP");
|
||||
// String actualStartDate = dataJson.getString("GSTRP");
|
||||
//
|
||||
// if (plannedStartDate != null && !plannedStartDate.equals("0000-00-00")) {
|
||||
// try {
|
||||
// orderDO.setStartDate(LocalDateTime.parse(plannedStartDate));
|
||||
// } catch (Exception e) {
|
||||
// // 忽略日期解析错误
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (actualStartDate != null && !actualStartDate.equals("0000-00-00")) {
|
||||
// try {
|
||||
// orderDO.setEndDate(LocalDateTime.parse(actualStartDate));
|
||||
// } catch (Exception e) {
|
||||
// // 忽略日期解析错误
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 物料和工艺信息
|
||||
// orderDO.setMainMaterialNumber(dataJson.getString("STLBEZ"));
|
||||
// orderDO.setUnit(dataJson.getString("GMEIN"));
|
||||
// orderDO.setMaterialDescription(dataJson.getString("MAKTX"));
|
||||
// orderDO.setProcessingList(dataJson.getString("L_AFVC"));
|
||||
// orderDO.setProcessingNumber(dataJson.getString("VORNR"));
|
||||
// orderDO.setProcessingDescription(dataJson.getString("LTXA1"));
|
||||
// orderDO.setObjectNumber(dataJson.getString("OBJID"));
|
||||
// orderDO.setWorkCenterNumber(dataJson.getString("ARBPL"));
|
||||
// orderDO.setWorkCenterDescription(dataJson.getString("KTEXT"));
|
||||
// orderDO.setCostcenterNumber(dataJson.getString("KOSTL"));
|
||||
// orderDO.setCostcenterName(dataJson.getString("TEXT_C"));
|
||||
//
|
||||
// list.add(orderDO);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 返回分页结果
|
||||
// return new PageResult<>(list, (long) list.size());
|
||||
// return erpProductiveOrderMapper.selectPage(pageReqVO);
|
||||
// }
|
||||
|
||||
// 直接从erp查询生产订单
|
||||
@Override
|
||||
public PageResult<ErpProductiveOrderDO> getErpProductiveOrderPage(ErpProductiveOrderPageReqVO pageReqVO) {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产订单明细;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
|
||||
// 构建查询参数
|
||||
req.put("BUKRS", pageReqVO.getCompanyNumber());
|
||||
req.put("WERKS", pageReqVO.getFactoryNumber());
|
||||
|
||||
// 处理日期参数
|
||||
if (pageReqVO.getStartDate() != null) {
|
||||
req.put("BEGDA", pageReqVO.getStartDate()[0].format(DateTimeFormatter.ofPattern("yyyyMMdd")));
|
||||
}
|
||||
if (pageReqVO.getEndDate() != null) {
|
||||
req.put("ENDDA", pageReqVO.getEndDate()[0].format(DateTimeFormatter.ofPattern("yyyyMMdd")));
|
||||
}
|
||||
|
||||
// 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
// 返回空结果而不是抛出异常
|
||||
return new PageResult<>(new ArrayList<>(), 0L);
|
||||
}
|
||||
|
||||
List<ErpProductiveOrderDO> list = new ArrayList<>();
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
if (dataJson != null) {
|
||||
ErpProductiveOrderDO orderDO = new ErpProductiveOrderDO();
|
||||
|
||||
// 基本信息
|
||||
orderDO.setCompanyNumber(dataJson.getString("BUKRS"));
|
||||
orderDO.setFactoryNumber(dataJson.getString("WERKS").trim());
|
||||
orderDO.setFactoryName(dataJson.getString("NAME1"));
|
||||
orderDO.setOrderNumber(dataJson.getString("AUFNR"));
|
||||
|
||||
// 日期处理
|
||||
String plannedStartDate = dataJson.getString("GLTRP");
|
||||
String actualStartDate = dataJson.getString("GSTRP");
|
||||
|
||||
if (plannedStartDate != null && !plannedStartDate.equals("0000-00-00")) {
|
||||
try {
|
||||
orderDO.setStartDate(LocalDateTime.parse(plannedStartDate));
|
||||
} catch (Exception e) {
|
||||
// 忽略日期解析错误
|
||||
}
|
||||
}
|
||||
|
||||
if (actualStartDate != null && !actualStartDate.equals("0000-00-00")) {
|
||||
try {
|
||||
orderDO.setEndDate(LocalDateTime.parse(actualStartDate));
|
||||
} catch (Exception e) {
|
||||
// 忽略日期解析错误
|
||||
}
|
||||
}
|
||||
|
||||
// 物料和工艺信息
|
||||
orderDO.setMainMaterialNumber(dataJson.getString("STLBEZ"));
|
||||
orderDO.setUnit(dataJson.getString("GMEIN"));
|
||||
orderDO.setMaterialDescription(dataJson.getString("MAKTX"));
|
||||
orderDO.setProcessingList(dataJson.getString("L_AFVC"));
|
||||
orderDO.setProcessingNumber(dataJson.getString("VORNR"));
|
||||
orderDO.setProcessingDescription(dataJson.getString("LTXA1"));
|
||||
orderDO.setObjectNumber(dataJson.getString("OBJID"));
|
||||
orderDO.setWorkCenterNumber(dataJson.getString("ARBPL"));
|
||||
orderDO.setWorkCenterDescription(dataJson.getString("KTEXT"));
|
||||
orderDO.setCostcenterNumber(dataJson.getString("KOSTL"));
|
||||
orderDO.setCostcenterName(dataJson.getString("TEXT_C"));
|
||||
|
||||
list.add(orderDO);
|
||||
}
|
||||
}
|
||||
|
||||
List<ErpProductiveOrderDO> listLast = list.stream()
|
||||
.filter(orderDO -> pageReqVO.getFactoryName() == null || pageReqVO.getFactoryName().equals(orderDO.getFactoryName()))
|
||||
.filter(orderDO -> pageReqVO.getOrderNumber() == null || pageReqVO.getOrderNumber().equals(orderDO.getOrderNumber()))
|
||||
.filter(orderDO -> pageReqVO.getMainMaterialNumber() == null || pageReqVO.getMainMaterialNumber().equals(orderDO.getMainMaterialNumber()))
|
||||
.filter(orderDO -> pageReqVO.getProcessingList() == null || pageReqVO.getProcessingList().equals(orderDO.getProcessingList()))
|
||||
.filter(orderDO -> pageReqVO.getProcessingNumber() == null || pageReqVO.getProcessingNumber().equals(orderDO.getProcessingNumber()))
|
||||
.filter(orderDO -> pageReqVO.getProcessingDescription() == null || pageReqVO.getProcessingDescription().equals(orderDO.getProcessingDescription()))
|
||||
.filter(orderDO -> pageReqVO.getObjectNumber() == null || pageReqVO.getObjectNumber().equals(orderDO.getObjectNumber()))
|
||||
.filter(orderDO -> pageReqVO.getWorkCenterNumber() == null || pageReqVO.getWorkCenterNumber().equals(orderDO.getWorkCenterNumber()))
|
||||
.filter(orderDO -> pageReqVO.getWorkCenterDescription() == null || pageReqVO.getWorkCenterDescription().equals(orderDO.getWorkCenterDescription()))
|
||||
.filter(orderDO -> pageReqVO.getCostcenterNumber() == null || pageReqVO.getCostcenterNumber().equals(orderDO.getCostcenterNumber()))
|
||||
.filter(orderDO -> pageReqVO.getCostcenterName() == null || pageReqVO.getCostcenterName().equals(orderDO.getCostcenterName()))
|
||||
.toList();
|
||||
|
||||
// 返回分页结果
|
||||
return new PageResult<>(listLast, (long) listLast.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@XxlJob("getErpProductiveOrderTask")
|
||||
// @XxlJob("getErpProductiveOrderTask")
|
||||
public void callErpRfcInterface() {
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产订单;
|
||||
OftenEnum.FuncnrEnum funcnrEnum = OftenEnum.FuncnrEnum.生产订单明细;
|
||||
String funcnr = funcnrEnum.getFuncnr();
|
||||
|
||||
//防止缓存数据丢失
|
||||
String key = "erpMap" + funcnrEnum.getFuncnr();
|
||||
if (myRedisConfig.getRedisCacheMap(key).isEmpty()) {
|
||||
initializeMap(key);
|
||||
}
|
||||
Map<String, Object> req = new HashMap<>();
|
||||
List<Map<String, String>> datumList = new ArrayList<>();
|
||||
Map<String, String> datumEntry = new HashMap<>();
|
||||
List<Map<String, String>> datumListS = new ArrayList<>();
|
||||
Map<String, String> datumEntryS = new HashMap<>();
|
||||
// 构建datum参数数组
|
||||
datumEntry.put("sign", "I");
|
||||
datumEntry.put("option", "EQ");
|
||||
datumEntry.put("low", LocalDate.now().toString());
|
||||
datumList.add(datumEntry);
|
||||
req.put(funcnrEnum.getDatekey(), datumList);
|
||||
datumEntryS.put("sign", "I");
|
||||
datumEntryS.put("option", "EQ");
|
||||
datumEntryS.put("low", LocalDate.now().toString());
|
||||
datumListS.add(datumEntryS);
|
||||
req.put("BEGDA", datumListS);
|
||||
List<Map<String, String>> datumListE = new ArrayList<>();
|
||||
Map<String, String> datumEntryE = new HashMap<>();
|
||||
// 构建datum参数数组
|
||||
datumEntryE.put("sign", "I");
|
||||
datumEntryE.put("option", "EQ");
|
||||
datumEntryE.put("low", LocalDate.now().toString());
|
||||
datumListE.add(datumEntryE);
|
||||
req.put("ENDDA", datumListE);
|
||||
JSONArray dataArrayALL = new JSONArray();
|
||||
List<String> redisCache = myRedisConfig.getRedisCache(OftenEnum.FuncnrEnum.工厂信息.getFuncnr());
|
||||
if (CollUtil.isEmpty(redisCache)) {
|
||||
List<String> redisCacheF = myRedisConfig.getRedisCache(OftenEnum.FuncnrEnum.工厂信息.getFuncnr());
|
||||
if (CollUtil.isEmpty(redisCacheF)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
List<String> redisCacheC = myRedisConfig.getRedisCache(OftenEnum.FuncnrEnum.公司代码.getFuncnr());
|
||||
if (CollUtil.isEmpty(redisCacheC)) {
|
||||
throw exception(ERP_FACTORY_NOT_EXISTS);
|
||||
}
|
||||
// 1. 调用ERP接口获取数据
|
||||
for (String number : redisCache) {
|
||||
req.put("WERKS", number);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
for (String numberC : redisCacheC) {
|
||||
for (String numberF : redisCacheF) {
|
||||
req.put("BUKRS", numberC);
|
||||
req.put("WERKS", numberF);
|
||||
// 1. 调用ERP接口获取数据
|
||||
HashMap<String, Object> dataFromERP = erpConfig.fetchDataFromERP(funcnr, req);
|
||||
JSONArray dataArray = (JSONArray) dataFromERP.get("E_RESP");
|
||||
if (dataArray == null || dataArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
dataArrayALL.addAll(dataArray);
|
||||
}
|
||||
|
||||
if (dataArrayALL.isEmpty()) {
|
||||
throw exception(ERP_PRODUCTIVE_ORDER_NOT_EXISTS);
|
||||
}
|
||||
@@ -234,34 +272,58 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
* 处理数据,区分新增和更新
|
||||
*/
|
||||
private ProcessingResult processData(JSONArray dataArray, OftenEnum.FuncnrEnum funcnr) {
|
||||
String key = "erp" + funcnr.getFuncnr();
|
||||
Map<String, List<String>> numbers = myRedisConfig.numbers(dataArray, key, funcnr.getDatakey());
|
||||
List<String> allnumbers = numbers.get("all");
|
||||
List<String> comnumbers = numbers.get("com");
|
||||
String key = "erpMap" + funcnr.getFuncnr();
|
||||
Map<String, Long> numbers = myRedisConfig.getRedisCacheMap(key);
|
||||
List<ErpProductiveOrderDO> toUpdate = new ArrayList<>();
|
||||
List<ErpProductiveOrderDO> toInsert = new ArrayList<>();
|
||||
|
||||
List<String> dataArrayNumbers = new ArrayList<>();
|
||||
for (int i = 0; i < dataArray.size(); i++) {
|
||||
JSONObject dataJson = dataArray.getJSONObject(i);
|
||||
if (dataJson != null) {
|
||||
String number = dataJson.getString("BUKRS").trim();
|
||||
if (number != null) {
|
||||
ErpProductiveOrderDO DO = new ErpProductiveOrderDO();
|
||||
// DO.setName(dataJson.getString("BUTXT"));
|
||||
// DO.setNumber(number);
|
||||
// DO.setCurrency(dataJson.getString("WAERS"));
|
||||
if (comnumbers.contains(number)) {
|
||||
// 更新
|
||||
toUpdate.add(DO);
|
||||
} else {
|
||||
// 新增
|
||||
toInsert.add(DO);
|
||||
}
|
||||
String number = dataJson.getString("AUFNR").trim();
|
||||
ErpProductiveOrderDO DO = new ErpProductiveOrderDO();
|
||||
DO.setCompanyNumber(dataJson.getString("BUKRS").trim());
|
||||
DO.setFactoryNumber(dataJson.getString("WERKS").trim());
|
||||
DO.setFactoryName(dataJson.getString("NAME1").trim());
|
||||
DO.setOrderNumber(dataJson.getString("AUFNR").trim());
|
||||
if (!dataJson.getString("GLTRP").equals("0000-00-00")) {
|
||||
DO.setStartDate(LocalDateTime.parse(dataJson.getString("GLTRP") + "T00:00:00"));
|
||||
}
|
||||
if (!dataJson.getString("GSTRP").equals("0000-00-00")) {
|
||||
DO.setEndDate(LocalDateTime.parse(dataJson.getString("GSTRP") + "T00:00:00"));
|
||||
}
|
||||
DO.setMainMaterialNumber(dataJson.getString("STLBEZ").trim());
|
||||
DO.setUnit(dataJson.getString("GMEIN").trim());
|
||||
DO.setMaterialDescription(dataJson.getString("MAKTX").trim());
|
||||
DO.setProcessingList(dataJson.getString("L_AFVC").trim());
|
||||
DO.setProcessingNumber(dataJson.getString("VORNR").trim());
|
||||
DO.setProcessingDescription(dataJson.getString("LTXA1").trim());
|
||||
DO.setObjectNumber(dataJson.getString("OBJID").trim());
|
||||
DO.setWorkCenterNumber(dataJson.getString("ARBPL").trim());
|
||||
DO.setWorkCenterDescription(dataJson.getString("KTEXT").trim());
|
||||
DO.setCostcenterNumber(dataJson.getString("KOSTL").trim());
|
||||
DO.setCostcenterName(dataJson.getString("TEXT_C").trim());
|
||||
if (numbers.get(number) != null) {
|
||||
// 更新
|
||||
DO.setId(numbers.get(number));
|
||||
toUpdate.add(DO);
|
||||
} else {
|
||||
// 新增
|
||||
toInsert.add(DO);
|
||||
}
|
||||
dataArrayNumbers.add(number);
|
||||
}
|
||||
}
|
||||
// 过滤出numbers中有,但dataArray中KOSTL没有的记录,即为需要删除的数据
|
||||
List<String> deleteNumbers = new ArrayList<>();
|
||||
for (String number : numbers.keySet()) {
|
||||
if (!dataArrayNumbers.contains(number)) {
|
||||
deleteNumbers.add(number);
|
||||
}
|
||||
}
|
||||
|
||||
return new ProcessingResult(toUpdate, toInsert, key, allnumbers);
|
||||
return new ProcessingResult(toUpdate, toInsert, key, deleteNumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,11 +333,26 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
// 批量新增和更新
|
||||
if (!result.toInsert.isEmpty()) {
|
||||
erpProductiveOrderMapper.insertBatch(result.toInsert);
|
||||
// 批量查询刚插入数据的id,提升效率
|
||||
List<String> insertedNumbers = result.toInsert.stream()
|
||||
.map(ErpProductiveOrderDO::getOrderNumber)
|
||||
.collect(Collectors.toList());
|
||||
List<ErpProductiveOrderDO> insertedRecords = erpProductiveOrderMapper.selectList(
|
||||
new LambdaQueryWrapperX<ErpProductiveOrderDO>()
|
||||
.in(ErpProductiveOrderDO::getOrderNumber, insertedNumbers)
|
||||
);
|
||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||
.collect(Collectors.toMap(ErpProductiveOrderDO::getOrderNumber, ErpProductiveOrderDO::getId));
|
||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||
}
|
||||
if (!result.toUpdate.isEmpty()) {
|
||||
erpProductiveOrderMapper.updateBatch(result.toUpdate);
|
||||
}
|
||||
myRedisConfig.updateRedisCache(result.key, result.allnumbers);
|
||||
if (!result.deleteNumbers.isEmpty()) {
|
||||
// 使用 in 条件批量删除,提高删除效率
|
||||
erpProductiveOrderMapper.delete(new LambdaQueryWrapperX<ErpProductiveOrderDO>().in(ErpProductiveOrderDO::getOrderNumber, result.deleteNumbers));
|
||||
myRedisConfig.deleteRedisCacheMap(result.key, result.deleteNumbers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,13 +362,24 @@ public class ErpProductiveOrderServiceImpl implements ErpProductiveOrderService
|
||||
private final List<ErpProductiveOrderDO> toUpdate;
|
||||
private final List<ErpProductiveOrderDO> toInsert;
|
||||
private final String key;
|
||||
private final List<String> allnumbers;
|
||||
private final List<String> deleteNumbers;
|
||||
|
||||
public ProcessingResult(List<ErpProductiveOrderDO> toUpdate, List<ErpProductiveOrderDO> toInsert, String key, List<String> allnumbers) {
|
||||
public ProcessingResult(List<ErpProductiveOrderDO> toUpdate, List<ErpProductiveOrderDO> toInsert, String key, List<String> deleteNumbers) {
|
||||
this.toUpdate = toUpdate;
|
||||
this.toInsert = toInsert;
|
||||
this.key = key;
|
||||
this.allnumbers = allnumbers;
|
||||
this.deleteNumbers = deleteNumbers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initializeMap(String key) {
|
||||
List<ErpProductiveOrderDO> assets = erpProductiveOrderMapper.selectList(new LambdaQueryWrapperX<ErpProductiveOrderDO>());
|
||||
Map<String, Long> existingNumbers = new HashMap<>();
|
||||
for (ErpProductiveOrderDO asset : assets) {
|
||||
String mapKey = asset.getOrderNumber();
|
||||
existingNumbers.put(mapKey, asset.getId());
|
||||
}
|
||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,22 @@
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
<update id="updateBatchByNumber">
|
||||
<foreach collection="toUpdate" item="item" separator=";" open="BEGIN" close=";END;">
|
||||
UPDATE sply_erp_cstm
|
||||
<set>
|
||||
<if test="item.number != null">NUM = #{item.number},</if>
|
||||
<if test="item.name != null">NAME = #{item.name},</if>
|
||||
<if test="item.accountGroup != null">ACCT_GRP = #{item.accountGroup},</if>
|
||||
<if test="item.description != null">DSP = #{item.description},</if>
|
||||
<if test="item.centerNumber != null">CTR_NUM = #{item.centerNumber},</if>
|
||||
<if test="item.createDate != null">CRT_DT = #{item.createDate},</if>
|
||||
<if test="item.repairDate != null">RPR_DT = #{item.repairDate},</if>
|
||||
<if test="item.isGiveback != null">IS_GIV = #{item.isGiveback},</if>
|
||||
<if test="item.isProvisional != null">IS_PRVS = #{item.isProvisional},</if>
|
||||
<if test="item.taxNumber != null">TAX_NUM = #{item.taxNumber},</if>
|
||||
</set>
|
||||
WHERE NUM = #{item.downCenterNumber}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user