diff --git a/base-buildpackage/src/main/java/com/hzya/frame/finance/bd/BdController.java b/base-buildpackage/src/main/java/com/hzya/frame/finance/bd/BdController.java index 3a3b06f8..db5234be 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/finance/bd/BdController.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/finance/bd/BdController.java @@ -3,6 +3,8 @@ package com.hzya.frame.finance.bd; import cn.hutool.core.lang.Assert; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.hzya.frame.finance.claim.entity.ClaimVO; +import com.hzya.frame.finance.utils.ClaimBillCodeUtil; import com.hzya.frame.mdm.mdmModule.dao.IMdmModuleDao; import com.hzya.frame.mdm.mdmModule.entity.MdmModuleEntity; import com.hzya.frame.mdm.mdmModule.service.IMdmModuleService; @@ -338,6 +340,44 @@ public class BdController extends DefaultController { } } + + @Autowired + private ClaimBillCodeUtil claimBillCodeUtil; + + + /** + * 根据类型获取当前最大编码 + */ + @RequestMapping(value = "/queryMaxBillCodeByType", method = RequestMethod.POST) + public JsonResultEntity queryMaxBillCodeByType (@RequestBody ClaimVO claimVO) { + try { + Assert.notNull(claimVO.getBillType(),"获取最大单据号时:单据类型不能为空"); + String s = claimBillCodeUtil.queryMaxBillCodeByType(claimVO.getBillType()); + return getSuccessMessageEntity("请求成功", s); + } catch (Exception e) { + e.printStackTrace(); + return getFailureMessageEntity(e.getMessage()); + } + } + + + /** + * 根据类型获取当前最大编码 + */ + @RequestMapping(value = "/saveBillCodeByTypeAndSourceCode", method = RequestMethod.POST) + public JsonResultEntity saveBillCodeByTypeAndSourceCode (@RequestBody ClaimVO claimVO) { + try { + Assert.notNull(claimVO.getBillType(),"获取最大单据号时:单据类型不能为空"); + Assert.notNull(claimVO.getSourceCode(),"获取最大单据号时:来源单据号不能为空"); + String s = claimBillCodeUtil.saveBillCodeByTypeAndSourceCode(claimVO.getBillType(),claimVO.getSourceCode()); + return getSuccessMessageEntity("请求成功", s); + } catch (Exception e) { + e.printStackTrace(); + return getFailureMessageEntity(e.getMessage()); + } + } + + // /** // * // */ diff --git a/base-buildpackage/src/main/java/com/hzya/frame/finance/claim/entity/ClaimVO.java b/base-buildpackage/src/main/java/com/hzya/frame/finance/claim/entity/ClaimVO.java new file mode 100644 index 00000000..7978e5ff --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/finance/claim/entity/ClaimVO.java @@ -0,0 +1,12 @@ +package com.hzya.frame.finance.claim.entity; + +import lombok.Data; + +/** + * Created by zydd on 2025-08-25 14:35 + */ +@Data +public class ClaimVO { + private String billType; + private String sourceCode; +} diff --git a/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/dao/IFeConfBillcodeRuleDao.java b/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/dao/IFeConfBillcodeRuleDao.java new file mode 100644 index 00000000..0368795a --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/dao/IFeConfBillcodeRuleDao.java @@ -0,0 +1,15 @@ +package com.hzya.frame.finance.conf.billcode.dao; + +import com.hzya.frame.finance.conf.billcode.entity.FeConfBillcodeRuleEntity; +import com.hzya.frame.basedao.dao.IBaseDao; + +/** + * 财资事项(finance_event)-配置-编码规则(fe_conf_billcode_rule: table)表数据库访问层 + * + * @author zydd + * @since 2025-08-25 15:06:03 + */ +public interface IFeConfBillcodeRuleDao extends IBaseDao { + +} + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/dao/impl/FeConfBillcodeRuleDaoImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/dao/impl/FeConfBillcodeRuleDaoImpl.java new file mode 100644 index 00000000..57f1e459 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/dao/impl/FeConfBillcodeRuleDaoImpl.java @@ -0,0 +1,17 @@ +package com.hzya.frame.finance.conf.billcode.dao.impl; + +import com.hzya.frame.finance.conf.billcode.entity.FeConfBillcodeRuleEntity; +import com.hzya.frame.finance.conf.billcode.dao.IFeConfBillcodeRuleDao; +import org.springframework.stereotype.Repository; +import com.hzya.frame.basedao.dao.MybatisGenericDao; +/** + * 财资事项(finance_event)-配置-编码规则(FeConfBillcodeRule)表数据库访问层 + * + * @author zydd + * @since 2025-08-25 15:06:03 + */ +@Repository +public class FeConfBillcodeRuleDaoImpl extends MybatisGenericDao implements IFeConfBillcodeRuleDao{ + +} + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/entity/FeConfBillcodeRuleEntity.java b/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/entity/FeConfBillcodeRuleEntity.java new file mode 100644 index 00000000..033ff81c --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/entity/FeConfBillcodeRuleEntity.java @@ -0,0 +1,28 @@ +package com.hzya.frame.finance.conf.billcode.entity; + +import com.hzya.frame.web.entity.BaseEntity; +import lombok.Data; + +/** + * 财资事项(finance_event)-配置-编码规则(FeConfBillcodeRule)实体类 + * + * @author zydd + * @since 2025-08-25 15:06:03 + */ +@Data +public class FeConfBillcodeRuleEntity extends BaseEntity { + + /** 年 */ + private String year; + /** 月 */ + private String month; + /** 日 */ + private String day; + /** 单据类型 */ + private String type; + /** 当前编码 */ + private String currentcode; + /** 来源单号 */ + private String sourcecode; +} + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/entity/FeConfBillcodeRuleEntity.xml b/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/entity/FeConfBillcodeRuleEntity.xml new file mode 100644 index 00000000..26703ff4 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/finance/conf/billcode/entity/FeConfBillcodeRuleEntity.xml @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + id + ,year + ,month + ,day + ,type + ,currentcode + ,sourcecode + + + + + + + + + + + + + + + + insert into fe_conf_billcode_rule( + + id , + year , + month , + day , + type , + currentcode , + sourcecode , + + )values( + + #{id} , + #{year} , + #{month} , + #{day} , + #{type} , + #{currentcode} , + #{sourcecode} , + + ) + + + + insert into fe_conf_billcode_rule(year, month, day, type, currentcode, sourcecode) + values + + (#{entity.year},#{entity.month},#{entity.day},#{entity.type},#{entity.currentcode},#{entity.sourcecode}) + + + + + insert into fe_conf_billcode_rule(year, month, day, type, currentcode, sourcecode) + values + + (#{entity.year},#{entity.month},#{entity.day},#{entity.type},#{entity.currentcode},#{entity.sourcecode}) + + on duplicate key update + year = values(year), + month = values(month), + day = values(day), + type = values(type), + currentcode = values(currentcode), + sourcecode = values(sourcecode) + + + + update fe_conf_billcode_rule set + + year = #{year}, + month = #{month}, + day = #{day}, + type = #{type}, + currentcode = #{currentcode}, + sourcecode = #{sourcecode}, + + where id = #{id} + + + + update fe_conf_billcode_rule + set modify_time = #{modify_time}, + modify_user_id = #{modify_user_id} + where id = #{id} + + + + update fe_conf_billcode_rule set sts= 'N' ,modify_time = #{modify_time},modify_user_id = #{modify_user_id} + + and id = #{id} + and year = #{year} + and month = #{month} + and day = #{day} + and type = #{type} + and currentcode = #{currentcode} + and sourcecode = #{sourcecode} + + + + + delete + from fe_conf_billcode_rule + where id = #{id} + + + + diff --git a/base-buildpackage/src/main/java/com/hzya/frame/finance/utils/ClaimBillCodeUtil.java b/base-buildpackage/src/main/java/com/hzya/frame/finance/utils/ClaimBillCodeUtil.java new file mode 100644 index 00000000..803f1f85 --- /dev/null +++ b/base-buildpackage/src/main/java/com/hzya/frame/finance/utils/ClaimBillCodeUtil.java @@ -0,0 +1,77 @@ +package com.hzya.frame.finance.utils; + +import cn.hutool.core.lang.Assert; +import com.hzya.frame.finance.conf.billcode.dao.IFeConfBillcodeRuleDao; +import com.hzya.frame.finance.conf.billcode.entity.FeConfBillcodeRuleEntity; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.time.LocalDate; +import java.time.Month; +import java.util.List; + +/** + * Created by zydd on 2025-08-25 14:52 + * 认领单 单号 工具类 + */ +@Repository +public class ClaimBillCodeUtil { + + @Autowired + private IFeConfBillcodeRuleDao billcodeRuleDao; + + public String queryMaxBillCodeByType(String billType){ + Assert.notNull(billType,"获取最大单据号时:单据类型不能为空"); + //获取当前年月日 + LocalDate now = LocalDate.now(); + String year = now.toString().substring(0, 4); + String month = now.toString().substring(5, 7); + String day = now.toString().substring(8, 10); + FeConfBillcodeRuleEntity feConfBillcodeRuleEntity = new FeConfBillcodeRuleEntity(); + feConfBillcodeRuleEntity.setType(billType); + feConfBillcodeRuleEntity.setYear(year); + feConfBillcodeRuleEntity.setMonth(month); + feConfBillcodeRuleEntity.setDay(day); + List query = billcodeRuleDao.query(feConfBillcodeRuleEntity); + if(query.size()==0){ + return "000000"; + } + int size = query.size(); + String result = String.format("%06d", size); + return result; + } + + public String saveBillCodeByTypeAndSourceCode(String billType,String sourceCode){ + //获取当前年月日 + LocalDate now = LocalDate.now(); + String year = now.toString().substring(0, 4); + String month = now.toString().substring(5, 7); + String day = now.toString().substring(8, 10); + + FeConfBillcodeRuleEntity feConfBillcodeRuleEntity = new FeConfBillcodeRuleEntity(); + feConfBillcodeRuleEntity.setType(billType); + feConfBillcodeRuleEntity.setYear(year); + feConfBillcodeRuleEntity.setMonth(month); + feConfBillcodeRuleEntity.setDay(day); + List query = billcodeRuleDao.query(feConfBillcodeRuleEntity); + if(query.size()==0){ + //新增单号 + String billCode= billType+year+month+day+"000001"; + feConfBillcodeRuleEntity.setSourcecode(sourceCode); + feConfBillcodeRuleEntity.setCurrentcode("000001"); + billcodeRuleDao.save(feConfBillcodeRuleEntity); + return billCode; + } + //获取个数+1 + int size = query.size(); + size+=1; + String result = String.format("%06d", size); + System.out.println(result); + String billCode= billType+year+month+day+result; + feConfBillcodeRuleEntity.setCurrentcode(result); + feConfBillcodeRuleEntity.setSourcecode(sourceCode); + billcodeRuleDao.save(feConfBillcodeRuleEntity); + return billCode; + } + +}