Commit bd1a4b5f authored by eddie.woo's avatar eddie.woo

add getEnterpriseAccountList

parent a32d7f12
......@@ -73,4 +73,9 @@ public class EnterpriseAccountConstant {
public static final List<String> acctPropLogList = Arrays.asList("", "资产", "负债", "共同", "权益", "成本", "损益", "其他");
public class StdCode{
public static final String NULL_STD_CODE = "00";
public static final String EMPTY_STD_CODE = "0000";
}
}
......@@ -261,4 +261,13 @@ public class EnterpriseAccountManagerController {
public List<EnterpriseAccountSetDto> getEnterpriseAccountSetListByOrgID(@RequestParam String orgID) {
return enterpriseAccountService.getEnterpriseAccountSetListByOrgID(orgID);
}
@ResponseBody
@ApiOperation(value = "科目对应列表")
@RequestMapping(value = "getEnterpriseAccountList", method = RequestMethod.GET)
public List<EnterpriseAccountDto> getEnterpriseAccountList(@RequestParam String espID,
@RequestParam String orgID,
@RequestParam String filterType) {
return enterpriseAccountService.getList(espID, orgID, filterType);
}
}
......@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.dto.epaccount.EnterpriseAccountDto;
import pwc.taxtech.atms.entitiy.EnterpriseAccount;
import pwc.taxtech.atms.entitiy.EnterpriseAccountExample;
......@@ -105,4 +106,7 @@ public interface EnterpriseAccountMapper extends MyMapper {
* @mbg.generated
*/
int updateByPrimaryKey(EnterpriseAccount record);
List<EnterpriseAccountDto> getDto(@Param("epAccountSetID") String epAccountSetID,
@Param("orgId") String orgId, @Param("industryId") String industryId);
}
\ No newline at end of file
......@@ -99,6 +99,8 @@ public interface EnterpriseAccountService {
List<AccountMappingDto> getAccountMappingOrg(String organizationID);
List<EnterpriseAccountSetDto> getEnterpriseAccountSetListByOrgID(String orgId);
List<EnterpriseAccountDto> getList(String epAccountSetID, String orgId, String filterType);
}
......@@ -2,6 +2,7 @@
package pwc.taxtech.atms.service.impl;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.nutz.lang.Files;
......@@ -621,6 +622,79 @@ public class EnterpriseAccountServiceImpl extends AbstractService implements Ent
.map(this::toAccountSetDto).collect(Collectors.toList());
}
@Override
public List<EnterpriseAccountDto> getList(String epAccountSetID, String orgId, String filterType) {
if (StringUtils.isAnyBlank(epAccountSetID, orgId)) {
return Collections.emptyList();
}
Organization organization = organizationMapper.selectByPrimaryKey(orgId);
Industry industry = industryMapper.selectByPrimaryKey(organization.getIndustryID());
String industryId = null == industry ? IndustryConstant.GeneralIndustryID : industry.getID();
List<EnterpriseAccountDto> dtoList = enterpriseAccountMapper.getDto(epAccountSetID, orgId, industryId);
// dtoList = dtoList.stream().map(x -> {
// if (StringUtils.isBlank(x.getParentCode())) {
// x.setParentCode(StringUtils.EMPTY);
// }
// return x;
// }).sorted(Comparator.comparing(EnterpriseAccountDto::getParentCode)
// .thenComparing(EnterpriseAccountDto::getIsActive).reversed()
// .thenComparing(EnterpriseAccountDto::getCode)).collect(Collectors.toList());
List<EnterpriseAccountDto> result;
switch (filterType) {
//未对应
case "0":
result = dtoList.stream().filter(x -> StringUtils.isBlank(x.getStdCode())).collect(Collectors.toList());
break;
//已对应
case "1":
result = dtoList.stream().filter(x -> StringUtils.isNotBlank(x.getStdCode())).collect(Collectors.toList());
break;
//借贷方向不一致
case "2":
result = dtoList.stream().filter(x -> StringUtils.isNotBlank(x.getStdCode())
&& !StringUtils.equalsAny(x.getStdCode(), EnterpriseAccountConstant.StdCode.EMPTY_STD_CODE, EnterpriseAccountConstant.StdCode.NULL_STD_CODE)
&& x.getDirection() != x.getStdDirection()).collect(Collectors.toList());
break;
//科目类型不一致
case "3":
result = dtoList.stream().filter(x -> StringUtils.isNotBlank(x.getStdCode())
&& !StringUtils.equalsAny(x.getStdCode(), EnterpriseAccountConstant.StdCode.EMPTY_STD_CODE, EnterpriseAccountConstant.StdCode.NULL_STD_CODE)
&& x.getAcctProp() != x.getStdAcctProp()).collect(Collectors.toList());
break;
default:
result = dtoList;
}
List<EnterpriseAccountDto> rootList = result.stream().filter(x -> StringUtils.isBlank(x.getParentCode())).map(x -> {
x.setTreeLevel(0);
return x;
}).collect(Collectors.toList());
List<EnterpriseAccountDto> total = Lists.newArrayList();
formatEpAccountDtoTree(rootList, result, total);
return total.stream().sorted(Comparator.comparing(EnterpriseAccountDto::getCode)).collect(Collectors.toList());
}
private void formatEpAccountDtoTree(List<EnterpriseAccountDto> rootList, List<EnterpriseAccountDto> allList,
List<EnterpriseAccountDto> result) {
if (CollectionUtils.isEmpty(rootList)) {
return;
}
int level = rootList.get(0).getTreeLevel() + 1;
rootList.forEach(item -> {
result.add(item);
List<EnterpriseAccountDto> subList = allList.stream().filter(x -> StringUtils.equals(x.getParentCode(), item.getCode()))
.map(x -> {
x.setTreeLevel(level);
x.setParentName(item.getName());
x.setParentFullName(item.getFullName());
return x;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(subList)) {
result.addAll(subList);
formatEpAccountDtoTree(subList, allList, result);
}
});
}
private EnterpriseAccountSetDto toAccountSetDto(EnterpriseAccountSet accountSet) {
EnterpriseAccountSetDto dto = new EnterpriseAccountSetDto();
return CommonUtils.copyProperties(accountSet, dto);
......
......@@ -508,4 +508,35 @@
order by ${orderByClause}
</if>
</select>
<select id="getDto" resultType="pwc.taxtech.atms.dto.epaccount.EnterpriseAccountDto">
SELECT ea.ID, ea.CODE as code, ea.NAME as name, ea.ParentCode as parentCode, ea.FullName as fullName
, ea.IsLeaf as isLeaf, ea.RuleType as ruleType, ea.AcctLevel as acctLevel, ea.AcctProp as acctProp, ea.Direction as direction
, ea.IsActive as isActive
, CASE
WHEN am.StandardAccountCode = '0000' THEN am.StandardAccountCode
ELSE sa.CODE
END AS stdCode, sa.NAME AS stdName, sa.ParentCode AS stdParentCode, sa.Direction AS stdDirection, sa.AcctProp AS stdAcctProp
, sa.FullName AS stdFullName
FROM (
SELECT *
FROM EnterpriseAccount
WHERE Enterpriseaccountsetid = #{epAccountSetID}
) ea
LEFT JOIN (
SELECT *
FROM AccountMapping
WHERE OrganizationID = #{orgId}
AND IndustryID = #{industryId}
AND EnterpriseAccountSetID = #{epAccountSetID}
) am
ON ea.CODE = am.EnterpriseAccountCode
LEFT JOIN (
SELECT *
FROM StandardAccount
WHERE IndustryID = #{industryId}
) sa
ON am.StandardAccountCode = sa.CODE
ORDER BY ea.CODE
</select>
</mapper>
\ 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