Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #13

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package jp.co.nok.business.db.select;

import java.time.LocalDate;
import java.util.List;

import jp.co.nok.db.entity.BusinessCalendarMt;

/**
* 営業日マスタ検索サービスインターフェース
*
* @version 1.0.0
*/
public interface BusinessCalendarMtSerachService {

List<BusinessCalendarMt> selectByMonth(LocalDate date);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package jp.co.nok.business.db.select;

import java.time.LocalDate;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import jp.co.nok.common.util.DateUtil;
import jp.co.nok.common.util.DateUtil.DateFormatType;
import jp.co.nok.db.dao.BusinessCalendarMtDao;
import jp.co.nok.db.entity.BusinessCalendarMt;

/**
* 営業日マスタ検索サービス実装クラス
*
* @version 1.0.0
*/
@Service
public class BusinessCalendarMtSerachServiceImpl
implements BusinessCalendarMtSerachService {

@Autowired
private BusinessCalendarMtDao dao;

@Override
public List<BusinessCalendarMt> selectByMonth(LocalDate date) {
return dao
.selectByMonth(DateUtil.toString(date, DateFormatType.YYYYMM_NOSEP));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package jp.co.nok.business.db.select;

import java.time.LocalDate;
import java.util.List;

import jp.co.nok.db.entity.DailyWorkEntryData;

/**
* 日別勤怠登録情報検索サービスインターフェース
*
* @version 1.0.0
*/
public interface DailyWorkEntryDataSearchService {

List<DailyWorkEntryData> getMonthList(Integer seqWorkUserMtId, LocalDate targetDate);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package jp.co.nok.business.db.select;

import java.time.LocalDate;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import jp.co.nok.db.dao.DailyWorkEntryDataDao;
import jp.co.nok.db.entity.BusinessCalendarMt;
import jp.co.nok.db.entity.DailyWorkEntryData;

/**
* 日別勤怠登録情報検索サービス実装クラス
*
* @version 1.0.0
*/
@Service
public class DailyWorkEntryDataSearchServiceImpl
implements DailyWorkEntryDataSearchService {

@Autowired
private DailyWorkEntryDataDao dao;
@Autowired
private BusinessCalendarMtSerachService businessCalendarMtSerachService;

@Override
public List<DailyWorkEntryData> getMonthList(Integer seqWorkUserMtId,
LocalDate targetDate) {

// 処理対象年月より、営業日マスタリストを検索
List<BusinessCalendarMt> businessCalendarMtList = businessCalendarMtSerachService
.selectByMonth(targetDate);

LocalDate begin = businessCalendarMtList.get(0).getDate();
LocalDate end = businessCalendarMtList.get(businessCalendarMtList.size() - 1)
.getDate();

// TODO SQLを改良する
// DATE_FORMAT(BEGIN, '%Y%m') = /* begin */200810
List<DailyWorkEntryData> dailyWorkEntryDataList = dao
.selectBySeqWorkUserMtIdAndBetweenBegin(seqWorkUserMtId, begin, end);

// TODO
// dailyWorkEntryDataListとbusinessCalendarMtListをマージする
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package jp.co.nok.business.work.dto;

import java.math.BigDecimal;

/**
* カレンダーのbeanクラス
*
* @version 1.0.0
*/
public class BusinessCalendarDto {

/** 日にち */
private BigDecimal day;
/** 曜日 */
private String weekDay;
/** 営業日フラグ */
private String businessFlg;

public BigDecimal getDay() {
return day;
}

public void setDay(BigDecimal day) {
this.day = day;
}

public String getWeekDay() {
return weekDay;
}

public void setWeekDay(String weekDay) {
this.weekDay = weekDay;
}

public String getBusinessFlg() {
return businessFlg;
}

public void setBusinessFlg(String businessFlg) {
this.businessFlg = businessFlg;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jp.co.nok.business.work;
package jp.co.nok.business.work.dto;

/**
* ユーザ定時情報機能Dto
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package jp.co.nok.business.work.service;

import java.time.LocalDate;
import java.util.List;

import jp.co.nok.business.work.dto.BusinessCalendarDto;

/**
* 当月勤怠登録画面サービスインタフェース
*
* @version 1.0.0
*/
public interface MonthlyWorkEntryService {

LocalDate getTargetDate(String year, String month);

List<BusinessCalendarDto> getBusinessCalendarDtoList(LocalDate targetDate);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package jp.co.nok.business.work.service;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;

import jp.co.nok.business.work.dto.BusinessCalendarDto;
import jp.co.nok.common.util.DateUtil;
import jp.co.nok.common.util.DateUtil.DateFormatType;
import jp.co.nok.common.util.StringUtil;

/**
* 当月勤怠登録画面サービス実装クラス
*
* @version 1.0.0
*/
@Service
public class MonthlyWorkEntryServiceImpl implements MonthlyWorkEntryService {

@Override
public LocalDate getTargetDate(String year, String month) {

String targetYear = StringUtil.isEmpty(year)
? DateUtil.toString(DateUtil.getSysDate(), DateFormatType.YYYY)
: year;

String targetMonth = StringUtil.isEmpty(month)
? DateUtil.toString(DateUtil.getSysDate(), DateFormatType.MM)
: month;

return LocalDate.of(Integer.parseInt(targetYear),
Integer.parseInt(targetMonth), 1);
}

@Override
public List<BusinessCalendarDto> getBusinessCalendarDtoList(LocalDate targetDate) {

// 月初から月末まで取得
List<LocalDate> dateList = DateUtil.getLocalDateList(targetDate);

return dateList.stream().map(e -> {

BusinessCalendarDto calendar = new BusinessCalendarDto();
calendar.setDay(new BigDecimal(e.getDayOfMonth()));
calendar.setWeekDay(e.getDayOfWeek().toString().toLowerCase());
return calendar;

}).collect(Collectors.toList());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import jp.co.nok.common.log.Logger;
Expand All @@ -29,13 +27,13 @@ public String getErrorPath() {
return AppView.APP_ERROR_VIEW.getValue();
}

@GetMapping
@PostMapping
public String error(Exception e) {

LOG.error("エラーが発生しました", e);

return AppView.APP_ERROR_VIEW.getValue();
}
// @GetMapping
// @PostMapping
// public String error(Exception e) {
//
// LOG.error("エラーが発生しました", e);
//
// return AppView.APP_ERROR_VIEW.getValue();
// }

}
4 changes: 3 additions & 1 deletion nok-app/src/main/java/jp/co/nok/common/util/DateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,9 @@ public static enum DateFormatType implements BaseEnum {
YYYYMMDD_NOSEP("yyyyMMdd"),
/** YYYY/MM/DD HH:mm:ss */
YYYYMMDDHHMMSS("yyyy/MM/dd HH:mm:ss"),
/** YYYYMMDD_HHmmss */
/** yyyyMM */
YYYYMM_NOSEP("yyyyMM"),
/** yyyyMMddHHmmss */
YYYYMMDDHHMMSS_NOSEP("yyyyMMddHHmmss");

/** 値 */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package jp.co.nok.dashboard.work.controller;

import java.time.LocalDate;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -10,9 +12,11 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import jp.co.nok.business.db.select.DailyWorkEntryDataService;
import jp.co.nok.business.db.select.DailyWorkEntryDataSearchService;
import jp.co.nok.business.db.select.WorkUserMtSearchService;
import jp.co.nok.business.work.service.MonthlyWorkEntryService;
import jp.co.nok.common.component.SessionComponent;
import jp.co.nok.dashboard.work.form.MonthEntryForm;
import jp.co.nok.db.entity.WorkUserCompositeMt;
Expand All @@ -25,13 +29,16 @@
*/
@Controller
@RequestMapping("/work/month")
public class MonthEntryController {
public class MonthlyEntryController {

@Autowired
private HttpSession session;
/** 当月勤怠登録画面サービス */
@Autowired
private MonthlyWorkEntryService monthlyWorkEntryService;
/** 日別勤怠登録情報検索サービス */
@Autowired
private DailyWorkEntryDataService dailyWorkEntryDataService;
private DailyWorkEntryDataSearchService dailyWorkEntryDataService;
/** 勤怠ユーザマスタ検索サービス */
@Autowired
private WorkUserMtSearchService workUserMtSearchService;
Expand All @@ -41,21 +48,31 @@ public class MonthEntryController {
*
* @param model
* Model
* @param year
* 指定年
* @param month
* 指定月
* @return 当月勤怠登録View
*/
@GetMapping("/entry")
public String entry(Model model) {
public String entry(Model model,
@RequestParam(name = "year", required = false) String year,
@RequestParam(name = "month", required = false) String month) {

SessionComponent sessionComponent = (SessionComponent) session
.getAttribute(SessionComponent.KEY);
Integer seqLoginId = sessionComponent.getLoginAuthDto().getSeqLoginId();

Integer seqLoginId = sessionComponent.getLoginAuthDto().getSeqLoginId();
// ログイン中のユーザに適用される最新の定時情報マスタを取得
WorkUserCompositeMt mt = workUserMtSearchService
WorkUserCompositeMt regularMt = workUserMtSearchService
.selectByLoginIdAndMaxWorkUserMtId(seqLoginId);
model.addAttribute("regularMt", regularMt);

// 処理対象年月
LocalDate targetDate = monthlyWorkEntryService.getTargetDate(year, month);

model.addAttribute("thisMonthList", dailyWorkEntryDataService
.getThisMonthList());
.getMonthList(regularMt.getSeqWorkUserMtId(), targetDate));

return AppView.WORK_MONTH_ENTRY_VIEW.getValue();
}
Expand Down
35 changes: 35 additions & 0 deletions nok-app/src/main/java/jp/co/nok/db/dao/BusinessCalendarMtDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package jp.co.nok.db.dao;

import java.util.List;

import org.seasar.doma.Dao;
import org.seasar.doma.Delete;
import org.seasar.doma.Insert;
import org.seasar.doma.Select;
import org.seasar.doma.Update;
import org.seasar.doma.boot.ConfigAutowireable;

import jp.co.nok.db.entity.BusinessCalendarMt;

/**
* 営業日マスタ Dao
*
* @version 1.0.0
*/
@Dao
@ConfigAutowireable
public interface BusinessCalendarMtDao extends BaseDao {

@Delete
public int delete(BusinessCalendarMt entity);

@Update
public int update(BusinessCalendarMt entity);

@Insert
public int insert(BusinessCalendarMt entity);

@Select
public List<BusinessCalendarMt> selectByMonth(String date);

}
Loading