项目小结

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title>签约排号管理</title>
    <%@include file="/static/common/common.jsp" %>
    <link rel="stylesheet" href="/static/style/seaInfo.css">
</head>
<body>
<div class="title">
    <h5>电子排号管理</h5>
</div>

<div class="content">
<ul class="nav nav-tabs">
    <li class="active">
        <a href="list">未排号家庭</a>
    </li>
    <li>
        <a href="listInfo">已排号家庭</a>
    </li>
</ul>
    </br>
    <div class="search">
        <div class="search_content">
            <form id="search" class="form-search">
                家庭编号:<tags:searchInput name="number" fieldType="string" operator="like" size="12"/>
                被腾退人姓名:<tags:searchInput name="name" fieldType="string" operator="like" size="10"/>
                身份证号:<tags:searchInput name="idCard" fieldType="string" operator="like" size="20"/>
                <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-search"></i> 查询</button>
            </form>
        </div>
    </div>
<table class="table table-bordered table-hover">
    <thead>
    <tr>
        <th class="text-center" width="5%">序号</th>
        <th class="text-center">村名</th>
        <th  class="text-center">房屋坐落</th>
        <th class="text-center">家庭编号</th>
        <th class="text-center">姓名</th>
        <th class="text-center">身份证号</th>
        <th class="text-center">获取签约顺序号</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach var="family" items="${pageInfo.result}" varStatus="status">
        <tr>
            <td class="text-center">${status.count+(pageInfo.pageNo-1)*pageInfo.pageSize}</td>
            <td class="text-center">${family.village}</td>
            <td class="text-center">${family.address}</td>
            <td class="text-center">${family.number}</td>
            <td class="text-center">${family.name}</td>
            <td class="text-center">${family.idCard}</td>
            <td class="text-center">
                <a href='javascript:void(0)' onclick="getNum('${family.id}','${family.name}')">获取签约顺序号</a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
    <tags:pageInfo/>
<script>
    function getNum(familyId,name) {
        if (confirm("将要获取【"+name+"】的签约顺序号,一旦获取该户的基础数据、数据将被锁定!

确定获取吗?")) {
            $.get("getSignNum", {familyId: familyId, _date: new Date().getTime()}, function (result) {
                if (result.success == 'true') {
                    location.href = "listInfo";
                } else {
                    alert(result.message);
                    window.location.reload();
                }
            });
        }
    }
</script>
</div>
</body>
</html>
View Code
<td class="text-center">
<a href='javascript:void(0)' onclick="getNum('${family.id}','${family.name}')">获取签约顺序号</a>
</td>
<script>
function getNum(familyId,name) {
if (confirm("将要获取【"+name+"】的签约顺序号,一旦获取该户的基础数据、数据将被锁定! 确定获取吗?")) {
$.get("getSignNum", {familyId: familyId, _date: new Date().getTime()}, function (result) {
if (result.success == 'true') {
location.href = "listInfo";
} else {
alert(result.message);
window.location.reload();
}
});
}
}
</script>



  /*
* 签约方法
* */
@RequestMapping("getSignNum")
@ResponseBody
public synchronized Map getSignNum(HttpServletRequest request, ModelMap modelMap) {
Map<String, String> map = new HashMap<String, String>();
Integer familyId = ParamUtils.getInteger(request, "familyId", 0);
Family family = familyService.get(familyId);
if(family == null){
map.put("success", "false");
map.put("message", "家庭信息不存在。");
return map;
}
if (family!=null && family.getCode() != null) {
map.put("success", "false");
map.put("message", "该家庭已经获取了签约顺序号。");
return map;
}
familyService.getSignNum(familyId);

map.put("success", "true");
return map;
}
 
/**
* 签约协议
*
* @param request
* @param modelMap
*/
@RequestMapping("agreementPrint")
public void agreementPrint(HttpServletRequest request, ModelMap modelMap) {
int familyId = ParamUtils.getInt(request, "familyId", 0);
int contractId = ParamUtils.getInt(request, "contractId", 0);
List<Contract> contracts = contractService.listByFamilyId(familyId);
Contract contract = contractService.get(contractId);
Family family = familyService.get(familyId);
String FS;
for (Contract contract1 : contracts) {
if (contract1.getContractType() == 1) {
FS = "安置";
} else {
FS = "货币";
}
modelMap.addAttribute("FS", FS);
}

FreeMarkerMoneyUtils freeMarkerMoneyUtils = new FreeMarkerMoneyUtils();

modelMap.addAttribute("family", family);
modelMap.addAttribute("contracts", contracts);
modelMap.addAttribute("contract", contract);
modelMap.addAttribute("contractId", contractId);
modelMap.addAttribute("moneyUtils", freeMarkerMoneyUtils);
}

/**
* 协议PDF打印
*/
@RequestMapping("printPDF")
public void printPDF(HttpServletRequest request, HttpServletResponse response, ModelMap model) throws
InvocationTargetException, NoSuchMethodException, NoSuchFieldException, IllegalAccessException {
int familyId = ParamUtils.getInt(request, "familyId", 0);
int contractId = ParamUtils.getInt(request, "contractId", 0);
Family family = familyService.get(familyId);

List<Contract> contracts = contractService.listByFamilyId(family.getId());

if (contractId == 0) {
if (contracts.size() == 0) {
throw new SqdsException("该家庭还未签协议!");
}
contractId = contracts.get(0).getId();
}
Contract contract = contractService.get(contractId);

Integer type = contract.getContractType();
String FS;

if (type == 1) {
FS = "房屋安置";
} else {
FS = "货币补偿";
}

Map map = Maps.newHashMap();
String template = null;
FreeMarkerMoneyUtils freeMarkerMoneyUtils = new FreeMarkerMoneyUtils();
map.put("moneyUtils", freeMarkerMoneyUtils);
map.put("contracts", contracts);
map.put("contract", contract);
map.put("family", family);
map.put("FS", FS);
template = "agreementPdf.html";
PdfDocumentGenerator pdfDocumentGenerator = new PdfDocumentGenerator();
OutputStream outputStream = null;
try {
outputStream = response.getOutputStream();
pdfDocumentGenerator.generate(template, map, outputStream);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
outputStream.flush();
outputStream.close();
response.reset();
} catch (Exception e) {

}
}
}







原文地址:https://www.cnblogs.com/xlzsdxk/p/7736764.html