Commit 6f8bcebf by kangxiaoshan

分摊收入报表权限

parent 82c2f74b
...@@ -426,7 +426,7 @@ public class ContractController { ...@@ -426,7 +426,7 @@ public class ContractController {
*/ */
@RequestMapping(value = "/shareincome/list", method = RequestMethod.GET) @RequestMapping(value = "/shareincome/list", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@AuthKey(AuthMenuEnmm.CONTRACTMNG_V) @AuthKey(AuthMenuEnmm.SHARED_INCOME_V)
public ResultModel shareIncome(@CurrentAccount User loginAccount, @PathVariable String platform, public ResultModel shareIncome(@CurrentAccount User loginAccount, @PathVariable String platform,
@RequestParam String startDate, @RequestParam String endDate, @RequestParam String startDate, @RequestParam String endDate,
String bodyCode, String serchName) { String bodyCode, String serchName) {
...@@ -437,7 +437,7 @@ public class ContractController { ...@@ -437,7 +437,7 @@ public class ContractController {
@RequestMapping(value = "/shareincome/export", method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) @RequestMapping(value = "/shareincome/export", method = RequestMethod.GET, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody @ResponseBody
@AuthKey(AuthMenuEnmm.CONTRACTMNG_V) @AuthKey(AuthMenuEnmm.SHARED_INCOME_E)
public ResponseEntity<byte[]> shareIncomeExport(@CurrentAccount User loginAccount, @PathVariable String platform, public ResponseEntity<byte[]> shareIncomeExport(@CurrentAccount User loginAccount, @PathVariable String platform,
@RequestParam String startDate, @RequestParam String endDate, @RequestParam String startDate, @RequestParam String endDate,
String bodyCode, String serchName, HttpServletResponse response, HttpServletRequest request) { String bodyCode, String serchName, HttpServletResponse response, HttpServletRequest request) {
......
...@@ -55,7 +55,7 @@ public class Contract { ...@@ -55,7 +55,7 @@ public class Contract {
private Long firstBackId;//先回款记录的id private Long firstBackId;//先回款记录的id
private Long adjustmentFund;// 分摊收入调整金额 private Long adjustmentFund;// 分摊收入调整金额 (*100的结果)
private Integer intervalUseDays;//区间使用天数 private Integer intervalUseDays;//区间使用天数
private Long incomeExcludingTax; //不含税收入 (*100的结果) private Long incomeExcludingTax; //不含税收入 (*100的结果)
private Long intervaIncomeShare;//区间分摊收入(*100的结果) private Long intervaIncomeShare;//区间分摊收入(*100的结果)
......
...@@ -104,9 +104,15 @@ public interface ContractRepository extends JpaRepository<Contract, Long> { ...@@ -104,9 +104,15 @@ public interface ContractRepository extends JpaRepository<Contract, Long> {
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and my_body_code = ?4",nativeQuery = true) @Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and my_body_code = ?4",nativeQuery = true)
List<Contract> findShareContranctByDate(String startDate, String endDate, String platform, String bodyCode); List<Contract> findShareContranctByDate(String startDate, String endDate, String platform, String bodyCode);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and (my_body_name like %?5% or customer_body like %?5% or contract_code like %?5%)",nativeQuery = true) @Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and (my_body_name like %?4% or customer_body like %?4% or contract_code like %?4%)",nativeQuery = true)
List<Contract> findShareContranctByDateSerche(String startDate, String endDate, String platform, String serchName); List<Contract> findShareContranctByDateSerche(String startDate, String endDate, String platform, String serchName);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and my_body_code = ?4 and (my_body_name like %?5% or customer_body like %?5% or contract_code like %?5%)",nativeQuery = true) @Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and my_body_code = ?4 and (my_body_name like %?5% or customer_body like %?5% or contract_code like %?5%)",nativeQuery = true)
List<Contract> findShareContranctByDate(String startDate, String endDate, String platform, String bodyCode, String serchName); List<Contract> findShareContranctByDate(String startDate, String endDate, String platform, String bodyCode, String serchName);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and (my_body_name like %?4% or customer_body like %?4% or contract_code like %?5%) and my_body_code in ?5",nativeQuery = true)
List<Contract> findShareContranctByDateSercheFinace(String startDate, String endDate, String platform, String serchName, List<String> financeBodies);
@Query(value="select * from contract where start_date >= ?1 and start_date <=?2 and end_date >= ?1 and create_time >= ?1 and platform=?3 and my_body_code in ?4",nativeQuery = true)
List<Contract> findShareContranctByDateFinace(String startDate, String endDate, String platform, List<String> financeBodies);
} }
...@@ -514,7 +514,6 @@ public class ContractServiceImpl implements ContractService { ...@@ -514,7 +514,6 @@ public class ContractServiceImpl implements ContractService {
// } // }
this.calculateShareIncome(resource); this.calculateShareIncome(resource);
resource = contractRepository.save(resource); resource = contractRepository.save(resource);
...@@ -524,7 +523,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -524,7 +523,7 @@ public class ContractServiceImpl implements ContractService {
return resource; return resource;
} }
public void calculateShareIncome(Contract resource){ public void calculateShareIncome(Contract resource) {
DateTime formStart = new DateTime(resource.getStartDate()); DateTime formStart = new DateTime(resource.getStartDate());
DateTime contractStart = new DateTime(resource.getStartDate()); DateTime contractStart = new DateTime(resource.getStartDate());
DateTime contractEnd = new DateTime(resource.getEndDate()); DateTime contractEnd = new DateTime(resource.getEndDate());
...@@ -534,7 +533,7 @@ public class ContractServiceImpl implements ContractService { ...@@ -534,7 +533,7 @@ public class ContractServiceImpl implements ContractService {
//分摊收入调整金 = 合同金额 * 6% / 合同总天数 *[录入日期前一月最后一日(含) - 合同开始日期] //分摊收入调整金 = 合同金额 * 6% / 合同总天数 *[录入日期前一月最后一日(含) - 合同开始日期]
int day1 = Days.daysBetween(contractStart, contractEnd).getDays(); int day1 = Days.daysBetween(contractStart, contractEnd).getDays();
int day2 = Days.daysBetween(contractStart, new DateTime().plusMonths(-1).dayOfMonth().withMaximumValue()).getDays(); int day2 = Days.daysBetween(contractStart, new DateTime().plusMonths(-1).dayOfMonth().withMaximumValue()).getDays();
resource.setAdjustmentFund(resource.getMoney() * 6 / day1 * day2 ); // 此处为 *100的结果 resource.setAdjustmentFund(resource.getMoney() * 6 / day1 * day2); // 此处为 *100的结果
} }
} }
...@@ -1198,11 +1197,8 @@ public class ContractServiceImpl implements ContractService { ...@@ -1198,11 +1197,8 @@ public class ContractServiceImpl implements ContractService {
if (RoleEnum.FINANCE.getKey().equals(loginAccount.getRole())) { if (RoleEnum.FINANCE.getKey().equals(loginAccount.getRole())) {
//财务 按签约主体查看 //财务 按签约主体查看
// List bodyids = Arrays.asList(loginAccount.getAuthExtend().split(","));
List bodyids = JSONArray.fromObject(auth.getAuthExtend()); List bodyids = JSONArray.fromObject(auth.getAuthExtend());
// List<String> bodycodes = contractBodyRepository.findByIds(bodyids);
if (!StringUtils.isEmpty(contractId)) { if (!StringUtils.isEmpty(contractId)) {
if (ids != null && ids.size() > 0) { if (ids != null && ids.size() > 0) {
...@@ -2358,15 +2354,42 @@ public class ContractServiceImpl implements ContractService { ...@@ -2358,15 +2354,42 @@ public class ContractServiceImpl implements ContractService {
public List<Contract> shareIncomeList(User loginAccount, String startDate, String endDate, String platform, String bodyCode, String serchName) { public List<Contract> shareIncomeList(User loginAccount, String startDate, String endDate, String platform, String bodyCode, String serchName) {
List<Contract> contracts = new ArrayList<>(); List<Contract> contracts = new ArrayList<>();
List<String> financeBodies = null;
if (RoleEnum.FINANCE.getKey().equals(loginAccount.getRole())) {
Auth auth = authRepository.findByUser(loginAccount.getId());
financeBodies = JSONArray.fromObject(auth.getAuthExtend());
}
if (!StringUtils.isEmpty(bodyCode) && !StringUtils.isEmpty(serchName)) { if (!StringUtils.isEmpty(bodyCode) && !StringUtils.isEmpty(serchName)) {
if (financeBodies != null && !financeBodies.contains(bodyCode)) {
//沒有权限查看
return contracts;
} else {
contracts = contractRepository.findShareContranctByDate(startDate, endDate, platform, bodyCode, serchName); contracts = contractRepository.findShareContranctByDate(startDate, endDate, platform, bodyCode, serchName);
}
} else if (!StringUtils.isEmpty(bodyCode)) { } else if (!StringUtils.isEmpty(bodyCode)) {
if (financeBodies != null && !financeBodies.contains(bodyCode)) {
//沒有权限查看
return contracts;
} else {
contracts = contractRepository.findShareContranctByDate(startDate, endDate, platform, bodyCode); contracts = contractRepository.findShareContranctByDate(startDate, endDate, platform, bodyCode);
}
} else if (!StringUtils.isEmpty(serchName)) { } else if (!StringUtils.isEmpty(serchName)) {
if (financeBodies != null) {
contracts = contractRepository.findShareContranctByDateSercheFinace(startDate, endDate, platform, serchName, financeBodies);
} else {
contracts = contractRepository.findShareContranctByDateSerche(startDate, endDate, platform, serchName); contracts = contractRepository.findShareContranctByDateSerche(startDate, endDate, platform, serchName);
}
} else {
if (financeBodies != null) {
contracts = contractRepository.findShareContranctByDateFinace(startDate, endDate, platform, financeBodies);
} else { } else {
contracts = contractRepository.findShareContranctByDate(startDate, endDate, platform); contracts = contractRepository.findShareContranctByDate(startDate, endDate, platform);
} }
}
List<ContractBody> bodies = contractBodyRepository.findAll(); List<ContractBody> bodies = contractBodyRepository.findAll();
Map<String, String> bodiesNameMap = bodies.stream().collect( Map<String, String> bodiesNameMap = bodies.stream().collect(
...@@ -2377,8 +2400,9 @@ public class ContractServiceImpl implements ContractService { ...@@ -2377,8 +2400,9 @@ public class ContractServiceImpl implements ContractService {
v.setMyBodyName(bodiesNameMap.get(v.getMyBodyCode())); v.setMyBodyName(bodiesNameMap.get(v.getMyBodyCode()));
//以下结果统一 *100
//不含稅收入 //不含稅收入
//以下结果统一 *100
// Long excludTax = v.getMoney() * 6 / 100; // Long excludTax = v.getMoney() * 6 / 100;
Long excludTax = (long) (v.getMoney() * 100 * 0.06); Long excludTax = (long) (v.getMoney() * 100 * 0.06);
...@@ -2405,13 +2429,15 @@ public class ContractServiceImpl implements ContractService { ...@@ -2405,13 +2429,15 @@ public class ContractServiceImpl implements ContractService {
int contractFormRange = Days.daysBetween(usedStart, usedEnd).getDays() + 1; int contractFormRange = Days.daysBetween(usedStart, usedEnd).getDays() + 1;
//区间分摊收入 //区间分摊收入
//以下结果统一 *100
Long intervalIncome = 0L; Long intervalIncome = 0L;
if (containEnd) { if (containEnd) {
//时间范围合同结束时间时 分两部分计算 //时间范围合同结束时间时 分两部分计算
//第一部分 //第一部分
intervalIncome = (v.getMoney() * 100) / contracAllDays * (contractFormRange - 1); intervalIncome = (v.getMoney() * 100) / contracAllDays * (contractFormRange - 1);
//第二部分 //第二部分
Long intervalIncomePart2 = v.getMoney() * 100 - (v.getMoney() * 100 / contracAllDays * (contracAllDays - 1)); Long intervalIncomePart2 = (long) (v.getMoney() -
(v.getMoney() * 100 / contracAllDays * (contracAllDays - 1)) * 1.0 / 100) * 100;
intervalIncome += intervalIncomePart2; intervalIncome += intervalIncomePart2;
v.setIntervaIncomeShare(intervalIncome); v.setIntervaIncomeShare(intervalIncome);
......
...@@ -37,6 +37,11 @@ public enum AuthMenuEnmm { ...@@ -37,6 +37,11 @@ public enum AuthMenuEnmm {
USERLOGS_V("32","system","查看"), USERLOGS_V("32","system","查看"),
USERLOGS_RE("32","system","恢复"), USERLOGS_RE("32","system","恢复"),
FINANCE_REPORT("financereport","0","财务报表"),
SHARED_INCOME("40","financereport","分摊收入报表"),
SHARED_INCOME_V("41","financereport","查看"),
SHARED_INCOME_E("412","financereport","导出"),
OTHER("0","0","0"); OTHER("0","0","0");
......
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