diff --git a/src/main/java/cn/palmte/work/bean/BudgetBean.java b/src/main/java/cn/palmte/work/bean/BudgetBean.java index 826746f..40270d1 100644 --- a/src/main/java/cn/palmte/work/bean/BudgetBean.java +++ b/src/main/java/cn/palmte/work/bean/BudgetBean.java @@ -75,6 +75,10 @@ public class BudgetBean extends IncomeCostBean{ this.costPurchaseTotalTaxInclude = costPurchaseTotalTaxInclude; } + public BigDecimal getCostPurchaseTotalTax() { + return getCostPurchaseTotalTaxInclude().subtract(getCostPurchaseTotalTaxExclude()); + } + public BigDecimal getIncomeDeviceTax() { return incomeDeviceTax; } diff --git a/src/main/java/cn/palmte/work/controller/backend/MonthlySettleController.java b/src/main/java/cn/palmte/work/controller/backend/MonthlySettleController.java index b78ea75..cfefa74 100644 --- a/src/main/java/cn/palmte/work/controller/backend/MonthlySettleController.java +++ b/src/main/java/cn/palmte/work/controller/backend/MonthlySettleController.java @@ -4,6 +4,7 @@ import cn.palmte.work.bean.ResponseMsg; import cn.palmte.work.model.MonthlySettle; import cn.palmte.work.model.MonthlySettleRepository; import cn.palmte.work.service.MonthlySettleService; +import cn.palmte.work.utils.FreeMarkerUtil; import cn.palmte.work.utils.Utils; import cn.palmte.work.utils.excel.AppendMore; import cn.palmte.work.utils.excel.ExcelLogs; @@ -53,16 +54,24 @@ public class MonthlySettleController extends BaseController { setModel(keywords, model); ConcurrentHashMap searchInfo = getSearchInfo(keywords, model); model.put("pager", monthlySettleService.list(searchInfo, pageNumber, pageSize)); + model.put("Utils", FreeMarkerUtil.fromStaticPackage("cn.palmte.work.utils.Utils")); return "/admin/monthlySettle_list"; } @RequestMapping("/info") - public String list(@RequestParam("id") int id, Map model) { + public String info(@RequestParam("id") int id, Map model) { MonthlySettle monthlySettle = monthlySettleRepository.findOne(id); model.put("monthlySettle", monthlySettle); return "/admin/monthlySettle_info"; } + @RequestMapping("/infoByTime") + public String infoByTime(@RequestParam("time") String time, @RequestParam("projectName") String projectName, Map model) { + MonthlySettle monthlySettle = monthlySettleRepository.findByMonthAndProjectName(time, projectName); + model.put("monthlySettle", monthlySettle); + return "/admin/monthlySettle_info"; + } + private void setModel(@RequestParam(value = "keywords", required = false) String keywords, Map model) { model.put("keywords", keywords); } @@ -109,13 +118,13 @@ public class MonthlySettleController extends BaseController { */ @RequestMapping("/batchImport") @ResponseBody - public String batchImport(MultipartFile file) { + public String batchImport(MultipartFile file, @RequestParam(value = "date",required = false) String date) { try { ExcelLogs logs = new ExcelLogs(); Collection maps = ExcelUtil.importExcel(Map.class, file.getInputStream(), "yyyy/MM/dd HH:mm:ss", logs, 0); synchronized (this) { - return JSON.toJSONString(monthlySettleService.check(maps)); + return JSON.toJSONString(monthlySettleService.check(maps, date)); } } catch (OfficeXmlFileException | EncryptedDocumentException | InvalidFormatException e) { return JSON.toJSONString(ResponseMsg.buildFailedMsg("格式错误,请上传excel 2003/2007格式文件")); diff --git a/src/main/java/cn/palmte/work/controller/backend/ProjectController.java b/src/main/java/cn/palmte/work/controller/backend/ProjectController.java index 4293378..7b69a1d 100644 --- a/src/main/java/cn/palmte/work/controller/backend/ProjectController.java +++ b/src/main/java/cn/palmte/work/controller/backend/ProjectController.java @@ -159,16 +159,16 @@ public class ProjectController extends BaseController { //收入明细 List budgetIncomeDetail = projectBudgetService.getBudgetIncomeDetail(project); Integer incomeTotalAmount = projectBudgetService.getBudgetIncomeAmount(project); - String[] headers2 = {"序号", "类别", "名称", "单位", "数量", "单价", "税率(%)", "含税总金额(元)", "不含税金额(元)"}; - String[] columns2 = {"tempId", "type", "name", "unit", "amount", "price", "taxRate", "totalTaxInclude", "totalTaxExclude"}; + String[] headers2 = {"序号", "类别", "名称", "单位", "数量", "单价", "税率(%)", "含税总金额(元)", "不含税金额(元)", "税金(元)"}; + String[] columns2 = {"tempId", "type", "name", "unit", "amount", "price", "taxRate", "totalTaxInclude", "totalTaxExclude", "totalTax"}; exportExcelUtils.exportIncomeDetailExcel(headers2, columns2, project, budgetBean, budgetIncomeDetail, incomeTotalAmount, "yyyy-MM-dd", 0, "收入明细表", outputStream); //成本明细 List budgetCostDetail = projectBudgetService.getBudgetCostDetail(project); Integer costTotalAmount = projectBudgetService.getBudgetCostAmount(project); List procurementTypes = procurementTypeService.allProcurementTypeList(); Map procurementMap = procurementTypes.stream().collect(Collectors.toMap(ProcurementType::getId, ProcurementType::getName)); - String[] headers3 = {"序号", "大类", "类别", "名称", "单位", "数量", "单价", "税率(%)", "含税总金额(元)", "不含税金额(元)"}; - String[] columns3 = {"tempId", "type", "category", "name", "unit", "amount", "price", "taxRate", "totalTaxInclude", "totalTaxExclude"}; + String[] headers3 = {"序号", "大类", "类别", "名称", "单位", "数量", "单价", "税率(%)", "含税总金额(元)", "不含税金额(元)", "税金(元)"}; + String[] columns3 = {"tempId", "type", "category", "name", "unit", "amount", "price", "taxRate", "totalTaxInclude", "totalTaxExclude", "totalTax"}; exportExcelUtils.exportCostDetailExcel(headers3, columns3, project, budgetBean, budgetCostDetail, costTotalAmount, procurementMap, "yyyy-MM-dd", 0, "采购成本明细表", outputStream); //项目管理成本明细 List budgetCostProjectManageDetail = projectBudgetService.getBudgetCostProjectManageDetail(project); @@ -296,7 +296,7 @@ public class ProjectController extends BaseController { rates.add(projectBudgetIncomeDetail.getTaxRate().toPlainString()); } } - if (incomeTaxSb.lastIndexOf(",") == incomeTaxSb.length() - 1) { + if (incomeTaxSb.lastIndexOf(",") > 0 && incomeTaxSb.lastIndexOf(",") == incomeTaxSb.length() - 1) { model.put("incomeTaxRates", incomeTaxSb.substring(0, incomeTaxSb.length() - 2)); } else { model.put("incomeTaxRates", incomeTaxSb.toString()); @@ -313,7 +313,7 @@ public class ProjectController extends BaseController { rates2.add(projectBudgetCostDetail.getTaxRate().toPlainString()); } } - if (costTaxSb.lastIndexOf(",") == costTaxSb.length() - 1) { + if (costTaxSb.lastIndexOf(",") > 0 && costTaxSb.lastIndexOf(",") == costTaxSb.length() - 1) { model.put("costTaxRates", costTaxSb.substring(0, costTaxSb.length() - 2)); } else { model.put("costTaxRates", costTaxSb.toString()); diff --git a/src/main/java/cn/palmte/work/model/MonthlySettle.java b/src/main/java/cn/palmte/work/model/MonthlySettle.java index 73aa1db..0ef3ad1 100644 --- a/src/main/java/cn/palmte/work/model/MonthlySettle.java +++ b/src/main/java/cn/palmte/work/model/MonthlySettle.java @@ -3,6 +3,7 @@ package cn.palmte.work.model; import org.hibernate.annotations.GenericGenerator; import javax.persistence.*; +import java.math.BigDecimal; import java.util.Date; /** @@ -17,6 +18,11 @@ public class MonthlySettle { @GeneratedValue(strategy = GenerationType.IDENTITY) @GenericGenerator(name = "persistenceGenerator", strategy = "increment") private int id; + /** + * 月份 + */ + @Column(name = "month") + private String month; /** * 项目编号 */ @@ -40,32 +46,32 @@ public class MonthlySettle { * 合同金额 */ @Column(name = "contract_amount") - private String contractAmount; + private BigDecimal contractAmount; /** * 累计已收款 */ @Column(name = "total_collect") - private String totalCollect; + private BigDecimal totalCollect; /** * 已采购累计付款 */ @Column(name = "total_purchased_paid") - private String totalPurchasedPaid; + private BigDecimal totalPurchasedPaid; /** * 已采购累计未付款 */ @Column(name = "total_purchased_unpaid") - private String totalPurchasedUnpaid; + private BigDecimal totalPurchasedUnpaid; /** * 超期垫资金额 */ @Column(name = "time_out_amount") - private String timeOutAmount; + private BigDecimal timeOutAmount; /** * 销售累计开票金额 */ @Column(name = "total_bill_amount") - private String totalBillAmount; + private BigDecimal totalBillAmount; /** * 合同编号 */ @@ -107,7 +113,7 @@ public class MonthlySettle { * 收款金额 */ @Column(name = "collect_amount") - private String collectAmount; + private BigDecimal collectAmount; /** * 实际收款时间 */ @@ -118,12 +124,12 @@ public class MonthlySettle { * 实际收款金额 */ @Column(name = "collect_actual_amount") - private String collectActualAmount; + private BigDecimal collectActualAmount; /** * 实际欠收金额 */ @Column(name = "uncollect_actual_amount") - private String uncollectActualAmount; + private BigDecimal uncollectActualAmount; /** * 超期天数 */ @@ -149,12 +155,12 @@ public class MonthlySettle { * 已计收金额 */ @Column(name = "cal_col_amount") - private String calColAmount; + private BigDecimal calColAmount; /** * 未计收金额 */ @Column(name = "uncal_col_amount") - private String uncalColAmount; + private BigDecimal uncalColAmount; public int getId() { return id; @@ -164,6 +170,14 @@ public class MonthlySettle { this.id = id; } + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } + public String getProjectNo() { return projectNo; } @@ -196,51 +210,51 @@ public class MonthlySettle { this.projectName = projectName; } - public String getContractAmount() { + public BigDecimal getContractAmount() { return contractAmount; } - public void setContractAmount(String contractAmount) { + public void setContractAmount(BigDecimal contractAmount) { this.contractAmount = contractAmount; } - public String getTotalCollect() { + public BigDecimal getTotalCollect() { return totalCollect; } - public void setTotalCollect(String totalCollect) { + public void setTotalCollect(BigDecimal totalCollect) { this.totalCollect = totalCollect; } - public String getTotalPurchasedPaid() { + public BigDecimal getTotalPurchasedPaid() { return totalPurchasedPaid; } - public void setTotalPurchasedPaid(String totalPurchasedPaid) { + public void setTotalPurchasedPaid(BigDecimal totalPurchasedPaid) { this.totalPurchasedPaid = totalPurchasedPaid; } - public String getTotalPurchasedUnpaid() { + public BigDecimal getTotalPurchasedUnpaid() { return totalPurchasedUnpaid; } - public void setTotalPurchasedUnpaid(String totalPurchasedUnpaid) { + public void setTotalPurchasedUnpaid(BigDecimal totalPurchasedUnpaid) { this.totalPurchasedUnpaid = totalPurchasedUnpaid; } - public String getTimeOutAmount() { + public BigDecimal getTimeOutAmount() { return timeOutAmount; } - public void setTimeOutAmount(String timeOutAmount) { + public void setTimeOutAmount(BigDecimal timeOutAmount) { this.timeOutAmount = timeOutAmount; } - public String getTotalBillAmount() { + public BigDecimal getTotalBillAmount() { return totalBillAmount; } - public void setTotalBillAmount(String totalBillAmount) { + public void setTotalBillAmount(BigDecimal totalBillAmount) { this.totalBillAmount = totalBillAmount; } @@ -300,11 +314,11 @@ public class MonthlySettle { this.collectRequiredTime = collectRequiredTime; } - public String getCollectAmount() { + public BigDecimal getCollectAmount() { return collectAmount; } - public void setCollectAmount(String collectAmount) { + public void setCollectAmount(BigDecimal collectAmount) { this.collectAmount = collectAmount; } @@ -316,19 +330,19 @@ public class MonthlySettle { this.collectActualTime = collectActualTime; } - public String getCollectActualAmount() { + public BigDecimal getCollectActualAmount() { return collectActualAmount; } - public void setCollectActualAmount(String collectActualAmount) { + public void setCollectActualAmount(BigDecimal collectActualAmount) { this.collectActualAmount = collectActualAmount; } - public String getUncollectActualAmount() { + public BigDecimal getUncollectActualAmount() { return uncollectActualAmount; } - public void setUncollectActualAmount(String uncollectActualAmount) { + public void setUncollectActualAmount(BigDecimal uncollectActualAmount) { this.uncollectActualAmount = uncollectActualAmount; } @@ -364,19 +378,19 @@ public class MonthlySettle { this.riskWarning = riskWarning; } - public String getCalColAmount() { + public BigDecimal getCalColAmount() { return calColAmount; } - public void setCalColAmount(String calColAmount) { + public void setCalColAmount(BigDecimal calColAmount) { this.calColAmount = calColAmount; } - public String getUncalColAmount() { + public BigDecimal getUncalColAmount() { return uncalColAmount; } - public void setUncalColAmount(String uncalColAmount) { + public void setUncalColAmount(BigDecimal uncalColAmount) { this.uncalColAmount = uncalColAmount; } } diff --git a/src/main/java/cn/palmte/work/model/MonthlySettleRepository.java b/src/main/java/cn/palmte/work/model/MonthlySettleRepository.java index 875f9d9..a7e2991 100644 --- a/src/main/java/cn/palmte/work/model/MonthlySettleRepository.java +++ b/src/main/java/cn/palmte/work/model/MonthlySettleRepository.java @@ -9,6 +9,9 @@ import org.springframework.data.jpa.repository.Query; */ public interface MonthlySettleRepository extends JpaRepository { + @Query(value = "select * from monthly_settle where month = ?1 and project_name = ?2 limit 1", nativeQuery = true) + MonthlySettle findByMonthAndProjectName(String time, String projectName); + // @Query(value = "select * from monthly_settle where id = ?1 order by month desc limit 1", nativeQuery = true) // MonthlySettle findLatest(int id); } diff --git a/src/main/java/cn/palmte/work/service/MonthlySettleService.java b/src/main/java/cn/palmte/work/service/MonthlySettleService.java index e82f50a..91a3599 100644 --- a/src/main/java/cn/palmte/work/service/MonthlySettleService.java +++ b/src/main/java/cn/palmte/work/service/MonthlySettleService.java @@ -1,15 +1,24 @@ package cn.palmte.work.service; +import cn.palmte.work.bean.ResponseMsg; +import cn.palmte.work.bean.StatusEnum; import cn.palmte.work.controller.backend.MonthlySettleController; -import cn.palmte.work.model.MonthlySettle; +import cn.palmte.work.model.*; +import cn.palmte.work.utils.DateKit; +import cn.palmte.work.utils.InterfaceUtil; +import cn.palmte.work.utils.StrKit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import top.jfunc.common.db.QueryHelper; import top.jfunc.common.db.bean.Page; +import top.jfunc.common.db.utils.Pagination; +import top.jfunc.common.utils.StrUtil; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.math.BigDecimal; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; /** @@ -20,15 +29,331 @@ import java.util.concurrent.ConcurrentHashMap; public class MonthlySettleService { private static final Logger logger = LoggerFactory.getLogger(MonthlySettleController.class); + @Autowired + private MonthlySettleRepository monthlySettleRepository; + + @Autowired + private MonthlySettleRepositoryCustom monthlySettleRepositoryCustom; + + @Autowired + private Pagination pagination; + public Page list(Map searchInfo, int pageNumber, int pageSize) { - return null; + QueryHelper queryHelper = getQueryHelper(searchInfo); + return pagination.paginate(queryHelper.getSql(), MonthlySettle.class,pageNumber,pageSize); } - public String check(Collection maps) { - return null; + @Transactional(rollbackFor = Exception.class) + public ResponseMsg check(Collection excelMap, String date) { + int successCount = 0; + int errorCount = 0; + List errorList = new ArrayList<>(); + List monthlySettleList = new ArrayList<>(); + Set projectNameSet = new HashSet<>(); + for (Map m : excelMap) { + try { + final Object o1 = m.get("项目编号"); + if (o1 == null || StrKit.isBlank(o1.toString())) { + throw new Exception("项目编号不能为空"); + } + + final Object o2 = m.get("最终业主"); + if (o2 == null || StrKit.isBlank(o2.toString())) { + throw new Exception("最终业主不能为空"); + } + + final Object o3 = m.get("合同方"); + if (o3 == null || StrKit.isBlank(o3.toString())) { + throw new Exception("合同方不能为空"); + } + + final Object o4 = m.get("项目名称"); + if (o4 == null || StrKit.isBlank(o4.toString())) { + throw new Exception("项目名称不能为空"); + } + String projectName = o4.toString(); + MonthlySettle old = monthlySettleRepository.findByMonthAndProjectName(date, projectName); + if (old != null) { + throw new Exception(o4 + " " + date + "已存在"); + } + if (projectNameSet.contains(projectName)) { + throw new Exception(o4 + " " + date + "重复"); + } + + final Object o5 = m.get("合同金额"); + if (o5 == null || StrKit.isBlank(o5.toString())) { + throw new Exception("合同金额不能为空"); + } + + final Object o6 = m.get("累计已收款"); + if (o6 == null || StrKit.isBlank(o6.toString())) { + throw new Exception("累计已收款不能为空"); + } + + final Object o7 = m.get("已采购累计付款"); + if (o7 == null || StrKit.isBlank(o7.toString())) { + throw new Exception("已采购累计付款不能为空"); + } + + final Object o8 = m.get("已采购累计未付款"); + if (o8 == null || StrKit.isBlank(o8.toString())) { + throw new Exception("已采购累计未付款不能为空"); + } + + final Object o9 = m.get("超期垫资金额"); + if (o9 == null || StrKit.isBlank(o9.toString())) { + throw new Exception("超期垫资金额不能为空"); + } + + final Object o10 = m.get("销售累计开票金额"); + if (o10 == null || StrKit.isBlank(o10.toString())) { + throw new Exception("销售累计开票金额不能为空"); + } + + final Object o11 = m.get("合同编号"); + if (o11 == null || StrKit.isBlank(o11.toString())) { + throw new Exception("合同编号不能为空"); + } + + final Object o12 = m.get("项目类型"); + if (o12 == null || StrKit.isBlank(o12.toString())) { + throw new Exception("项目类型不能为空"); + } + + final Object o13 = m.get("合同签订时间"); + if (o13 == null || StrKit.isBlank(o13.toString())) { + throw new Exception("合同签订时间不能为空"); + } + if (!o13.toString().matches("\\d{4}-\\d{2}-\\d{2}")) { + throw new Exception(o4 + " " + date + "的合同签订时间不符合规范(yyyy-MM-dd)"); + } + + final Object o14 = m.get("销售经理"); + if (o14 == null || StrKit.isBlank(o14.toString())) { + throw new Exception("销售经理不能为空"); + } + + final Object o15 = m.get("项目经理"); + if (o15 == null || StrKit.isBlank(o15.toString())) { + throw new Exception("项目经理不能为空"); + } + + final Object o16 = m.get("收款节点"); + if (o16 == null || StrKit.isBlank(o16.toString())) { + throw new Exception("收款节点不能为空"); + } + + final Object o17 = m.get("收款要求时间"); + if (o17 == null || StrKit.isBlank(o17.toString())) { + throw new Exception("收款要求时间不能为空"); + } + if (!o17.toString().matches("\\d{4}-\\d{2}-\\d{2}")) { + throw new Exception(o4 + " " + date + "的收款要求时间不符合规范(yyyy-MM-dd)"); + } + + final Object o18 = m.get("收款金额"); + if (o18 == null || StrKit.isBlank(o18.toString())) { + throw new Exception("收款金额不能为空"); + } + + final Object o19 = m.get("实际收款时间"); + if (o19 == null || StrKit.isBlank(o19.toString())) { + throw new Exception("实际收款时间不能为空"); + } + if (!o19.toString().matches("\\d{4}-\\d{2}-\\d{2}")) { + throw new Exception(o4 + " " + date + "的实际收款时间不符合规范(yyyy-MM-dd)"); + } + + final Object o20 = m.get("实际收款金额"); + if (o20 == null || StrKit.isBlank(o20.toString())) { + throw new Exception("实际收款金额不能为空"); + } + + final Object o21 = m.get("实际欠收金额"); + if (o21 == null || StrKit.isBlank(o21.toString())) { + throw new Exception("实际欠收金额不能为空"); + } + + final Object o22 = m.get("超期天数"); + if (o22 == null || StrKit.isBlank(o22.toString())) { + throw new Exception("超期天数不能为空"); + } + + final Object o23 = m.get("到货证明"); + if (o23 == null || StrKit.isBlank(o23.toString())) { + throw new Exception("到货证明不能为空"); + } + + final Object o24 = m.get("验收报告时间"); + if (o24 == null || StrKit.isBlank(o24.toString())) { + throw new Exception("验收报告时间不能为空"); + } + if (!o24.toString().matches("\\d{4}-\\d{2}-\\d{2}")) { + throw new Exception(o4 + " " + date + "的验收报告时间不符合规范(yyyy-MM-dd)"); + } + + final Object o25 = m.get("项目风险预警"); + if (o25 == null || StrKit.isBlank(o25.toString())) { + throw new Exception("项目风险预警不能为空"); + } + + final Object o26 = m.get("已计收金额"); + if (o26 == null || StrKit.isBlank(o26.toString())) { + throw new Exception("已计收金额不能为空"); + } + + final Object o27 = m.get("未计收金额"); + if (o27 == null || StrKit.isBlank(o27.toString())) { + throw new Exception("未计收金额不能为空"); + } + + successCount++; + projectNameSet.add(projectName); + saveMonthlySettle(m, date, projectName, monthlySettleList); + } catch (Exception e) { + logger.error("", e); + errorCount++; + if (!e.getMessage().isEmpty()) { + errorList.add(e.getMessage()); + } + } + } + monthlySettleRepository.save(monthlySettleList); + final ResponseMsg msg = ResponseMsg.buildSuccessMsg(String.format("成功:%d, 失败:%d", successCount, errorCount)); + msg.setData(errorList); + return msg; + } + + private void saveMonthlySettle(Map m, String date, String projectName, List monthlySettleList) { + MonthlySettle settle = new MonthlySettle(); + String key; + Object o1; + settle.setMonth(date); + key = "项目编号"; + o1 = m.get(key); + settle.setProjectNo((String) o1); + key = "最终业主"; + o1 = m.get(key); + settle.setOwner((String) o1); + key = "合同方"; + o1 = m.get(key); + settle.setContractParty((String) o1); + key = "项目名称"; + o1 = m.get(key); + settle.setProjectName((String) o1); + key = "合同金额"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setContractAmount(new BigDecimal((String) o1)); + key = "累计已收款"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setTotalCollect(new BigDecimal((String) o1)); + key = "已采购累计付款"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setTotalPurchasedPaid(new BigDecimal((String) o1)); + key = "已采购累计未付款"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setTotalPurchasedUnpaid(new BigDecimal((String) o1)); + key = "超期垫资金额"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setTimeOutAmount(new BigDecimal((String) o1)); + key = "销售累计开票金额"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setTotalBillAmount(new BigDecimal((String) o1)); + key = "合同编号"; + o1 = m.get(key); + settle.setContractNo((String) o1); + key = "项目类型"; + o1 = m.get(key); + settle.setProjectType((String) o1); + key = "合同签订时间"; + o1 = m.get(key); + settle.setContractSignTime(DateKit.getDate((String) o1, DateKit.DATE_FORMAT)); + key = "销售经理"; + o1 = m.get(key); + settle.setSaleManager((String) o1); + key = "项目经理"; + o1 = m.get(key); + settle.setProjectManager((String) o1); + key = "收款节点"; + o1 = m.get(key); + settle.setCollectPoint((String) o1); + key = "收款要求时间"; + o1 = m.get(key); + settle.setCollectRequiredTime(DateKit.getDate((String) o1, DateKit.DATE_FORMAT)); + key = "收款金额"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setCollectAmount(new BigDecimal((String) o1)); + key = "实际收款时间"; + o1 = m.get(key); + settle.setCollectActualTime(DateKit.getDate((String) o1, DateKit.DATE_FORMAT)); + key = "实际收款金额"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setCollectActualAmount(new BigDecimal((String) o1)); + key = "实际欠收金额"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setUncollectActualAmount(new BigDecimal((String) o1)); + key = "超期天数"; + o1 = m.get(key); + settle.setTimeOutDay((String) o1); + key = "到货证明"; + o1 = m.get(key); + settle.setProductCertificate((String) o1); + key = "验收报告时间"; + o1 = m.get(key); + settle.setInspectionReportTime(DateKit.getDate((String) o1, DateKit.DATE_FORMAT)); + key = "项目风险预警"; + o1 = m.get(key); + settle.setRiskWarning((String) o1); + key = "已计收金额"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setCalColAmount(new BigDecimal((String) o1)); + key = "未计收金额"; + o1 = (m.get(key) == null || "".equals(m.get(key))) ? "0.00" : m.get(key); + settle.setUncalColAmount(new BigDecimal((String) o1)); + + monthlySettleList.add(settle); } public List findOne(String id, String time, String projectName) { - return null; + List list = new ArrayList<>(); + MonthlySettle monthlySettle = monthlySettleRepository.findByMonthAndProjectName(time, projectName); + list.add(monthlySettle); + return list; + } + + private QueryHelper getQueryHelper(Map searchInfo) { + QueryHelper queryHelper = new QueryHelper("SELECT *","(select project_name as name, max(ms.month) as time from monthly_settle ms group by ms.project_name)","ms"); + queryHelper.leftJoin("monthly_settle s", "ms.time = s.month and ms.name = s.project_name"); + + queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("projectNo")),"s.project_no LIKE ?", "%"+searchInfo.get("projectNo")+"%"); + queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("name")),"s.name LIKE ?", "%"+searchInfo.get("name")+"%"); + queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("owner")),"s.owner LIKE ?", "%"+searchInfo.get("owner")+"%"); + queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("contractParty")),"s.contract_party LIKE ?", "%"+searchInfo.get("contractParty")+"%"); + queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("contractNo")),"s.contract_no LIKE ?", "%"+searchInfo.get("contractNo")+"%"); + queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("projectType")),"s.project_type LIKE ?", "%"+searchInfo.get("projectType")+"%"); + queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("saleManager")),"s.sale_manager LIKE ?", "%"+searchInfo.get("saleManager")+"%"); + queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("projectManager")),"s.project_manager LIKE ?", "%"+searchInfo.get("projectManager")+"%"); + queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("timeOutDay")),"s.time_out_day LIKE ?", "%"+searchInfo.get("timeOutDay")+"%"); + + if(StrUtil.isNotEmpty(searchInfo.get("startTime"))){ + String time = searchInfo.get("startTime") + " 00:00:00"; + queryHelper.addCondition("s.start_time>=?", time); + } + if(StrUtil.isNotEmpty(searchInfo.get("endTime"))){ + String time = searchInfo.get("endTime") + " 00:00:00"; + queryHelper.addCondition("s.end_time<=?", time); + } + if(StrUtil.isNotEmpty(searchInfo.get("contractStartTime"))){ + String time = searchInfo.get("contractStartTime") + " 00:00:00"; + queryHelper.addCondition("s.contract_time>=?", time); + } + if(StrUtil.isNotEmpty(searchInfo.get("contractEndTime"))){ + String time = searchInfo.get("contractEndTime") + " 00:00:00"; + queryHelper.addCondition("s.contract_time<=?", time); + } + + queryHelper.addDescOrderProperty("s.id"); + + return queryHelper; } } diff --git a/src/main/resources/static/assets/js/project_budget_cost.js b/src/main/resources/static/assets/js/project_budget_cost.js index 4b8fb5a..122bba6 100644 --- a/src/main/resources/static/assets/js/project_budget_cost.js +++ b/src/main/resources/static/assets/js/project_budget_cost.js @@ -195,6 +195,7 @@ function appendTrCost() { ''+ ''+ ''+ + ''+ ''+ ''; @@ -261,6 +262,7 @@ function updateCostData(data, returnData) { var serviceTaxExclude = 0; var otherTaxInclude = 0; var otherTaxExclude = 0; + var costTaxRates = ""; details.forEach(function (t, number, ts) { if(t["type"] == "1"){ //设备类 @@ -279,6 +281,7 @@ function updateCostData(data, returnData) { otherTaxInclude += f2(t["totalTaxInclude"]); otherTaxExclude += f2(t["totalTaxExclude"]); } + costTaxRates += t["taxRate"] + "%,"; }); $("input[name='costPurchaseDeviceTaxInclude']").val(f2Fixed(deviceTaxInclude)); $("input[name='costPurchaseDeviceTaxExclude']").val(f2Fixed(deviceTaxExclude)); @@ -310,6 +313,9 @@ function updateCostData(data, returnData) { calCostInclude(); calCostTotalTax(); updateProjectContributionProfitRate(); + if (costTaxRates.length > 0) { + $(".costTaxRates").text(costTaxRates.substr(0, costTaxRates.length - 1)); + } layuiAlert("保存成功"); $('#my-prompt-cost-detail').modal('close'); diff --git a/src/main/resources/static/assets/js/project_budget_income.js b/src/main/resources/static/assets/js/project_budget_income.js index f714a9b..30b0f6e 100644 --- a/src/main/resources/static/assets/js/project_budget_income.js +++ b/src/main/resources/static/assets/js/project_budget_income.js @@ -83,6 +83,7 @@ function updateIncomeData(data,returnData) { var engineerTaxExclude = 0; var serviceTaxInclude = 0; var serviceTaxExclude = 0; + var incomeTaxRates = ""; incomeDetails.forEach(function (t, number, ts) { if(t["type"] == "1"){ //设备类 @@ -97,7 +98,9 @@ function updateIncomeData(data,returnData) { serviceTaxInclude += f2(t["totalTaxInclude"]); serviceTaxExclude += f2(t["totalTaxExclude"]); } + incomeTaxRates += t["taxRate"] + "%,"; }); + console.log("incomeTaxRates: " + incomeTaxRates); $("input[name='incomeDeviceTaxInclude']").val(f2Fixed(deviceTaxInclude)); $("input[name='incomeDeviceTaxExclude']").val(f2Fixed(deviceTaxExclude)); $("input[name='incomeEngineerTaxInclude']").val(f2Fixed(engineerTaxInclude)); @@ -115,6 +118,9 @@ function updateIncomeData(data,returnData) { updateProjectContributionProfitRate(); + if (incomeTaxRates.length > 0) { + $(".incomeTaxRates").text(incomeTaxRates.substr(0, incomeTaxRates.length - 1)); + } layuiAlert("保存成功"); $('#my-prompt-income-detail').modal('close'); @@ -143,7 +149,7 @@ function appendTrIncome() { ' \n' + ' \n' + ' \n' + - ' \n' + + ' \n' + ' \n' + ' '; $("#incomeTotal").before(template); @@ -179,14 +185,17 @@ function bindIncomeTotal() { updateAmount("input-changeable-amount-income", "input-changeable-total-amount-income"); updateTotal("input-changeable-total-tax-include-income", "input-changeable-total-total-tax-include-income"); updateTotal("input-changeable-total-tax-exclude-income", "input-changeable-total-total-tax-exclude-income"); + updateTotal("input-changeable-total-tax-income", "input-changeable-total-total-tax-income"); }); //单价改变 $(".input-changeable-price-income").change(function () { updateTotal("input-changeable-total-tax-include-income", "input-changeable-total-total-tax-include-income"); updateTotal("input-changeable-total-tax-exclude-income", "input-changeable-total-total-tax-exclude-income"); + updateTotal("input-changeable-total-tax-income", "input-changeable-total-total-tax-income"); }); //税率改变 $(".input-changeable-tax-rate-income").change(function () { updateTotal("input-changeable-total-tax-exclude-income", "input-changeable-total-total-tax-exclude-income"); + updateTotal("input-changeable-total-tax-income", "input-changeable-total-total-tax-income"); }); } \ No newline at end of file diff --git a/src/main/resources/templates/admin/monthly_settle_info.ftl b/src/main/resources/templates/admin/monthly_settle_info.ftl index 0440af4..1913f74 100644 --- a/src/main/resources/templates/admin/monthly_settle_info.ftl +++ b/src/main/resources/templates/admin/monthly_settle_info.ftl @@ -265,6 +265,26 @@