Commit b2ffa029 authored by chase's avatar chase

Merge branch 'dev_mysql' of http://code.tech.tax.asia.pwcinternal.com/root/atms into dev_mysql

parents 1fc68560 6d78f520
package pwc.taxtech.atms.constant.enums;
public enum EnumCitAssetType {
//固定资产
FixedAssets(1),
//长期待摊
LongTermPrepaid (2),
//无形资产
InvisibleAssets (3);
private Integer code;
EnumCitAssetType(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
public static EnumCitAssetType valueOf(Integer value) {
for (EnumCitAssetType item : EnumCitAssetType.values()) {
if (item.getCode().equals(value)) {
return item;
}
}
return null;
}
}
......@@ -43,7 +43,8 @@ public class CitImportExcelController {
OperationResultDto citImportExcel(@RequestParam MultipartFile file, @RequestParam(required = false) String orgIds,
@RequestParam String periodDate,
@RequestParam Integer importType,
@RequestParam Integer importFileType){
@RequestParam Integer importFileType,
@RequestParam(required = false) Integer month){
logger.info("CIT文件导入");
OperationResultDto opeResultDto = new OperationResultDto();
try{
......@@ -55,7 +56,7 @@ public class CitImportExcelController {
}
logger.debug("file name: " + file.getOriginalFilename());
List<String> orgList = (List<String>) JSONArray.parse(orgIds);
opeResultDto = citImportExcelService.citImportExcel(file, orgList, file.getOriginalFilename(), periodDate, importType, importFileType);
opeResultDto = citImportExcelService.citImportExcel(file, orgList, file.getOriginalFilename(), periodDate, importType, importFileType, month);
return opeResultDto;
}catch (Exception e){
logger.error("文件导入失败,错误信息如下:");
......@@ -122,7 +123,7 @@ public class CitImportExcelController {
*/
@RequestMapping(value = "/getCitDataImportLog", method = RequestMethod.GET)
public ApiResultDto getCitDataImportLog(Integer type){
logger.info("获取CIT调整版日记账");
logger.info("获取CIT导入记录");
ApiResultDto apiResultDto = new ApiResultDto();
apiResultDto.setCode(1);
apiResultDto.setData(citImportExcelService.getCitDataImportLog(type));
......
......@@ -14,10 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.dao.AssetDetailGroupMapper;
import pwc.taxtech.atms.dao.AssetGroupMapper;
import pwc.taxtech.atms.dao.CitAssetGroupResultMapper;
import pwc.taxtech.atms.dao.CitAssetsListMapper;
import pwc.taxtech.atms.constant.enums.EnumCitAssetType;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dpo.CitAssetSumDataDto;
import pwc.taxtech.atms.dto.*;
import pwc.taxtech.atms.entity.*;
......@@ -27,8 +25,10 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.*;
import java.util.stream.Collectors;
......@@ -42,18 +42,16 @@ public class AssetListServiceImpl extends BaseService {
@Autowired
private CitAssetsListMapper assetListMapper;
@Autowired
private CitAssetGroupResultMapper assetGroupResultMapper;
@Autowired
private AssetDetailGroupMapper assetDetailGroupMapper;
@Autowired
private AssetGroupMapper assetGroupMapper;
@Autowired
private FileService fileService;
@Autowired
private ProjectMapper projectMapper;
/**
* 获取资产清单
......@@ -220,22 +218,42 @@ public class AssetListServiceImpl extends BaseService {
Set assetNameSet = new HashSet();
List<CitAssetGroupResult> citAssetGroupResults = selectGroupResult(projectId);
Integer period = CitCommonUtil.getPeriod();
ProjectExample projectExample = new ProjectExample();
Project project = projectMapper.selectByPrimaryKey(projectId);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
StringBuilder sb = new StringBuilder();
//去年年底
sb.append(project.getYear()-1);
sb.append("-12-31");
Date endOfLastYearDate = sdf.parse(sb.toString());
// Integer period = CitCommonUtil.getPeriod();
List<CitAssetsList> citAssetsLists = new ArrayList<>();
//通过循环来完成sheet获取每一行每一列数据并进行相关逻辑处理
for (int rowNum = sheet.getFirstRowNum() + 1; rowNum <= sheet.getLastRowNum(); rowNum++) {
for (int rowNum = sheet.getFirstRowNum() + 6; rowNum <= sheet.getLastRowNum(); rowNum++) {
CitAssetsList citAsset = new CitAssetsList();
citAsset.setId(idService.nextId());
//赋值projectId
citAsset.setProjectId(projectId);
citAsset.setPeriod(Integer.valueOf(period));
citAsset.setPeriod(project.getYear());
//获取该行数据
Row rowData = sheet.getRow(rowNum);
//因模板固定,则按照写死的做法处理数据单元格数据
citAsset = cellToCitAsset(rowData, citAsset, assetNameSet, citAssetGroupResults);
//获取报废类型
citAsset.setScrapType(CitCommonUtil.getValue(rowData.getCell(38)).toString());
//获取报废日期
Object value = CitCommonUtil.getValue(rowData.getCell(37));
if(!"".equals(value)){
citAsset.setDisposedDate(sdf.parse(value.toString()));
}
//先判断该条数据是否需要直接舍弃掉,筛选条件:报废类型是完全报废,报废日期小于去年年底最后一天的就剔除。
if("完全报废".equals(citAsset.getScrapType()) && endOfLastYearDate.after(citAsset.getDisposedDate())){
errorMsgSb.append(rowNum+",");
continue;
}
citAsset = cellToCitAsset(rowData, citAsset, assetNameSet, citAssetGroupResults, project.getYear() );
if(citAsset == null){
errorMsgSb.append(rowNum+",");
continue;
......@@ -264,7 +282,7 @@ public class AssetListServiceImpl extends BaseService {
CitAssetGroupResult citAssetGroupResult = new CitAssetGroupResult();
citAssetGroupResult.setId(idService.nextId());
citAssetGroupResult.setProjectId(projectId);
citAssetGroupResult.setPeriod(Integer.valueOf(period));
citAssetGroupResult.setPeriod(project.getYear());
citAssetGroupResult.setAssetName(it.next());
assetGroupResultMapper.insertSelective(citAssetGroupResult);
}
......@@ -278,7 +296,7 @@ public class AssetListServiceImpl extends BaseService {
* @param rowData
* @return
*/
private CitAssetsList cellToCitAsset(Row rowData, CitAssetsList citAsset, Set assetNameSet, List<CitAssetGroupResult> citAssetGroupResults ) throws ParseException {
private CitAssetsList cellToCitAsset(Row rowData, CitAssetsList citAsset, Set assetNameSet, List<CitAssetGroupResult> citAssetGroupResults, Integer year) throws ParseException {
//获取单元格数据,并set进入实体
//获取资产编号
......@@ -299,18 +317,16 @@ public class AssetListServiceImpl extends BaseService {
String assetName = value.toString();
citAsset.setAssetGroupName(assetName);
//获取购入日期
//获取购入日期,根据启用日期进行计算
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
value = CitCommonUtil.getValue(rowData.getCell(15));
if(!"".equals(value)){
citAsset.setBuyDate(sdf.parse(value.toString()));
}
//获取开始折旧日期,DD没有提供,我们要根据购入日期和税法分类做预处理自己转化
// citAsset.setDepreciationDate(sdf.parse(CitCommonUtil.getValue(rowData.getCell(15)).toString()));
//获取折旧期限,接下来计算需要用到,所以赋给一个对象
value = CitCommonUtil.getValue(rowData.getCell(30));
Integer depreciationPeriod = Integer.valueOf(value==null?"0":value.toString());
Integer depreciationPeriod = Integer.valueOf(("".equals(value))?"0":value.toString());
citAsset.setDepreciationPeriod(depreciationPeriod);
//获取原值,接下来计算需要用到,所以赋给一个对象
......@@ -323,12 +339,7 @@ public class AssetListServiceImpl extends BaseService {
//获取原值调整值0----列数待定,滴滴无调整值
// citAsset.setAdjustmentValue(new BigDecimal(CitCommonUtil.getValue(rowData.getCell(32)).toString()));
//获取报废日期
value = CitCommonUtil.getValue(rowData.getCell(37));
if(!"".equals(value)){
citAsset.setDisposedDate(sdf.parse(value.toString()));
}
citAsset.setScrapType(CitCommonUtil.getValue(rowData.getCell(38)).toString());
//获取残值额,原为残值率现为残值额,接下来计算需要用到,所以赋给一个对象
BigDecimal residualRate = new BigDecimal(CitCommonUtil.getValue(rowData.getCell(20)).toString());
citAsset.setResidualRate(residualRate);
......@@ -372,7 +383,7 @@ public class AssetListServiceImpl extends BaseService {
AssetDetailGroup assetDetailGroup = selectAssetDetailGroup(groupResults.get(0).getAssetDetailGroupId());
// Integer assetGroupType = selectAssetDetailGroup(groupResults.get(0).getAssetDetailGroupId()).getAssetGroupType();
//进行税务的计算
setCitAssetTaxData(citAsset,groupResults.get(0),assetDetailGroup);
setCitAssetTaxData(citAsset,groupResults.get(0),assetDetailGroup, year);
}else{
//目前没有进行税法分类,标注状态
citAsset.setStatus(0);
......@@ -416,6 +427,7 @@ public class AssetListServiceImpl extends BaseService {
* @return
*/
public ApiResultDto saveAssetGroupInfo(List<CitAssetGroupResult> assetGroupResults, Integer saveGroupType, String projectId) {
Project project = projectMapper.selectByPrimaryKey(projectId);
ApiResultDto resultDto = new ApiResultDto();
for (CitAssetGroupResult assetGroupResult : assetGroupResults) {
//根据主键修改资产类别有关数据,主要修改的字段为资产一级分类主键、资产二级分类主键
......@@ -424,7 +436,7 @@ public class AssetListServiceImpl extends BaseService {
// Integer assetGroupType = selectAssetGroup(assetGroupResult.getAssetGroupId()).getAssetGroupType();
List<CitAssetsList> citAssetsLists = selectAssetsList(projectId, assetGroupResult.getAssetName(),saveGroupType);
citAssetsLists.stream().forEach(citAsset -> {
setCitAssetTaxData(citAsset,assetGroupResult,assetDetailGroup);
setCitAssetTaxData(citAsset,assetGroupResult,assetDetailGroup,project.getYear());
//根据主键修改资产清单数据
assetListMapper.updateByPrimaryKeySelective(citAsset);
});
......@@ -448,39 +460,92 @@ public class AssetListServiceImpl extends BaseService {
* @param assetGroupResult
* @param assetDetailGroup
*/
public void setCitAssetTaxData(CitAssetsList citAsset,CitAssetGroupResult assetGroupResult,AssetDetailGroup assetDetailGroup){
public void setCitAssetTaxData(CitAssetsList citAsset,CitAssetGroupResult assetGroupResult,AssetDetailGroup assetDetailGroup, Integer year){
Calendar cal = Calendar.getInstance();
Calendar calendar = Calendar.getInstance();
//设置税法分类
citAsset.setTaxGroupName(assetDetailGroup.getDetailGroupName());
citAsset.setAssetDetailGroupId(assetDetailGroup.getId());
Integer assetGroupType = assetDetailGroup.getAssetGroupType();
//获取税务折旧期限,此值根据分类查数据库带出的值不在此进行操作
citAsset.setTaxDepreciationPeriod(assetGroupResult.getTaxDepreciationPeriod());
//获取截止去年累计折旧期间,此值根据分类查数据库带出的值不在此进行操作
Integer tempPeriod = 0;
cal.setTime(citAsset.getBuyDate());
if(assetGroupType == 1 || assetGroupType == 2){
tempPeriod = cal.get(Calendar.MONTH)+1;
}else{
tempPeriod = cal.get(Calendar.MONTH)+2;
}
citAsset.setTaxToLastYearDepreciationPeriod(tempPeriod);
//获取截止本年累计折旧期间,此值根据分类查数据库带出的值不在此进行操作
if(assetGroupType == 1 || assetGroupType == 2){
tempPeriod = 12-cal.get(Calendar.MONTH)+1;
}else{
tempPeriod = 12-cal.get(Calendar.MONTH)+2;
EnumCitAssetType enumCitAssetType = EnumCitAssetType.valueOf(assetDetailGroup.getAssetGroupType());
switch(enumCitAssetType){
case FixedAssets:
//获取税务折旧期限
citAsset.setTaxDepreciationPeriod(Math.max(citAsset.getDepreciationPeriod(),assetDetailGroup.getGroupYear()));
//把购入日期放入到Calendar
cal.setTime(citAsset.getBuyDate());
//获取截止去年累计折旧期间,此值根据分类
citAsset.setTaxToLastYearDepreciationPeriod((year-1-cal.get(Calendar.YEAR)) == -1?0:((year-1-cal.get(Calendar.YEAR))*12+12-cal.get(Calendar.MONTH)));
//获取截止本年累计折旧期间,此值根据分类
if("完全报废".equals(citAsset.getScrapType())){
calendar.setTime(citAsset.getDisposedDate());
citAsset.setTaxToCurrentYearDepreciationPeriod((calendar.get(Calendar.YEAR)-cal.get(Calendar.YEAR))*12+12-cal.get(Calendar.MONTH));
}else{
citAsset.setTaxToCurrentYearDepreciationPeriod((year-cal.get(Calendar.YEAR))*12+12-cal.get(Calendar.MONTH));
}
calendar.setTime(new Date());
calendar.add(Calendar.MONTH,1);
//计算开始折旧日期,DD没有提供,我们要根据购入日期和税法分类做预处理自己转化
//开始折旧日期计算逻辑是固定资产和长期待摊费用是购入日期的次月,无形资产的开始折旧日期等于购入日期
citAsset.setDepreciationDate(calendar.getTime());
break;
case LongTermPrepaid:
//获取税务折旧期限
citAsset.setTaxDepreciationPeriod(citAsset.getDepreciationPeriod());
//把购入日期放入到Calendar
cal.setTime(citAsset.getBuyDate());
//获取截止去年累计折旧期间,此值根据分类
citAsset.setTaxToLastYearDepreciationPeriod((year-1-cal.get(Calendar.YEAR)) == -1?0:((year-1-cal.get(Calendar.YEAR))*12+12-cal.get(Calendar.MONTH)));
//获取截止本年累计折旧期间,此值根据分类
if("完全报废".equals(citAsset.getScrapType())){
calendar.setTime(citAsset.getDisposedDate());
citAsset.setTaxToCurrentYearDepreciationPeriod((calendar.get(Calendar.YEAR)-cal.get(Calendar.YEAR))*12+12-cal.get(Calendar.MONTH));
}else{
citAsset.setTaxToCurrentYearDepreciationPeriod((year-cal.get(Calendar.YEAR))*12+12-cal.get(Calendar.MONTH));
}
calendar.setTime(new Date());
calendar.add(Calendar.MONTH,1);
//计算开始折旧日期,DD没有提供,我们要根据购入日期和税法分类做预处理自己转化
//开始折旧日期计算逻辑是固定资产和长期待摊费用是购入日期的次月,无形资产的开始折旧日期等于购入日期
citAsset.setDepreciationDate(calendar.getTime());
break;
case InvisibleAssets:
//获取税务折旧期限
citAsset.setTaxDepreciationPeriod(Math.max(citAsset.getDepreciationPeriod(),assetDetailGroup.getGroupYear()));
//把购入日期放入到Calendar
cal.setTime(citAsset.getBuyDate());
//获取截止去年累计折旧期间,此值根据分类
citAsset.setTaxToLastYearDepreciationPeriod((year-1-cal.get(Calendar.YEAR)) == -1?0:((year-1-cal.get(Calendar.YEAR))*12+12-cal.get(Calendar.MONTH)+1));
//获取截止本年累计折旧期间,此值根据分类
if("完全报废".equals(citAsset.getScrapType())){
calendar.setTime(citAsset.getDisposedDate());
citAsset.setTaxToCurrentYearDepreciationPeriod((calendar.get(Calendar.YEAR)-cal.get(Calendar.YEAR))*12+12-cal.get(Calendar.MONTH)+1);
}else{
citAsset.setTaxToCurrentYearDepreciationPeriod((year-cal.get(Calendar.YEAR))*12+12-cal.get(Calendar.MONTH)+1);
}
//计算开始折旧日期
citAsset.setDepreciationDate(citAsset.getBuyDate());
break;
}
citAsset.setTaxToCurrentYearDepreciationPeriod(tempPeriod);
//获取本年折旧期间,此值根据分类查数据库带出的值
citAsset.setTaxYearDepreciationPeriod(citAsset.getTaxToLastYearDepreciationPeriod()-citAsset.getTaxToCurrentYearDepreciationPeriod());
//获取税务每月折旧额
//获取本年折旧期间 ,截至本年累计折旧期间-截至去年累计折旧期间
citAsset.setTaxYearDepreciationPeriod(citAsset.getTaxToCurrentYearDepreciationPeriod()-citAsset.getTaxToLastYearDepreciationPeriod());
//获取税务每月折旧额,(原值-残值)/税法折旧期间
citAsset.setTaxMonthDepreciationAmount(citAsset.getAcquisitionValue().subtract(citAsset.getResidualRate()).divide(new BigDecimal(assetGroupResult.getTaxDepreciationPeriod()), 2));
//获取税务截止本年累计折旧额
//获取税务截止本年累计折旧额, 本年折旧期间* 每月折旧额
citAsset.setTaxToCurrentYearDepreciationAmount(citAsset.getTaxMonthDepreciationAmount().multiply(new BigDecimal(citAsset.getTaxToCurrentYearDepreciationPeriod())));
//获取税务本年折旧额
//获取税务本年折旧额, 截至本年累计折旧期间*每月折旧额
citAsset.setTaxCurrentYearDepreciationAmount(citAsset.getTaxMonthDepreciationAmount().multiply(new BigDecimal(citAsset.getTaxYearDepreciationPeriod())));
//获取累计差异
//获取累计差异, 截止本年累计折旧额(税务)- 截止本年累计折旧额(财务)
citAsset.setTotalDifferenceAmount(citAsset.getTaxToCurrentYearDepreciationAmount().subtract(citAsset.getAccountTotalDepreciationAmount()));
//获取当年差异
citAsset.setYearDifferenceAmount(citAsset.getTaxCurrentYearDepreciationAmount().subtract(citAsset.getAccountYearDepreciationAmount()));
......
......@@ -4,16 +4,14 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.util.JxlsUtils;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.CountTypeConstant;
import pwc.taxtech.atms.constant.ExportTemplatePathConstant;
import pwc.taxtech.atms.dao.CitJournalEntryAdjustMapper;
import pwc.taxtech.atms.dao.CitTbamMapper;
import pwc.taxtech.atms.dao.CitTrialBalanceMapper;
import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dto.CitJournalAdjustDto;
import pwc.taxtech.atms.dpo.CitTrialBalanceDto;
import pwc.taxtech.atms.dto.CitTrialBalanceExportDto;
......@@ -56,6 +54,10 @@ public class CitDataPreviewServiceImpl extends BaseService {
private CitTrialBalanceMapper citTbMapper;
@Resource
private CitTbamMapper citTbamMapper;
@Resource
private ProjectMapper projectMapper;
@Resource
private OrganizationMapper organizationMapper;
/**
* 获取日记账合并版
......@@ -64,9 +66,12 @@ public class CitDataPreviewServiceImpl extends BaseService {
*/
public PageInfo<CitJournalAdjustDto> getJournalMergeData(CitJournalAdjustDto citJournalAdjustDto) {
CitJournalEntryAdjust citJournalEntryAdjust = beanUtil.copyProperties(citJournalAdjustDto, new CitJournalEntryAdjust());
List<String> orgList = getOrgList(citJournalAdjustDto.getProjectId());
if(citJournalEntryAdjust.getPeriodEnd()!=null && citJournalEntryAdjust.getPeriodEnd()%100 ==12){
citJournalEntryAdjust.setPeriodEnd(citJournalEntryAdjust.getPeriodEnd()/100*100+13);
}
Page page = PageHelper.startPage(citJournalAdjustDto.getPageInfo().getPageIndex(), citJournalAdjustDto.getPageInfo().getPageSize());
List<CitJournalEntryAdjust> journalMerges = citJournalMapper.getJournalMerge(citJournalEntryAdjust);
List<CitJournalEntryAdjust> journalMerges = citJournalMapper.getJournalMergeByOrgList(citJournalEntryAdjust,orgList);
List<CitJournalAdjustDto> journalAdjustDtos = Lists.newArrayList();
journalMerges.forEach(journal -> {
CitJournalAdjustDto citJournalDto = new CitJournalAdjustDto();
......@@ -80,6 +85,27 @@ public class CitDataPreviewServiceImpl extends BaseService {
return pageInfo;
}
/**
* 根据卡片主键获取隶属的机构及子机构,若本身就是子机构那么只获取本身
* @param projectId
* @return
*/
public List<String> getOrgList(String projectId){
Project project = projectMapper.selectByPrimaryKey(projectId);
Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId());
List<String> orgList = new ArrayList<>();
orgList.add(project.getOrganizationId());
if(StringUtils.isBlank(organization.getParentId())){
OrganizationExample organizationExample = new OrganizationExample();
organizationExample.createCriteria().andParentIdEqualTo(project.getOrganizationId());
List<Organization> organizations = organizationMapper.selectByExample(organizationExample);
for (Organization org:organizations) {
orgList.add(org.getId());
}
}
return orgList;
}
/**
* 日记账导出(第一种方式)--暂时不使用
* @param citJournalAdjustDto
......@@ -114,7 +140,8 @@ public class CitDataPreviewServiceImpl extends BaseService {
*/
public int exportJournalMergeData2(CitJournalAdjustDto citJournalAdjustDto, HttpServletResponse response){
CitJournalEntryAdjust citJournalEntryAdjust = beanUtil.copyProperties(citJournalAdjustDto, new CitJournalEntryAdjust());
List<CitJournalEntryAdjust> journalMerges = citJournalMapper.getJournalMerge(citJournalEntryAdjust);
List<String> orgList = getOrgList(citJournalAdjustDto.getProjectId());
List<CitJournalEntryAdjust> journalMerges = citJournalMapper.getJournalMergeByOrgList(citJournalEntryAdjust,orgList);
if(journalMerges.size()==0){
return 0;
}
......
......@@ -80,7 +80,7 @@ public class CitImportExcelServiceImpl extends BaseService {
* @throws InvalidFormatException
* @throws ParseException
*/
public OperationResultDto citImportExcel(MultipartFile file,List<String> orgList, String fileName, String periodDate, Integer importType, Integer importFileType) throws IOException, InvalidFormatException, ParseException {
public OperationResultDto citImportExcel(MultipartFile file,List<String> orgList, String fileName, String periodDate, Integer importType, Integer importFileType, Integer month) throws IOException, InvalidFormatException, ParseException {
OperationResultDto operationResultDto = new OperationResultDto();
InputStream input = file.getInputStream();
......@@ -114,7 +114,7 @@ public class CitImportExcelServiceImpl extends BaseService {
break;
case SalaryAdvance:
//目前只有预提费用需要月份
Integer month = DateUtils.strToPeriodM(periodDate);
// Integer month = DateUtils.strToPeriodM(periodDate);
operationResultDto = importSalaryAdvance(input, orgList, fileName, period, month, importType);
break;
}
......@@ -165,11 +165,11 @@ public class CitImportExcelServiceImpl extends BaseService {
//根据code(主体)获取机构相关信息
List<Organization> organizations = getOrganizationByCode(companyCode);
String orgId = "";
String projectId = "";
Project project = null;
String taxPayerId = "";
if (organizations != null && organizations.size() > 0) {
orgId = organizations.get(0).getId();
projectId = getProjectId(orgId,period);
project = getProject(orgId,period);
taxPayerId = StringUtils.isNotEmpty(organizations.get(0).getLegalCode()) ?
organizations.get(0).getLegalCode() : organizations.get(0).getTaxPayerNumber();
......@@ -178,7 +178,7 @@ public class CitImportExcelServiceImpl extends BaseService {
saveResult.setResultMsg(ErrorMessageCN.DoNotSelectCompany);
return saveResult;
}
if(StringUtils.isBlank(projectId)){
if(project == null){
saveResult.setResult(false);
saveResult.setResultMsg(ErrorMessageCN.NoProjectError);
return saveResult;
......@@ -205,7 +205,7 @@ public class CitImportExcelServiceImpl extends BaseService {
//拼接日记账调整版的实体
CitJournalEntryAdjust citJournal = new CitJournalEntryAdjust();
citJournal.setId(idService.nextId());
citJournal.setProjectId(projectId);
citJournal.setProjectId(project.getId());
citJournal.setOrganizationId(orgId);
citJournal.setPeriod(period);
citJournal.setSource("人工导入");
......@@ -307,16 +307,16 @@ public class CitImportExcelServiceImpl extends BaseService {
//覆盖导入要删除原有的该操作人在当前期间导入的数据,且更改之前导入的日志记录状态
msg = "覆盖导入成功";
CitJournalEntryAdjustExample citJEAExample = new CitJournalEntryAdjustExample();
citJEAExample.createCriteria().andCreatedByEqualTo(currentUserName).andPeriodEqualTo(period).andProjectIdEqualTo(projectId);
citJEAExample.createCriteria().andCreatedByEqualTo(currentUserName).andPeriodEqualTo(period).andProjectIdEqualTo(project.getId());
logger.info("删除符合条件的日记账");
citJournalEntryAdjustMapper.deleteByExample(citJEAExample);
//删除自动生成的试算平衡表相关数据
CitTrialBalanceExample citTbExample = new CitTrialBalanceExample();
citTbExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andProjectIdEqualTo(projectId);
citTbExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andProjectIdEqualTo(project.getId());
int deleteByExample = citTrialBalanceMapper.deleteByExample(citTbExample);
logger.info("删除符合条件的试算平衡表数据");
CitTbamExample citTbamExample = new CitTbamExample();
citTbamExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andProjectIdEqualTo(projectId);
citTbamExample.createCriteria().andPeriodEqualTo(period).andCreateByEqualTo(currentUserName).andProjectIdEqualTo(project.getId());
logger.info("删除符合条件的试算平衡表Mapping数据");
citTbamMapper.deleteByExample(citTbamExample);
updateImportLog(EnumCitImportType.JournalAdjust.getCode());
......@@ -332,7 +332,8 @@ public class CitImportExcelServiceImpl extends BaseService {
//导入日志录入到数据库
addDataImportLog(citDataImportLogList);
//根据日记账自动生成试算平衡表,即试算平衡表生成版
autoGeneTB(period, orgId, orgList,projectId);
List<String> orgListTemp = getOrgList(project);
autoGeneTB(project, orgListTemp,currentUserName);
saveResult.setResult(true);
saveResult.setData(insertBatchNum);
saveResult.setResultMsg("导入成功");
......@@ -406,11 +407,11 @@ public class CitImportExcelServiceImpl extends BaseService {
List<Organization> organizations = getOrganizationByCode(companyCode);
String companyName = "";
String orgId = "";
String projectId = "";
Project project = null;
String taxPayerId = "";
if (organizations != null && organizations.size() > 0) {
orgId = organizations.get(0).getId();
projectId = getProjectId(orgId, period);
project = getProject(orgId, period);
taxPayerId = StringUtils.isNotEmpty(organizations.get(0).getLegalCode()) ?
organizations.get(0).getLegalCode() : organizations.get(0).getTaxPayerNumber();
companyName = organizations.get(0).getName();
......@@ -427,11 +428,11 @@ public class CitImportExcelServiceImpl extends BaseService {
companyFailMap.put(sb.toString(),companyFailMap.containsKey(sb.toString())?companyFailMap.get(sb.toString())+1:1);
continue;
}
if(StringUtils.isBlank(projectId)){
if(project == null){
noProjectMap.put(sb.toString(),noProjectMap.containsKey(sb.toString())?noProjectMap.get(sb.toString())+1:1);
continue;
}
projectIdList.add(projectId);
projectIdList.add(project.getId());
companySuccessMap.put(sb.toString(),companySuccessMap.containsKey(sb.toString())?companySuccessMap.get(sb.toString())+1:1);
}else{
......@@ -440,7 +441,7 @@ public class CitImportExcelServiceImpl extends BaseService {
}
trialBalance.setOrganizationId(orgId);
trialBalance.setProjectId(projectId);
trialBalance.setProjectId(project.getId());
cellValue = CitCommonUtil.getValue(rowData.getCell(7));
if("".equals(cellValue)){
citDataImportLogError.setErrorMsg("数据错误,第"+(rowNum+1)+"行科目为空");
......@@ -675,12 +676,12 @@ public class CitImportExcelServiceImpl extends BaseService {
List<Organization> organizations = getOrganizationByCode(companyCode);
String companyName = "";
String orgId = "";
String projectId = "";
Project project = null;
String taxPayerId = "";
if (organizations != null && organizations.size() > 0) {
companyName = organizations.get(0).getName();
orgId = organizations.get(0).getId();
projectId = getProjectId(orgId, period);
project = getProject(orgId, period);
if(!orgList.contains(orgId)){
saveResult.setResult(false);
......@@ -689,7 +690,7 @@ public class CitImportExcelServiceImpl extends BaseService {
return saveResult;
}
if(StringUtils.isBlank(projectId)){
if(project == null){
saveResult.setResult(false);
saveResult.setData(false);
saveResult.setResultMsg(ErrorMessageCN.NoProjectError);
......@@ -721,7 +722,7 @@ public class CitImportExcelServiceImpl extends BaseService {
citBSPrcAdjust.setId(idService.nextId());
citBSPrcAdjust.setPeriod(period);
citBSPrcAdjust.setOrganizationId(orgId);
citBSPrcAdjust.setProjectId(projectId);
citBSPrcAdjust.setProjectId(project.getId());
citBSPrcAdjust.setCreateBy(currentUserName);
Object cellValue = CitCommonUtil.getValue(rowData.getCell(0));
......@@ -758,7 +759,7 @@ public class CitImportExcelServiceImpl extends BaseService {
CitBalanceSheetPrcAdjustExample.Criteria criteria = example.createCriteria();
criteria.andCreateByEqualTo(currentUserName);
criteria.andPeriodEqualTo(period);
criteria.andProjectIdEqualTo(projectId);
criteria.andProjectIdEqualTo(project.getId());
citBSPrcAdjustMapper.deleteByExample(example);
updateImportLog(EnumCitImportType.BalanceSheetPrcAdjust.getCode());
}
......@@ -818,7 +819,7 @@ public class CitImportExcelServiceImpl extends BaseService {
List<Organization> organizations = getOrganizationByCode(companyCode);
String companyName = "";
String orgId = "";
String projectId = "";
Project project = null;
String taxPayerId = "";
if (organizations != null && organizations.size() > 0) {
orgId = organizations.get(0).getId();
......@@ -831,9 +832,9 @@ public class CitImportExcelServiceImpl extends BaseService {
}
taxPayerId = StringUtils.isNotEmpty(organizations.get(0).getLegalCode()) ?
organizations.get(0).getLegalCode() : organizations.get(0).getTaxPayerNumber();
projectId = getProjectId(orgId, period);
project = getProject(orgId, period);
if(StringUtils.isBlank(projectId)){
if(project == null){
saveResult.setResult(false);
saveResult.setData(false);
saveResult.setResultMsg(ErrorMessageCN.NoProjectError);
......@@ -860,7 +861,7 @@ public class CitImportExcelServiceImpl extends BaseService {
CitProfitPrcAdjust citProfitPrcAdjust = new CitProfitPrcAdjust();
citProfitPrcAdjust.setId(idService.nextId());
citProfitPrcAdjust.setOrganizationId(orgId);
citProfitPrcAdjust.setProjectId(projectId);
citProfitPrcAdjust.setProjectId(project.getId());
citProfitPrcAdjust.setPeriod(period);
citProfitPrcAdjust.setCreateBy(currentUserName);
......@@ -897,7 +898,7 @@ public class CitImportExcelServiceImpl extends BaseService {
CitProfitPrcAdjustExample.Criteria criteria = example.createCriteria();
criteria.andCreateByEqualTo(currentUserName);
criteria.andPeriodEqualTo(period);
criteria.andProjectIdEqualTo(projectId);
criteria.andProjectIdEqualTo(project.getId());
citProfitPrcAdjustMapper.deleteByExample(example);
updateImportLog(EnumCitImportType.ProfitPrcAdjust.getCode());
}
......@@ -1084,7 +1085,7 @@ public class CitImportExcelServiceImpl extends BaseService {
List<Organization> organizations = getOrganizationByCode(companyCode);
String companyName = "";
String orgId = "";
String projectId = "";
Project project = null;
String taxPayerId = "";
//判断是否查询到该机构,若数据库中不存在则不执行导入并记录日志
if (organizations != null && organizations.size() > 0) {
......@@ -1107,8 +1108,8 @@ public class CitImportExcelServiceImpl extends BaseService {
continue;
}
projectId = getProjectId(orgId, period);
if(StringUtils.isBlank(projectId)){
project = getProject(orgId, period);
if(project == null){
noProjectMap.put(sb.toString(),noProjectMap.containsKey(sb.toString())?noProjectMap.get(sb.toString())+1:1);
continue;
}
......@@ -1122,7 +1123,7 @@ public class CitImportExcelServiceImpl extends BaseService {
CitSalaryAdvance citSalaryAdvance = new CitSalaryAdvance();
citSalaryAdvance.setId(idService.nextId());
citSalaryAdvance.setOrganizationId(orgId);
citSalaryAdvance.setProjectId(projectId);
citSalaryAdvance.setProjectId(project.getId());
citSalaryAdvance.setPeriod(period);
citSalaryAdvance.setMonth(month);
citSalaryAdvance.setCreatedBy(currentUserName);
......@@ -1215,6 +1216,7 @@ public class CitImportExcelServiceImpl extends BaseService {
CitSalaryAdvanceExample.Criteria criteria = example.createCriteria();
criteria.andCreatedByEqualTo(currentUserName);
criteria.andPeriodEqualTo(period);
criteria.andMonthEqualTo(month);
citSalaryAdvanceMapper.deleteByExample(example);
updateImportLog(EnumCitImportType.SalaryAdvance.getCode());
}
......@@ -1319,13 +1321,13 @@ public class CitImportExcelServiceImpl extends BaseService {
* @return
*/
private int updateImportLog(Integer type) {
int updateDisplayOld = citDataImportLogMapper.updateDisplayOld(type);
int updateDisplayOld = citDataImportLogMapper.updateDisplayOld(type,authUserHelper.getCurrentAuditor().get());
return updateDisplayOld;
}
private int addDataImportLog(List<CitDataImportLog> dataImportLogs) {
//在添加import log前先将原来导入的数据版本置为旧版本
// citDataImportLogMapper.updateDisplayOld(dataImportLogs.get(0).getType());
//// citDataImportLogMapper.updateDisplayOld(dataImportLogs.get(0).getType());
int res = 0;
for (CitDataImportLog dataImportLog : dataImportLogs) {
res += citDataImportLogMapper.insertSelective(dataImportLog);
......@@ -1346,7 +1348,7 @@ public class CitImportExcelServiceImpl extends BaseService {
if (EnumImportType.Undefined.getCode().equals(type)) {
citDataImportLogExample.setOrderByClause("update_time desc");
} else {
citDataImportLogExample.createCriteria().andTypeEqualTo(type).andDisplayEqualTo(true);
citDataImportLogExample.createCriteria().andTypeEqualTo(type).andDisplayEqualTo(true).andOperatorEqualTo(authUserHelper.getCurrentAuditor().get());
citDataImportLogExample.setOrderByClause("update_time desc");
}
//把从数据库获取的实体转化成页面Dto
......@@ -1389,14 +1391,14 @@ public class CitImportExcelServiceImpl extends BaseService {
* @param periodYear
* @return
*/
private String getProjectId(String orgId, Integer periodYear) {
private Project getProject(String orgId, Integer periodYear) {
ProjectExample pExample = new ProjectExample();
pExample.createCriteria().andOrganizationIdEqualTo(orgId).andYearEqualTo(periodYear);
List<Project> pList = projectMapper.selectByExample(pExample);
if(pList != null && !pList.isEmpty()){
return pList.get(0).getId();
return pList.get(0);
}else{
return "";
return null;
}
}
......@@ -1405,44 +1407,80 @@ public class CitImportExcelServiceImpl extends BaseService {
//删除自动生成的试算平衡表相关数据
CitTrialBalanceExample citTbExample = new CitTrialBalanceExample();
citTbExample.createCriteria().andPeriodEqualTo(project.getYear()).andCreateByEqualTo(authUserHelper.getCurrentAuditor().get()).andProjectIdEqualTo(projectId);
int deleteByExample = citTrialBalanceMapper.deleteByExample(citTbExample);
citTrialBalanceMapper.deleteByExample(citTbExample);
logger.info("删除符合条件的试算平衡表数据");
CitTbamExample citTbamExample = new CitTbamExample();
citTbamExample.createCriteria().andPeriodEqualTo(project.getYear()).andCreateByEqualTo(authUserHelper.getCurrentAuditor().get()).andProjectIdEqualTo(projectId);
logger.info("删除符合条件的试算平衡表Mapping数据");
citTbamMapper.deleteByExample(citTbamExample);
updateImportLog(EnumCitImportType.JournalAdjust.getCode());
autoGeneTB(project.getYear(), project.getOrganizationId(), new ArrayList<>(), projectId);
List<String> orgList = getOrgList(project);
autoGeneTB(project, orgList, authUserHelper.getCurrentAuditor().get());
}
/**
* 获取该机构以及该机构的子机构的所有机构主键
* @param project
* @return
*/
public List<String> getOrgList(Project project){
//该机构以及该机构的子机构的所有机构主键集合变量
List<String> orgListTemp = new ArrayList<>();
Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId());
orgListTemp.add(project.getOrganizationId());
if(StringUtils.isBlank(organization.getParentId())){
Integer year = project.getYear();
String orgId = project.getOrganizationId();
//要处理日记账的卡片主键(projectId)集合变量
List<Project> projects = projectMapper.queryChildOrgAndProjectByOrgId(year, orgId);
for (Project pro : projects) {
orgListTemp.add(pro.getOrganizationId());
}
String currentUserName = authUserHelper.getCurrentAuditor().get();
new Thread(new Runnable() {
@Override
public void run() {
try{
for (Project pro : projects) {
List<String> orgChildTemp = new ArrayList<>();
orgChildTemp.add(pro.getOrganizationId());
autoGeneTB(pro,orgChildTemp,currentUserName);
}
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
return orgListTemp;
}
/**
* 自动生成试算平衡表和join出Mapping版的attribute mapping TB
* @param period
* @param project
* @param orgList
* @return
*/
public void autoGeneTB(Integer period, String orgId, List<String> orgList,String projectId){
List<String> orgListTemp = new ArrayList<>();
orgListTemp.add(orgId);
public void autoGeneTB(Project project, List<String> orgList, String currentUserName){
//第一步,根据合并日记账计算出借方发生额,贷方发生额,科目代码等相关信息
StringBuilder periodSb = new StringBuilder();
periodSb.append(period);
periodSb.append(project.getYear());
periodSb.append("%");
//第二步,查出cit_journal_entry_adjust该期间的调整日记账,
List<CitJournalEntryAdjust> citJournalEntryAdjustList = citJournalEntryAdjustMapper.sumAmountByCondition(periodSb.toString(), orgListTemp);
List<CitJournalEntryAdjust> citJournalEntryAdjustList = citJournalEntryAdjustMapper.sumAmountByCondition(periodSb.toString(), orgList);
List<CitTrialBalance> trialBalanceList = new ArrayList<>();
//存放TB与Mapping结合的实体
List<CitTbam> citTbamList = new ArrayList<>();
String currentUserName = authUserHelper.getCurrentAuditor().get();
for (CitJournalEntryAdjust citJournal:citJournalEntryAdjustList) {
CitTrialBalance trialBalance = new CitTrialBalance();
trialBalance.setPeriod(period);
trialBalance.setPeriod(project.getYear());
trialBalance.setCreateBy(currentUserName);
trialBalance.setOrganizationId(orgId);
trialBalance.setProjectId(projectId);
trialBalance.setOrganizationId(project.getOrganizationId());
trialBalance.setProjectId(project.getId());
trialBalance.setAccountCode(citJournal.getSubjectCode());
trialBalance.setAccountDescription(citJournal.getSubjectName());
//此期间默认为12
......@@ -1457,7 +1495,7 @@ public class CitImportExcelServiceImpl extends BaseService {
CitTrialBalanceExample citTrialBalanceExample = new CitTrialBalanceExample();
CitTrialBalanceExample.Criteria criteria = citTrialBalanceExample.createCriteria();
criteria.andAccountCodeEqualTo(citJournal.getSubjectCode());
criteria.andPeriodEqualTo(period-1);
criteria.andPeriodEqualTo(project.getYear()-1);
List<CitTrialBalance> trialBalances = citTrialBalanceMapper.selectByExample(citTrialBalanceExample);
if(trialBalances != null && trialBalances.size() > 0){
lastYearBegBla = trialBalances.get(0).getBeginningBalance();
......@@ -1469,7 +1507,7 @@ public class CitImportExcelServiceImpl extends BaseService {
//根据科目代码及期间查询出相应底稿&科目Mapping数据并赋值给实体CitTBam
CitDraftAccountMappingExample citDAMappingExample = new CitDraftAccountMappingExample();
citDAMappingExample.createCriteria().andAcctCodeEqualTo(citJournal.getSubjectCode()).andPeriodEqualTo(period);
citDAMappingExample.createCriteria().andAcctCodeEqualTo(citJournal.getSubjectCode()).andPeriodEqualTo(project.getYear());
List<CitDraftAccountMapping> citDraftAccountMappings = citDAMappingMapper.selectByExample(citDAMappingExample);
for (CitDraftAccountMapping daMapping : citDraftAccountMappings) {
CitTbam citTbam = new CitTbam();
......@@ -1491,9 +1529,12 @@ public class CitImportExcelServiceImpl extends BaseService {
trialBalance.setId(idService.nextId());
trialBalanceList.add(trialBalance);
}
citTrialBalanceMapper.insertBatch(trialBalanceList);
citTbamMapper.insertBatch(citTbamList);
if(trialBalanceList != null && trialBalanceList.size() >0){
citTrialBalanceMapper.insertBatch(trialBalanceList);
}
if(citTbamList != null && citTbamList.size() >0){
citTbamMapper.insertBatch(citTbamList);
}
logger.info("自动生成TB成功");
}
......
......@@ -1448,10 +1448,10 @@ public class DataImportService extends BaseService {
organizationExample.createCriteria().andNameEqualTo(billingBody);
List<Organization> orgs = organizationMapper.selectByExample(organizationExample);
DataImportLog dataImportLog = generalDataImportLog(irs.get(0).getBillingBody(),"", "",
DataImportLog dataImportLog = generalDataImportLog("","", "",
EnumImportType.InvoiceRecord.getCode(), irs.get(0).getPeriod()/100,
tmsPeriod%100, irs.get(0).getPeriod()%100,
"", "");
irs.get(0).getBillingBody(), "");
dataImportLog.setRecordSize(irs.size());
if(orgs.size()<1){
......@@ -1788,8 +1788,6 @@ public class DataImportService extends BaseService {
DataImportLogExample.Criteria criteria =example.createCriteria();
Page page = PageHelper.startPage(param.getPageInfo().getPageIndex(), param.getPageInfo().getPageSize());
List<String> orgIds = organizationService.getMyOrgList().stream().map(OrgSelectDto::getId).collect(Collectors.toList());
// 这里会导致任何人都可以看到未映射到主体的数据
orgIds.add("");
......@@ -1798,7 +1796,7 @@ public class DataImportService extends BaseService {
criteria.andOrganizationIdIn(orgIds);
}
example.setOrderByClause("update_time desc");
Page page = PageHelper.startPage(param.getPageInfo().getPageIndex(), param.getPageInfo().getPageSize());
PageInfo<DataImportLogDto> pageInfo = new PageInfo<>(dataImportLogMapper.selectByExample(example).stream()
.map(o -> beanUtil.copyProperties(o, new DataImportLogDto())).collect(Collectors.toList()));
pageInfo.setTotal(page.getTotal());
......
......@@ -326,4 +326,22 @@ public class FormulaAgent {
}
return citTbams.get(0).getEndingBalance();
}
/**
* 本年底的Q列,预提
* @param projectId
* @return
*/
public BigDecimal getAdvance(String projectId){
return adminMp.getAdvance(projectId);
}
/**
* 下年初的S列,已批准标准发票金额
* @param projectId
* @return
*/
public BigDecimal getApprovedStandardInvoiceAmount(String projectId){
return adminMp.getApprovedStandardInvoiceAmount(projectId);
}
}
package pwc.taxtech.atms.vat.service.impl.report.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import java.math.BigDecimal;
import java.util.*;
/**
* 预提重分类 获取预提费用
*/
public class YT extends FunctionBase implements FreeRefFunction {
public YT(FormulaContext formulaContext) {
super(formulaContext);
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
try{
List<Object> dataSource = new ArrayList<>();
String formulaExpression = "YT()";
logger.debug(formulaExpression);
//预提
BigDecimal advance = agent.getAdvance(formulaContext.getProjectId());
//已批准标准发票金额
BigDecimal approvedStandardInvoiceAmount = agent.getApprovedStandardInvoiceAmount(formulaContext.getProjectId());
BigDecimal value = advance.subtract(approvedStandardInvoiceAmount);
Long dataSourceId = saveDataSource(ec, Collections.singletonList(dataSource),
FormulaDataSourceDetailType.AssetDetailDataSourceDto,
value, formulaContext.getPeriod(), formulaContext.getReportTemplateGroupId(), formulaContext.getProjectId());
saveFormulaBlock(0, ec, formulaExpression, value, dataSourceId, formulaContext.getProjectId());
return new NumberEval(value.doubleValue());
}catch (Exception e){
return new NumberEval(0.00);
}
}
}
\ No newline at end of file
......@@ -106,5 +106,5 @@ public interface CitDataImportLogMapper extends MyMapper {
*/
int updateByPrimaryKey(CitDataImportLog record);
int updateDisplayOld(@Param("type") Integer type);
int updateDisplayOld(@Param("type") Integer type, @Param("operator") String operator);
}
\ No newline at end of file
......@@ -130,4 +130,12 @@ public interface CitJournalEntryAdjustMapper extends MyMapper {
* @return List<CitJournalEntryAdjust>
*/
List<CitJournalEntryAdjust> getJournalMerge(CitJournalEntryAdjust record);
/**
* fetch data by projectId
*
* @param record
* @return List<CitJournalEntryAdjust>
*/
List<CitJournalEntryAdjust> getJournalMergeByOrgList(@Param("record") CitJournalEntryAdjust record, @Param("orgList") List<String> orgList);
}
\ No newline at end of file
......@@ -187,4 +187,10 @@ public interface FormulaAdminMapper extends MyMapper {
@Param("selectFilter") String selectFilter,
@Param("year") String year,
@Param("selectPeriod") String selectPeriod);
@Select("select sum(advance) from cit_salary_advance where project_id = #{projectId} and month=0 and po_no in(select po_no from cit_salary_advance where month=1)")
BigDecimal getAdvance(@Param("projectId") String projectId);
@Select("select sum(approved_standard_invoice_amount) from cit_salary_advance where project_id = #{projectId} and month=1 and po_no in(select po_no from cit_salary_advance where month=0)")
BigDecimal getApprovedStandardInvoiceAmount(@Param("projectId") String projectId);
}
......@@ -249,4 +249,6 @@ public interface ProjectMapper extends MyMapper {
List<ProjectAnaylsisDto> getTemlateWithServiceType(@Param("list") List<String> orgIds, @Param("year") Integer year, @Param("month") Integer month,@Param("reportName")String reportName);
List<ProjectAnaylsisDto> getTemlateWithServiceType2(@Param("orgId")String orgId, @Param("year") Integer year, @Param("month") Integer month,@Param("code")String code);
List<Project> queryChildOrgAndProjectByOrgId(@Param("year")Integer year ,@Param("orgId")String orgId);
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.dao.CitDataImportLogMapper">
<update id="updateDisplayOld" parameterType="java.lang.Integer">
<update id="updateDisplayOld" parameterType="map">
update cit_data_import_log
set display = 0
where
type = #{type,jdbcType=TINYINT}
and display = 1
and operator = #{operator,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
......@@ -338,7 +338,6 @@
group by jfinal.subject_code
</select>
<select id="getJournalMerge" parameterType="map" resultMap="BaseResultMap">
select
id, organization_id, project_id, period, date, source, ledger_id, ledger_name, currency_code,
......@@ -394,7 +393,7 @@
and segment1_name = #{orgName,jdbcType=VARCHAR}
</if>
<if test="subjectName != null and subjectName != ''">
and segment3_name LIKE CONCAT('%' ,#{segment3_name},'%')
and segment3_name LIKE CONCAT('%' ,#{subjectName},'%')
</if>
<if test="description != null and description != ''">
and description LIKE CONCAT('%' ,#{description},'%')
......@@ -407,4 +406,72 @@
</if>
</select>
<select id="getJournalMergeByOrgList" parameterType="map" resultMap="BaseResultMap">
select
id, organization_id, project_id, period, date, source, ledger_id, ledger_name, currency_code,
status, header_id, line_num, approval_status, posted_status, account_period, accounting_date,
journal_source, category, name, voucher_num, description, org_code, subject_code,
org_name, segment2_name, subject_name, segment4_name, segment5_name, segment6_name, segment7_name, segment8_name,
segment9_name, segment10_name, journal_currency_code, sob_currency_code, accounted_dr, accounted_cr,
entered_dr, entered_cr, cf_item, attribute1, attribute2, attribute3, attribute4, attribute5,
attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15,
attribute16,
created_by, created_date, late_updated_by,
late_updated_date, create_time, update_time,is_select
from cit_journal_entry_adjust where period like #{record.period}
<if test="orgList != null and orgList.size > 0">
AND organization_id in
<foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="record.subjectCode != null and record.subjectCode != ''">
and subject_code LIKE CONCAT('%' ,#{record.subjectCode},'%')
</if>
<if test="record.subjectName != null and record.subjectName != ''">
and subject_name LIKE CONCAT('%' ,#{record.subjectName},'%')
</if>
<if test="record.description != null and record.description != ''">
and description LIKE CONCAT('%' ,#{description},'%')
</if>
<if test="record.periodStart!=null">
AND account_period >= #{record.periodStart,jdbcType=INTEGER}
</if>
<if test="record.periodEnd!=null">
AND account_period &lt;= #{record.periodEnd,jdbcType=INTEGER}
</if>
UNION ALL
select
id, organization_id, project_id, tms_period as period ,date,source, ledger_id, ledger_name, currency_code,
status, header_id, line_num, approval_status, posted_status, period as account_period, accounting_date,
journal_source, category, name, voucher_num, description, segment1 as org_code, segment3 as subject_code,
segment1_name as org_name, segment2_name, segment3_name as subject_name, segment4_name, segment5_name, segment6_name,
segment7_name, segment8_name, segment9_name, segment10_name, journal_currency_code, sob_currency_code,
accounted_dr, accounted_cr, entered_dr, entered_cr, cf_item, attribute1, attribute2, attribute3, attribute4, attribute5,
attribute6, attribute7, attribute8, attribute9, attribute10, attribute11, attribute12, attribute13, attribute14, attribute15,
attribute16, created_by, created_date, late_updated_by, late_updated_date, create_time, update_time, is_select
from journal_entry where tms_period like #{record.period}
<if test="orgList != null and orgList.size > 0">
AND organization_id in
<foreach item="item" index="index" collection="orgList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="record.subjectCode != null and record.subjectCode != ''">
and segment3 LIKE CONCAT('%' ,#{record.subjectCode},'%')
</if>
<if test="record.subjectName != null and record.subjectName != ''">
and segment3_name LIKE CONCAT('%' ,#{record.subjectName},'%')
</if>
<if test="record.description != null and record.description != ''">
and description LIKE CONCAT('%' ,#{record.description},'%')
</if>
<if test="record.periodStart!=null">
AND period &gt;= #{record.periodStart,jdbcType=INTEGER}
</if>
<if test="record.periodEnd!=null">
AND period &lt;= #{record.periodEnd,jdbcType=INTEGER}
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -37,5 +37,13 @@
and t.code = #{code}
</select>
<select id="queryChildOrgAndProjectByOrgId" parameterType="map" resultMap="BaseResultMap">
select p.*
from project p
left join organization o on p.organization_id=o.id
where p.year = #{year,jdbcType=INTEGER}
and o.parent_id = #{orgId,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
......@@ -6,19 +6,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import pwc.taxtech.atms.common.DDUserInfoRes;
import pwc.taxtech.atms.common.HttpUtil;
import pwc.taxtech.atms.dto.AtmsTokenDto;
import pwc.taxtech.atms.dto.LoginOutputDto;
import pwc.taxtech.atms.web.AtmsWebSettings;
import javax.servlet.ServletException;
......@@ -56,6 +50,16 @@ public class IndexController {
@Autowired
private RestTemplate restTemplate;
/**
*
* @param atmsApiToken
* @param ltpaToken
* @param request
* @param response
* @return
* @throws IOException
* @throws ServletException
*/
@RequestMapping(value = {"/", "/index", "/index.html"}, method = RequestMethod.GET)
public String login(@CookieValue(value = "AtmsApiToken", required = false) String atmsApiToken,
@CookieValue(value = "LtpaToken", required = false) String ltpaToken,
......@@ -93,15 +97,24 @@ public class IndexController {
return "redirect:Account/LogOn";
}
/**
*
* @param jumpto
* @param code
* @param response
* @throws IOException
* @throws ServletException
*/
@RequestMapping(value = {"/sso/callback"})
public void ddSSOCallback(@RequestParam(value = "jumpto") String jumpto,
@RequestParam(value = "code") String code,
HttpServletResponse response) throws IOException, ServletException {
try{
@RequestParam(value = "code") String code,
HttpServletResponse response) throws IOException, ServletException {
try {
logger.info("jumpto=" + jumpto + "code=" + code);
String ticketStr = getTicket(code);
response.sendRedirect(jumpto+"?code="+code+"&ticketStr="+ticketStr);
}catch (Exception e){
logger.error("ddSSOCallback error",e);
response.sendRedirect(jumpto + "?code=" + code + "&ticketStr=" + ticketStr);
} catch (Exception e) {
logger.error("ddSSOCallback error", e);
}
}
......@@ -109,56 +122,84 @@ public class IndexController {
* 18/03/2019 20:46
* 跨站cookie的问题,所以做了一次跳转
* [code, ticketStr, request, response]
* @author Gary J Li
*
* @return
* @author Gary J Li
*/
@RequestMapping(value = {"/sso/accept"})
public String accept(@RequestParam(value = "code") String code,
@RequestParam(value = "ticketStr") String ticketStr,HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
@RequestParam(value = "ticketStr") String ticketStr, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
StringBuffer url = request.getRequestURL();
String tempContextUrl = url.delete(url.length() - request.getRequestURI().length(), url.length()).append("/").toString();
try{
Cookie codeCookie = new Cookie("ddCode",URLEncoder.encode(code, "UTF-8"));
try {
Cookie codeCookie = new Cookie("ddCode", URLEncoder.encode(code, "UTF-8"));
codeCookie.setPath("/");
codeCookie.setMaxAge(18000);
Cookie ddTicket = new Cookie("ddTicket",URLEncoder.encode(ticketStr, "UTF-8"));
Cookie ddTicket = new Cookie("ddTicket", URLEncoder.encode(ticketStr, "UTF-8"));
ddTicket.setPath("/");
ddTicket.setMaxAge(18000);
response.addCookie(codeCookie);
response.addCookie(ddTicket);
}catch (Exception e){
logger.error("ddSSOCallback error",e);
} catch (Exception e) {
logger.error("ddSSOCallback error", e);
}
return "redirect:"+tempContextUrl;
return "redirect:" + tempContextUrl;
}
@RequestMapping(value = {"/admin", "/admin.html"}, method = RequestMethod.GET)
public String admin(@CookieValue(value = "AtmsApiToken", required = false) String atmsApiToken) {
if (StringUtils.hasText(atmsApiToken)) {
if (StringUtils.hasText( atmsApiToken)) {
return "admin";
}
return "redirect:Account/LogOn";
}
public String getTicket(String code) {
try{
try {
JSONObject object;
String ddResp = HttpUtil.post(getUserInfoUrl + "check_code", "code=" + code + "&app_key=" + appKey+ "&app_id=" + appId, "application/x-www-form-urlencoded", "UTF-8", 10000, 10000);
String url = getUserInfoUrl + "check_code";
String ddResp = HttpUtil.post(url, "code=" + code + "&app_key=" + appKey + "&app_id=" + appId, "application/x-www-form-urlencoded", "UTF-8", 10000, 10000);
object = JSONObject.parseObject(ddResp);
logger.info("get ddTicket by code , object=" + object);
Map<String, Object> res = object.getInnerMap();
int errno = (int) res.get("errno");
if (errno != 0) {
logger.warn(String.format("DD Ticket get Failed:[%s]", object.toJSONString()));
return null;
}else{
Map<String, String> data = (Map)res.get("data");
} else {
Map<String, String> data = (Map) res.get("data");
logger.info("check_code data=" + data);
return data.get("ticket");
}
}catch (Exception e){
logger.error(String.format("通过code:[%s]获取Ticket失败",code));
} catch (Exception e) {
logger.error(String.format("通过code:[%s]获取Ticket失败", code));
}
return null;
}
/**
* sam
* @param ticket
* @param request
* @param response
* @return
*/
@RequestMapping(value = {"/sso/getUser"}, method = RequestMethod.GET)
@ResponseBody
public String accept(@RequestParam(value = "ticket") String ticket, HttpServletRequest request,
HttpServletResponse response) {
DDUserInfoRes ddUserInfoRes = null;
try {
String responseDD = HttpUtil.post(getUserInfoUrl + "get_user_by_ticket", "ticket=" + ticket + "&app_id=" + appId, "application/x-www-form-urlencoded", "UTF-8", 10000, 10000);
logger.info(String.format("DD-get_user_by_ticket返回:[%s]", responseDD));
ddUserInfoRes = JSONObject.parseObject(responseDD, DDUserInfoRes.class);
} catch (Exception e) {
logger.info(String.format("调用DDSSO获取用户信息失败:[%s]", e.getMessage()), e);
}
return JSON.toJSONString(ddUserInfoRes);
}
}
......@@ -1153,6 +1153,9 @@
"ItemData": "Item Data",
"GenerateJournalMergeAndTB": "Handle Journal",
"ProcessSuccess": "Process Success",
"ProcessFail": "Process Fail"
"ProcessFail": "Process Fail",
"EndOfThisYear": "End Of This Year",
"BeginOfNextYear": "Begin Of Next Year",
"PreClassified": "Pre Classified"
}
\ No newline at end of file
......@@ -1206,7 +1206,10 @@
"ItemData": "条数据",
"GenerateJournalMergeAndTB": "处理日记账",
"ProcessSuccess": "处理成功",
"ProcessFail": "处理失败"
"ProcessFail": "处理失败",
"EndOfThisYear": "本年底",
"BeginOfNextYear": "下年初",
"PreClassified": "预提重分类"
......
......@@ -519,7 +519,7 @@
rowData.taxDepreciationPeriod = null;
} else {
rowData.assetDetailGroupId = aseetDetailList[0].id;
rowData.taxDepreciationPeriod = aseetDetailList[0].groupYear * 12;
rowData.taxDepreciationPeriod = aseetDetailList[0].groupYear;
}
;
},
......@@ -543,7 +543,7 @@
return item.id == value;
});
if (aseetDetailList.length > 0) {
rowData.taxDepreciationPeriod = aseetDetailList[0].groupYear * 12;
rowData.taxDepreciationPeriod = aseetDetailList[0].groupYear;
}
},
lookup: {
......@@ -657,7 +657,8 @@
{
caption: $translate.instant('ResidualRate'),
dataField: "residualRate",
format: {type: 'percent', precision: 2},
// format: {type: 'percent', precision: 2},
format: {type: 'fixedPoint', precision: 2},
width: 80,
allowEditing: false
},
......
......@@ -37,6 +37,7 @@
$scope.queryParams = {
pageInfo: {},
period: vatSessionService.year,
periodStart: '',
periodEnd: '',
subjectCode: null,
......@@ -90,6 +91,7 @@
var doDataFilterReset = function () {
$scope.queryParams = {
pageInfo: {},
period: vatSessionService.year,
periodStart: '',
periodEnd: '',
subjectCode: null,
......@@ -185,7 +187,8 @@
$scope.pagingOptions = {
pageIndex: 1, //当前页码
totalItems: 0, //总数据
pageSize: 50 //每页多少条数据
pageSize: 50, //每页多少条数据
pageSizeString:"50"
};
$('#input-invoice-period-picker').focus(function () {
......@@ -281,6 +284,7 @@
initPeriods();
//初始化查询条件-期间范围
$scope.queryParams.period = vatSessionService.year;
$scope.queryParams.periodStart = vatSessionService.year * 100 + 1;
$scope.queryParams.periodEnd = vatSessionService.year * 100 + 12;
$scope.queryParams.organizationId = vatSessionService.project.organizationID;
......
......@@ -26,8 +26,8 @@
$scope.selectedDate = new Date(vatSessionService.year, vatSessionService.month - 1, 1);
$scope.startDate = new Date(year - 20, 1, 1);
$scope.endDate = new Date(year + 20, 1, 1);
$scope.viewMode = 1;
$scope.dateFormat = $translate.instant('dateFormat4YearMonth');
$scope.viewMode = 2;
$scope.dateFormat = $translate.instant('dateFormat4Year');
$scope.importExcelFile = null;
$scope.UploadPeriodTime = null;
......@@ -38,6 +38,28 @@
$scope.checkedCompanyTypeList = "";
$scope.maxTitleLength = constant.maxButtonTitleLength;
$scope.month = 0;
//税会差异选项内容
$scope.applyFilterTypes = [{
key: "0",
name: $translate.instant('EndOfThisYear')
}, {
key: "1",
name: $translate.instant('BeginOfNextYear')
}];
//初始化税会差异选项
$scope.endBeginOptions = {
items: $scope.applyFilterTypes,
value: $scope.applyFilterTypes[0].key,
valueExpr: "key",
displayExpr: "name",
onValueChanged: function (data) {
$scope.month = data.value;
}
};
//写日志
var logDto = {
......@@ -157,7 +179,8 @@
orgIds : orgIds,
periodDate : period,
importType : importType,
importFileType : constant.citImportFileType.SalaryAdvance
importFileType : constant.citImportFileType.SalaryAdvance,
month: $scope.month
},
file: impExl,
headers: {
......
......@@ -31,6 +31,11 @@
</li>
</ul>
</div>
<!--本年底、下年初的选择-->
<span class="text-bold" translate="PreClassified"></span>:
<div class="option" style="display: inline-block">
<div id="endBeginButton" dx-select-box="endBeginOptions" style="width: 130px"></div>
</div>
<span class="text-bold" translate="InvoiceQJ"></span>:
<div class="period-picker" style="margin-left:10px">
<input type="text" id="periodDatepicker" class="datepicker imp-subheader" style="width:120px;"
......
......@@ -149,10 +149,10 @@
}
input {
width: 50px;
//width: 50px;
outline: none;
border-radius: 3px;
border: 1px solid #3c3a36;
//border: 1px solid #3c3a36;
padding: 2px;
text-align: center;
}
......@@ -342,4 +342,22 @@
float:left;
padding-left: 15px;
}
}
.option {
margin-top: 10px;
margin-bottom: 10px;
}
.option > span {
margin-right: 10px;
}
.option > .dx-selectbox {
display: inline-block;
vertical-align: middle;
}
.option > input {
width: auto;
}
\ No newline at end of file
......@@ -9,8 +9,8 @@ webservices.factory('citImportDataService', ['$http', 'apiConfig', function ($ht
},
/***************************************批量数据导入服务(真) end**************************************************************/
autoGeneTB: function () {
return $http.post('/citImport/getCitDataImportLog', apiConfig.create());
},
// autoGeneTB: function () {
// return $http.post('/citImport/getCitDataImportLog', apiConfig.create());
// },
};
}]);
\ No newline at end of file
......@@ -196,7 +196,7 @@
width: '10%',
caption: $translate.instant('LogOperationTime'),
calculateCellValue: function(data) {
return new Date(data.operateTime).formatDateTime('yyyy-MM-dd hh:mm:ss');
return new Date(data.operateTime).formatDateTime('yyyy-MM-dd HH:mm:ss');
}
}
],
......
......@@ -6,23 +6,6 @@
<meta name=viewport content="width=device-width,initial-scale=1">
<link rel=icon href=favicon.ico>
<title>didi2</title>
<link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
<link rel=stylesheet href="https://fonts.googleapis.com/css?family=Material+Icons">
<link href=js/about.17654e8a.js rel=prefetch>
<link href=css/app.cf16809e.css rel=preload as=style>
<link href=css/chunk-vendors.2f35f377.css rel=preload as=style>
<link href=js/app.c8b0fed0.js rel=preload as=script>
<link href=js/chunk-vendors.39b13767.js rel=preload as=script>
<link href=css/chunk-vendors.2f35f377.css rel=stylesheet>
<link href=css/app.cf16809e.css rel=stylesheet>
</head>
<body>
<noscript>
<strong>We're sorry but didi2 doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script src=js/chunk-vendors.39b13767.js></script>
<script src=js/app.c8b0fed0.js></script>
<script>
//获取地址栏参数,name:参数名称
var z =function getUrlParms(name){
......@@ -32,8 +15,10 @@
return unescape(r[2]);
return null;
}
var code = z("code");
var ticket=z("ticketStr");
var ddTicket = z("ticketStr");
//設置cookie
var sc= function setCookie(name,value) {
var Days = 30;
var exp = new Date();
......@@ -41,20 +26,54 @@
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
sc("ddCode",code);
sc("ddTicket",ticket );
var gc= function getCookie(name)
{
sc("ddTicket",ddTicket);
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
var ReUrl="https://me.xiaojukeji.com/project/stargate-auth/html/login.html?redirect_uri=http%3A%2F%2Fmis.diditaxi.com.cn%2Fauth%3Fapp_id%3D2500%26version%3D1.0%26jumpto%3Dhttp://dts-test.erp.didichuxing.com/orangeweb/index.html%26callback_index%3D0"
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
if(ddTicket==undefined || ddTicket=="" || ddTicket == null){
document.location=ReUrl;
}
else {
//创建核心对象
xmlhttp = null;
if (window.XMLHttpRequest) {// code for Firefox, Opera, IE7, etc.
xmlhttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
//编写回调函数
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//
}
}
//這個 url 測試的
var getUserUrl="http://dts-test.erp.didichuxing.com/H5/sso/getUser?ticket=";
//open设置请求方式和请求路径
xmlhttp.open("get", getUserUrl+ddTicket);
//send 发送
xmlhttp.send();
}
}
</script>
<link rel=stylesheet href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
<link rel=stylesheet href="https://fonts.googleapis.com/css?family=Material+Icons">
<link href=js/about.17654e8a.js rel=prefetch>
<link href=css/app.cf16809e.css rel=preload as=style>
<link href=css/chunk-vendors.2f35f377.css rel=preload as=style>
<link href=js/app.c8b0fed0.js rel=preload as=script>
<link href=js/chunk-vendors.39b13767.js rel=preload as=script>
<link href=css/chunk-vendors.2f35f377.css rel=stylesheet>
<link href=css/app.cf16809e.css rel=stylesheet>
</head>
<body>
<noscript>
<strong>We're sorry but didi2 doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script src=js/chunk-vendors.39b13767.js></script>
<script src=js/app.c8b0fed0.js></script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment