1、新增业务数据动态查询,根据系统编码和单据时间查询
This commit is contained in:
parent
b9e95da6a4
commit
cf1d65737c
|
@ -10,12 +10,17 @@ import java.util.Map;
|
|||
* Created by zydd on 2025-06-06 10:03
|
||||
*/
|
||||
public interface IMdmDBQueryVODAO extends IBaseDao<MdmDBQueryVO, String> {
|
||||
/**
|
||||
* 1-5模糊搜索
|
||||
* 6-10精确搜索
|
||||
*/
|
||||
List<Map<String, Object>> queryMdmDb(MdmDBQueryVO u8CQueryVO);
|
||||
List<Map<String, Object>> queryDataByMdmIdGroupBy(MdmDBQueryVO mdmDBQueryVO);
|
||||
List<CashFlowVO> queryCashflowVO(CashFlowVO cashFlowVO);
|
||||
List<GlSubrelationVO> queryGlsubrelationVO(GlSubrelationVO glSubrelationVO);
|
||||
List<BdBdinfoEntity> queryBdBdinfoList(BdBdinfoEntity entity);
|
||||
List<BdAccassitemVO> queryBdInfoBySubjass(BdAccassitemVO entity);
|
||||
List<BdVoucherTypeVO> queryVoucherType(BdVoucherTypeVO entity);
|
||||
List<BdCurrtypeVO> queryBdCurrtype(BdCurrtypeVO entity);
|
||||
|
||||
List<BdCurrtypeVO> queryBdCurrtype(BdCurrtypeVO entity);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,11 @@ public class MdmDBQueryVODAOImpl extends MybatisGenericDao<MdmDBQueryVO, String>
|
|||
List<Map<String, Object>> maps = (List<Map<String, Object>>) selectList("com.hzya.frame.voucher.ae.comf.bd.dao.impl.MdmDBQueryVODAOImpl.queryMdmDb", u8CQueryVO);
|
||||
return maps;
|
||||
}
|
||||
@Override
|
||||
public List<Map<String, Object>> queryDataByMdmIdGroupBy(MdmDBQueryVO u8CQueryVO) {
|
||||
List<Map<String, Object>> maps = (List<Map<String, Object>>) selectList("com.hzya.frame.voucher.ae.comf.bd.dao.impl.MdmDBQueryVODAOImpl.queryDataByMdmIdGroupBy", u8CQueryVO);
|
||||
return maps;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,15 +19,47 @@
|
|||
<if test="prop3 !=null and propValue3 != null">${prop3}like concat('%', #{propValue3},'%')</if>
|
||||
<if test="prop4 !=null and propValue4 != null">${prop4}like concat('%', #{propValue4},'%')</if>
|
||||
<if test="prop5 !=null and propValue5 != null">${prop5}like concat('%', #{propValue5},'%')</if>
|
||||
<if test="prop6 !=null and propValue6 != null">${prop6}like concat('%', #{propValue6},'%')</if>
|
||||
<if test="prop7 !=null and propValue7 != null">${prop7}like concat('%', #{propValue7},'%')</if>
|
||||
<if test="prop8 !=null and propValue8 != null">${prop8}like concat('%', #{propValue8},'%')</if>
|
||||
<if test="prop9 !=null and propValue9 != null">${prop9}like concat('%', #{propValue9},'%')</if>
|
||||
<if test="prop10 !=null and propValue10 != null">${prop10}like concat('%', #{propValue10},'%')</if>
|
||||
<if test="prop6 !=null and propValue6 != null">${prop6}=#{propValue6}</if>
|
||||
<if test="prop7 !=null and propValue7 != null">${prop7}=#{propValue7}</if>
|
||||
<if test="prop8 !=null and propValue8 != null">${prop8}=#{propValue8}</if>
|
||||
<if test="prop9 !=null and propValue9 != null">${prop9}=#{propValue9}</if>
|
||||
<if test="prop10 !=null and propValue10 != null">${prop10}=#{propValue10}</if>
|
||||
<if test="pkentityorg !=null and pkentityorg != null">pk_corp= #{pkentityorg}</if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
<select id="queryDataByMdmIdGroupBy" parameterType="com.hzya.frame.voucher.ae.comf.bd.entity.vo.MdmDBQueryVO" resultType="map">
|
||||
select
|
||||
${prop1} as bill_code,
|
||||
${prop2} as bill_date
|
||||
from
|
||||
${tablename}
|
||||
<trim prefix="where" prefixOverrides="and">
|
||||
1=1
|
||||
<if test="prop3 !=null and propValue3 != null">and ${prop3}>=#{propValue3}</if>
|
||||
<if test="prop4 !=null and propValue4 != null">and ${prop4}<=#{propValue4}</if>
|
||||
<if test="prop5 !=null and propValue5 != null">and ${prop5}=#{propValue5}</if>
|
||||
<if test="prop6 !=null and propValue6 != null">and ${prop6}=#{propValue6}</if>
|
||||
<if test="prop7 !=null and propValue7 != null">and ${prop7}=#{propValue7}</if>
|
||||
<if test="prop8 !=null and propValue8 != null">and ${prop8}=#{propValue8}</if>
|
||||
<if test="prop9 !=null and propValue9 != null">and ${prop9}=#{propValue9}</if>
|
||||
<if test="prop10 !=null and propValue10 != null">and ${prop10}=#{propValue10}</if>
|
||||
<if test="pkentityorg !=null and pkentityorg != null">and pk_corp= #{pkentityorg}</if>
|
||||
</trim>
|
||||
group by 1
|
||||
<if test="prop1 !=null and prop1 != null">,${prop1}</if>
|
||||
<if test="prop2 !=null and prop2 != null">,${prop2}</if>
|
||||
<if test="prop3 !=null and prop3 != null">,${prop3}</if>
|
||||
<if test="prop4 !=null and prop4 != null">,${prop4}</if>
|
||||
<if test="prop5 !=null and prop5 != null">,${prop5}</if>
|
||||
<if test="prop6 !=null and prop6 != null">,${prop6}</if>
|
||||
<if test="prop7 !=null and prop7 != null">,${prop7}</if>
|
||||
<if test="prop8 !=null and prop8 != null">,${prop8}</if>
|
||||
<if test="prop9 !=null and prop9 != null">,${prop9}</if>
|
||||
order by ${prop2} asc
|
||||
|
||||
</select>
|
||||
|
||||
<select id="queryCashflowVO" parameterType="com.hzya.frame.voucher.ae.comf.bd.entity.vo.CashFlowVO" resultType="com.hzya.frame.voucher.ae.comf.bd.entity.vo.CashFlowVO">
|
||||
SELECT
|
||||
pk_cashflow AS pkCashflow,
|
||||
|
|
|
@ -33,5 +33,7 @@ public class MdmDbFiledVO extends BaseEntity {
|
|||
private String namefieldname;
|
||||
/** 编码字段名称 */
|
||||
private String codefieldname;
|
||||
/** 日期字段名称 */
|
||||
private String datefieldname;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,16 @@
|
|||
db.remark as dbName,
|
||||
fileds.sys_pk as tablepkname,
|
||||
fileds.sys_code AS codefieldname,
|
||||
fileds.sys_name AS namefieldname
|
||||
fileds.sys_name AS namefieldname,
|
||||
fileds.sys_date AS datefieldname
|
||||
FROM
|
||||
mdm_module mdm
|
||||
LEFT JOIN mdm_module_db db ON db.mdm_id = mdm.id
|
||||
LEFT JOIN (SELECT db_id,
|
||||
MAX(CASE WHEN sys_pk = 'Y' THEN en_name ELSE NULL END) AS sys_pk,
|
||||
MAX(CASE WHEN sys_code = 'Y' THEN en_name ELSE NULL END) AS sys_code,
|
||||
MAX(CASE WHEN sys_name = 'Y' THEN en_name ELSE NULL END) AS sys_name
|
||||
MAX(CASE WHEN sys_name = 'Y' THEN en_name ELSE NULL END) AS sys_name,
|
||||
MAX(CASE WHEN sys_date = 'Y' THEN en_name ELSE NULL END) AS sys_date
|
||||
FROM mdm_module_db_fileds
|
||||
GROUP BY db_id) fileds ON fileds.db_id = db.id
|
||||
WHERE
|
||||
|
|
|
@ -4,6 +4,8 @@ import cn.hutool.core.lang.Assert;
|
|||
import com.github.pagehelper.PageInfo;
|
||||
import com.hzya.frame.page.PageAttribute;
|
||||
import com.hzya.frame.voucher.ae.comf.module.entity.AeConfBusinessModuleEntity;
|
||||
import com.hzya.frame.voucher.ae.comf.module.entity.AeConfBusinessModuleMdmEntity;
|
||||
import com.hzya.frame.voucher.ae.comf.module.service.IAeConfBusinessModuleMdmService;
|
||||
import com.hzya.frame.voucher.ae.comf.module.service.IAeConfBusinessModuleService;
|
||||
import com.hzya.frame.web.action.DefaultController;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
|
@ -21,6 +23,8 @@ public class BusinessModuleController extends DefaultController {
|
|||
|
||||
@Autowired
|
||||
private IAeConfBusinessModuleService aeConfBusinessModuleService;
|
||||
@Autowired
|
||||
private IAeConfBusinessModuleMdmService aeConfBusinessModuleMdmService;
|
||||
|
||||
@RequestMapping(value = "/queryPaged", method = RequestMethod.POST)
|
||||
public JsonResultEntity queryPaged(@RequestBody AeConfBusinessModuleEntity entity) {
|
||||
|
@ -82,6 +86,13 @@ public class BusinessModuleController extends DefaultController {
|
|||
public JsonResultEntity delete(@RequestBody AeConfBusinessModuleEntity entity) {
|
||||
try {
|
||||
Assert.notNull(entity.getId(), "删除时,id不能为空");
|
||||
//删除主数据
|
||||
AeConfBusinessModuleMdmEntity aeConfBusinessModuleMdmEntity = new AeConfBusinessModuleMdmEntity();
|
||||
aeConfBusinessModuleMdmEntity.setAeConfModuleId(Long.valueOf(entity.getId()));
|
||||
List<AeConfBusinessModuleMdmEntity> moduleMdmList = aeConfBusinessModuleMdmService.query(aeConfBusinessModuleMdmEntity);
|
||||
for (AeConfBusinessModuleMdmEntity confBusinessModuleMdmEntity : moduleMdmList) {
|
||||
aeConfBusinessModuleMdmService.logicRemove(confBusinessModuleMdmEntity);
|
||||
}
|
||||
int i = aeConfBusinessModuleService.logicRemove(entity);
|
||||
return getSuccessMessageEntity("请求成功", null);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -91,7 +91,7 @@ public class AeConfBusinessModuleMdmServiceImpl extends BaseService<AeConfBusine
|
|||
*/
|
||||
@Override
|
||||
public List<AeConfBusinessModuleMdmEntity> queryMdmsByModuleId(AeConfBusinessModuleMdmEntity entity) {
|
||||
Assert.notNull(entity.getAeConfModuleId(), "查询主数据列表时,业务模块id不能为空");
|
||||
// Assert.notNull(entity.getAeConfModuleId(), "查询主数据列表时,业务模块id不能为空");
|
||||
List<AeConfBusinessModuleMdmEntity> all = aeConfBusinessModuleMdmDao.query(entity);
|
||||
return all;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package com.hzya.frame.voucher.ae.generate.core.controller;
|
||||
|
||||
import com.hzya.frame.voucher.ae.comf.bd.entity.vo.MdmDBQueryVO;
|
||||
import com.hzya.frame.voucher.ae.generate.core.service.ICoreService;
|
||||
import com.hzya.frame.voucher.ae.generate.core.vo.CreateVoucherVO;
|
||||
import com.hzya.frame.web.action.DefaultController;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by zydd on 2025-07-09 10:10
|
||||
* 凭证生成核心类
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ae/core")
|
||||
public class CoreController extends DefaultController {
|
||||
|
||||
@Autowired
|
||||
private ICoreService coreService;
|
||||
|
||||
/**
|
||||
* 查询主数据根据mdmId
|
||||
* 根据设定的单据主键进行group by
|
||||
*/
|
||||
@RequestMapping(value = "/queryDataByMdmId", method = RequestMethod.POST)
|
||||
public JsonResultEntity queryDataByMdmId (@RequestBody CreateVoucherVO createVoucherVO) {
|
||||
try {
|
||||
List<Map<String, Object>> objectList = coreService.queryDataByMdmId(createVoucherVO);
|
||||
return getSuccessMessageEntity("请求成功", objectList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return getFailureMessageEntity(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/generate", method = RequestMethod.POST)
|
||||
public JsonResultEntity generateVoucher(@RequestBody CreateVoucherVO createVoucherVO) {
|
||||
try {
|
||||
coreService.generateVoucher(createVoucherVO);
|
||||
|
||||
return getSuccessMessageEntity("生成成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return getFailureMessageEntity(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.hzya.frame.voucher.ae.generate.core.dao;
|
||||
|
||||
/**
|
||||
* Created by zydd on 2025-07-11 14:07
|
||||
*/
|
||||
public interface ICoreDao {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.hzya.frame.voucher.ae.generate.core.dao.impl;
|
||||
|
||||
import com.hzya.frame.voucher.ae.generate.core.dao.ICoreDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by zydd on 2025-07-11 14:08
|
||||
*/
|
||||
@Repository
|
||||
public class ICoreDaoImpl implements ICoreDao {
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.hzya.frame.voucher.ae.generate.core.service;
|
||||
|
||||
import com.hzya.frame.voucher.ae.comf.bd.entity.vo.MdmDBQueryVO;
|
||||
import com.hzya.frame.voucher.ae.generate.core.vo.CreateVoucherVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by zydd on 2025-07-09 10:11
|
||||
*/
|
||||
public interface ICoreService {
|
||||
void generateVoucher(CreateVoucherVO createVoucherVO);
|
||||
|
||||
List<Map<String, Object>> queryDataByMdmId(CreateVoucherVO createVoucherVO);
|
||||
}
|
|
@ -0,0 +1,213 @@
|
|||
package com.hzya.frame.voucher.ae.generate.core.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.hzya.frame.mdm.mdmModule.dao.IMdmModuleDao;
|
||||
import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity;
|
||||
import com.hzya.frame.mdm.mdmModuleDb.dao.IMdmModuleDbDao;
|
||||
import com.hzya.frame.mdm.mdmModuleDb.entity.MdmModuleDbEntity;
|
||||
import com.hzya.frame.mdm.mdmModuleDbFileds.dao.IMdmModuleDbFiledsDao;
|
||||
import com.hzya.frame.mdm.mdmModuleDbFileds.entity.MdmModuleDbFiledsEntity;
|
||||
import com.hzya.frame.voucher.ae.comf.bd.dao.IAeConfBdOrgBookVODao;
|
||||
import com.hzya.frame.voucher.ae.comf.bd.dao.IMdmDBQueryVODAO;
|
||||
import com.hzya.frame.voucher.ae.comf.bd.dao.IMdmDbFiledVODAO;
|
||||
import com.hzya.frame.voucher.ae.comf.bd.entity.vo.BdVoucherTypeVO;
|
||||
import com.hzya.frame.voucher.ae.comf.bd.entity.vo.MdmDBQueryVO;
|
||||
import com.hzya.frame.voucher.ae.comf.bd.entity.vo.MdmDbFiledVO;
|
||||
import com.hzya.frame.voucher.ae.comf.bd.entity.vo.OrgBookVO;
|
||||
import com.hzya.frame.voucher.ae.comf.template.dao.IAeConfVoucherTemplateAssistDao;
|
||||
import com.hzya.frame.voucher.ae.comf.template.dao.IAeConfVoucherTemplateDao;
|
||||
import com.hzya.frame.voucher.ae.comf.template.dao.IAeConfVoucherTemplateTypeDao;
|
||||
import com.hzya.frame.voucher.ae.comf.template.entity.AeConfVoucherTemplateEntity;
|
||||
import com.hzya.frame.voucher.ae.comf.template.entity.AeConfVoucherTemplateTypeEntity;
|
||||
import com.hzya.frame.voucher.ae.generate.core.dao.ICoreDao;
|
||||
import com.hzya.frame.voucher.ae.generate.core.service.ICoreService;
|
||||
import com.hzya.frame.voucher.ae.generate.core.vo.CreateVoucherVO;
|
||||
import com.hzya.frame.voucher.ae.generate.core.vo.VoucherData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by zydd on 2025-07-09 10:11
|
||||
*/
|
||||
@Service
|
||||
public class ICoreServiceImpl implements ICoreService {
|
||||
|
||||
@Autowired
|
||||
private ICoreDao coreDao;
|
||||
|
||||
@Autowired
|
||||
private IAeConfBdOrgBookVODao aeConfBdOrgBookVODao;
|
||||
@Autowired
|
||||
private IMdmDBQueryVODAO mdmDBQueryVODAO;
|
||||
@Autowired
|
||||
private IMdmDbFiledVODAO mdmDbFiledVODAO;
|
||||
|
||||
@Autowired
|
||||
private IMdmModuleDao mdmModuleDao;
|
||||
@Autowired
|
||||
private IMdmModuleDbDao mdmModuleDbDao;
|
||||
@Autowired
|
||||
private IMdmModuleDbFiledsDao mdmModuleDbFiledsDao;
|
||||
|
||||
@Autowired
|
||||
private IAeConfVoucherTemplateDao templateDao;
|
||||
@Autowired
|
||||
private IAeConfVoucherTemplateTypeDao templateTypeDao;
|
||||
@Autowired
|
||||
private IAeConfVoucherTemplateAssistDao templateAssDao;
|
||||
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> queryDataByMdmId(CreateVoucherVO createVoucherVO) {
|
||||
String mdmId = createVoucherVO.getMdmId();
|
||||
|
||||
//单据编码 sys_code,sys_date的字段,进行分组
|
||||
MdmDbFiledVO mdmDbFiledVO = new MdmDbFiledVO();
|
||||
mdmDbFiledVO.setMdmId(mdmId);
|
||||
List<MdmDbFiledVO> mdmDbFiledVOList = mdmDbFiledVODAO.queryMdmDbFiledVO(mdmDbFiledVO);
|
||||
if (mdmDbFiledVOList == null || mdmDbFiledVOList.size() == 0) {
|
||||
Assert.state(false, "根据mdmId:{},未查询到数据表,请检查", mdmId);
|
||||
}
|
||||
String tablename = mdmDbFiledVOList.get(0).getTablename();
|
||||
String codefieldname = mdmDbFiledVOList.get(0).getCodefieldname();
|
||||
String datefieldname = mdmDbFiledVOList.get(0).getDatefieldname();
|
||||
if (codefieldname == null || "".equals(codefieldname)) {
|
||||
Assert.state(false,"单据汇总字段(sys_code)为空,请检查。");
|
||||
}
|
||||
if (datefieldname == null || "".equals(datefieldname)) {
|
||||
Assert.state(false,"单据汇总字段(sys_date)为空,请检查。");
|
||||
}
|
||||
System.out.println(codefieldname);
|
||||
|
||||
//查询单据信息
|
||||
MdmDBQueryVO mdmDBQueryVO = new MdmDBQueryVO();
|
||||
mdmDBQueryVO.setTablename(tablename);
|
||||
mdmDBQueryVO.setProp1(codefieldname);
|
||||
mdmDBQueryVO.setProp2(datefieldname);
|
||||
//日期
|
||||
if(createVoucherVO.getTimeStart()!=null&&!"".equals(createVoucherVO.getTimeStart())){
|
||||
mdmDBQueryVO.setProp3(datefieldname);
|
||||
mdmDBQueryVO.setPropValue3(createVoucherVO.getTimeStart());
|
||||
}
|
||||
if(createVoucherVO.getTimeEnd()!=null&&!"".equals(createVoucherVO.getTimeEnd())){
|
||||
mdmDBQueryVO.setProp4(datefieldname);
|
||||
mdmDBQueryVO.setPropValue4(createVoucherVO.getTimeEnd());
|
||||
}
|
||||
List<Map<String, Object>> dateMaps = mdmDBQueryVODAO.queryDataByMdmIdGroupBy(mdmDBQueryVO);
|
||||
System.out.println(dateMaps);
|
||||
return dateMaps;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 1、根据mdmId查询表,查询汇总规则。
|
||||
* 2、再根据billCode查询单据信息
|
||||
* 3、再根据汇总规则,区分主子表
|
||||
* <p>
|
||||
* <p>
|
||||
* 1、选择的会计科目(分类定义)
|
||||
* 2、看会分类定义没有默认会计科目,没有话,从对照表中查询。
|
||||
* 3、根据影响因素,对应单据信息,在对照表中匹配相应的会计科目。
|
||||
* 4、根据会计科目的辅助核算项,再去配置的模板中匹配相对应的辅助核算项。
|
||||
* 5、辅助核算值取单据上的字段,进行匹配,由此批注核算匹配完成。
|
||||
*/
|
||||
@Override
|
||||
public void generateVoucher(CreateVoucherVO createVoucherVO) {
|
||||
Assert.notNull(createVoucherVO.getMdmId(), "生成凭证时,主数据id不能为空");
|
||||
Assert.notNull(createVoucherVO.getBillCode(), "生成凭证时,单据编号不能为空");
|
||||
|
||||
MdmModuleDbEntity mdmModuleDbEntity = new MdmModuleDbEntity();
|
||||
mdmModuleDbEntity.setDbType("1");
|
||||
mdmModuleDbEntity.setMdmId(createVoucherVO.getMdmId());
|
||||
List<MdmModuleDbEntity> moduleDbList = mdmModuleDbDao.query(mdmModuleDbEntity);
|
||||
if (moduleDbList.size() == 0 || moduleDbList.size() > 1) {
|
||||
Assert.state(false, "根据mdmId:{},查询数据表为空,或数据不唯一请检查!", createVoucherVO.getMdmId());
|
||||
}
|
||||
MdmModuleDbEntity mdmModuleDb = moduleDbList.get(0);
|
||||
|
||||
//查询字段,转成map,方便查询字段
|
||||
MdmModuleDbFiledsEntity mdmModuleDbFiledsEntity = new MdmModuleDbFiledsEntity();
|
||||
mdmModuleDbFiledsEntity.setDbId(mdmModuleDb.getId());
|
||||
List<MdmModuleDbFiledsEntity> moduleDbFiledsList = mdmModuleDbFiledsDao.query(mdmModuleDbFiledsEntity);
|
||||
if (moduleDbFiledsList.size() == 0) {
|
||||
Assert.state(false, "根据bdId:{},bdName:{},查询数据表字段为空,请检查!", mdmModuleDb.getId(), mdmModuleDb.getDbName());
|
||||
}
|
||||
Map<String, String> filedsMap = moduleDbFiledsList.stream().collect(Collectors.toMap(MdmModuleDbFiledsEntity::getId, MdmModuleDbFiledsEntity::getEnName));
|
||||
|
||||
//查询数据
|
||||
MdmDBQueryVO mdmDBQueryVO = new MdmDBQueryVO();
|
||||
mdmDBQueryVO.setTablename(mdmModuleDb.getDbName());
|
||||
mdmDBQueryVO.setProp6("bill_code");
|
||||
mdmDBQueryVO.setPropValue6(createVoucherVO.getBillCode());
|
||||
List<Map<String, Object>> dataMapList = mdmDBQueryVODAO.queryMdmDb(mdmDBQueryVO);
|
||||
|
||||
//获取汇总规则
|
||||
String mergeRules = mdmModuleDb.getMergeRules();
|
||||
String[] mergeRulesSplit = mergeRules.split(",");
|
||||
//查询汇总字段
|
||||
List<String> collectFileds = Arrays.stream(mergeRulesSplit).map(filedsMap::get).collect(Collectors.toList());
|
||||
String[] arrayFileds = collectFileds.toArray(new String[0]);
|
||||
// 构建 grouping key(组合字段)
|
||||
Function<Map<String, Object>, List<Object>> grouper = map -> Arrays.stream(arrayFileds).map(map::get).collect(Collectors.toList());
|
||||
|
||||
//汇总分组
|
||||
Map<List<Object>, List<Map<String, Object>>> groupedResult = dataMapList.stream().collect(Collectors.groupingBy(grouper));
|
||||
System.out.println(groupedResult);
|
||||
|
||||
|
||||
//根据mdmId获取凭证模板
|
||||
AeConfVoucherTemplateEntity aeConfVoucherTemplateEntity = new AeConfVoucherTemplateEntity();
|
||||
aeConfVoucherTemplateEntity.setMdmId(createVoucherVO.getMdmId());
|
||||
List<AeConfVoucherTemplateEntity> templateList = templateDao.query(aeConfVoucherTemplateEntity);
|
||||
if (templateList.size() == 0) {
|
||||
Assert.state(false, "根据mdmId:{},查询凭证模板为空,请检查!", createVoucherVO.getMdmId());
|
||||
}
|
||||
//根据凭证类型分组
|
||||
Map<String, List<AeConfVoucherTemplateEntity>> collectTempType = templateList.stream().collect(Collectors.groupingBy(index -> index.getPkGlorgbook() + "," + index.getVoucherTypeId() + "," + index.getTemplateTypeId()));
|
||||
|
||||
System.out.println(collectTempType);
|
||||
|
||||
List<VoucherData.Voucher> voucher = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, List<AeConfVoucherTemplateEntity>> entry : collectTempType.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String[] split = key.split(",");
|
||||
|
||||
VoucherData.Voucher vouche = new VoucherData.Voucher();
|
||||
voucher.add(vouche);
|
||||
|
||||
//凭证组装头
|
||||
//pk_corp;//公司
|
||||
OrgBookVO orgBookVO = new OrgBookVO();
|
||||
orgBookVO.setPkglorgbook(split[0]);
|
||||
List<OrgBookVO> orgBookVOS = aeConfBdOrgBookVODao.queryOrgBookVO(orgBookVO);
|
||||
if (orgBookVOS == null || orgBookVOS.size() == 0) {
|
||||
Assert.state(false, "根据pk_glorgbook:{},查询公司为空,请检查!", split[0]);
|
||||
}
|
||||
vouche.setPk_corp(orgBookVOS.get(0).getPkentityorg());
|
||||
//pk_glorgbook;//账簿
|
||||
vouche.setPk_glorgbook(split[0]);
|
||||
|
||||
//pk_prepared;//制单人编码
|
||||
vouche.setPk_prepared("tbadmin");
|
||||
|
||||
//pk_vouchertype;//凭证类别简称
|
||||
BdVoucherTypeVO bdVoucherTypeVO = new BdVoucherTypeVO();
|
||||
|
||||
List<BdVoucherTypeVO> bdVoucherTypeVOS = mdmDBQueryVODAO.queryVoucherType(bdVoucherTypeVO);
|
||||
String s = split[1];
|
||||
|
||||
|
||||
//prepareddate;//制单日期(格式示例:2021-04-27))
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.hzya.frame.voucher.ae.generate.core.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Created by zydd on 2025-07-11 14:04
|
||||
* 业务数据VO
|
||||
*/
|
||||
@Data
|
||||
public class BusinessDataVO {
|
||||
private String billCode;
|
||||
private String billDate;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.hzya.frame.voucher.ae.generate.core.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by zydd on 2025-07-10 11:20
|
||||
* 生成凭证参数
|
||||
*/
|
||||
@Data
|
||||
public class CreateVoucherVO implements Serializable {
|
||||
/**
|
||||
* 主数据id
|
||||
*/
|
||||
private String mdmId;
|
||||
/**
|
||||
* 单据编码
|
||||
*/
|
||||
private String billCode;
|
||||
private String timeStart;
|
||||
private String timeEnd;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.hzya.frame.voucher.ae.generate.core.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by zydd on 2025-07-10 13:50
|
||||
*/
|
||||
@Data
|
||||
public class VoucherData {
|
||||
private List<Voucher> voucher;
|
||||
|
||||
@Data
|
||||
public static class Voucher {
|
||||
private String attachment;//附单据数
|
||||
private String pk_corp;//公司
|
||||
private String pk_glorgbook;//账簿
|
||||
private String pk_prepared;//制单人编码
|
||||
private String pk_vouchertype;//凭证类别简称
|
||||
private String prepareddate;//制单日期(格式示例:2021-04-27))
|
||||
private List<Detail> details;
|
||||
|
||||
@Data
|
||||
public class Detail {
|
||||
private String detailindex;//分录号
|
||||
private String excrate2;//汇率(2.7版本及以前版本不支持外面传进来,需要在外币汇率节点设置)
|
||||
private String price;//单价
|
||||
private String explanation;//摘要
|
||||
private String pk_accsubj;//科目
|
||||
private String pk_currtype;//币种编码
|
||||
//借
|
||||
private String debitquantity;// 借方数量
|
||||
private String debitamount;//原币借方金额(必填,没有就传0就行了)
|
||||
private String localdebitamount;//本币借方金额(必填,没有就传0就行了)
|
||||
//贷
|
||||
private String creditquantity;//贷方数量
|
||||
private String creditamount;//原币贷方金额(必填,没有就传0就行了)
|
||||
private String localcreditamount;//本币贷方金额(必填,没有就传0就行了)
|
||||
//辅助核算
|
||||
private List<Ass> ass;
|
||||
private List<Cashflow> cashflow;
|
||||
|
||||
@Data
|
||||
public class Ass {
|
||||
private String checktypecode;//辅助核算类型编码
|
||||
private String checkvaluecode;//辅助核算的值编码
|
||||
}
|
||||
@Data
|
||||
public class Cashflow {
|
||||
private String memo;//备注(v5.1开始支持)
|
||||
private String money;//原币金额
|
||||
private String moneyass;//辅币(v5.1开始支持)
|
||||
private String moneymain;//主币(v5.1开始支持)
|
||||
private String pk_cashflow;//现金流量表项编码
|
||||
private String pk_currtype;//现金流量币种编码
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue