结算可选时间跨度
parent
999c3bbc52
commit
2f02bb9ef3
|
@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.format.datetime.DateFormatter;
|
||||
import org.springframework.format.number.NumberStyleFormatter;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -54,6 +55,9 @@ public class ProjectSettleController extends BaseController{
|
|||
@Autowired
|
||||
private ProjectUserTimeRepository projectUserTimeRepository;
|
||||
|
||||
@Autowired
|
||||
private ProjectSettleMonthRangeRepository projectSettleMonthRangeRepository;
|
||||
|
||||
@RequestMapping("/add")
|
||||
public String add(@RequestParam("id") int id, Map<String, Object> model) {
|
||||
String time = null;
|
||||
|
@ -68,12 +72,14 @@ public class ProjectSettleController extends BaseController{
|
|||
instance.set(Calendar.MONTH, instance.get(Calendar.MONTH) + 1);
|
||||
Date current = instance.getTime();
|
||||
time = DateKit.toStr(current, DateKit.DATE_FORMAT_YEAR_MONTH2);
|
||||
model.put("time", time);
|
||||
model.put("startMonth", time);
|
||||
model.put("endMonth", time);
|
||||
model.put("formerBean", projectSettleService.getFormerSettle(project, time));
|
||||
} else {
|
||||
time = DateKit.toStr(project.getStartDate(), DateKit.DATE_FORMAT_YEAR_MONTH2);
|
||||
|
||||
model.put("time", time);
|
||||
model.put("startMonth", time);
|
||||
model.put("endMonth", time);
|
||||
model.put("formerBean", new FormerBean());
|
||||
}
|
||||
|
||||
|
@ -100,7 +106,13 @@ public class ProjectSettleController extends BaseController{
|
|||
ProjectSettleIncome projectSettleIncome = projectSettleIncomeRepository.findNewByProjectId(id);
|
||||
List<ProjectBudgetPlanDetail> projectBudgetPlanDetails = projectBudgetService.getProjectBudgetPlanDetails(project);
|
||||
String time = projectSettleIncome.getTime();
|
||||
model.put("time", time);
|
||||
ProjectSettleMonthRange projectSettleMonthRange = projectSettleMonthRangeRepository.findAllByProjectIdAndEndDate(id, time);
|
||||
if (projectSettleMonthRange != null) {
|
||||
model.put("startMonth", projectSettleMonthRange.getStartDate());
|
||||
} else {
|
||||
model.put("startMonth", time);
|
||||
}
|
||||
model.put("endMonth", time);
|
||||
model.put("project", project);
|
||||
model.put("estimateBean", projectEstimateService.getEstimate(project));
|
||||
model.put("budgetBean", projectBudgetService.getBudget(project));
|
||||
|
@ -122,8 +134,15 @@ public class ProjectSettleController extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping("/save")
|
||||
public String save(Project project, SettleBean settleBean, BudgetSettleBean budgetBean, EstimateSettleBean estimateBean, String time) {
|
||||
projectSettleService.save(project, settleBean, budgetBean, estimateBean, time);
|
||||
public String save(Project project, BindingResult bindingResult, SettleBean settleBean, BudgetSettleBean budgetBean, EstimateSettleBean estimateBean, String startMonth, String endMonth) {
|
||||
if (!startMonth.equals(endMonth) && projectSettleMonthRangeRepository.findAllByProjectIdAndEndDate(project.getId(), endMonth) == null) {
|
||||
ProjectSettleMonthRange range = new ProjectSettleMonthRange();
|
||||
range.setProjectId(project.getId());
|
||||
range.setStartDate(startMonth);
|
||||
range.setEndDate(endMonth);
|
||||
projectSettleMonthRangeRepository.save(range);
|
||||
}
|
||||
projectSettleService.save(project, settleBean, budgetBean, estimateBean, endMonth);
|
||||
return "redirect:/project/list";
|
||||
}
|
||||
|
||||
|
@ -133,13 +152,20 @@ public class ProjectSettleController extends BaseController{
|
|||
* @param settleBean
|
||||
* @param budgetBean
|
||||
* @param estimateBean
|
||||
* @param time
|
||||
* @param endMonth
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/saveAndApprove")
|
||||
public String saveAndApprove(Project project, SettleBean settleBean, BudgetSettleBean budgetBean, EstimateSettleBean estimateBean, String time) throws Exception{
|
||||
projectSettleService.saveAndApprove(project, settleBean, budgetBean, estimateBean, time);
|
||||
public String saveAndApprove(Project project, SettleBean settleBean, BudgetSettleBean budgetBean, EstimateSettleBean estimateBean, String startMonth, String endMonth) throws Exception{
|
||||
if (!startMonth.equals(endMonth) && projectSettleMonthRangeRepository.findAllByProjectIdAndEndDate(project.getId(), endMonth) == null) {
|
||||
ProjectSettleMonthRange range = new ProjectSettleMonthRange();
|
||||
range.setProjectId(project.getId());
|
||||
range.setStartDate(startMonth);
|
||||
range.setEndDate(endMonth);
|
||||
projectSettleMonthRangeRepository.save(range);
|
||||
}
|
||||
projectSettleService.saveAndApprove(project, settleBean, budgetBean, estimateBean, endMonth);
|
||||
return "redirect:/project/list";
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package cn.palmte.work.model;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "project_settle_month_range")
|
||||
public class ProjectSettleMonthRange {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@GenericGenerator(name = "persistenceGenerator", strategy = "increment")
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "project_id")
|
||||
private int projectId;
|
||||
|
||||
@Column(name = "start_date")
|
||||
private String startDate;
|
||||
|
||||
@Column(name = "end_date")
|
||||
private String endDate;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
|
||||
public void setProjectId(int projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public String getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(String endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package cn.palmte.work.model;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Yuanping Zhang
|
||||
* @date 2022/12/22
|
||||
*/
|
||||
public interface ProjectSettleMonthRangeRepository extends JpaRepository<ProjectSettleMonthRange, Integer> {
|
||||
|
||||
@Query(value = "select * from project_settle_month_range where project_id = ?1 and end_date = ?2 limit 1", nativeQuery = true)
|
||||
ProjectSettleMonthRange findAllByProjectIdAndEndDate(int id, String endDate);
|
||||
}
|
|
@ -39,7 +39,11 @@
|
|||
<div class="am-u-sm-10">
|
||||
<div class="am-form am-form-inline">
|
||||
<div class="am-form-group am-form-icon">
|
||||
<input type="text" id="time" name="time" autocomplete="off" readonly value="${time!}">
|
||||
<input type="text" id="startMonth" name="startMonth" autocomplete="off" readonly value="${startMonth!}">
|
||||
</div>
|
||||
<div class="am-form-group">至</div>
|
||||
<div class="am-form-group am-form-icon">
|
||||
<input type="text" id="endMonth" name="endMonth" autocomplete="off" style="background-color: #FFFFFF;" readonly value="${endMonth!}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -409,19 +413,19 @@
|
|||
<script src="${base}/assets/js/project_settle.js"></script>
|
||||
<script src="${base}/assets/js/project_settle_valid.js"></script>
|
||||
<script>
|
||||
// layui.use('laydate', function(){
|
||||
// var laydate = layui.laydate;
|
||||
//
|
||||
// laydate.render({
|
||||
// elem: '#time',
|
||||
// type: 'month',
|
||||
// btns: ['confirm'],
|
||||
// trigger: 'click',
|
||||
// ready: function(date){
|
||||
// console.log(date);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
layui.use('laydate', function(){
|
||||
var laydate = layui.laydate;
|
||||
|
||||
laydate.render({
|
||||
elem: '#endMonth',
|
||||
type: 'month',
|
||||
btns: ['confirm'],
|
||||
trigger: 'click',
|
||||
ready: function(date){
|
||||
console.log(date);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
calculateSettle();
|
||||
|
|
|
@ -38,7 +38,11 @@
|
|||
<div class="am-u-sm-10">
|
||||
<div class="am-form am-form-inline">
|
||||
<div class="am-form-group am-form-icon">
|
||||
<input type="text" id="time" name="time" autocomplete="off" readonly value="${time!}">
|
||||
<input type="text" id="startMonth" name="startMonth" autocomplete="off" readonly value="${startMonth!}">
|
||||
</div>
|
||||
<div class="am-form-group">至</div>
|
||||
<div class="am-form-group am-form-icon">
|
||||
<input type="text" id="endMonth" name="endMonth" autocomplete="off" readonly value="${endMonth!}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue