2024-08-28 17:42:16 +08:00
package com.engine.salary.service.impl ;
import cn.hutool.core.bean.BeanUtil ;
2024-08-30 17:44:26 +08:00
import com.cloudstore.eccom.pc.table.WeaTableColumn ;
2024-08-28 17:42:16 +08:00
import com.engine.common.util.ServiceUtil ;
import com.engine.core.impl.Service ;
2024-09-04 16:15:01 +08:00
import com.engine.salary.entity.hrm.DeptInfo ;
import com.engine.salary.entity.hrm.SubCompanyInfo ;
2024-10-11 09:10:33 +08:00
import com.engine.salary.entity.ly.dto.* ;
2024-09-04 16:15:01 +08:00
import com.engine.salary.entity.ly.param.* ;
import com.engine.salary.entity.ly.po.* ;
2024-08-28 17:42:16 +08:00
import com.engine.salary.entity.salaryformula.ExpressFormula ;
import com.engine.salary.entity.salaryformula.po.FormulaVar ;
2024-09-04 16:15:01 +08:00
import com.engine.salary.enums.ly.LyFzhsTypeEnum ;
2024-08-30 17:44:26 +08:00
import com.engine.salary.enums.ly.LyJDDirectionTypeEnum ;
2024-08-28 17:42:16 +08:00
import com.engine.salary.enums.ly.LyPZTypeEnum ;
import com.engine.salary.enums.salaryformula.ReferenceTypeEnum ;
2024-09-04 16:15:01 +08:00
import com.engine.salary.exception.SalaryRunTimeException ;
2024-08-28 17:42:16 +08:00
import com.engine.salary.formlua.entity.parameter.DataType ;
import com.engine.salary.formlua.entity.standard.ExcelResult ;
2024-09-04 16:15:01 +08:00
import com.engine.salary.mapper.ly.LyVoucherDetailMapper ;
import com.engine.salary.mapper.ly.LyVoucherMapper ;
2024-08-30 17:44:26 +08:00
import com.engine.salary.mapper.ly.UfKjkmMapper ;
2024-09-04 16:15:01 +08:00
import com.engine.salary.service.* ;
import com.engine.salary.util.SalaryDateUtil ;
import com.engine.salary.util.SalaryEntityUtil ;
import com.engine.salary.util.db.IdGenerator ;
2024-08-30 17:44:26 +08:00
import com.engine.salary.util.db.MapperProxyFactory ;
2024-08-28 17:42:16 +08:00
import com.engine.salary.util.page.PageInfo ;
2024-09-04 16:15:01 +08:00
import com.engine.salary.util.page.SalaryPageUtil ;
2024-10-11 09:10:33 +08:00
import com.engine.salary.util.xml.XStreamUtil ;
2024-09-04 16:15:01 +08:00
import com.google.common.collect.Lists ;
2024-08-28 17:42:16 +08:00
import lombok.extern.slf4j.Slf4j ;
2024-09-04 16:15:01 +08:00
import org.apache.commons.collections4.CollectionUtils ;
import org.apache.commons.collections4.MapUtils ;
2024-10-11 09:10:33 +08:00
import org.apache.commons.httpclient.HttpClient ;
import org.apache.commons.httpclient.methods.PostMethod ;
import org.apache.commons.httpclient.methods.RequestEntity ;
import org.apache.commons.httpclient.methods.StringRequestEntity ;
2024-09-06 15:36:20 +08:00
import org.apache.commons.lang.StringUtils ;
2024-08-28 17:42:16 +08:00
import org.apache.commons.lang3.math.NumberUtils ;
2024-09-04 16:15:01 +08:00
import weaver.conn.RecordSet ;
import weaver.general.BaseBean ;
2024-08-28 17:42:16 +08:00
import weaver.general.Util ;
import weaver.hrm.User ;
import java.math.BigDecimal ;
2024-09-04 16:15:01 +08:00
import java.util.* ;
import java.util.stream.Collectors ;
2024-08-28 17:42:16 +08:00
/ * *
* @author Harryxzy
* @ClassName LyPZServiceImpl
* @date 2024 / 08 / 27 10 : 14
* @description
* /
@Slf4j
public class LyPZServiceImpl extends Service implements LyPZService {
private LySalaryReportService getLySalaryReportService ( User user ) {
return ServiceUtil . getService ( LySalaryReportServiceImpl . class , user ) ;
}
private LySocialReportService getLySocialReportService ( User user ) {
return ServiceUtil . getService ( LySocialReportServiceImpl . class , user ) ;
}
2024-10-21 18:02:04 +08:00
private LyFundReportService getLyFundReportService ( User user ) {
return ServiceUtil . getService ( LyFundReportServiceImpl . class , user ) ;
}
2024-08-28 17:42:16 +08:00
private FormulaRunService getFormulaRunService ( User user ) {
return ServiceUtil . getService ( FormulaRunServiceImpl . class , user ) ;
}
2024-09-04 16:15:01 +08:00
private LyVoucherMapper getLyVoucherMapper ( ) {
return MapperProxyFactory . getProxy ( LyVoucherMapper . class ) ;
}
private LyVoucherDetailMapper getLyVoucherDetailMapper ( ) {
return MapperProxyFactory . getProxy ( LyVoucherDetailMapper . class ) ;
}
2024-08-30 17:44:26 +08:00
private UfKjkmMapper getUfKjkmMapper ( ) {
return MapperProxyFactory . getProxy ( UfKjkmMapper . class ) ;
}
2024-09-04 16:15:01 +08:00
private SalaryEmployeeService getSalaryEmployeeService ( User user ) {
return ServiceUtil . getService ( SalaryEmployeeServiceImpl . class , user ) ;
}
2024-08-28 17:42:16 +08:00
2024-09-06 15:36:20 +08:00
private TaxAgentService getTaxAgentService ( User user ) {
return ServiceUtil . getService ( TaxAgentServiceImpl . class , user ) ;
}
2024-08-28 17:42:16 +08:00
@Override
2024-08-30 17:44:26 +08:00
public Map < String , Object > genPZ ( LyPZGenParam queryParam ) {
2024-09-04 16:15:01 +08:00
// 获取报表结果,并将其每一列都转换为变量
List < Long > reportDataIds = new ArrayList < > ( ) ;
List < List < FormulaVar > > formulaVarsList = getLyReportFormulaVar ( queryParam , reportDataIds ) ;
// 校验这些数据是否已经生成过了凭证
verifyCanGen ( queryParam , reportDataIds ) ;
// 获取当前凭证对应的所有会计科目信息
List < UfKjkmPO > ufKjkmList = genKjkmList ( queryParam . getPzlx ( ) ) ;
Map < String , Map < String , Object > > pzDetailValueMap = new LinkedHashMap < > ( ) ;
Map < String , Object > totalKjkmValueMap = new HashMap < String , Object > ( ) ;
BaseBean baseBean = new BaseBean ( ) ;
RecordSet rs = new RecordSet ( ) ;
String yFlag = baseBean . getPropValue ( " lySalaryNCVoucher " , " sfddpzfl_y_flag " ) ;
String dkgrsdsBm = baseBean . getPropValue ( " lySalaryNCVoucher " , " kjkm_dkkrsds_bm " ) ;
// 获取所有的部门信息
List < DeptInfo > deptInfos = getSalaryEmployeeService ( user ) . listAllDeptInfoList ( ) ;
// key:分部id-部门名称, value:部门id
Map < String , DeptInfo > depInfoMap = SalaryEntityUtil . convert2Map ( deptInfos , dep - > dep . getSubcompanyid1 ( ) + " - " + dep . getName ( ) ) ;
Set < Long > subCompanyIds = new HashSet < > ( ) ;
for ( List < FormulaVar > varList : formulaVarsList ) {
String subcompanyId = " " ;
// 获取他们的职能项目类型,如果是项目则单独统计,如果是职能获取他部门上“是否单独凭证分录”的属性
boolean singleCount = false ;
Map < String , String > varMap = SalaryEntityUtil . convert2Map ( varList , FormulaVar : : getFieldId , FormulaVar : : getContent ) ;
subcompanyId = varMap . get ( " subcompanyId " ) ;
String znxmlxContent = varMap . get ( " 职能项目类型 " ) ;
if ( StringUtils . isBlank ( znxmlxContent ) ) {
singleCount = true ;
} else {
2024-09-06 15:36:20 +08:00
if ( znxmlxContent . equals ( " 项目/案场 " ) ) {
2024-09-04 16:15:01 +08:00
singleCount = true ;
} else if ( znxmlxContent . equals ( " 职能 " ) ) {
// 获取部门信息
DeptInfo dept = depInfoMap . get ( subcompanyId + " - " + varMap . getOrDefault ( " 职能项目名称 " , " " ) ) ;
// 获取部门属性信息
if ( dept = = null ) {
singleCount = true ;
} else {
rs . execute ( " SELECT sfddpzfl FROM hrmdepartmentdefined where deptid= " + dept . getId ( ) ) ;
if ( rs . next ( ) ) {
if ( rs . getInt ( " sfddpzfl " ) = = new Integer ( yFlag ) ) {
singleCount = true ;
}
}
}
} else {
singleCount = true ;
}
}
String key = " " ;
if ( singleCount = = false & & znxmlxContent . equals ( " 职能 " ) ) {
// 所有职能合并算
key = " 职能 " ;
} else {
key = varMap . get ( " 职能项目名称 " ) ;
}
Map < String , Object > kjkmValueMap = pzDetailValueMap . computeIfAbsent ( key + " _split " + znxmlxContent + " _split " + subcompanyId , k - > new HashMap < String , Object > ( ) ) ;
// 每一条记录都需要执行一遍公式并把结果相加
for ( UfKjkmPO kjkm : ufKjkmList ) {
// 给公式中的变量填入值
ExcelResult result = new ExcelResult ( ) ;
try {
result = getFormulaRunService ( user ) . run ( kjkm . getKjkmSalaryItemFormula ( ) , varList , null ) ;
} catch ( Exception e ) {
log . error ( " express execute fail " , e ) ;
result . setStatus ( false ) ;
result . setErrorMsg ( e . getMessage ( ) ) ;
}
//核算出错,给个默认值
if ( ! result . isStatus ( ) | | result . getData ( ) = = null ) {
log . error ( " express execute fail status " , result . getErrorMsg ( ) ) ;
result . setData ( " 0 " ) ;
}
String resultStr = result . getData ( ) = = null ? " 0 " : result . getData ( ) . toString ( ) ;
BigDecimal resultBigDecimal = NumberUtils . isCreatable ( resultStr ) ? new BigDecimal ( resultStr ) : BigDecimal . ZERO ;
if ( kjkm . getSfhbtj ( ) ! = null & & kjkm . getSfhbtj ( ) . equals ( NumberUtils . INTEGER_ONE ) ) {
// 需要合并计算的会计科目
totalKjkmValueMap . put ( kjkm . getKmbm ( ) , ( ( BigDecimal ) totalKjkmValueMap . getOrDefault ( kjkm . getKmbm ( ) , new BigDecimal ( 0 ) ) ) . add ( resultBigDecimal ) ) ;
totalKjkmValueMap . put ( " subCompanyId " , subcompanyId ) ;
subCompanyIds . add ( NumberUtils . isCreatable ( subcompanyId ) ? Long . valueOf ( subcompanyId ) : 0 ) ;
} else {
if ( kjkm . getKmbm ( ) . equals ( dkgrsdsBm ) & & queryParam . getPzlx ( ) . equals ( LyPZTypeEnum . XZFFPZ . getValue ( ) ) ) {
kjkmValueMap . put ( kjkm . getKmbm ( ) + kjkm . getXzxm ( ) , ( ( BigDecimal ) kjkmValueMap . getOrDefault ( kjkm . getKmbm ( ) + kjkm . getXzxm ( ) , new BigDecimal ( 0 ) ) ) . add ( resultBigDecimal ) ) ;
kjkmValueMap . put ( " subCompanyId " , subcompanyId ) ;
subCompanyIds . add ( NumberUtils . isCreatable ( subcompanyId ) ? Long . valueOf ( subcompanyId ) : 0 ) ;
} else {
kjkmValueMap . put ( kjkm . getKmbm ( ) , ( ( BigDecimal ) kjkmValueMap . getOrDefault ( kjkm . getKmbm ( ) , new BigDecimal ( 0 ) ) ) . add ( resultBigDecimal ) ) ;
kjkmValueMap . put ( " subCompanyId " , subcompanyId ) ;
subCompanyIds . add ( NumberUtils . isCreatable ( subcompanyId ) ? Long . valueOf ( subcompanyId ) : 0 ) ;
}
}
}
}
if ( MapUtils . isNotEmpty ( totalKjkmValueMap ) ) {
pzDetailValueMap . put ( " totalKjkm " , totalKjkmValueMap ) ;
}
// 封装会计科目的摘要信息、会计科目信息、借贷金额薪资,过滤金额为0的会计科目
List < LyPzPreview > lyPzPreviewList = new ArrayList < > ( ) ;
Map < String , String > kmbmInfoMap = new HashMap < > ( ) ;
List < UfKjkmPO > allKjkm = getUfKjkmMapper ( ) . listAll ( ) ;
allKjkm . forEach ( po - > kmbmInfoMap . put ( po . getKmbm ( ) , po . getKmmc ( ) ) ) ;
// 获取所有分部的辅助核算信息
List < LyFzhsInfo > fzhsList = getSalaryEmployeeService ( user ) . listAllFzhsInfo ( ) ;
Map < Long , LyFzhsInfo > lyFzhsInfoMap = SalaryEntityUtil . convert2Map ( fzhsList , LyFzhsInfo : : getSubCompanyId ) ;
List < SubCompanyInfo > subCompanyInfoList = getSalaryEmployeeService ( user ) . getSubCompanyInfoList ( subCompanyIds . stream ( ) . collect ( Collectors . toList ( ) ) ) ;
Map < Long , String > subCompanyMap = SalaryEntityUtil . convert2Map ( subCompanyInfoList , SubCompanyInfo : : getId , SubCompanyInfo : : getName ) ;
// 获取辅助核算列表信息
List < String > fzhsBmList = new ArrayList < > ( ) ;
fzhsList . stream ( ) . forEach ( info - > {
fzhsBmList . add ( info . getFzhs ( ) ) ;
fzhsBmList . add ( info . getFzhsks ( ) ) ;
fzhsBmList . add ( info . getFzhssllb ( ) ) ;
fzhsBmList . add ( info . getFzhsfwlb ( ) ) ;
} ) ;
// 根据辅助核算编码获取辅助核算浏览框
Map < String , LyFzhsBrowser > fzhsBrowserMap = getFzhsBrowserByBm ( fzhsBmList ) ;
// 获取对应的薪资所属月和季度(季度为上一季度)
queryParam . setSalaryMonthDate ( SalaryDateUtil . dateStrToLocalYearMonth ( queryParam . getSalaryMonth ( ) ) ) ;
String chnYearMonth = SalaryDateUtil . getFormatCHNYearMonth ( queryParam . getSalaryMonthDate ( ) ) ;
String chnLastSeason = getLastSeason ( queryParam . getSalaryMonthDate ( ) ) ;
// 获取摘要根据科目名称生成的摘要科目
List < String > xzffSpecialZyKjkmbm = Arrays . stream ( baseBean . getPropValue ( " lySalaryNCVoucher " , " xzff_special_zy_kjkmbm " ) . split ( " , " ) ) . collect ( Collectors . toList ( ) ) ;
List < String > sbffSpecialZyKjkmbm = Arrays . stream ( baseBean . getPropValue ( " lySalaryNCVoucher " , " sbff_special_zy_kjkmbm " ) . split ( " , " ) ) . collect ( Collectors . toList ( ) ) ;
// 社保公积金计提母子公司往来款
String sbgjjJtMzkswlkbm = baseBean . getPropValue ( " lySalaryNCVoucher " , " sbgjj_jt_mzkswlkbm " ) ;
for ( Map . Entry < String , Map < String , Object > > entry : pzDetailValueMap . entrySet ( ) ) {
Map < String , Object > kjkmValueMap = entry . getValue ( ) ;
Long subCompanyId = Long . valueOf ( kjkmValueMap . get ( " subCompanyId " ) . toString ( ) ) ;
LyFzhsInfo lyFzhsInfo = lyFzhsInfoMap . get ( subCompanyId ) ;
for ( UfKjkmPO kjkm : ufKjkmList ) {
// 获取该会计科目对应的辅助核算
BigDecimal value = new BigDecimal ( 0 ) ;
if ( kjkm . getKmbm ( ) . equals ( dkgrsdsBm ) & & queryParam . getPzlx ( ) . equals ( LyPZTypeEnum . XZFFPZ . getValue ( ) ) ) {
value = ( BigDecimal ) kjkmValueMap . get ( kjkm . getKmbm ( ) + kjkm . getXzxm ( ) ) ;
} else {
value = ( BigDecimal ) kjkmValueMap . get ( kjkm . getKmbm ( ) ) ;
}
if ( value ! = null & & ! value . equals ( BigDecimal . ZERO ) ) {
LyPzPreview build = LyPzPreview . builder ( )
. zy ( genZy ( chnYearMonth , chnLastSeason , queryParam . getPzlx ( ) , entry . getKey ( ) , kjkm . getSfsjdkm ( ) , subCompanyMap , kjkm , xzffSpecialZyKjkmbm , sbffSpecialZyKjkmbm , sbgjjJtMzkswlkbm ) )
. kjkm ( getFullPathKjkm ( kjkm . getKmbm ( ) , kmbmInfoMap ) )
. jfValue ( kjkm . getFx ( ) . equals ( LyJDDirectionTypeEnum . DEBIT . getValue ( ) ) ? value . toString ( ) : " 0.00 " )
. dfValue ( kjkm . getFx ( ) . equals ( LyJDDirectionTypeEnum . CREDIT . getValue ( ) ) ? value . toString ( ) : " 0.00 " )
. fzhsXmqs ( lyFzhsInfo ! = null & & kjkm . isFzhsFlag ( ) ? fzhsBrowserMap . get ( lyFzhsInfo . getFzhs ( ) ) : null )
. fzhsFwlb ( lyFzhsInfo ! = null & & kjkm . isFzhsFwlbFlag ( ) ? fzhsBrowserMap . get ( lyFzhsInfo . getFzhsfwlb ( ) ) : null )
. fzhsSllb ( lyFzhsInfo ! = null & & kjkm . isFzhsSllbFlag ( ) ? fzhsBrowserMap . get ( lyFzhsInfo . getFzhssllb ( ) ) : null )
. fzhsKs ( lyFzhsInfo ! = null & & kjkm . isFzhsKsFlag ( ) ? fzhsBrowserMap . get ( lyFzhsInfo . getFzhsks ( ) ) : null )
. dataSource ( reportDataIds )
. build ( ) ;
lyPzPreviewList . add ( build ) ;
}
}
}
List < WeaTableColumn > columns = new ArrayList < > ( ) ;
columns . add ( new WeaTableColumn ( " 100px " , " 摘要 " , " zy " ) ) ;
columns . add ( new WeaTableColumn ( " 100px " , " 会计科目 " , " kjkm " ) ) ;
columns . add ( new WeaTableColumn ( " 100px " , " 辅助核算-项目期数 " , " fzhsXmqs " ) ) ;
columns . add ( new WeaTableColumn ( " 100px " , " 辅助核算-房屋类别 " , " fzhsFwlb " ) ) ;
columns . add ( new WeaTableColumn ( " 100px " , " 辅助核算-税率类别 " , " fzhsSllb " ) ) ;
columns . add ( new WeaTableColumn ( " 100px " , " 辅助核算-客商 " , " fzhsKs " ) ) ;
columns . add ( new WeaTableColumn ( " 100px " , " 辅助核算 " , " fzhsOther " ) ) ;
columns . add ( new WeaTableColumn ( " 100px " , " 借方金额 " , " jfValue " ) ) ;
columns . add ( new WeaTableColumn ( " 100px " , " 贷方金额 " , " dfValue " ) ) ;
Map < String , Object > resultMap = new HashMap < > ( ) ;
resultMap . put ( " columns " , columns ) ;
resultMap . put ( " data " , lyPzPreviewList ) ;
2024-09-06 09:12:38 +08:00
// 求合计值
BigDecimal jfTotal = new BigDecimal ( " 0 " ) ;
BigDecimal dfTotal = new BigDecimal ( " 0 " ) ;
for ( LyPzPreview pzPreview : lyPzPreviewList ) {
if ( NumberUtils . isCreatable ( pzPreview . getJfValue ( ) ) ) {
jfTotal = jfTotal . add ( new BigDecimal ( pzPreview . getJfValue ( ) ) ) ;
}
if ( NumberUtils . isCreatable ( pzPreview . getDfValue ( ) ) ) {
dfTotal = dfTotal . add ( new BigDecimal ( pzPreview . getDfValue ( ) ) ) ;
}
}
LyPzPreview sumPz = LyPzPreview . builder ( ) . zy ( " 合计 " ) . jfValue ( jfTotal . toPlainString ( ) ) . dfValue ( dfTotal . toPlainString ( ) ) . build ( ) ;
resultMap . put ( " totalData " , sumPz ) ;
2024-09-04 16:15:01 +08:00
return resultMap ;
}
/ * *
* 根据凭证编码获取浏览框
* @param fzhsBmList
* @return
* /
private Map < String , LyFzhsBrowser > getFzhsBrowserByBm ( List < String > fzhsBmList ) {
if ( CollectionUtils . isEmpty ( fzhsBmList ) ) {
return Collections . emptyMap ( ) ;
}
List < LyFzhsBrowser > lyFzhsBrowserList = new ArrayList < > ( ) ;
RecordSet rs = new RecordSet ( ) ;
2024-10-21 18:02:04 +08:00
BaseBean baseBean = new BaseBean ( ) ;
String fzhslxFieldId = baseBean . getPropValue ( " lySalaryNCVoucher " , " fzhslx_field_id " ) ;
2024-09-04 16:15:01 +08:00
List < List < String > > partition = Lists . partition ( fzhsBmList , 500 ) ;
partition . forEach ( part - > {
String bmIdStr = StringUtils . join ( part , " ',' " ) ;
2024-10-21 18:02:04 +08:00
rs . execute ( " SELECT b.SELECTNAME,fzhslx,fzhslxbh,bh,mc FROM uf_ncfuhs a left join workflow_selectitem b on a.fzhslx= b.selectvalue where bh in (' " + bmIdStr + " ') and fieldid= " + fzhslxFieldId ) ;
2024-09-04 16:15:01 +08:00
while ( rs . next ( ) ) {
LyFzhsBrowser browser = new LyFzhsBrowser ( ) ;
2024-10-21 18:02:04 +08:00
browser . setFzhslx ( rs . getString ( " SELECTNAME " ) ) ;
2024-09-04 16:15:01 +08:00
browser . setBh ( rs . getString ( " bh " ) ) ;
browser . setMc ( rs . getString ( " mc " ) ) ;
2024-10-12 16:39:09 +08:00
browser . setFzhslxbh ( rs . getString ( " fzhslxbh " ) ) ;
2024-09-04 16:15:01 +08:00
lyFzhsBrowserList . add ( browser ) ;
}
} ) ;
return SalaryEntityUtil . convert2Map ( lyFzhsBrowserList , LyFzhsBrowser : : getBh ) ;
}
/ * *
* 校验这些数据是否已经生成过了凭证
*
* @param queryParam
* @param reportDataIds
* /
private void verifyCanGen ( LyPZGenParam queryParam , List < Long > reportDataIds ) {
Date salaryMonth = SalaryDateUtil . dateStrToLocalYearMonth ( queryParam . getSalaryMonth ( ) ) ;
// 根据薪资所属月和凭证类型查询凭证
2024-09-06 15:36:20 +08:00
List < LyVoucherPO > lyVoucherPOS = getLyVoucherMapper ( ) . listSome ( LyVoucherPO . builder ( ) . salaryMonth ( salaryMonth ) . pzlx ( queryParam . getPzlx ( ) ) . ffgsqc ( queryParam . getFfgsqc ( ) ) . build ( ) ) ;
2024-09-04 16:15:01 +08:00
List < Long > dataIds = lyVoucherPOS . stream ( )
. map ( po - > po . getDataSource ( ) . split ( " , " ) )
. flatMap ( Arrays : : stream )
. filter ( NumberUtils : : isCreatable )
. map ( Long : : valueOf )
2024-09-06 15:36:20 +08:00
. distinct ( )
2024-09-04 16:15:01 +08:00
. collect ( Collectors . toList ( ) ) ;
Optional < Long > existVoucher = reportDataIds . stream ( ) . filter ( dataIds : : contains ) . findFirst ( ) ;
if ( existVoucher . isPresent ( ) ) {
throw new SalaryRunTimeException ( " 该数据已生成过凭证,请联系管理员删除后再重新生成凭证 " ) ;
}
}
@Override
public PageInfo < Map < String , Object > > fzhsBrowserList ( LyFzhslxParam queryParam ) {
RecordSet rs = new RecordSet ( ) ;
BaseBean baseBean = new BaseBean ( ) ;
String fzhslxFieldId = baseBean . getPropValue ( " lySalaryNCVoucher " , " fzhslx_field_id " ) ;
2024-09-06 09:12:38 +08:00
if ( queryParam . getFzhslx ( ) = = null ) {
2024-10-12 16:39:09 +08:00
rs . execute ( " select bh,mc,fzhslx,fzhslxbh,b.selectname from uf_NCfuhs a left join workflow_selectitem b on a. fzhslx= b.SELECTVALUE where b.FIELDID= " + fzhslxFieldId ) ;
2024-09-06 09:12:38 +08:00
} else {
2024-10-12 16:39:09 +08:00
rs . execute ( " select bh,mc,fzhslx,fzhslxbh,b.selectname from uf_NCfuhs a left join workflow_selectitem b on a. fzhslx= b.SELECTVALUE where b.FIELDID= " + fzhslxFieldId + " and a.fzhslx = " + queryParam . getFzhslx ( ) ) ;
2024-09-06 09:12:38 +08:00
}
2024-09-04 16:15:01 +08:00
List < Map < String , Object > > resultList = new ArrayList < > ( ) ;
while ( rs . next ( ) ) {
if ( StringUtils . isNotBlank ( queryParam . getKey ( ) )
& & ! rs . getString ( " mc " ) . contains ( queryParam . getKey ( ) )
& & ! rs . getString ( " bh " ) . contains ( queryParam . getKey ( ) ) ) {
} else {
Map < String , Object > resultMap = new HashMap < > ( ) ;
resultMap . put ( " bh " , rs . getString ( " bh " ) ) ;
resultMap . put ( " mc " , rs . getString ( " mc " ) ) ;
resultMap . put ( " fzhslx " , rs . getString ( " selectname " ) ) ;
2024-10-12 16:39:09 +08:00
resultMap . put ( " fzhslxbh " , rs . getString ( " fzhslxbh " ) ) ;
2024-09-04 16:15:01 +08:00
resultList . add ( resultMap ) ;
}
}
return SalaryPageUtil . buildPage ( queryParam . getCurrent ( ) , queryParam . getPageSize ( ) , resultList ) ;
}
/ * *
* 获取报表结果 , 并将其每一列都转换为变量
*
* @param queryParam
* @return
* /
private List < List < FormulaVar > > getLyReportFormulaVar ( LyPZGenParam queryParam , List < Long > reportDataIds ) {
2024-08-28 17:42:16 +08:00
List < List < FormulaVar > > formulaVarsList = new ArrayList < > ( ) ;
if ( queryParam . getPzlx ( ) . equals ( LyPZTypeEnum . XZFFPZ . getValue ( ) ) | | queryParam . getPzlx ( ) . equals ( LyPZTypeEnum . XZJTPZ . getValue ( ) ) ) {
// 是工资单凭证
2024-09-14 14:06:31 +08:00
Map < String , Object > resultMap = getLySalaryReportService ( user ) . listSalaryReport ( LySalaryReportQueryParam . builder ( ) . salaryMonth ( queryParam . getSalaryMonth ( ) ) . ffgsqc ( Collections . singletonList ( queryParam . getFfgsqc ( ) ) ) . export ( true ) . build ( ) ) ;
2024-08-28 17:42:16 +08:00
List < LySalaryReportPO > dataList = ( ( PageInfo < LySalaryReportPO > ) resultMap . get ( " data " ) ) . getList ( ) ;
// 将每一个结果转换成map的格式并作为变量存储
for ( LySalaryReportPO po : dataList ) {
2024-09-04 16:15:01 +08:00
reportDataIds . add ( po . getId ( ) ) ;
2024-08-28 17:42:16 +08:00
Map < String , Object > dataMap = BeanUtil . beanToMap ( po ) ;
List < FormulaVar > formulaVars = new ArrayList < > ( ) ;
for ( Map . Entry < String , Object > entry : dataMap . entrySet ( ) ) {
FormulaVar build = FormulaVar . builder ( )
. fieldId ( entry . getKey ( ) )
. content ( Util . null2String ( entry . getValue ( ) ) )
2024-08-30 17:44:26 +08:00
. fieldType ( DataType . NUMBER )
2024-08-28 17:42:16 +08:00
. build ( ) ;
2024-08-30 17:44:26 +08:00
if ( entry . getKey ( ) . equals ( " ffgsqc " ) | | entry . getKey ( ) . equals ( " fycdgsqc " ) | | entry . getKey ( ) . equals ( " znxmmc " ) ) {
build . setFieldType ( DataType . STRING ) ;
}
2024-08-28 17:42:16 +08:00
formulaVars . add ( build ) ;
}
formulaVarsList . add ( formulaVars ) ;
}
2024-10-21 18:02:04 +08:00
} else if ( queryParam . getPzlx ( ) . equals ( LyPZTypeEnum . SBJTPZ . getValue ( ) ) | | queryParam . getPzlx ( ) . equals ( LyPZTypeEnum . SBFFPZ . getValue ( ) ) ) {
// 是社保凭证
2024-09-14 14:06:31 +08:00
Map < String , Object > resultMap = getLySocialReportService ( user ) . listSIReport ( LySalaryReportQueryParam . builder ( ) . salaryMonth ( queryParam . getSalaryMonth ( ) ) . ffgsqc ( Collections . singletonList ( queryParam . getFfgsqc ( ) ) ) . export ( true ) . build ( ) ) ;
2024-08-28 17:42:16 +08:00
List < LySocialReportPO > dataList = ( ( PageInfo < LySocialReportPO > ) resultMap . get ( " data " ) ) . getList ( ) ;
// 将每一个结果转换成map的格式并作为变量存储
for ( LySocialReportPO po : dataList ) {
2024-09-04 16:15:01 +08:00
reportDataIds . add ( po . getId ( ) ) ;
2024-08-28 17:42:16 +08:00
Map < String , Object > dataMap = BeanUtil . beanToMap ( po ) ;
List < FormulaVar > formulaVars = new ArrayList < > ( ) ;
for ( Map . Entry < String , Object > entry : dataMap . entrySet ( ) ) {
FormulaVar build = FormulaVar . builder ( )
. fieldId ( entry . getKey ( ) )
. content ( Util . null2String ( entry . getValue ( ) ) )
2024-08-30 17:44:26 +08:00
. fieldType ( DataType . NUMBER )
2024-08-28 17:42:16 +08:00
. build ( ) ;
2024-08-30 17:44:26 +08:00
if ( entry . getKey ( ) . equals ( " ffgsqc " ) | | entry . getKey ( ) . equals ( " fycdgsqc " ) | | entry . getKey ( ) . equals ( " znxmmc " ) ) {
build . setFieldType ( DataType . STRING ) ;
}
2024-08-28 17:42:16 +08:00
formulaVars . add ( build ) ;
}
formulaVarsList . add ( formulaVars ) ;
}
2024-10-21 18:02:04 +08:00
} else if ( queryParam . getPzlx ( ) . equals ( LyPZTypeEnum . GJJJTPZ . getValue ( ) ) | | queryParam . getPzlx ( ) . equals ( LyPZTypeEnum . GJJFFPZ . getValue ( ) ) ) {
// 是公积金凭证
Map < String , Object > resultMap = getLyFundReportService ( user ) . listFundReport ( LySalaryReportQueryParam . builder ( ) . salaryMonth ( queryParam . getSalaryMonth ( ) ) . ffgsqc ( Collections . singletonList ( queryParam . getFfgsqc ( ) ) ) . export ( true ) . build ( ) ) ;
List < LyFundReportPO > dataList = ( ( PageInfo < LyFundReportPO > ) resultMap . get ( " data " ) ) . getList ( ) ;
// 将每一个结果转换成map的格式并作为变量存储
for ( LyFundReportPO po : dataList ) {
reportDataIds . add ( po . getId ( ) ) ;
Map < String , Object > dataMap = BeanUtil . beanToMap ( po ) ;
List < FormulaVar > formulaVars = new ArrayList < > ( ) ;
for ( Map . Entry < String , Object > entry : dataMap . entrySet ( ) ) {
FormulaVar build = FormulaVar . builder ( )
. fieldId ( entry . getKey ( ) )
. content ( Util . null2String ( entry . getValue ( ) ) )
. fieldType ( DataType . NUMBER )
. build ( ) ;
if ( entry . getKey ( ) . equals ( " ffgsqc " ) | | entry . getKey ( ) . equals ( " fycdgsqc " ) | | entry . getKey ( ) . equals ( " znxmmc " ) ) {
build . setFieldType ( DataType . STRING ) ;
}
formulaVars . add ( build ) ;
}
formulaVarsList . add ( formulaVars ) ;
}
2024-08-28 17:42:16 +08:00
}
2024-09-04 16:15:01 +08:00
return formulaVarsList ;
}
2024-08-28 17:42:16 +08:00
2024-09-04 16:15:01 +08:00
/ * *
* 获取会计科目信息
*
* @param pzlx
* @return
* /
private List < UfKjkmPO > genKjkmList ( Integer pzlx ) {
List < UfKjkmPO > ufKjkmList = getUfKjkmMapper ( ) . listSome ( UfKjkmPO . builder ( ) . pzlx ( pzlx ) . build ( ) ) ;
// 封装会计科目对应的公式及辅助核算信息
2024-08-30 17:44:26 +08:00
for ( UfKjkmPO kjkm : ufKjkmList ) {
2024-08-28 17:42:16 +08:00
ExpressFormula expressFormula = ExpressFormula . builder ( ) . name ( " t " )
. referenceType ( ReferenceTypeEnum . FORMULA . getValue ( ) )
2024-08-30 17:44:26 +08:00
. formula ( kjkm . getXzxm ( ) )
. formulaRunScript ( kjkm . getXzxm ( ) )
2024-08-28 17:42:16 +08:00
. extendParam ( " {} " )
. build ( ) ;
2024-08-30 17:44:26 +08:00
kjkm . setKjkmSalaryItemFormula ( expressFormula ) ;
2024-09-04 16:15:01 +08:00
String fzhs = kjkm . getFzhs ( ) ;
if ( StringUtils . isNotBlank ( fzhs ) ) {
List < Integer > fzhsIdList = Arrays . stream ( fzhs . split ( " , " ) ) . filter ( NumberUtils : : isCreatable ) . map ( Integer : : valueOf ) . collect ( Collectors . toList ( ) ) ;
if ( fzhsIdList . contains ( LyFzhsTypeEnum . XMQS . getValue ( ) ) ) {
kjkm . setFzhsFlag ( true ) ;
}
if ( fzhsIdList . contains ( LyFzhsTypeEnum . FWLB . getValue ( ) ) ) {
kjkm . setFzhsFwlbFlag ( true ) ;
}
if ( fzhsIdList . contains ( LyFzhsTypeEnum . KS . getValue ( ) ) ) {
kjkm . setFzhsKsFlag ( true ) ;
}
if ( fzhsIdList . contains ( LyFzhsTypeEnum . SLLB . getValue ( ) ) ) {
kjkm . setFzhsSllbFlag ( true ) ;
}
}
2024-08-28 17:42:16 +08:00
}
2024-09-04 16:15:01 +08:00
return ufKjkmList ;
}
2024-08-28 17:42:16 +08:00
2024-09-04 16:15:01 +08:00
/ * *
* 生成摘要
*
* @param chnYearMonth
* @param chnLastSeason
* @param pzlx
* @return
* /
private String genZy ( String chnYearMonth ,
String chnLastSeason ,
Integer pzlx ,
String keyName ,
Integer sfsjdkm ,
Map < Long , String > subCompanyMap ,
UfKjkmPO kjkm ,
List < String > xzffFpecialZyKjkmbm ,
List < String > sbffSpecialZyKjkmbm ,
String sbgjjJtMzkswlkbm ) {
String [ ] split = keyName . split ( " _split " ) ;
// "职能" / "职能项目名称"
String znxmmc = split . length > 1 ? split [ 0 ] : " " ;
// 职能项目类型 “职能”/“项目”
String znxmlx = split . length > 2 ? split [ 1 ] : " " ;
// 分部id
String subCompanyId = split . length > 3 ? split [ 2 ] : " 0 " ;
StringBuilder zySb = new StringBuilder ( ) ;
if ( pzlx . equals ( LyPZTypeEnum . XZJTPZ . getValue ( ) ) ) {
zySb . append ( " 计提 " ) ;
// 所在分部名称规则
// 1、如果是项目则为项目职能名称;
// 2、如果是职能, 合并的职能固定为”职能工资“, 单独统计的职能为该部门对应的”分部名称“
if ( znxmlx . equals ( " 职能 " ) ) {
if ( znxmmc . equals ( " 职能 " ) ) {
zySb . append ( " 职能 " ) ;
} else {
// 分部名称
zySb . append ( subCompanyMap . getOrDefault ( Long . valueOf ( subCompanyId ) , " " ) ) ;
2024-08-28 17:42:16 +08:00
}
2024-09-06 15:36:20 +08:00
} else if ( znxmlx . equals ( " 项目/案场 " ) ) {
2024-09-04 16:15:01 +08:00
zySb . append ( znxmmc ) ;
}
if ( sfsjdkm ! = null & & sfsjdkm . equals ( 1 ) ) {
// 是绩效科目
zySb . append ( chnLastSeason ) . append ( " 绩效 " ) ;
} else {
zySb . append ( chnYearMonth ) . append ( " 工资 " ) ;
}
} else if ( pzlx . equals ( LyPZTypeEnum . XZFFPZ . getValue ( ) ) ) {
// 薪资发放凭证
// 发放+【职能、项目、分部】 +【绩效、工资、特殊会计科目】
zySb . append ( " 发放 " ) ;
if ( znxmlx . equals ( " 职能 " ) ) {
if ( znxmmc . equals ( " 职能 " ) ) {
zySb . append ( " 职能 " ) ;
} else {
// 分部名称
zySb . append ( subCompanyMap . getOrDefault ( Long . valueOf ( subCompanyId ) , " " ) ) ;
2024-08-28 17:42:16 +08:00
}
2024-09-06 15:36:20 +08:00
} else if ( znxmlx . equals ( " 项目/案场 " ) ) {
2024-09-04 16:15:01 +08:00
zySb . append ( znxmmc ) ;
}
if ( sfsjdkm ! = null & & sfsjdkm . equals ( 1 ) ) {
// 是绩效科目
zySb . append ( chnLastSeason ) . append ( " 绩效 " ) ;
} else {
if ( xzffFpecialZyKjkmbm . contains ( kjkm . getKmbm ( ) ) ) {
zySb . append ( kjkm . getKmmc ( ) ) ;
} else {
zySb . append ( chnYearMonth ) . append ( " 工资 " ) ;
}
}
} else if ( pzlx . equals ( LyPZTypeEnum . SBJTPZ . getValue ( ) ) | | pzlx . equals ( LyPZTypeEnum . GJJJTPZ . getValue ( ) ) ) {
// 社保公积金计提凭证
zySb . append ( " 计提 " + chnYearMonth )
. append ( pzlx . equals ( LyPZTypeEnum . SBJTPZ . getValue ( ) ) ? " 社保 " : " 公积金 " ) ;
} else if ( pzlx . equals ( LyPZTypeEnum . SBFFPZ . getValue ( ) ) | | pzlx . equals ( LyPZTypeEnum . GJJFFPZ . getValue ( ) ) ) {
// 社保公积金发放凭证
if ( sbffSpecialZyKjkmbm . contains ( kjkm . getKmbm ( ) ) ) {
zySb . append ( kjkm . getKmmc ( ) ) ;
} else {
if ( sbgjjJtMzkswlkbm . equals ( kjkm . getKmbm ( ) ) ) {
zySb . append ( " 代缴纳 " ) ;
} else {
zySb . append ( " 银行扣 " ) ;
}
zySb . append ( " " + chnYearMonth )
. append ( pzlx . equals ( LyPZTypeEnum . SBFFPZ . getValue ( ) ) ? " 社保 " : " 公积金 " ) ;
2024-08-28 17:42:16 +08:00
}
}
2024-09-04 16:15:01 +08:00
return zySb . toString ( ) ;
}
2024-08-30 17:44:26 +08:00
2024-09-04 16:15:01 +08:00
/ * *
* 根据科目编码获取对应的全路径名称
* @param kmbm
* @param kmbmInfoMap
* @return
* /
private String getFullPathKjkm ( String kmbm , Map < String , String > kmbmInfoMap ) {
int length = kmbm . length ( ) ;
if ( length = = 4 ) {
// 是一级科目,不需要拼接
return kmbm + " \\ " + kmbmInfoMap . getOrDefault ( kmbm , " " ) ;
} else if ( length = = 6 ) {
// 是二级科目,先找一级科目
String firstKjkmbm = kmbm . substring ( 0 , 4 ) ;
String firstKjkm = kmbmInfoMap . getOrDefault ( firstKjkmbm , " " ) ;
return kmbm + " \\ " + firstKjkm + " \\ " + kmbmInfoMap . getOrDefault ( kmbm , " " ) ;
} else if ( length = = 8 ) {
// 是三级科目
String firstKjkmbm = kmbm . substring ( 0 , 4 ) ;
String firstKjkm = kmbmInfoMap . getOrDefault ( firstKjkmbm , " " ) ;
String secondKjkmbm = kmbm . substring ( 0 , 6 ) ;
String secondKjkm = kmbmInfoMap . getOrDefault ( secondKjkmbm , " " ) ;
return kmbm + " \\ " + firstKjkm + " \\ " + secondKjkm + " \\ " + kmbmInfoMap . getOrDefault ( kmbm , " " ) ;
} else {
return " 科目编码格式错误! " ;
2024-08-30 17:44:26 +08:00
}
2024-09-04 16:15:01 +08:00
}
2024-08-30 17:44:26 +08:00
2024-09-04 16:15:01 +08:00
private String getLastSeason ( Date currentDate ) {
Calendar cal = Calendar . getInstance ( ) ;
cal . setTime ( currentDate ) ;
// 确定当前日期所在的季度
int currentMonth = cal . get ( Calendar . MONTH ) + 1 ;
int currentQuarter = ( currentMonth - 1 ) / 3 + 1 ;
// 计算上一个季度的季度号
int previousQuarter = currentQuarter - 1 ;
int previousYear = cal . get ( Calendar . YEAR ) ;
// 如果上一个季度跨越了年度
if ( previousQuarter < = 0 ) {
previousQuarter + = 4 ; // 上一个季度为上一年的第四个季度
previousYear - = 1 ;
}
// 格式化输出
String result = previousYear + " 年 " + previousQuarter + " 季度 " ;
return result ;
}
/ * *
* 推送凭证
* @param pushParam
* /
@Override
2024-10-12 16:39:09 +08:00
public Map < String , Object > pushUCAndSave ( LyVoucherPushParam pushParam ) {
2024-09-04 16:15:01 +08:00
// 校验会计科目是否合法
verifyKjkm ( pushParam ) ;
// 推送凭证
pushVoucher ( pushParam ) ;
// 推送成功后修改报表数据的凭证生成状态
updateReportStatus ( pushParam ) ;
// 推送成功后保存凭证
2024-10-12 16:39:09 +08:00
return saveVoucher ( pushParam ) ;
2024-09-04 16:15:01 +08:00
}
2024-08-30 17:44:26 +08:00
2024-09-04 16:15:01 +08:00
/ * *
* 推送成功后修改报表数据的凭证生成状态
*
* @param pushParam
* /
private void updateReportStatus ( LyVoucherPushParam pushParam ) {
List < Long > dataSource = pushParam . getDataSource ( ) ;
if ( pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . XZJTPZ . getValue ( ) ) | | pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . XZFFPZ . getValue ( ) ) ) {
List < LySalaryReportPO > salaryReportList = getLySalaryReportService ( user ) . getByIds ( dataSource ) ;
salaryReportList . stream ( ) . forEach ( po - > {
if ( pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . XZJTPZ . getValue ( ) ) ) {
po . setXzjtpzFlag ( NumberUtils . INTEGER_ONE ) ;
} else if ( pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . XZFFPZ . getValue ( ) ) ) {
po . setXzffpzFlag ( NumberUtils . INTEGER_ONE ) ;
}
getLySalaryReportService ( user ) . update ( po ) ;
} ) ;
2024-10-21 18:02:04 +08:00
} else if ( pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . SBJTPZ . getValue ( ) ) | | pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . SBFFPZ . getValue ( ) ) ) {
2024-09-04 16:15:01 +08:00
List < LySocialReportPO > socialReportList = getLySocialReportService ( user ) . getByIds ( dataSource ) ;
socialReportList . stream ( ) . forEach ( po - > {
if ( pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . SBJTPZ . getValue ( ) ) ) {
po . setSbjtpzFlag ( NumberUtils . INTEGER_ONE ) ;
} else if ( pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . SBFFPZ . getValue ( ) ) ) {
po . setSbffpzFlag ( NumberUtils . INTEGER_ONE ) ;
2024-10-21 18:02:04 +08:00
}
getLySocialReportService ( user ) . update ( po ) ;
} ) ;
} else if ( pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . GJJJTPZ . getValue ( ) ) | | pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . GJJFFPZ . getValue ( ) ) ) {
List < LyFundReportPO > fundReportList = getLyFundReportService ( user ) . getByIds ( dataSource ) ;
fundReportList . stream ( ) . forEach ( po - > {
if ( pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . GJJJTPZ . getValue ( ) ) ) {
2024-09-04 16:15:01 +08:00
po . setGjjjtpzFlag ( NumberUtils . INTEGER_ONE ) ;
} else if ( pushParam . getPzlx ( ) . equals ( LyPZTypeEnum . GJJFFPZ . getValue ( ) ) ) {
po . setGjjffpzFlag ( NumberUtils . INTEGER_ONE ) ;
}
2024-10-21 18:02:04 +08:00
getLyFundReportService ( user ) . update ( po ) ;
2024-09-04 16:15:01 +08:00
} ) ;
}
}
2024-08-28 17:42:16 +08:00
2024-09-04 16:15:01 +08:00
/ * *
* 保存凭证
* @param pushParam
* /
2024-10-12 16:39:09 +08:00
private Map < String , Object > saveVoucher ( LyVoucherPushParam pushParam ) {
Map < String , Object > resultMap = new HashMap < String , Object > ( ) ;
2024-09-04 16:15:01 +08:00
Date now = new Date ( ) ;
long mainId = IdGenerator . generate ( ) ;
LyVoucherPO voucher = LyVoucherPO
. builder ( )
. id ( mainId )
. pzlx ( pushParam . getPzlx ( ) )
2024-09-06 15:36:20 +08:00
. dataSource ( StringUtils . join ( pushParam . getDataSource ( ) , " , " ) )
2024-09-04 16:15:01 +08:00
. ffgsqc ( pushParam . getFfgsqc ( ) )
. salaryMonth ( SalaryDateUtil . dateStrToLocalYearMonth ( pushParam . getSalaryMonth ( ) ) )
. pkVoucher ( pushParam . getPkVoucher ( ) )
. status ( pushParam . getStatus ( ) )
2024-09-13 13:32:01 +08:00
. pushMsg ( pushParam . getPushMsg ( ) )
2024-09-04 16:15:01 +08:00
. creator ( Long . valueOf ( user . getUID ( ) ) )
. createTime ( now )
. updateTime ( now )
. deleteType ( 0 )
. build ( ) ;
getLyVoucherMapper ( ) . insertIgnoreNull ( voucher ) ;
pushParam . getDetails ( ) . stream ( ) . forEach ( detail - > {
LyVoucherDetailPO voucherDetail = LyVoucherDetailPO
. builder ( )
. id ( IdGenerator . generate ( ) )
. voucherId ( mainId )
. zy ( detail . getZy ( ) )
. kjkmId ( detail . getKjkm ( ) )
2024-10-12 16:39:09 +08:00
. fzhsXmqsBm ( detail . getFzhsXmqs ( ) . getBh ( ) )
. fzhsFwlbBm ( detail . getFzhsFwlb ( ) . getBh ( ) )
. fzhsSllbBm ( detail . getFzhsSllb ( ) . getBh ( ) )
. fzhsKsBm ( detail . getFzhsKs ( ) . getBh ( ) )
. fzhsOtherBms ( CollectionUtils . isEmpty ( detail . getFzhsOtherBmList ( ) ) ? " " : detail . getFzhsOtherBmList ( ) . stream ( ) . map ( LyFzhsBrowser : : getBh ) . collect ( Collectors . joining ( " , " ) ) )
2024-09-04 16:15:01 +08:00
. jfValue ( detail . getJfValue ( ) )
. dfValue ( detail . getDfValue ( ) )
. creator ( Long . valueOf ( user . getUID ( ) ) )
. createTime ( now )
. updateTime ( now )
. deleteType ( 0 ) . build ( ) ;
getLyVoucherDetailMapper ( ) . insertIgnoreNull ( voucherDetail ) ;
} ) ;
2024-10-12 16:39:09 +08:00
resultMap . put ( " status " , ( pushParam . getStatus ( ) ! = null & & pushParam . getStatus ( ) . equals ( NumberUtils . INTEGER_ONE ) ) ? Boolean . TRUE : Boolean . FALSE ) ;
resultMap . put ( " errMsg " , pushParam . getPushMsg ( ) ) ;
return resultMap ;
2024-09-04 16:15:01 +08:00
}
2024-08-28 17:42:16 +08:00
2024-09-04 16:15:01 +08:00
/ * *
* 推送凭证
* @param pushParam
* /
private void pushVoucher ( LyVoucherPushParam pushParam ) {
2024-10-12 16:39:09 +08:00
Date salaryDate = SalaryDateUtil . dateStrToLocalYearMonth ( pushParam . getSalaryMonth ( ) ) ;
if ( salaryDate = = null ) {
throw new SalaryRunTimeException ( " 薪资所属月为空 " ) ;
}
2024-10-11 09:10:33 +08:00
Calendar cal = Calendar . getInstance ( ) ;
2024-10-12 16:39:09 +08:00
cal . setTime ( salaryDate ) ;
BaseBean baseBean = new BaseBean ( ) ;
2024-10-11 09:10:33 +08:00
LyNCVoucher lyNCVoucher = new LyNCVoucher ( ) ;
// 凭证类别 非空 (凭证类别)
2024-10-12 16:39:09 +08:00
String pkVoucherType = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " pk_voucher_type " ) ;
lyNCVoucher . setPkVouchertype ( pkVoucherType ) ;
2024-10-11 09:10:33 +08:00
// 会计年度 非空
lyNCVoucher . setYear ( String . valueOf ( cal . get ( Calendar . YEAR ) ) ) ;
// 来源系统 非空 只支持模块编号
2024-10-12 16:39:09 +08:00
String pkSystem = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " pk_system " ) ;
lyNCVoucher . setPkSystem ( pkSystem ) ;
2024-10-11 09:10:33 +08:00
// 凭证类型值 0: 正常凭证 3: 数量调整凭证 不可空
2024-10-12 16:39:09 +08:00
String voucherKind = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " voucher_kind " ) ;
lyNCVoucher . setVoucherkind ( voucherKind ) ;
2024-10-11 09:10:33 +08:00
// 核算账簿 非空 ( 账簿_财务核算账簿)
2024-10-12 16:39:09 +08:00
lyNCVoucher . setPkAccountingbook ( pushParam . getZbbm ( ) ) ;
// lyNCVoucher.setPkAccountingbook("12re23r32");
2024-10-11 09:10:33 +08:00
// 会计期间 非空
lyNCVoucher . setPeriod ( String . valueOf ( cal . get ( Calendar . MONTH ) + 1 ) ) ;
// 制单日期 非空
lyNCVoucher . setPrepareddate ( SalaryDateUtil . getFormatLocalDateTime ( new Date ( ) ) ) ;
// 制单人 非空 (用户)
2024-10-12 16:39:09 +08:00
String pkPrepared = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " pk_prepared " ) ;
lyNCVoucher . setPkPrepared ( pkPrepared ) ;
2024-10-11 09:10:33 +08:00
//所属组织 非空 (组织)
2024-10-12 16:39:09 +08:00
lyNCVoucher . setPkOrg ( pushParam . getZbbm ( ) . split ( " - " ) [ 0 ] ) ;
// lyNCVoucher.setPkOrg("201");
2024-10-11 09:10:33 +08:00
lyNCVoucher . setDiscardflag ( " N " ) ;
List < LyVoucherDetailPushParam > jfDetailList = new ArrayList < > ( ) ;
List < LyVoucherDetailPushParam > dfDetailList = new ArrayList < > ( ) ;
pushParam . getDetails ( ) . stream ( ) . forEach ( detail - > {
if ( ( StringUtils . isNotBlank ( detail . getJfValue ( ) ) ) & & ( ! " 0.00 " . equals ( detail . getJfValue ( ) ) ) ) {
jfDetailList . add ( detail ) ;
} else {
dfDetailList . add ( detail ) ;
}
} ) ;
ArrayList < LyNCVoucherDetail > lyNCVoucherDetailList = new ArrayList < > ( ) ;
2024-10-12 16:39:09 +08:00
RecordSet rs = new RecordSet ( ) ;
2024-10-11 09:10:33 +08:00
// 借方分录
for ( int i = 0 ; i < jfDetailList . size ( ) ; i + + ) {
LyVoucherDetailPushParam detailParam = jfDetailList . get ( i ) ;
LyNCVoucherDetail lyNCVoucherDetail = new LyNCVoucherDetail ( ) ;
// 分录号 非空
lyNCVoucherDetail . setDetailindex ( String . valueOf ( i + 1 ) ) ;
// 摘要 非空
lyNCVoucherDetail . setExplanation ( detailParam . getZy ( ) ) ;
// 折本汇率
lyNCVoucherDetail . setExcrate2 ( " 1 " ) ;
// 原币借方金额
lyNCVoucherDetail . setDebitamount ( detailParam . getJfValue ( ) ) ;
// 本币借方金额 可空
lyNCVoucherDetail . setLocaldebitamount ( detailParam . getJfValue ( ) ) ;
// 币种 非空
lyNCVoucherDetail . setPkCurrtype ( " CNY " ) ;
// 科目 非空
String kjkm = detailParam . getKjkm ( ) ;
String kjkmbm = kjkm . split ( " \\ \\ " ) [ 0 ] ;
lyNCVoucherDetail . setPkAccasoa ( kjkmbm ) ;
// 辅助核算
List < LyNCVoucherAss > lyNCVoucherAssList = new ArrayList < > ( ) ;
2024-10-12 16:39:09 +08:00
if ( detailParam . getFzhsXmqs ( ) ! = null ) {
2024-10-11 09:10:33 +08:00
// 项目期数
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
2024-10-12 16:39:09 +08:00
ass . setPkChecktype ( detailParam . getFzhsXmqs ( ) . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( detailParam . getFzhsXmqs ( ) . getBh ( ) ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherAssList . add ( ass ) ;
}
2024-10-12 16:39:09 +08:00
if ( detailParam . getFzhsFwlb ( ) ! = null ) {
2024-10-11 09:10:33 +08:00
// 房屋列别
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
2024-10-12 16:39:09 +08:00
ass . setPkChecktype ( detailParam . getFzhsFwlb ( ) . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( detailParam . getFzhsFwlb ( ) . getBh ( ) ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherAssList . add ( ass ) ;
}
2024-10-12 16:39:09 +08:00
if ( detailParam . getFzhsSllb ( ) ! = null ) {
2024-10-11 09:10:33 +08:00
// 税率类别
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
2024-10-12 16:39:09 +08:00
ass . setPkChecktype ( detailParam . getFzhsSllb ( ) . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( detailParam . getFzhsSllb ( ) . getBh ( ) ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherAssList . add ( ass ) ;
}
2024-10-12 16:39:09 +08:00
if ( detailParam . getFzhsKs ( ) ! = null ) {
2024-10-11 09:10:33 +08:00
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
// 客商
2024-10-12 16:39:09 +08:00
ass . setPkChecktype ( detailParam . getFzhsKs ( ) . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( detailParam . getFzhsKs ( ) . getBh ( ) ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherAssList . add ( ass ) ;
}
2024-10-12 16:39:09 +08:00
// 其他
if ( CollectionUtils . isNotEmpty ( detailParam . getFzhsOtherBmList ( ) ) ) {
detailParam . getFzhsOtherBmList ( ) . stream ( ) . forEach ( fzhs - > {
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
ass . setPkChecktype ( fzhs . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( fzhs . getBh ( ) ) ;
lyNCVoucherAssList . add ( ass ) ;
} ) ;
}
List < LyNCVoucherAss > assList = lyNCVoucherAssList . stream ( ) . filter ( ass - > StringUtils . isNotBlank ( ass . getPkChecktype ( ) ) ) . collect ( Collectors . toList ( ) ) ;
lyNCVoucherDetail . setAss ( assList ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherDetailList . add ( lyNCVoucherDetail ) ;
}
// 贷方分录
for ( int i = 0 ; i < dfDetailList . size ( ) ; i + + ) {
LyVoucherDetailPushParam detailParam = dfDetailList . get ( i ) ;
LyNCVoucherDetail lyNCVoucherDetail = new LyNCVoucherDetail ( ) ;
// 分录号 非空
lyNCVoucherDetail . setDetailindex ( lyNCVoucherDetailList . size ( ) + String . valueOf ( i + 1 ) ) ;
// 摘要 非空
lyNCVoucherDetail . setExplanation ( detailParam . getZy ( ) ) ;
// 折本汇率
lyNCVoucherDetail . setExcrate2 ( " 1 " ) ;
// 原币借方金额
lyNCVoucherDetail . setCreditamount ( detailParam . getDfValue ( ) ) ;
// 本币借方金额 可空
lyNCVoucherDetail . setLocalcreditamount ( detailParam . getDfValue ( ) ) ;
// 币种 非空
lyNCVoucherDetail . setPkCurrtype ( " CNY " ) ;
// 科目 非空
String kjkm = detailParam . getKjkm ( ) ;
String kjkmbm = kjkm . split ( " \\ \\ " ) [ 0 ] ;
lyNCVoucherDetail . setPkAccasoa ( kjkmbm ) ;
// 辅助核算
List < LyNCVoucherAss > lyNCVoucherAssList = new ArrayList < > ( ) ;
2024-10-12 16:39:09 +08:00
if ( detailParam . getFzhsXmqs ( ) ! = null ) {
// 项目期数
2024-10-11 09:10:33 +08:00
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
2024-10-12 16:39:09 +08:00
ass . setPkChecktype ( detailParam . getFzhsXmqs ( ) . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( detailParam . getFzhsXmqs ( ) . getBh ( ) ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherAssList . add ( ass ) ;
}
2024-10-12 16:39:09 +08:00
if ( detailParam . getFzhsFwlb ( ) ! = null ) {
// 房屋列别
2024-10-11 09:10:33 +08:00
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
2024-10-12 16:39:09 +08:00
ass . setPkChecktype ( detailParam . getFzhsFwlb ( ) . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( detailParam . getFzhsFwlb ( ) . getBh ( ) ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherAssList . add ( ass ) ;
}
2024-10-12 16:39:09 +08:00
if ( detailParam . getFzhsSllb ( ) ! = null ) {
// 税率类别
2024-10-11 09:10:33 +08:00
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
2024-10-12 16:39:09 +08:00
ass . setPkChecktype ( detailParam . getFzhsSllb ( ) . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( detailParam . getFzhsSllb ( ) . getBh ( ) ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherAssList . add ( ass ) ;
}
2024-10-12 16:39:09 +08:00
if ( detailParam . getFzhsKs ( ) ! = null ) {
2024-10-11 09:10:33 +08:00
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
2024-10-12 16:39:09 +08:00
// 客商
ass . setPkChecktype ( detailParam . getFzhsKs ( ) . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( detailParam . getFzhsKs ( ) . getBh ( ) ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherAssList . add ( ass ) ;
}
2024-10-12 16:39:09 +08:00
// 其他
if ( CollectionUtils . isNotEmpty ( detailParam . getFzhsOtherBmList ( ) ) ) {
detailParam . getFzhsOtherBmList ( ) . stream ( ) . forEach ( fzhs - > {
LyNCVoucherAss ass = new LyNCVoucherAss ( ) ;
ass . setPkChecktype ( fzhs . getFzhslxbh ( ) ) ;
ass . setPkCheckvalue ( fzhs . getBh ( ) ) ;
lyNCVoucherAssList . add ( ass ) ;
} ) ;
}
List < LyNCVoucherAss > assList = lyNCVoucherAssList . stream ( ) . filter ( ass - > StringUtils . isNotBlank ( ass . getPkChecktype ( ) ) ) . collect ( Collectors . toList ( ) ) ;
lyNCVoucherDetail . setAss ( assList ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherDetailList . add ( lyNCVoucherDetail ) ;
}
lyNCVoucher . setDetails ( lyNCVoucherDetailList ) ;
LyNCVoucherHead voucherHead = new LyNCVoucherHead ( ) ;
voucherHead . setVoucherHead ( lyNCVoucher ) ;
LyNCVoucherUfinterface lyNCVoucherUfinterface = new LyNCVoucherUfinterface ( ) ;
lyNCVoucherUfinterface . setVoucher ( voucherHead ) ;
2024-10-12 16:39:09 +08:00
String account = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " account " ) ;
lyNCVoucherUfinterface . setAccount ( account ) ;
String billtype = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " billtype " ) ;
lyNCVoucherUfinterface . setBilltype ( billtype ) ;
String businessunitcode = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " businessunitcode " ) ;
lyNCVoucherUfinterface . setBusinessunitcode ( businessunitcode ) ;
2024-10-11 09:10:33 +08:00
lyNCVoucherUfinterface . setFilename ( " " ) ;
lyNCVoucherUfinterface . setGroupcode ( " " ) ;
lyNCVoucherUfinterface . setIsexchange ( " " ) ;
lyNCVoucherUfinterface . setOrgcode ( " " ) ;
lyNCVoucherUfinterface . setReceiver ( " " ) ;
lyNCVoucherUfinterface . setReplace ( " " ) ;
lyNCVoucherUfinterface . setRoottag ( " " ) ;
2024-10-12 16:39:09 +08:00
String sender = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " sender " ) ;
lyNCVoucherUfinterface . setSender ( sender ) ;
2024-10-11 09:10:33 +08:00
// "<?xml version=\"1.0\" encoding='gb2312'?>"
String xml = XStreamUtil . marshal ( lyNCVoucherUfinterface ) ;
System . out . println ( xml ) ;
HttpClient httpClient = new HttpClient ( ) ;
2024-10-12 16:39:09 +08:00
String accountParam = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " account_param " ) ;
String groupcodeParam = baseBean . getPropValue ( " lySalaryNCVoucherPushParam " , " groupcode_param " ) ;
PostMethod httpPost = new PostMethod ( " http://172.18.0.10:8090/service/XChangeServlet?account= " + accountParam + " &groupcode= " + groupcodeParam ) ;
2024-10-11 09:10:33 +08:00
httpPost . setRequestHeader ( " content-type " , " application/json;charset=utf-8 " ) ;
String result = " " ;
try {
2024-10-12 16:39:09 +08:00
RequestEntity entity = new StringRequestEntity ( xml , " application/json " , " UTF-8 " ) ;
2024-10-11 09:10:33 +08:00
httpPost . setRequestEntity ( entity ) ;
httpClient . executeMethod ( httpPost ) ;
result = httpPost . getResponseBodyAsString ( ) ;
System . out . println ( result ) ;
2024-10-12 16:39:09 +08:00
LyNCVoucherReturn lyNCVoucherReturn = XStreamUtil . unmarshal ( LyNCVoucherReturn . class , StringUtils . substring ( result , result . indexOf ( " <ufinterface " ) , result . indexOf ( " </ufinterface> " ) + 14 ) ) ;
boolean success = lyNCVoucherReturn . getSuccessful ( ) . equals ( " Y " ) ;
if ( ! success ) {
// 失败
String errorMsg = lyNCVoucherReturn . getSendresult ( ) . getResultdescription ( ) ;
pushParam . setStatus ( NumberUtils . INTEGER_ZERO ) ;
pushParam . setPushMsg ( errorMsg ) ;
} else {
pushParam . setStatus ( NumberUtils . INTEGER_ONE ) ;
pushParam . setPushMsg ( " 推送成功 " ) ;
}
2024-10-11 09:10:33 +08:00
} catch ( Exception e ) {
2024-10-12 16:39:09 +08:00
baseBean . writeLog ( " 推送错误 " + e . getMessage ( ) ) ;
throw new SalaryRunTimeException ( " 推送错误,请联系管理员 " ) ;
2024-10-11 09:10:33 +08:00
}
2024-09-04 16:15:01 +08:00
}
2024-08-28 17:42:16 +08:00
2024-09-04 16:15:01 +08:00
/ * *
* 校验会计科目是否合法
* @param pushParam
* /
private void verifyKjkm ( LyVoucherPushParam pushParam ) {
2024-10-12 16:39:09 +08:00
if ( StringUtils . isBlank ( pushParam . getZbbm ( ) ) ) {
throw new SalaryRunTimeException ( " 账簿编码不能为空 " ) ;
}
2024-09-04 16:15:01 +08:00
// 校验科目id是否合规
Map < String , String > kmbmInfoMap = new HashMap < > ( ) ;
List < UfKjkmPO > allKjkm = getUfKjkmMapper ( ) . listAll ( ) ;
allKjkm . forEach ( po - > kmbmInfoMap . put ( po . getKmbm ( ) , po . getKmmc ( ) ) ) ;
List < LyVoucherDetailPushParam > details = pushParam . getDetails ( ) ;
List < String > kjlmList = new ArrayList < > ( ) ;
details . stream ( ) . forEach ( detail - > {
2024-09-06 15:36:20 +08:00
String kjkm = detail . getKjkm ( ) ;
if ( StringUtils . isNotBlank ( kjkm ) ) {
kjlmList . add ( kjkm ) ;
} else {
throw new SalaryRunTimeException ( " 会计科目不能为空 " ) ;
2024-09-04 16:15:01 +08:00
}
} ) ;
List < String > failList = kjlmList . stream ( )
. filter ( StringUtils : : isNotBlank )
. distinct ( )
. filter ( fullPath - > {
2024-09-06 15:36:20 +08:00
String [ ] split = fullPath . split ( " \\ \\ " ) ;
String kjkm = split [ 0 ] ;
2024-09-04 16:15:01 +08:00
String fullPathKjkm = getFullPathKjkm ( kjkm , kmbmInfoMap ) ;
2024-09-06 15:36:20 +08:00
return ! fullPath . equals ( fullPathKjkm ) ;
2024-09-04 16:15:01 +08:00
} ) . collect ( Collectors . toList ( ) ) ;
if ( CollectionUtils . isNotEmpty ( failList ) ) {
throw new SalaryRunTimeException ( " 推送凭证失败,以下科目信息不存在: " + failList ) ;
}
2024-08-28 17:42:16 +08:00
}
/ * *
2024-09-04 16:15:01 +08:00
* 本地历史凭证列表
*
* @param queryParam
2024-08-28 17:42:16 +08:00
* @return
* /
2024-09-04 16:15:01 +08:00
@Override
public PageInfo < LyVoucherPO > historyVoucherList ( LyVoucherQueryParam queryParam ) {
List < LyVoucherPO > lyVoucherPOS = getLyVoucherMapper ( ) . listSome ( LyVoucherPO . builder ( )
. pzlx ( queryParam . getPzlx ( ) )
. salaryMonth ( SalaryDateUtil . dateStrToLocalYearMonth ( queryParam . getSalaryMonth ( ) ) )
. id ( queryParam . getId ( ) )
. build ( ) ) ;
// 筛选法人主体
if ( StringUtils . isNotBlank ( queryParam . getFrzt ( ) ) ) {
lyVoucherPOS = lyVoucherPOS . stream ( ) . filter ( po - > po . getFfgsqc ( ) . contains ( queryParam . getFrzt ( ) ) ) . collect ( Collectors . toList ( ) ) ;
2024-08-28 17:42:16 +08:00
}
2024-09-06 15:36:20 +08:00
// 分权
// 是否是薪酬总管理员
boolean isChief = getTaxAgentService ( user ) . isChief ( ( long ) user . getUID ( ) ) ;
if ( ! isChief ) {
List < String > canManageFrztByUid = getLySalaryReportService ( user ) . getCanManageFrztByUid ( user ) ;
lyVoucherPOS = lyVoucherPOS . stream ( ) . filter ( po - > canManageFrztByUid . contains ( po . getFfgsqc ( ) ) ) . collect ( Collectors . toList ( ) ) ;
}
2024-09-04 16:15:01 +08:00
PageInfo < LyVoucherPO > pageInfo = SalaryPageUtil . buildPage ( queryParam . getCurrent ( ) , queryParam . getPageSize ( ) , lyVoucherPOS , LyVoucherPO . class ) ;
List < LyVoucherPO > list = pageInfo . getList ( ) ;
2024-09-13 13:32:01 +08:00
list . stream ( ) . forEach ( voucher - > {
voucher . setPzlxStr ( LyPZTypeEnum . getDefaultLabelByValue ( voucher . getPzlx ( ) ) ) ;
voucher . setPushStatusStr ( voucher . getStatus ( ) ! = null & & voucher . getStatus ( ) . equals ( NumberUtils . INTEGER_ONE ) ? " 成功 " : " 失败 " ) ;
2024-10-14 09:19:07 +08:00
voucher . setErrorMsg ( voucher . getStatus ( ) ! = null & & voucher . getStatus ( ) . equals ( NumberUtils . INTEGER_ONE ) ? " " : voucher . getPushMsg ( ) . replace ( " \ n " , " </br> " ) ) ;
2024-09-13 13:32:01 +08:00
} ) ;
2024-09-04 16:15:01 +08:00
return SalaryPageUtil . buildPage ( queryParam . getCurrent ( ) , queryParam . getPageSize ( ) , lyVoucherPOS , LyVoucherPO . class ) ;
2024-08-28 17:42:16 +08:00
}
2024-09-04 16:15:01 +08:00
@Override
2024-09-05 09:05:57 +08:00
public Map < String , Object > historyVoucherDetailList ( Long voucherId ) {
2024-09-04 16:15:01 +08:00
if ( voucherId = = null ) {
2024-09-05 09:05:57 +08:00
return Collections . emptyMap ( ) ;
2024-09-04 16:15:01 +08:00
}
List < LyVoucherDetailPO > lyVoucherDetailList = getLyVoucherDetailMapper ( ) . listSome ( LyVoucherDetailPO . builder ( )
. voucherId ( voucherId )
. build ( ) ) ;
// 获取辅助核算浏览框list
List < String > fzhsBmList = new ArrayList < > ( ) ;
lyVoucherDetailList . stream ( ) . forEach ( detailPO - > {
fzhsBmList . add ( detailPO . getFzhsXmqsBm ( ) ) ;
fzhsBmList . add ( detailPO . getFzhsFwlbBm ( ) ) ;
fzhsBmList . add ( detailPO . getFzhsSllbBm ( ) ) ;
fzhsBmList . add ( detailPO . getFzhsKsBm ( ) ) ;
if ( StringUtils . isNotBlank ( detailPO . getFzhsOtherBms ( ) ) ) {
List < String > bmList = Arrays . stream ( detailPO . getFzhsOtherBms ( ) . split ( " , " ) ) . collect ( Collectors . toList ( ) ) ;
fzhsBmList . addAll ( bmList ) ;
}
} ) ;
List < String > finalFzhsBmList = fzhsBmList . stream ( ) . filter ( StringUtils : : isNotBlank ) . collect ( Collectors . toList ( ) ) ;
Map < String , LyFzhsBrowser > fzhsBrowserByBm = getFzhsBrowserByBm ( finalFzhsBmList ) ;
List < LyVoucherDetailDTO > dtoList = lyVoucherDetailList . stream ( ) . map ( detailPO - > {
String fzhsOtherBmStr = detailPO . getFzhsOtherBms ( ) ;
List < LyFzhsBrowser > fzhsOtherBrowserList = new ArrayList < > ( ) ;
if ( StringUtils . isNotBlank ( fzhsOtherBmStr ) ) {
fzhsOtherBrowserList = Arrays . stream ( fzhsOtherBmStr . split ( " , " ) )
. map ( bm - > fzhsBrowserByBm . get ( bm ) )
. filter ( browser - > browser ! = null )
. collect ( Collectors . toList ( ) ) ;
}
return LyVoucherDetailDTO . builder ( )
. voucherId ( detailPO . getVoucherId ( ) )
. zy ( detailPO . getZy ( ) )
. kjkmId ( detailPO . getKjkmId ( ) )
. fzhsXmqsBrowser ( fzhsBrowserByBm . get ( detailPO . getFzhsXmqsBm ( ) ) )
. fzhsFwlbBrowser ( fzhsBrowserByBm . get ( detailPO . getFzhsFwlbBm ( ) ) )
. fzhsSllbBrowser ( fzhsBrowserByBm . get ( detailPO . getFzhsSllbBm ( ) ) )
. fzhsKsBrowser ( fzhsBrowserByBm . get ( detailPO . getFzhsKsBm ( ) ) )
. fzhsOtherBrowserList ( fzhsOtherBrowserList )
. jfValue ( detailPO . getJfValue ( ) )
. dfValue ( detailPO . getDfValue ( ) )
. build ( ) ;
} ) . collect ( Collectors . toList ( ) ) ;
2024-09-05 09:05:57 +08:00
PageInfo < LyVoucherDetailDTO > pageInfo = new PageInfo < > ( LyVoucherDetailDTO . class ) ;
Map < String , Object > resultMap = new HashMap < > ( ) ;
resultMap . put ( " data " , dtoList ) ;
resultMap . put ( " columns " , pageInfo . getColumns ( ) ) ;
return resultMap ;
2024-09-04 16:15:01 +08:00
}
2024-09-06 15:36:20 +08:00
@Override
public void deleteHistoryVoucher ( Long voucherId ) {
// 判断是否是薪酬总管理员
boolean isChief = getTaxAgentService ( user ) . isChief ( ( long ) user . getUID ( ) ) ;
if ( isChief ) {
2024-09-13 13:32:01 +08:00
LyVoucherPO voucherPO = getLyVoucherMapper ( ) . getById ( voucherId ) ;
2024-09-06 15:36:20 +08:00
getLyVoucherMapper ( ) . delete ( LyVoucherPO . builder ( ) . id ( voucherId ) . build ( ) ) ;
getLyVoucherDetailMapper ( ) . delete ( LyVoucherDetailPO . builder ( ) . voucherId ( voucherId ) . build ( ) ) ;
2024-09-13 13:32:01 +08:00
// 修改报表中数据推送状态
Integer pzlx = voucherPO . getPzlx ( ) ;
String dataSourceStr = voucherPO . getDataSource ( ) ;
List < Long > dataSourceIdList = new ArrayList < > ( ) ;
if ( StringUtils . isNotBlank ( dataSourceStr ) ) {
dataSourceIdList = Arrays . stream ( dataSourceStr . split ( " , " ) ) . filter ( NumberUtils : : isCreatable ) . map ( Long : : valueOf ) . collect ( Collectors . toList ( ) ) ;
}
if ( pzlx . equals ( LyPZTypeEnum . XZJTPZ . getValue ( ) ) | | pzlx . equals ( LyPZTypeEnum . XZFFPZ . getValue ( ) ) ) {
// 薪资
List < LySalaryReportPO > lySalaryReportList = getLySalaryReportService ( user ) . listByIds ( dataSourceIdList ) ;
lySalaryReportList . stream ( ) . forEach ( po - > {
if ( pzlx . equals ( LyPZTypeEnum . XZJTPZ . getValue ( ) ) ) {
po . setXzjtpzFlag ( NumberUtils . INTEGER_ZERO ) ;
} else {
po . setXzffpzFlag ( NumberUtils . INTEGER_ZERO ) ;
}
getLySalaryReportService ( user ) . updateIgnoreNull ( po ) ;
} ) ;
} else if ( pzlx . equals ( LyPZTypeEnum . SBJTPZ . getValue ( ) ) | | pzlx . equals ( LyPZTypeEnum . SBFFPZ . getValue ( ) ) ) {
// 社保
List < LySocialReportPO > lySocialReportList = getLySocialReportService ( user ) . getByIds ( dataSourceIdList ) ;
lySocialReportList . stream ( ) . forEach ( po - > {
if ( pzlx . equals ( LyPZTypeEnum . SBJTPZ . getValue ( ) ) ) {
po . setSbjtpzFlag ( NumberUtils . INTEGER_ZERO ) ;
} else {
po . setSbffpzFlag ( NumberUtils . INTEGER_ZERO ) ;
}
getLySocialReportService ( user ) . updateIgnoreNull ( po ) ;
} ) ;
2024-10-21 18:02:04 +08:00
} else if ( pzlx . equals ( LyPZTypeEnum . GJJJTPZ . getValue ( ) ) | | pzlx . equals ( LyPZTypeEnum . GJJFFPZ . getValue ( ) ) ) {
2024-09-13 13:32:01 +08:00
// 公积金
2024-10-21 18:02:04 +08:00
List < LyFundReportPO > lyFundReportList = getLyFundReportService ( user ) . getByIds ( dataSourceIdList ) ;
lyFundReportList . stream ( ) . forEach ( po - > {
if ( pzlx . equals ( LyPZTypeEnum . GJJJTPZ . getValue ( ) ) ) {
po . setGjjjtpzFlag ( NumberUtils . INTEGER_ZERO ) ;
} else {
po . setGjjffpzFlag ( NumberUtils . INTEGER_ZERO ) ;
}
getLyFundReportService ( user ) . updateIgnoreNull ( po ) ;
} ) ;
2024-09-13 13:32:01 +08:00
}
2024-09-06 15:36:20 +08:00
}
}
2024-08-28 17:42:16 +08:00
}