import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional
public class OrgSearchBLogicImpl implements OrgSearchBLogic {
/** 組織サービス. */
@Autowired
private OrgService orgService;
/*
* (non-Javadoc)
*
* @see
* com.isurp.neo.app.blogic.OrgSearchBLogic#execute(com.isurp.neo.app.dto.
* OrgSearchBLogicInputDto)
*/
@Override
public OrgSearchBLogicOutputDto execute(OrgSearchBLogicInputDto inputDto) {
MOrgExample example = new MOrgExample();
// 検索要求元より、組織名称で検索を要求した場合。
// 組織名称がなにもない場合、
if (inputDto.getOrgName() != "") {
example.createCriteria().andDeleteFlagEqualTo(DeleteFlagEnum.OFF.getValue())
.andOrgNameLike(inputDto.getOrgName()).andCompanyCodeEqualTo(inputDto.getCompanyCode());
} else
// 組織名称が指定されている場合、
{
example.createCriteria().andDeleteFlagEqualTo(DeleteFlagEnum.OFF.getValue());
}
List<MOrg> list = orgService.selectByExample(example);
OrgSearchBLogicOutputDto outputDto = new OrgSearchBLogicOutputDto();
outputDto.setList(list);
return outputDto;
}
}
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class OrgSearchController {
/** 組織検索BLogic. */
@Autowired
private OrgSearchBLogic orgSearchBLogic;
/**
* AJAX用メソッド.
*
* @param criteria
* 組織検索クリテリア
* @return 組織検索結果クラス.
*/
@RequestMapping(value = "/org/search/ajax", method = { RequestMethod.GET, RequestMethod.POST })
@ResponseBody
public OrgSearchResult search(@AuthenticationPrincipal final CustomUserDetails userDetails,
@Validated OrgSearchCriteria criteria) {
OrgSearchBLogicInputDto inputDto = new OrgSearchBLogicInputDto();
// 組織名称とユーザーの会社コードを設定しておく。
inputDto.setOrgName(criteria.getOrgName());
inputDto.setCompanyCode(userDetails.getMUser().getCompanyCode());
OrgSearchBLogicOutputDto outputDto = orgSearchBLogic.execute(inputDto);
OrgSearchResult searchResult = new OrgSearchResult();
searchResult.setList(outputDto.getList());
return searchResult;
}
}
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.terasoluna.gfw.common.exception.BusinessException;
@Service
@Transactional
public class HinmokuDeleteConfirmDeleteBLogicImpl implements HinmokuDeleteConfirmDeleteBLogic {
/** 品目サービス. */
@Autowired
private HinmokuService hinmokuService;
/**
* ロジック実行.
*
* @param inputDto
* ロジックパラメータ
* @return ロジック結果
*/
@Override
public HinmokuDeleteConfirmDeleteBLogicOutputDto execute(final HinmokuDeleteConfirmDeleteBLogicInputDto inputDto) {
MHinmoku mHinmokuBefore = inputDto.getmHinmoku();
String key = mHinmokuBefore.getHinmokuCode();
MHinmoku selectedMHinmoku = hinmokuService.selectByPrimaryKey(key);
// 値チェック
validate(mHinmokuBefore, selectedMHinmoku);
// 削除フラグを有効で設定。
Date updateDate = Timestamp.valueOf(LocalDateTime.now());
selectedMHinmoku.setDeleteFlag(DeleteFlagEnum.ON.getValue());
selectedMHinmoku.setUpdateDate(updateDate);
selectedMHinmoku.setUpdateUserId(inputDto.getUpdateUserId());
// 品目
int deleteResultCount = hinmokuService.updateByPrimaryKey(selectedMHinmoku);
if (deleteResultCount <= 0) {
throw new BusinessException("e.ne.fw.9001");
}
return new HinmokuDeleteConfirmDeleteBLogicOutputDto();
}
/**
* 検証.
*
* @param mHinmokuBefore
* 更新前の品目情報
* @param selectedMHinmoku
* DBの品目情報
*/
private void validate(MHinmoku mHinmokuBefore, MHinmoku selectedMHinmoku) {
LocalDateTime temp = LocalDateTime.ofInstant(mHinmokuBefore.getUpdateDate().toInstant(),
ZoneId.systemDefault());
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
LocalDateTime tempSelect = LocalDateTime.ofInstant(selectedMHinmoku.getUpdateDate().toInstant(),
ZoneId.systemDefault());
System.out.println("Select = " + tempSelect.format(formatter));
System.out.println("Before = " + temp.format(formatter));
//DB情報の更新日時が既に更新されている場合
if (selectedMHinmoku.getUpdateDate().after(mHinmokuBefore.getUpdateDate())) {
throw new BusinessException("e.ne.fw.9001");
}
}
}
<meta name="contextPath" content="${pageContext.request.contextPath}" />
<script type="text/javascript">
var contextPath = $("meta[name='contextPath']").attr("content");
$(document).ready(function() {
$('#confirm').click(function() {
$('#HokanbashoRegistForm').submit();
});
$('#cancel').click(function(){
document.location.href = "${pageContext.request.contextPath}/admin/master/hokanbashoRegist/cancel";
});
// 組織検索ボタンの押下時、処理
$('#selectOrgButton').click(function() {
//alert("contextPath:"+contextPath);
searchOrg();
});
// モダル画面の組織検索ボタンが押下された場合
$('#selectOrgModalButton').click(function() {
//alert("contextPath:"+contextPath);
searchOrg();
});
// モダル画面の閉じるボタンが押下された場合
$("#modalClose").click(function() {
$("#orgName").val("");
});
});
// 組織検索
function searchOrg() {
$.ajax(contextPath + "/org/search/ajax", {
data : $("#OrgSerachModelForm").serialize(),
dataType : "json",
}).done(function(json) {
//alert("json:"+json.list);
//結果を画面に表示する。
var titleStr = "<tr><th></th><th>コード</th><th>名称</th></tr>"
var str = titleStr;
var length = parseInt(Object.keys(json.list).length);
$('#org_list').empty();
$('#modal_org_list_message').empty();
//読み込んだデータが0件の場合は、エラーメッセージを表示する。
//もし、データがあれば、データをtable形式で表示する。
if (length <= 0) {
$('#modal_org_list_message').append("<p>組織データがありません。</p>");
} else if (length > 0) {
$.each(json.list, function(index) {
str = str + "<tr><td>" +
"<button type='button' class='btn btn-primary btnSelected" + index + "'" + "id='selectBtn'>Select</button>" + "</td>" +
"<td style='vertical-align:middle'><span>" + json.list[index].orgCode + "</span></td><td style='vertical-align:middle'><span>" + json.list[index].orgName + "</span></td></tr>";
});
$('#org_list').append(str);
// 各行のごとに、selectボタンにクリックイベントをバインドしておく。
$.each(json.list, function(index) {
$(".btnSelected" + index).on("click", function() {
var orgCode = $(this).closest('td').next('td').find('span').text();
var orgName = $(this).closest('td').next('td').next('td').find('span').text();
//alert(orgCode + " / " + orgName);
$('#kanriOrgId').val(orgCode);
$('#kanriOrgName').val(orgName);
//閉じる。
$("#modalClose").click();
});
});
}
}).fail(function(xhr) {
$('#modal_org_list_message').append(xhr);
});
return false;
}
</script>
<style>
.modal-header{
background-color:#00cc00;
color:#ffffff;
}
</style>
<div class="container">
<h2 class="page-header">
<spring:message code="web.admin.master.hokanbashoRegist.headerTitle" />
</h2>
<p>
<font color="red"><spring:message
code="web.admin.master.hokanbashoRegist.messageForMarkedFields" /></font>
</p>
<form:form class="form-horizontal"
modelAttribute="hokanbashoRegistForm" method="post"
action="${pageContext.request.contextPath}/admin/master/hokanbashoRegist/confirm"
id="HokanbashoRegistForm" name="HokanbashoRegistForm">
<form:errors path="*" />
<div class="form-group">
<label class="col-sm-3 control-label" for="plant"><spring:message
code="web.admin.master.hokanbashoRegist.plant" /><font color="red"> *</font></label>
<div class="col-sm-8">
<select id="plantCode" name="plantCode" class="form-control">
<c:forEach var="item" items="${mPlantMap}">
<c:if test="${item.key == mHokanbasho.plantCode}"><option value="${item.key}" selected>${item.value}</option></c:if>
<c:if test="${item.key != mHokanbasho.plantCode}"><option value="${item.key}" >${item.value}</option></c:if>
</c:forEach>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="hokanbashoCode"><spring:message
code="web.admin.master.hokanbashoRegist.hokanbashoCode" /><font
color="red"> *</font></label>
<div class="col-sm-8">
<form:input type="text" path="hokanbashoCode" class="form-control"
value="${mHokanbasho.hokanbashoCode}" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="hokanbashoName"><spring:message
code="web.admin.master.hokanbashoRegist.hokanbashoName" /><font
color="red"> *</font></label>
<div class="col-sm-8">
<form:input type="text" path="hokanbashoName" class="form-control"
value="${mHokanbasho.hokanbashoName}" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="kanriOrgName"><spring:message
code="web.admin.master.hokanbashoRegist.kanriOrgName" /><font
color="red"> *</font></label>
<div class="col-sm-8">
<div class="form-inline">
<form:input type="hidden" path="kanriOrgId"
value="${mHokanbasho.kanriOrgId}" />
<div class="form-group col-sm-2">
<button type="button" class="btn btn-primary" id="selectOrgButton" data-toggle="modal" data-target="#orgSearchModal">
<spring:message
code="web.admin.master.hokanbashoRegist.selectOrgButton" />
</button>
</div>
<div class="form-group col-sm-10">
<form:input type="text" path="kanriOrgName" class="form-control" style="width:100%"
value="${mHokanbasho.kanriOrgName}" />
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="hokanbashoKbn"><spring:message
code="web.admin.master.hokanbashoRegist.hokanbashoKbn" /><font
color="red"> *</font></label>
<div class="col-sm-8">
<c:forEach var="hokanbashoKbnItem" items="${CL_HOKANBASHO_KBN}"
varStatus="hokanbashoKbnStatus">
<label class="radio-inline">
<input type="radio" name="hokanbashoKbn"
<c:choose>
<c:when test="${!empty mHokanbasho.hokanbashoKbn}">
<c:if test="${hokanbashoKbnItem.key == mHokanbasho.hokanbashoKbn}">checked</c:if>
</c:when>
<c:otherwise>
<c:if test="${hokanbashoKbnStatus.index == 0}">checked</c:if>
</c:otherwise>
</c:choose>
value="${hokanbashoKbnItem.key}">
<spring:message code="${hokanbashoKbnItem.value}" />
</label>
</c:forEach>
</div>
</div>
<!-- danaExist Flag -->
<div class="form-group">
<label class="col-sm-3 control-label" for=danaExistFlag><spring:message
code="web.admin.master.hokanbashoRegist.danaExistFlag" /><font
color="red"> *</font></label>
<div class="col-sm-8">
<c:forEach var="danaExistFlagItem" items="${CL_DANA_EXIST_FLAG}"
varStatus="danaExistFlagStatus">
<label class="radio-inline">
<input type="radio" name="danaExistFlag"
<c:choose>
<c:when test="${!empty mHokanbasho.danaExistFlag}">
<c:if test="${danaExistFlagItem.key == mHokanbasho.danaExistFlag}">checked</c:if>
</c:when>
<c:otherwise>
<c:if test="${danaExistFlagStatus.index == 0}">checked</c:if>
</c:otherwise>
</c:choose>
value="${danaExistFlagItem.key}">
<spring:message code="${danaExistFlagItem.value}" />
</label>
</c:forEach>
</div>
</div>
<!-- yoko flag -->
<div class="form-group">
<label class="col-sm-3 control-label" for="yukoFlag"><spring:message
code="web.admin.master.hokanbashoRegist.yukoFlag" /><font
color="red"> *</font></label>
<div class="col-sm-8">
<c:forEach var="yukoFlagItem" items="${CL_YUKO_FLAG}"
varStatus="yukoFlagStatus">
<label class="radio-inline">
<input type="radio" name="yukoFlag"
<c:choose>
<c:when test="${!empty mHokanbasho.yukoFlag}">
<c:if test="${yukoFlagItem.key == mHokanbasho.yukoFlag}">checked</c:if>
</c:when>
<c:otherwise>
<c:if test="${yukoFlagStatus.index == 0}">checked</c:if>
</c:otherwise>
</c:choose>
value="${yukoFlagItem.key}">
<spring:message code="${yukoFlagItem.value}" />
</label>
</c:forEach>
</div>
</div>
<!-- confirm, cancel button -->
<div>
<button type="button" class="btn btn-primary" id="confirm">
<spring:message code="web.admin.master.hokanbashoRegist.confirm" />
</button>
<button type="button" class="btn btn-primary" id="cancel">
<spring:message code="web.admin.master.hokanbashoRegist.cancel" />
</button>
</div>
</form:form>
</div>
<!-- Modal -->
<div class="modal" id="orgSearchModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<label><spring:message code="web.admin.master.hokanbashoRegist.organizationSearchTitle"></spring:message></label>
</div>
<div class="modal-body">
<div style="margin: 0px 0px 20px 0px;text-align:right">
<form class="form-horizontal" id="OrgSerachModelForm" name="OrgSerachModelForm">
<form:errors path="*" />
<div style="display:inline-block">
<input type="text" class="form-control" id="orgName" name="orgName"
placeholder="<spring:message code="web.admin.master.hokanbashoRegist.organizationSearchModalOrgNamePlaceholder"></spring:message>">
</div>
<div style="display:inline-block">
<button type="button" class="btn btn-primary" id="selectOrgModalButton">
<spring:message code="web.admin.master.hokanbashoRegist.organizationSearchModalSearchBtnName"></spring:message>
</button>
</div>
</form>
</div>
<div>
<table id="org_list" class="table table-striped">
</table>
</div>
<div id="modal_org_list_message">
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary pull-Right" data-dismiss="modal" id="modalClose">
<spring:message code="web.admin.master.hokanbashoRegist.organizationSearchModalCancelBtnName"></spring:message>
</button>
</div>
</div>
</div>
</div>
댓글 없음:
댓글 쓰기