项目study
springboot+vue
-
idea选中生成方法快捷键ctrl+alt+m
-
idea驼峰快捷键: shift+alt+u
-
idea规范编码格式:ctrl + alt + l
-
idea快捷键:ctrl + alt + T
-
idea批量改变字母,选中需要修改的字母shit+f6改成你对应的
-
Ctrl+h 全文搜索替换
-
Ctrl+shift+f9:外置Tomcat编译
-
数据库改成开发环境,在表后面加_dev
-
代码生成器mbg
-
第一步创建表写好注释
-
改对应配置文件的表名
-
4.xml里面的sql语句不要动,几乎可以满足你所需要的所有单表查询
- 查询 思路首先在,页面看到你所显示的位置 ——>去前端vue的front 找到路由rout ——>全局搜索对应的路径 ——>找到路径后根据他的方法,搜索方法找到相对应的类 ——>
- ctrl+f本类搜索出来
-
mvc不用model传参,用对应的参数
-
去了解po、bo、vo、pojo
-
业务service接口–>实现类serviceImpl(重写方法)–>controller(server接口依赖注入,调用它方法)
数据库下划线与实体类对应字段
第一次完整步骤
1.先在系统管理菜单管理中配好对应访问路径和权限
2.写好controller方法和返回页面路径
3.复制一个页面相仿的前端页面,测试一下是否能跳到对应页面,做一步测试一步
4.编写好对应的sql语句,和对应页面的模糊查询语句
学习总结:1.写sql查数据的时候,谨记有目标联表查询,写好需要的字段再去联表,查出对应的数据,少用*
2.后端获取数据都是用它对应的实体get对应的方法获取值,前端则是直接点,谨记!低级错误(example:bzServiceItem.getItemId())
3.前端获取值,都是在里面直接点即可而不是在{}外面,低级错误,谨记!(example: ${asd.count})
controller层,注意这里有分页
/**
*查询出殡留炉盅箱预拨表
* @param bzServiceItem
* @param response
* @param request
* @param model
* @return
*/
@RequiresPermissions("bz:consumelistproject:bzConsumelistProjectRelation:view")
@RequestMapping(value = "getCupBox")
public String getCupBox(BzServiceItem bzServiceItem,HttpServletResponse response,HttpServletRequest request,Model model){
// Page<BzServiceItem> page = bzConsumelistProjectRelationService.findPageByAccount(new Page<BzConsumelistProjectRelation>(request, response), bzConsumelistProjectRelation);
// List<BzServiceItem> list = bzServiceItemService.findCupBox(bzServiceItem);
Page<BzServiceItem> page = bzServiceItemService.findCupBox(new Page<BzServiceItem>(request, response), bzServiceItem);
model.addAttribute("page",page);
model.addAttribute("bzServiceItem",bzServiceItem);
System.out.println("e333333333333333333333"+bzServiceItem.getItemId());
return "modules/bz/lfgl/bzCupBoxList";
}
service层
public Page<BzServiceItem> findCupBox(Page<BzServiceItem> page,BzServiceItem bzServiceItem) {
bzServiceItem.setPage(page);
List<BzServiceItem> list = bzServiceItemDao.findCupBox(bzServiceItem);
page.setList(list);
return page;
}
dao层
List<BzServiceItem> findCupBox(BzServiceItem bzServiceItem);
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>出殡留炉盅箱预拨表</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
$(document).ready(function() {
});
function page(n,s){
$("#pageNo").val(n);
$("#pageSize").val(s);
$("#searchForm").submit();
return false;
}
</script>
</head>
<body>
<ul class="nav nav-tabs">
<li class="active"><a href="${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/getCupBox">出殡留炉盅箱预拨表</a></li>
</ul>
<form:form id="searchForm" modelAttribute="bzServiceItem" action="${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/getCupBox" method="post" class="breadcrumb form-search">
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<ul class="ul-form">
<li><label>死者编号:</label>
<form:input path="deceased.serialNumber" htmlEscape="false" maxlength="100" class="input-medium"/>
</li>
<li><label>死者姓名:</label>
<form:input path="deceased.actualName" htmlEscape="false" maxlength="100" class="input-medium"/>
</li>
<li><label>出殡时间:</label>
<input name="beginRentDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
value="<fmt:formatDate value="${bzServiceItem.beginRentDate}" pattern="yyyy-MM-dd"/>"
onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
<input name="endRentDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
value="<fmt:formatDate value="${bzServiceItem.endRentDate}" pattern="yyyy-MM-dd"/>"
onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
</li>
<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
</ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>序号</th>
<th>死者编号</th>
<th>死者姓名</th>
<th>出殡日期</th>
<th>盅箱名</th>
<th>价格</th>
<th>留炉或捡灰炉</th>
<th>备注</th>
<shiro:hasPermission name="signunit:bzSignUnit:edit"><th>操作</th></shiro:hasPermission>
</tr>
</thead>
<tbody>
<c:forEach items="${page.list}" var="bzServiceItem" varStatus="asd">
<tr>
<td>
${asd.count}
</td>
<td>
${bzServiceItem.deceased.serialNumber}
</td>
<td>
${bzServiceItem.deceased.actualName}
</td>
<td>
<fmt:formatDate value="${bzServiceItem.bzYsglCbbc.bzYsglDate}" pattern="yyyy-MM-dd"/> ${bzServiceItem.bzYsglCbbc.bzCbbcGbhapBdate}
</td>
<td>
${bzServiceItem.name}
</td>
<td>
${bzServiceItem.unitPrice}
</td>
<td>
</td>
<td>
</td>
<shiro:hasPermission name="signunit:bzSignUnit:edit"><td>
<%-- <a href="${ctx}/business/signunit/bzSignUnit/form?id=${bzSignUnit.id}">修改</a>--%>
<%-- <a href="${ctx}/business/signunit/bzSignUnit/delete?id=${bzSignUnit.id}" onclick="return confirmx('确认要删除该签发单位吗?', this.href)">删除</a>--%>
</td></shiro:hasPermission>
</tr>
</c:forEach>
</tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>
=============================2021.7.7=========================================
在后台路径传值,前台接收
/bz/consumelistproject/bzConsumelistProjectRelation/getCupBox?itemId=94769618f76c53bb1c772463b1d3e7d6&itemId=b04e6889195df6d1ae7a506bfe15aa37&itemId=d695eeacfcff83fb8293607631c679f3
<input style="display: none" name="itemId" value="94769618f76c53bb1c772463b1d3e7d6">
<input style="display: none" name="itemId" value="b04e6889195df6d1ae7a506bfe15aa37">
<input style="display: none" name="itemId" value="d695eeacfcff83fb8293607631c679f3">
<!--查询出殡留炉盅箱预拨信息-->
<select id="findCupBox" resultType="bzServiceItem">
SELECT
c.serial_number AS "deceased.serialNumber",
c.actual_name AS "deceased.actualName",
d.name AS "name",
d.unit_price AS "unitPrice",
e.bz_ysgl_date AS "bzYsglCbbc.bzYsglDate",
e.bz_cbbc_gbhap_bdate AS "bzYsglCbbc.bzCbbcGbhapBdate"
FROM
bz_consumelist_project_relation AS a
LEFT JOIN bz_negotiation_consumelist b ON b.id = a.consumelist_id
AND b.del_flag = 0
LEFT JOIN bz_deceased c ON c.id = b.deceased_id
AND c.del_flag = 0
LEFT JOIN bz_service_item d ON a.consume_project_id = d.id
AND d.del_flag = 0
left join bz_ysgl_cbbc e on e.bz_deceased_id = c.id and e.del_flag=0
<where>
d.parent_id in
('94769618f76c53bb1c772463b1d3e7d6','b04e6889195df6d1ae7a506bfe15aa37','d695eeacfcff83fb8293607631c679f3')
<if test="deceased != null"> --用之前判断下这个实体是否为空
<if test="deceased.serialNumber != null and deceased.serialNumber != ''"> --模糊查询
AND c.serial_number LIKE
<if test="dbName == 'oracle'">'%'||#{deceased.serialNumber}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{deceased.serialNumber}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{deceased.serialNumber},'%')</if>
</if>
<if test="deceased.actualName != null and deceased.actualName != ''">
AND c.actual_name LIKE
<if test="dbName == 'oracle'">'%'||#{deceased.actualName}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{deceased.actualName}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{deceased.actualName},'%')</if>
</if>
</if>
<if test="beginRentDate != null and beginRentDate != '' and endRentDate != null and endRentDate != '' "> --时间区间查询,前面and的是数据库的字段名,between后面是实体类的值
AND e.bz_ysgl_date between #{beginRentDate} and #{endRentDate}
</if>
</where>
</select>
Java后台代码总结
@ResponseBody注解会返回一个字符串给前端
BzNegotiationConsumelist negotiationConsumelist = negotiationConsumelistService.get(sjid);
BzDeceased bzDeceased = new BzDeceased(); //提升作用域
为了防止空指针异常,提前在后台判断好,是否为空,为空的话就不执行
if (negotiationConsumelist!=null && StringUtils.isNotBlank(negotiationConsumelist.getDeceasedId())){
bzDeceased = bzDeceasedService.get(negotiationConsumelist.getDeceasedId());
}
BzYsgl bzYsgl = new BzYsgl();
if (negotiationConsumelist !=null && StringUtils.isNotBlank(negotiationConsumelist.getDeceasedId())){
bzYsgl = bzYsglService.findBzceasedLastObj(negotiationConsumelist.getDeceasedId());
}
model.addAttribute("bzDeceased",bzDeceased);
model.addAttribute("bzYsgl", bzYsgl);
if (bzYsgl != null) {
model.addAttribute("cbsj", YsglUtils.getBzYsglCbsjStr(bzYsgl.getId(), "1"));
}
return "modules/business/negotiation/bzPrintingNegotiation";
=========================================================================================
controller层
/**
* 外运审核,返回页面
* @param bzOutTransport
* @param redirectAttributes
* @return
*/
@RequiresPermissions("outtransport:bzOutTransport:edit")
@RequestMapping(value = "examine")
public String examine(BzOutTransport bzOutTransport,Model model,RedirectAttributes redirectAttributes){
model.addAttribute("bzOutTransport",bzOutTransport);
return "modules/business/outtransport/bzOutTransportAudit";
}
/**
* 外运审核,保存数据
* @param bzOutTransport
* @param redirectAttributes
* @return
*/
@RequiresPermissions("outtransport:bzOutTransport:edit")
@RequestMapping(value = "find")
@ResponseBody
public Msg find(BzOutTransport bzOutTransport,Model model,RedirectAttributes redirectAttributes){
// bzOutTransportService.examine(bzOutTransport);
// BzOutTransport bzOutTransport1 = bzOutTransportService.getExamine(bzOutTransport);
// model.addAttribute("bzOutTransport1", bzOutTransport1);
Msg msg = new Msg(); //new一个Msg对象,new了之后msg才是对象,没new之前是累
int i=bzOutTransportService.updateStatus(bzOutTransport); //这个返回类型 主要看后面方法的返回类型
msg.setFlag(i+""); //把上面的值赋值给对应的类型,set进msg里面
return msg; //把封装的msg对象返回给前端
}
service层
@Transactional(readOnly = false)
public int updateStatus(BzOutTransport bzOutTransport) {
return bzOutTransportDao.updateSattus(bzOutTransport);
}
@Transactional(readOnly = false)
public void examine(BzOutTransport bzOutTransport) {
BzOutTransport bzOutTransport1 = bzOutTransportDao.getExamineById(bzOutTransport.getId());
dao.update(bzOutTransport);
}
@Transactional(readOnly = false)
public BzOutTransport getExamine(BzOutTransport bzOutTransport) {
return dao.findList(bzOutTransport).get(0);//去查出来的第一条数据
}
dao层
int updateSattus(BzOutTransport bzOutTransport);
BzOutTransport getExamineById(String id);
dao.xml 文件
<update id="updateSattus">
UPDATE bz_out_transport SET
job_number=#{jobNumber},
job_name=#{jobName}
WHERE id = #{id}
</update>
<!--审核外运-->
<!-- <select id="getExamineById" resultType="BzOutTransport">-->
<!-- select audit_opinion from bz_out_transport where id = #{id}-->
<!-- </select>-->
字典sql
<select id="getAuditStatusList" resultType="BzOutTransport">
select
sys_dict.label as 'name',
sys_dict.value as 'type'
from
sys_dict
where
value in ('0','1','2')
and
del_flag='0'
and
type='auditStatus'
</select>
=================2021.6.30=========================
注意看返回的是页面还是数据
1.返回页面
@RequiresPermissions("transport:bzTransport:view")
@RequestMapping(value = "getPrintData")
public String getPrintData(String bzDeceasedId, Model model, HttpServletRequest request, HttpServletResponse response) {
BzDeceased printData = bzTransportService.getPrintData(bzDeceasedId);
BzScheduling bzScheduling = bzSchedulingService.geTemployeeId(bzDeceasedId);
model.addAttribute("bzScheduling",bzScheduling);
model.addAttribute("bzDeceased", printData);
return "modules/business/transport/printGrassListPage";
像这样是返回页面的话可以直接通过model.addAttribute返回数据到前端
2.返回数据
@RequestMapping(value = "getData")
public String getData(String bzDeceasedId, Model model, HttpServletRequest request, HttpServletResponse response) {
BzDeceased printData = bzTransportService.getPrintData(bzDeceasedId);
//调度
String no = UserUtils.getUser().getNo();
BzScheduling bzScheduling = bzSchedulingService.geTemployeeId(bzDeceasedId);
model.addAttribute("bzScheduling",bzScheduling);
//电话接听
String telNo = systemService.getUser(printData.getCreateBy().getId()).getNo();
printData.setBzScheduling(bzScheduling);
printData.setGender(DictUtils.getDictLabel(printData.getGender(), "sex", "") + "_" + no + "_" + telNo);
printData.setTransportType(DictUtils.getDictLabel(printData.getTransportType(), "transport_type", ""));
return renderString(response, printData);
可以通过set把需要的值塞进自己定义的里面,然后response返回给前端
谨记要在对应的BzDeceased 返回类型加上实体类然后get、set方法才能存值进去
========================2021.7.7==========================================
if (bzServiceItem.getBeginRentDate()==null && bzServiceItem.getEndRentDate()==null){
bzServiceItem.setBeginRentDate(new Date());
bzServiceItem.setEndRentDate(new Date());
}
2021.6.30===============
每次点击按钮确认时间,多数都会绑定一个id,根据这个id查出对应的数据
然后把这个id拼到路径后面定义一个名k后面接上的就是值v
window.location.href=“${ctx}/business/transport/bzTransport/updateType?bzTransportId=”+bzTransportId+“&type=”+type+“&deceasedId=”+deceasedId;
后台想要拿到前台这个id,可以直接拿名字k去查询即可
2021.7.19===============
size和lenght拿第一条数据
拿值的时候注意查看,对应该实体类的字段,然后可以通过set存值到对象中,通过get一层一层拿到对应的值
通过后台set值存数据,需要传参数
可以通过get拿值,不要参数
debug的时候,注意断点有没有进方法,否则方法里面是对的也没有用,因为没有进去执行
2021.7.20===============
定义数组的参数:string[] ids
遍历数组:for (String id:ids) {}
2021.7.23===============
- list<实体类> list = new ArrayList<>(); 创建一个新数组
- 数组用add存值,list.add();
- new的数组list实体是什么类型下面就用什么类型存储值,可以通过new对应的对象来存值
BzDeceasedController实体类
BzCountry bzCountry = new BzCountry();
List<BzCountry> list = bzCountryService.findList(bzCountry);
model.addAttribute("list",list);
BzDeceased实体类
private String country = "中国"; // 可以在这默认国家为中国
前端jsp
<form:select path="country" class="input-large required"> //path是对应BzDeceased实体类的有的属性
<form:option value="" label=""/>
<form:options items="${list}" itemLabel="name" itemValue="name" htmlEscape="false"/> // itemLabel="name" itemValue="name" 代表数据表对应的属性,value代表他要获取的值
</form:select>
2021.7.27===============
- js要先var定义才能使用,要不然直接使用,不赋值无法使用,截取对应的字符串使用,substring截串含头不含尾
inspectionObj.checkoutTime = mapInspection.get("checkoutTime");
var checkoutTime = mapInspection.get("checkoutTime");
inspectionObj.month = checkoutTime.substring(5,7);
var checkoutTime = mapInspection.get("checkoutTime");
inspectionObj.day = checkoutTime.substring(9,11);
var checkoutTime = mapInspection.get("checkoutTime");
inspectionObj.hours = checkoutTime.substring(14,16);
hashmap
Map<String, Object> resultMap = Maps.newHashMap();
resultMap.put("bzBusinessNotice", bzBusinessNoticeService.get(id));
return resultMap;
map中取数据可以用key来指定取哪个,但是lsit则必须指定序号来取,并且有排序的功能。
=2021.7.30=========
/** 1.
- StringUtils.isNotBlank();
- 判断参数是否不为空.
- 1.如果不为空返回true。
- 2.如果为空返回false。
- StringUtils.isNotEmpty(null) -> false
- StringUtils.isNotEmpty(“”) -> false
- StringUtils.isNotEmpty(“a”) -> true
- StringUtils.isNotEmpty(" ") -> true
*/
先将json对象转为字符串(JSON.stringify(obj))再将字符串编码(encodeURI(jsonstr)),传过去之后再先解码(decodeURI(jsonstr)),再转成json对象(JSON.parse(jsonstr))。先将json对象转为字符串(JSON.stringify(obj))再将字符串编码(encodeURI(jsonstr)),传过去之后再先解码(decodeURI(jsonstr)),再转成json对象(JSON.parse(jsonstr))。
在参数定义一个string data接收前端传过来的数据
//取值
String dataTemp = data.replaceAll(""", "\"");
JSONObject stuObj = JSON.parseObject(dataTemp);
top.$.jBox.open("iframe:${ctx}/business/donate/bzDonate/saveBzDonate?data="+encodeURI(JSON.stringify(donateObj))+"&deceasedId=${bzDeceased.id}", "捐献信息添加", $(top.document).width() / 2, $(top.document).height() / 1.3, {`
-
- mysql锁表解表:锁表解表博客描述
首先我们查看被锁表的进程
SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX;
1
然后找到进程号,即 trx_mysql_thread_id
然后执行;
kill 进程号;
2021.8.4=================
Date boneDate = DateUtils.parseDate(businessMap.get("boneDate"));
bzDonate.setBoneDate(boneDate); string类型转Date类型
//findlist增加判断条件查询出当前的数据,不加条件的话,容易全部查出来造成数据混乱
<if test="deceasedId != null and deceasedId != ''">
AND a.deceased_id = #{deceasedId}
</if>
<if test="consumesProRelationId != null and consumesProRelationId != ''">
AND a.consumes_pro_relation_id =#{consumesProRelationId}
</if>
//通过jsonmapper.fromjsonstring来转义data数据 (BzDonate)是强转
BzDonate donate = (BzDonate) JsonMapper.fromJsonString(dataObj,BzDonate.class);
-
谨记,页面取值是属性点字段,example:value=“${bzDonate.boneDate}”
2021.8.6=================
- 可以在查出一个id的情况下,根据这个id去查询属于他这个表的数据,记得要先判断是否为空否则很容易为空指针
- 前端报错的时候,首先看后台有无数据其次字段属性有没有写错最后看报错的信息提示,根据提示查看后台数据是否传到前台,一步一步debugger查找错误
- 注意返回页面的数据是直接页面返回还是数据封装返回,注意对应的实体有无自己需要传输的值,如果没有的话就需要自己增加属性添加get、set属性
2021.8.9=================
-
controller层不用注入实体类 注入就会报错,已经自动导入所有的实体类,直接调用即可
-
resultType对应的类型就是前面方法返回的类型
-
注意空指针问题,当调用get、set方法的时候,注意查看本身是否有值,否则会报空指针,无法继续执行下面代码
-
编写sql语句的时候,and的用法,注意使用()括起来,查询的是部分条件要分开,否则and是肯要查出来,会查出多余的数据,其余的条件写到where后面即可,example:where a.del_flag = 0
SELECT
*
FROM
bz_consumelist_project_relation a
LEFT JOIN bz_negotiation_consumelist b ON b.id = a.consumelist_id
AND b.del_flag = 0
LEFT JOIN bz_service_item c ON c.id = a.consume_project_id
AND c.del_flag = 0
WHERE
a.del_flag = 0
AND b.deceased_id = 'c377553eb7b645349d4677504cf92ddb'
AND (
c.id='1dca25bef4c04d1d50638b5cf532b8c4' OR c.id='35f91788c05e15062505a6bc187d0a59' OR c.id = '8251cc005fae6bf12d71e92a0809ffed'
)
ORDER BY b.create_date LIMIT 1
SELECT * FROM bz_service_item WHERE `name` = '尊享礼宾接运服务(市区内)' and del_flag = 0 1dca25bef4c04d1d50638b5cf532b8c4
SELECT * from bz_service_item WHERE name = '安享礼宾接运服务(市区内)' and del_flag = 0 35f91788c05e15062505a6bc187d0a59
SELECT * from bz_service_item WHERE name = '高档运尸车(接运遗体)' and del_flag = 0 8251cc005fae6bf12d71e92a0809ffed
2021.8.10=================
- LIst集合的使用,example:List<泛型、实体类> 对象名称(随意,见名知意) = new ArrayList<泛型、实体类>(); 通过对象点add塞值存值
@RequestMapping(value = "printTailoredTaxi")
public String printTailoredTaxi(Model model,HttpServletResponse response,HttpServletRequest request,String bzDeceasedId){
BzDeceased printTailoredTaxiData = bzTransportService.getPrintData(bzDeceasedId);
BzNegotiationConsumelist getDcumentsNo = bzNegotiationConsumelistService.getDcumentsNo(bzDeceasedId);
List<BzDeceased> data = new ArrayList<BzDeceased>();//定义一个数组data对象
data.add(printTailoredTaxiData); // 往data数据塞值,存数据
double sum = 0.0; //定义一个小数类型,用来做总额的起始值
for (BzDeceased list : data){ //通过for循环遍历,拿出他的所有值
sum+= Double.parseDouble(list.getTransportFee()); //拿到数组的他的金额,每次相加得到总金额
}
model.addAttribute("sum", sum);
model.addAttribute("list",data);
model.addAttribute("DcumentsNo",getDcumentsNo);
return "modules/business/transport/printTailoredTaxi";
}
- for(类型 对象名字(随意,见名知意):数组对象名){}遍历,输出值就是对象名字
2021.8.11=================
- map的使用方法,example:Map<string,string> map = new HashMap<>(); 创建一个Map拿来存取值
- list和map的主要作用就是用来存取值,结构特点List是存储单列数据的集合,Map是存储键值对这样的双列数据的集合;List中存储的数据是有顺序的,并且值允许重复;Map中存储的数据是无序的,它的键是不允许重复的,但是值是允许重复的。
- mysql中union的用法,注意它的区间范围,不然容易报错
<select id="findTransportPerson" resultType="BzEmployee">
select a.serial_number
from
bz_employee a
<where>
a.del_flag = '0'
<if test="diverId != null and diverId !=''">
and
a.id = #{diverId}
</if>
</where>
<if test="employeeId != null and employeeId !=''">
union
select a.serial_number
from
bz_employee a
<where>
a.del_flag = '0'
and
a.id = #{employeeId}
</where>
</if>
<if test="otherEmployeeId != null and otherEmployeeId !=''"> //可以直接拿map的k值来判断,不为空就执行sql
union
select a.serial_number
from
bz_employee a
<where>
a.del_flag = '0'
and
a.id = #{otherEmployeeId}
</where>
</if>
</select>
- 同一个类中有多个需要查询的字段,可以在对应的实体类加多几个字段分别set赋值,再到前台取值
controller层
@RequestMapping(value = "getTanSportData")
public String getTanSportData(String bzTransportId,Model model,HttpServletRequest request,HttpServletResponse response){
BzTransport printTransportData = bzTransportService.getTanSportData(bzTransportId);
Map<String,String> map = new HashMap<>();
map.put("diverId", printTransportData.getBzScheduling().getDiverId());
map.put("employeeId", printTransportData.getBzScheduling().getEmployeeId());
map.put("otherEmployeeId", printTransportData.getBzScheduling().getOtherEmployeeId());
List<BzEmployee> transportPersons = bzEmployeeService.findTransportPerson(map);//对应的属性字段用对应的实体类接收,list返回的是对应的实体类类型
printTransportData.getBzDeceased().setServiceType(DictUtils.getDictLabel(printTransportData.getBzDeceased().getServiceType(),"service_type",""));
printTransportData.getBzDeceased().setTransportType(DictUtils.getDictLabel(printTransportData.getBzDeceased().getTransportType(),"transport_type", ""));
if(transportPersons !=null && transportPersons.size()>0){
if(transportPersons.size() >= 1){
printTransportData.setDriverNumber(transportPersons.get(0).getSerialNumber());
} if (transportPersons.size() >= 2){
printTransportData.setTransportNumber1(transportPersons.get(1).getSerialNumber());
}if (transportPersons.size() >= 3){
printTransportData.setTransportNumber2(transportPersons.get(2).getSerialNumber());
}
}
//调度
String no = UserUtils.getUser().getNo();
String telNo = systemService.getUser(printTransportData.getBzDeceased().getCreateBy().getId()).getNo();
printTransportData.getBzDeceased().setGender(DictUtils.getDictLabel(printTransportData.getBzDeceased().getGender(), "sex", "")+ "_" + no + "_" + telNo);
return renderString(response, printTransportData);
}
entity实体类,增加了对应的这三个属性存值
private String driverNumber; //司机编号
private String transportNumber1;//接运1编号
private String transportNumber2;//接运2编号
2021.8.14=================
-
ajax异步请求(默认ajax请求是异步请求 async:true)和同步请求
-
一、ajax异步(默认async:true)
异步:并行处理,程序向服务器发送一个请求,在结果返回之前,程序还是可以执行其它操作(以前台界面为例,用户依然可以输入其它信息,并且和服务器进行其它交付),大大节省了用户的时间,也提高用户的体验 -
二、ajax同步(设置async:false)
同步:顺序处理,程序向服务器发送一个请求,在结果返回之前,程序要一直等待结果返回才可以执行下一步操作 -
同步是指:发送方发出数据后,等接收方发回响应以后才发下一个数据包的通讯方式。
异步是指:发送方发出数据后,不等接收方发回响应,接着发送下个数据包的通讯方式。
(注:除非有特殊要求或需求,尽量不要用同步) -
js事件绑定多个方法
<input id="printHhgl" onclick="dynamicProxy('saveNegotiationConsumelist','printHhgl','')" class="btn btn-primary ${bzDeceased.funeralType=='0'?'':'hide'}" type="button" value="打印火葬通知单"/> js事件绑定多个方法
-
for()循环,谨记第一个是,不是;
for(var i=0,len=signUnits.length;i<len;i++){
signUnitArr.push(signUnits[i].name);
}
- mysql类型decimal是数字
- 样式class三元表达式:
class="btn btn-primary ${bzDeceased.funeralType=='0'?'':'hide'}" 三元表达式
2021.8.16=================
- 在dao传参数记得加上
List<BuyOrder> getBuyOrderPrintData(@Param("id") String id, @Param("number") String number); 注解@Parma`
- 获取当前登录用户名
User user = new User();
user.setName(UserUtils.getUser().getName());
model.addAttribute("user", user);`
- 找错误的时候,除了检查报错的地方,还要查看报错上下代码是否有报错,影响到本行代码报错
2021.8.17================= - 谨记模仿源代码,写方法,多看源码,例如:findPage的源码,page到不了dao,转成了list,在service
2021.8.19================= - 导出文档
controller层
* 导出出境许可证号信息
* @param redirectAttributes
* @param response
* @param request
* @return
*/
@RequiresPermissions("certificate:bzCertificate:view")
@RequestMapping(value = "export",method = RequestMethod.POST)
public String exportFile(BzCertificate bzCertificate,RedirectAttributes redirectAttributes, HttpServletResponse response,HttpServletRequest request){
try {
String fileName = "出境许可证号信息"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
Page<BzCertificate> page = bzCertificateService.findExportData(new Page<BzCertificate>(request,response,-1),new BzCertificate());
new ExportExcel("出境许可证号信息", BzCertificate.class).setDataList(page.getList()).write(response,fileName).dispose();
return null;
} catch (IOException e) {
addMessage(redirectAttributes,"导出出境许可证号信息!失败信息:"+e.getMessage());
}
// bzCertificateService.selectTransportContentType();
return "redirect:"+ adminPath +"/business/certificate/bzCertificate/list?repage";
}
service层
public Page<BzCertificate> findExportData(Page<BzCertificate> page, BzCertificate bzCertificate) {
bzCertificate.setPage(page);
page.setList(dao.findExportData(bzCertificate));
return page;
}
dao层
List<BzCertificate> findExportData(BzCertificate bzCertificate);
}
2021.8.22=================
- 构造函数
package com.liang.day01;
///
// * 在没有定义构造方法之前, MagicBox box2 = new MagicBox(, );这种方法是可以使用的但是定义了带有参数的构造方法,发现原来的这种写法不能用了
// *在java语言中一旦定义了构造方法,系统就不会再默认构造方法
// *
// * /
public class gouzao {
public static void main(String[] args) {
MagicBox box = new MagicBox(100, 200, 300);
System.out.println("长"+box.lenght);
System.out.println("宽"+box.width);
System.out.println("高"+box.height);
MagicBox box2 = new MagicBox( );
}
}
class MagicBox {// 构造方法
public int lenght;
public int width;
public int height;
/*
定义一个构造方法,它用于对盒子进行初始化、
定义一个带有参数的方法,用于接收外界传递进来的初始化参数
构造方法没有返回值类型
构造方法的形式 public MagicBox(){
}
*/
public MagicBox(){
//系统默认提供的构造方法,只不过在用户未定义构造方法之前,这个方法是由系统提供的
//并且是不可见得,如果用户自定义了一个构造方法,并且与原来系统默认提供的构造方法一直,那么原来的构造方法失效
//一个类中可以同时存在多个构造方法,此时形成了构造方法的重载
//建议将构造方法的访问权限设置为public方便调用,同时建议保留原来默认的构造方法的写法
}
//只传递长和宽,小
public MagicBox(int lenght, int width){
// this(10,20,30); 报错
this.lenght = lenght;
this.width = width;
}
//大,三个参数,已经包含上面的两个参数
public MagicBox(int lenght, int width, int height){
// this.lenght = lenght;
// this.width = width;
//可以使用this关键字来对构造方法进行调用
//使用this去调用另一个构造方法的时候,被调用的与语句必须放在第一行
this(lenght,width);
this.height = height;
}
/*
如果一个方法的结构包含另一个构造方法的结构,那么他们之间是存在调用的关系
*/
public void print(){
//在普通方法中是无法引用构造方法的,对构造方法的引用只能出现在构造方法重
// this(); 报错
}
}
2021.8.24=================
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>出殡留炉盅箱预拨表</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
$(document).ready(function() {
//点击"清除"
$(":reset").click(function(){
var resetArr = $(this).parents("form").find(":text");
for(var i=0; i<resetArr.length; i++){
resetArr.eq(i).val("");
}
return false;
});
});
function page(n,s){
$("#pageNo").val(n);
$("#pageSize").val(s);
$("#searchForm").submit();
return false;
}
function printTable() {
<%--$("#searchForm").attr("action","${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/printCupBox");--%>
<%--$("#searchForm").submit();--%>
<%--$("#searchForm").attr("action","${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/bzCupBoxList");--%>
let beginRentDate = $("#beginRentDate").val();
let endRentDate = $("#endRentDate").val();
let serialNumber = $("#serialNumber").val();
let actualName = $("#actualName").val();
url="${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/printCupBox?beginRentDate="+beginRentDate+"&endRentDate="+endRentDate+"&bzDeceased.serialNumber="+serialNumber+"&bzDeceased.actualName="+actualName;
window.open(url);
}
</script>
</head>
<body>
<ul class="nav nav-tabs">
<li class="active"><a href="${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/getCupBox">出殡留炉盅箱预拨表</a></li>
</ul>
<form:form id="searchForm" modelAttribute="consumelistProjectRelation" action="${ctx}/bz/consumelistproject/bzConsumelistProjectRelation/getCupBox" method="post" class="breadcrumb form-search">
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<ul class="ul-form">
<li><label>死者编号:</label>
<form:input path="bzDeceased.serialNumber" id="serialNumber" htmlEscape="false" maxlength="100" class="input-medium"/>
</li>
<li><label>死者姓名:</label>
<form:input path="bzDeceased.actualName" id="actualName" htmlEscape="false" maxlength="100" class="input-medium"/>
</li>
<li><label>出殡日期:</label>
<input id="beginRentDate" name="beginRentDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
value="<fmt:formatDate value="${consumelistProjectRelation.beginRentDate}" pattern="yyyy-MM-dd"/>"
onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
-
<input id="endRentDate" name="endRentDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
value="<fmt:formatDate value="${consumelistProjectRelation.endRentDate}" pattern="yyyy-MM-dd"/>"
onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
</li>
<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
<li class="btns"><input id="btnClean" type="reset" class="btn btn-primary" value="清除"/></li>
<li class="btns"><input class="btn btn-primary" type="button" onclick="printTable();" value="打印"/></li>
<%-- <a href="javascript:;" class="btn btn-primary" onclick="printTable(this)">打印</a>--%>
</ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed" style="text-align: center">
<thead>
<tr>
<th style="text-align: center">序号</th>
<th style="text-align: center">死者编号</th>
<th style="text-align: center">死者姓名</th>
<th style="text-align: center">出殡日期</th>
<th style="text-align: center">盅箱名</th>
<th style="text-align: center">价格</th>
<th style="text-align: center">留炉或捡灰炉</th>
<th style="text-align: center">备注</th>
<%-- <shiro:hasPermission name="signunit:bzSignUnit:edit"><th>操作</th></shiro:hasPermission>--%>
</tr>
</thead>
<tbody>
<c:forEach items="${list}" var="consumelistProjectRelation" varStatus="asd">
<tr>
<td style="text-align: center">
${asd.count}
</td>
<td style="width: 150px;text-align: center">
${consumelistProjectRelation.bzDeceased.serialNumber}
</td>
<td style="width: 150px;text-align: center">
${consumelistProjectRelation.bzDeceased.actualName}
</td>
<td style="text-align: center">
<fmt:formatDate value="${consumelistProjectRelation.bzYsgl.bzYsglDate}" pattern="yyyy-MM-dd"/>
${consumelistProjectRelation.bzCbbc.gbhapBdate}
</td>
<td style="text-align: center">
${consumelistProjectRelation.name}
</td>
<td style="text-align: center">
<c:if test="${consumelistProjectRelation.unitPrice != '0' && consumelistProjectRelation.unitPrice != '0.0' }">
${consumelistProjectRelation.unitPrice}
</c:if>
</td>
<td style="text-align: center">
${consumelistProjectRelation.setmealName}
</td>
<td style="text-align: center">
${consumelistProjectRelation.lettering}
</td>
<%-- <shiro:hasPermission name="bz:consumelistproject:bzConsumelistProjectRelation:view"><td>--%>
<%-- <a href="${ctx}/business/signunit/bzSignUnit/form?id=${bzSignUnit.id}">修改</a>--%>
<%-- <a href="${ctx}/business/signunit/bzSignUnit/delete?id=${bzSignUnit.id}" onclick="return confirmx('确认要删除该签发单位吗?', this.href)">删除</a>--%>
<%-- </td></shiro:hasPermission>--%>
</tr>
</c:forEach>
</tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>
2021.8.30=================
- 根据数据,进行判断是否为空值,给出弹窗
function printTable() {
let beginDeathDate = $("#beginDeathDate").val();
let endDeathDate = $("#endDeathDate").val();
if (beginDeathDate == '' || beginDeathDate == null || endDeathDate == '' || endDeathDate == null ){
top.$.jBox.tip("请输入死亡日期区间进行查询!", 'error');
return false;
}
url="${ctx}/bz/unclaimed/printChaoqiInfo?beginDeathDate="+beginDeathDate+"&endDeathDate="+endDeathDate;
window.open(url);
}
- foreach 遍历后台数据
controller层: model.addAttribute("bzUnclaimedTel", bzUnclaimedTel);
<span>
邮寄地址:
<c:forEach items="${bzUnclaimedTel.bzUnclaimedTelAddresses}" var="bzDeceased" varStatus="asd">
邮寄地址${asd.count}:
${bzDeceased.mailingAddress}
编码和地址${asd.count}:
${bzDeceased.codeAddress}
</c:forEach>
</span>
2021.9.2=================
- 数组中的数据不能直接存取值(get、set),可以通过下标拿到数据get、set存值
printUnclaimedTelData.get(0).setNowTime(new Date());
/**
*套打遗体处理告知书(家属)
* @param bzUnclaimedTelId
* @param model
* @param request
* @param response
* @return
*/
@RequestMapping(value = "getUnclaimedTelDataF")
public String getUnclaimedTelDataF(String bzUnclaimedTelId,Model model,HttpServletRequest request,HttpServletResponse response){
List<BzUnclaimed> printUnclaimedTelData = bzUnclaimedService.getUnclaimedTelDataF(bzUnclaimedTelId);
printUnclaimedTelData.get(0).setNowTime(new Date());
if (!StringUtils.isEmpty(printUnclaimedTelData)) {
printUnclaimedTelData.get(0).setAnnouncementEndDate1(DateUtils.addDate(printUnclaimedTelData.get(0).getAnnouncementEndDate(), 1)); //使用时间工具类当前时间推后一天
printUnclaimedTelData.get(0).setGender(DictUtils.getDictLabel(printUnclaimedTelData.get(0).getGender(), "sex", ""));
BzUnclaimed amount = bzUnclaimedService.getAmount(bzUnclaimedTelId);
printUnclaimedTelData.get(0).setAmount(amount.getAmount());
}
return renderString(response, printUnclaimedTelData);
}
- 前端遍历数据
- 谨记要先设置全局变量才可以在下面获取值
//定义一个全局 var objDece = {};
//定义一个全局
var objDece = {};
function getUnclaimedTelData(bzUnclaimedTelId){
$.ajax({
type:"get",
url:"${ctx}/bz/unclaimed/tel/getUnclaimedTelData?bzUnclaimedTelId="+bzUnclaimedTelId,
dataType:'JSON',
async: false,
success: function (data){
debugger
objDece = data;
}
});
}
//遗体处理告知书套打(公安)
function printDonateManage(bzUnclaimedTelId){
getUnclaimedTelData(bzUnclaimedTelId);
for (i in objDece){ //遍历数据
}
LODOP = getLodop();
LODOP.PRINT_INIT(name + "测试打印");
LODOP.PRINT_INITA(50, 0, 2200, 1289, "");
LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4"); //A4纸 1竖版 2横版
// LODOP.ADD_PRINT_TEXT(20,80,220,30,objDece[0].mailingAddress);
// LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
// LODOP.SET_PRINT_MODE("RESELECT_ORIENT",false);
LODOP.ADD_PRINT_TEXT(25,150,400,30,objDece[0].mailingAddress);//邮寄地址
LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
- 数组越界,因为数组get值得时候没有值,所以报错
@RequiresPermissions("bz:unclaimed:view")
@RequestMapping(value = "printChaoqiInfo")
public String printChaoqiInfo(BzUnclaimed bzUnclaimed, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<BzUnclaimed> page = bzUnclaimedService.queryUnclaimed(bzUnclaimed);
if (page.getList().size() > 0 && page.getList() != null) {//这里判断是否为空,就不会报数据越界了
bzUnclaimed.setAnnouncementDate(page.getList().get(0).getAnnouncementDate());
bzUnclaimed.setAnnouncementEndDate(page.getList().get(0).getAnnouncementEndDate());
model.addAttribute("bzUnclaimed", bzUnclaimed);
model.addAttribute("page", page);
BzCountry bzCountry = new BzCountry();
List<BzCountry> list = bzCountryService.findList(bzCountry);
model.addAttribute("bzCountrys", list);
}
return "modules/bz/unclaimedRemains/printChaoqiInfo";
}
-
使用日期工具类时间日期加1
-
可以直接在model中赋值好值,直接塞给前台取
BzUnclaimed amount = bzUnclaimedService.getAmount(bzUnclaimedTelId);
printUnclaimedTelData.get(0).setAmount(amount.getAmount());
model.addAttribute("amount", amount.getAmount());//前台直接取amount即可${amount}
- 修改别人的方法,一步一步debugger看值,注意返回值
javascript 数字日期格式转换为中文
写一个函数,把数字日期如2014-06-21转换为 二零一四年六月二十一日星期三
function convert(dateStr) {
var dict = {
"0": "零",
"1": "一",
"2": "二",
"3": "三",
"4": "四",
"5": "五",
"6": "六",
"7": "七",
"8": "八",
"9": "九",
"10": "十",
"11":"十一",
"12":"十二",
"13":"十三",
"14":"十四",
"15":"十五",
"16":"十六",
"17":"十七",
"18":"十八",
"19":"十九",
"20":"二十",
"21":"二十一",
"22":"二十二",
"23":"二十三",
"24":"二十四",
"25":"二十五",
"26":"二十六",
"27":"二十七",
"28":"二十八",
"29":"二十九",
"30":"三十",
"31":"三十一"
};
var date = dateStr.split('-'),
yy = date[0],
mm = date[1],
dd = date[2];
var yearStr = dict[yy[0]] + dict[yy[1]] + dict[yy[2]] + dict[yy[3]] + '年',
monthStr = dict[''+Number(mm)] + '月',
dayStr = dict[dd];
console.log(yearStr +monthStr +dayStr);
}
convert('2014-11-22');
哇需改后
function convert(dateStr) {
var dict = {
"0": "零",
"01": "一",
"02": "二",
"03": "三",
"04": "四",
"05": "五",
"06": "六",
"07": "七",
"08": "八",
"09": "九",
"10": "十",
"11":"十一",
"12":"十二",
"13":"十三",
"14":"十四",
"15":"十五",
"16":"十六",
"17":"十七",
"18":"十八",
"19":"十九",
"20":"二十",
"21":"二一",
"22":"二二",
"23":"二三",
"24":"二四",
"25":"二五",
"26":"二六",
"27":"二七",
"28":"二八",
"29":"二九",
"30":"三十",
"31":"三一"
};
var date = dateStr.split('-'),
yy = date[0];
// mm = date[1],
// dd = date[2];
// var yearStr = dict[yy[0]] + dict[yy[1]] + dict[yy[2]] + dict[yy[3]] + '年'
return dict[date[0]];
}
取值: LODOP.ADD_PRINT_TEXT(976,529,60,30,convert(objDece[0].announcementDate.substring(2,4)));
2021.9.6=================
- set值的时候可以直接塞值不用get再传
printUnclaimedTelData.get(0).setNowTime(new Date());
printUnclaimedTelData.get(0).setGender(DictUtils.getDictLabel(printUnclaimedTelData.get(0).getGender(), "sex", ""));
- 后台传现在时间,不用字段可以直接new date赋值给值传
model.addAttribute("dateTime",new Date());
- ip电脑地址:ip:http://192.168.199.229:8085/zh_bz/a/bz/unclaimed/printNarmalClaim?beginDeathDate=2021-07-06&endDeathDate=2022-09-06
- ip:192.168.199.229:8085/zh_bz/
- ID选择器获取值:
let beginDeathDate = $("#beginDeathDate").val();
2021.9.7================= - string强转double
- Double.parseDouble方法是把数字类型的字符串,转换成double类型
Double.valueOf方法是把数字类型的字符串,转换成Double类型
- Double.parseDouble方法是把数字类型的字符串,转换成double类型
- wps生成目录
- 获取当前时间,年月日
//获取当前月份
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
model.addAttribute("year", year);
model.addAttribute("month", month);
- 后台遍历获取合计总金额
//计算合计总额
Double money = 0.0;
for (BzUnclaimed bzUnclaimed1 : list) {
String amount = bzUnclaimed1.getAmount();
money += Double.valueOf(amount);
}
- 前台根据后台值,判断
${year}年
第
<c:if test="${1<=month && month<=3}">一</c:if>
<c:if test="${4<=month && month<=6}">二</c:if>
<c:if test="${7<=month && month<=9}">三</c:if>
<c:if test="${10<=month && month<=12}">四</c:if>
季度无人认领遗体处理费申请表二
controller层
/**
* 打印非正常处理的无人认领遗体数据
*
* @param bzUnclaimed
* @param model
* @param response
* @param request
* @return
*/
@RequiresPermissions("bz:unclaimed:view")
@RequestMapping("printImproperUnclaimed")
public String printImproperUnclaimed(BzUnclaimed bzUnclaimed, Model model, HttpServletResponse response, HttpServletRequest request) {
List<BzUnclaimed> list = bzUnclaimedService.getUnclaimedListsMoreThan(bzUnclaimed);
model.addAttribute("list", list);
//计算合计总额
Double money = 0.0;
for (BzUnclaimed bzUnclaimed1 : list) {
String amount = bzUnclaimed1.getAmount();
money += Double.valueOf(amount);
}
model.addAttribute("money", money);
//获取当前月份
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
model.addAttribute("year", year);
model.addAttribute("month", month);
return "modules/bz/unclaimedRemains/printImproperUnclaimed";
}
2021.9.8=================
- 可以使用类名点类里面的静态方法来调用它
- 数字时间转大写
//日期转中文,转成字符串,再转大写 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); String beforedate = sdf.format(new Date());
//日期转中文
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String beforedate = sdf.format(new Date());
if (beforedate != null) {
String enddate = SmallBig.dataToUpper(beforedate);
model.addAttribute("enddate", enddate);
}
工具类
package com.thinkgem.jeesite.modules.bz.utils.data;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class SmallBig {
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
String beforedate=sdf.format(new Date());
System.out.println("转换之前:"+beforedate);
String enddate=dataToUpper(beforedate);
System.out.println("转换之后:"+enddate);
}
//日期转化为大小写
public static String dataToUpper(String dateString) throws Exception {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date dateTime = null;
try {
dateTime = simpleDateFormat.parse(dateString);
} catch (Exception e) {
e.printStackTrace();
}
Calendar ca = Calendar.getInstance();
ca.setTime(dateTime);
int year = ca.get(Calendar.YEAR);
int month = ca.get(Calendar.MONTH) + 1;
int day = ca.get(Calendar.DAY_OF_MONTH);
return numToUpper(year) + "年" + monthToUppder(month) + "月" + dayToUppder(day) + "日";
}
// 将数字转化为大写(字体格式可自己定义)
public static String numToUpper(int num) {
String u[] = {"〇","一","二","三","四","五","六","七","八","九"};
char[] str = String.valueOf(num).toCharArray();
String rstr = "";
for (int i = 0; i < str.length; i++) {
rstr = rstr + u[Integer.parseInt(str[i] + "")];
}
return rstr;
}
// 月转化为大写
public static String monthToUppder(int month) {
if(month < 10) {
return numToUpper(month);
} else if(month == 10){
return "十";
} else {
return "十" + numToUpper(month - 10);
}
}
// 日转化为大写
public static String dayToUppder(int day) {
if (day < 20) {
return monthToUppder(day);
} else {
char[] str = String.valueOf(day).toCharArray();
if (str[1] == '0') {
return numToUpper(Integer.parseInt(str[0] + "")) + "十";
} else {
return numToUpper(Integer.parseInt(str[0] + "")) + "十" + numToUpper(Integer.parseInt(str[1] + ""));
}
}
}
}
- html计算页面数据条数
记录数据数量:<input id="pageSize" name="pageSize" type="button" readonly="readonly" style="color: red;float: right"
value="条数:${page.pageSize}"/>
- 判断是否相等
//删除
if ("1".equals(delStatus)) {
unclaimedDao.delUnclaimedAddress(id);
}
- 多判断,不为空才进去方法,防止空指针
if (!StringUtils.isEmpty(bzUnclaimedService.getUnclaimedListsSummaryApplicationLessThan(bzUnclaimed))) {
BzUnclaimed bzUnclaimed1 = bzUnclaimedService.getUnclaimedListsSummaryApplicationLessThan(bzUnclaimed);
model.addAttribute("bzUnclaimed1", bzUnclaimed1);
}
- 当类型不对的时候报错,service和controller比如接收是实体对象,dao的是list,可以在service通过list.size(0)拿第一条数据
- 类型就不会报错了,拿到list数组的时候记得判断一下是否数组有值,防止数组下标越界报错
return unclaimedDao.getUnclaimedListsSummaryApplicationLessThan(bzUnclaimed).get(0);
if (unclaimedDao.getUnclaimedListsSummaryApplicationLessThan(bzUnclaimed).size()>0){
return unclaimedDao.getUnclaimedListsSummaryApplicationLessThan(bzUnclaimed).get(0);
}
2021.9.9=================
- jq通过id绑定,获取数据添加样式隐藏
- jq: $(“#id”).css(‘display’,‘none’);
- js: document.getElementById(“ffzm”).innerHTML; //获得 div 里的所有 html 数据
jq绑定id,隐藏id当前内容
function printPage(){
$("#sf").css('display','none');
$("#sf1").css('display','none');
$("#fp").css('display','none');
$("#searchForm").css('display','none');
window.print();
}
function printTable() {
var printData = document.getElementById("ffzm").innerHTML; //获得 div 里的所有 html 数据
window.document.body.innerHTML = printData;
window.print();
// window.document.body.innerHTML = printData;
}
2021.9.10=================
-
什么是泛型?
-
(泛型:
而在new对象时,以栈里只能存放整形为例,前面的尖括号必须写基本数据类型对应的包装类,而后面的尖括号可以不用写,示例如下:
Stack stack = new Stack<>();)
-html标签:< a href="javascript:history.go(-1)" class="Btnprint" style="font-weight: bolder;font-size: 18px">返回上一步</ a>
-
<style media="print"> @page { size: auto; margin: 0 auto; } .Btnprint { display:none; } </style>
-
选择框
<%-- <td>--%>
<%-- <input type="checkbox" class="bzRentVehicleID" value="${bzRetrieval.id}" style="display: inline-block; width:20px;height: 20px;">--%>
<%-- </td>--%>
<%-- <th><input type="checkbox" id="checkAll" style="display: inline-block; width:20px;height: 20px;"></th>--%>
2021.9.14=================
- 前端通过判断后台传过来的数组判断是否有值
<c:if test="${fn:length(list) eq 0}">
<tr><td style="text-align: center;" colspan="12">暂无火化遗体交接信息</td></tr>
</c:if>
<c:if test="${fn:length(list) > 0}">
<c:forEach var="obj" items="${list}">
<tr>
<td>
${obj.bzLfglName}
</td>
<td>
${obj.bzDeceasedId.serialNumber }
</td>
<td>
${obj.bzDeceasedId.actualName}
</td>
<td>
${fns:getDictLabel(obj.bzDeceasedId.gender, 'sex', '')}
</td>
<td>
${obj.bzDeceasedId.age}
</td>
<td>
${obj.gmType}
</td>
<td>
${obj.cbsj}
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</c:forEach>
</c:if>
- Mybatis—动态查询(choose,when,otherwise)
-
if标签是与(and)的关系,而 choose 是或(or)的关系
-
choose标签是按顺序判断其内部when标签中的test条件出否成立,如果有一个成立,则 choose 结束。当 choose 中所有 when 的条件都不满则时,则执行 otherwise 中的sql。
-
java try catch补抓异常
try catch补抓异常
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
bzConsumelistProjectRelation.getBzYsgl().setBeginBzYsglDate(sdf.parse(beginBzYsglDate));
bzConsumelistProjectRelation.getBzYsgl().setEndBzYsglDate(sdf.parse(endBzYsglDate));
} catch (ParseException e) {
e.printStackTrace();
logger.error("查询两万打印数据时,日期转换异常[printMoreTwentyThousand]--------->"+e.getMessage());
}
- java后台计算
java后台计算:
BigDecimal totalAmount = BigDecimal.ZERO;
if(relations != null && relations.size() > 0){//首先判断数组不为空
for(BzConsumelistProjectRelation relation:relations){
if(StringUtils.isNotEmpty(relation.getTotalAmount())){//再判断get的值不为空,防止空指针
totalAmount = totalAmount.add(new BigDecimal(relation.getTotalAmount()));
}
}
controller层
@RequiresPermissions("bz:consumelistproject:bzConsumelistProjectRelation:view")
@RequestMapping(value = "printMoreTwentyThousand")
public String printMoreTwentyThousand(String beginBzYsglDate,String endBzYsglDate,String serialNumber,BzConsumelistProjectRelation bzConsumelistProjectRelation, HttpServletRequest request, HttpServletResponse response, Model model) {
if(bzConsumelistProjectRelation.getBzYsgl() == null){
BzYsgl bzYsgl = new BzYsgl();
bzConsumelistProjectRelation.setBzYsgl(bzYsgl);
}
if(bzConsumelistProjectRelation.getBzDeceased() == null){
BzDeceased bzDeceased = new BzDeceased();
bzConsumelistProjectRelation.setBzDeceased(bzDeceased);
}
bzConsumelistProjectRelation.getBzDeceased().setSerialNumber(serialNumber);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
bzConsumelistProjectRelation.getBzYsgl().setBeginBzYsglDate(sdf.parse(beginBzYsglDate));
bzConsumelistProjectRelation.getBzYsgl().setEndBzYsglDate(sdf.parse(endBzYsglDate));
} catch (ParseException e) {
e.printStackTrace();
logger.error("查询两万打印数据时,日期转换异常[printMoreTwentyThousand]--------->"+e.getMessage());
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy年MM月dd日");
Map<String,Object> map = bzConsumelistProjectRelationService.printMoreTwentyThousand(bzConsumelistProjectRelation);
model.addAttribute("list", map.get("relations"));
model.addAttribute("count", map.get("count"));
model.addAttribute("totalAmount",map.get("totalAmount"));
model.addAttribute("beginBzYsglDate", simpleDateFormat.format(bzConsumelistProjectRelation.getBzYsgl().getBeginBzYsglDate()));
model.addAttribute("endBzYsglDate", simpleDateFormat.format(bzConsumelistProjectRelation.getBzYsgl().getEndBzYsglDate()));
return "modules/bz/consumelistproject/bzPrintQueryConsumelistProjectRelationList";
}
service层
public Map<String,Object> printMoreTwentyThousand(BzConsumelistProjectRelation bzConsumelistProjectRelation) {
Map<String,Object> map = new HashedMap();
List<BzConsumelistProjectRelation> relations = dao.queryConsume(bzConsumelistProjectRelation);
map.put("relations",relations);
map.put("count", relations.size());
BigDecimal totalAmount = BigDecimal.ZERO;
if (relations != null && relations.size()>0){
for (BzConsumelistProjectRelation relation : relations){
if (StringUtils.isNotBlank(relation.getAllTotalPrice())){
totalAmount = totalAmount.add(new BigDecimal(relation.getAllTotalPrice()));
}
}
}
map.put("totalAmount",totalAmount);
return map;
}
存值:bzConsumelistProjectRelation.getBzDeceased().setSerialNumber(serialNumber);
分页service:Page<BzConsumelistProjectRelation> page,
2021.9.15==============- id选择器获取值
1、class 通过id获取到,增加或移除他的class元素
$("#ages").removeClass('hide');
$("#age").addClass('required');
<span id="ages" class="hide"><font color="red">*</font> </span>
2、css
$("#commissionPhones").css('display','none');隐藏
$("#commissionNames").css('display','inline');显示
<span id="ages" style="display: none"><font color="red">*</font> </span>
- class=“active”:不要高亮
- 清除redis缓存
- 首先打开一个redis窗口启动redis
- 再打开一个redis窗口,redis-cli启动
- 输入auth输入自己的密码登录
- 最后flushall回车即可
2021.9.16==============
- 批量打印,选择多条或一条或者全部
页面初始化的时候调用
//点击全部选中、取消选中
$("#checkAll").click(function (){
$(".unclaimedId").attr("checked",this.check);//unclaimedId是单选框的id
})
单选框
<td>
<input name="input_id" class="unclaimedId" type="checkbox" value="${bzDeceased.id}"style="display: inline-block; width:20px;height: 20px;">
</td>
点击打印,触发函数事件
//打印无人认领费用清册
function printChargeList(){
// alert("打印方法");
var arr = new Array(); //定义一个arr数组,来接收多个id,封装好传到后台
if ($(".unclaimedId:checked").length == 0){
$.jBox.alert('请至少选择一条数据打印');
return false;
}else {
//获取需要打印的数据
$(".unclaimedId:checked").each(function (){
if ($(this).attr("checked") == "checked"){
arr.push($(this).val());//把发现的值找出来传到数组里面
}
})
var url = "${ctx}/bz/unclaimed/getChargeListData?ids="+arr;
window.open(url);
}
}
controller层
/**
* 打印收费清册需要的数据
* @param ids
* @param response
* @param request
* @param model
* @return
*/
@RequiresPermissions("bz:unclaimed:view")
@RequestMapping(value = "getChargeListData")
public String getChargeListData(String[] ids,HttpServletResponse response,HttpServletRequest request,Model model){//定义一个string[]数组来接收前端传过来的id数组值
List<BzUnclaimed> list = bzUnclaimedService.getChargeListData(ids);
model.addAttribute("list", list);
return "modules/bz/unclaimedRemains/printChargeList";
}
service层
public List<BzUnclaimed> getChargeListData(String[] ids) {
List<String> list = new ArrayList<>();//定义一个list集合来接收数组id
List<BzUnclaimed> list1 = new ArrayList<>();//再定义一个list集合来接收查询返回的数据
try {
if(ids != null && ids.length >0){
list = Arrays.asList(ids);//该方法是将数组转化成List集合的方法。
list1 = dao.getChargeListData(list);
}
}catch (Exception e){
e.printStackTrace();
}
return list1;//返回查询出来的数据给controller
dao层
List<BzUnclaimed> getChargeListData(List<String> list);
xml层(list是封装好的list集合)
SELECT
bdu.id,
bdu.death_date,
bdu.serial_number,
bdu.actual_name,
bdu.gender,
bdu.age,
bdu.collect_site,
bdu.death_number,
bd.country as country,
bd.nation as nation,
bc.name AS countryName
FROM
bz_deceased_unclaimed bdu
LEFT JOIN bz_deceased bd ON bdu.id = bd.id
LEFT JOIN bz_country bc ON bd.country = bc.id
WHERE
1=1
and
bdu.del_flag = '0'
and
<if test="list.size()>0">
bdu.id in
<foreach collection="list" separator="," item="id" open="(" close=")">
#{id}
</foreach>
</if>
}
- sql遍历数组id
<if test="list.size()>0">
bdu.id in
<foreach collection="list" separator="," item="id" open="(" close=")">
#{id}
</foreach>
</if>
2021.9.22==============
<input class="btn btn-primary" type="button" onclick="printOneClickapprovalCount()" value="审批表打印(汇总)"/>
//公告审批表(汇总)
function oneClickapprovalCount(){
debugger
var arr = new Array();
if ($(".unclaimedId:checked").length == 0){
$.jBox.alert('请至少选择一条数据打印');
return false;//return false只是在这个方法结束,函数在下面依然执行,所以也要在下面函数方法中,return false
}else {
//获取需要打印的数据
$(".unclaimedId:checked").each(function () {
if ($(this).attr("checked") == "checked") {
arr.push($(this).val());
}
});
<%--var url = "${ctx}/bz/unclaimed/getprintOther?ids="+arr;--%>
<%--window.open(url);--%>
$.ajax({
type:"get",
url:"${ctx}/bz/unclaimed/oneClickapprovalCount?ids="+arr,
dataType:'json',
async:false,
success(data){
objDece = data;
}
})
}
function printOneClickapprovalCount() {
var i = oneClickapprovalCount();
if (i == false){
return false;
}//定义一个i变量,在这里判断i等于false,就结束,不继续进行下去
LODOP = getLodop();
LODOP.PRINT_INITA(50,0,2100,2970,"");
LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE",1);
LODOP.ADD_PRINT_TEXT(45,219,460,58,"无人认领遗体信息公告审批表");
LODOP.SET_PRINT_STYLEA(0,"FontSize",24);
LODOP.ADD_PRINT_TEXT(143,103,190,30,"服务质量控制部:");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(202,154,510,30,"根据《广州市无人认领遗体处理办法》(穗府办规【2017】");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(242,107,290,30,"8号)相关规定,我部拟对编号为");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(280,108,414,30,"人认领遗体进行处理前公告;其中正常公告遗体");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(320,108,324,30,"件1),涉外、涉港澳台无人认领遗体");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(540,154,341,30,"附件1:无人认领遗体信息公告情况表");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(700,491,108,30,"殡仪二部");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(750,490,28,30,"年");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(750,560,29,30,"月");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(750,635,33,30,"日");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(242,396,125,30,objDece.serialNumber);
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(242,518,49,30,"等共");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(242,564,34,30,objDece.counts + objDece.counts1 + objDece.counts2);
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(243,598,66,30,"具无");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(280,525,43,30,objDece.counts);
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(280,571,92,30,"具(附");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(320,436,30,30,objDece.counts1);
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(321,495,172,30,"(附件2),部分");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(320,468,26,30,"具");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(362,108,358,30,"信息不全(含国籍或民族)无人认领遗体");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(362,465,30,30,objDece.counts2);
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(363,495,161,30,"具(附件3)。上");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(400,107,572,30,"述情况详见附表。现将以上拟公告的无人认领遗体情况呈报中心,");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(440,107,93,30,"请审批。");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(578,154,489,30,"附件2:涉外、涉港澳台无人认领遗体信息公告情况表");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(615,154,478,30,"附件3:部分信息不全(含国籍或民族)无人认领遗体");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(653,103,169,30,"信息公告情况表");
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(750,440,55,30,objDece.dateTime.substring(0,4));
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(750,522,30,30,objDece.dateTime.substring(5,7));
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.ADD_PRINT_TEXT(750,593,30,30,objDece.dateTime.substring(8,10));
LODOP.SET_PRINT_STYLEA(0,"FontSize",14);
LODOP.PRINT_DESIGN();
// LODOP.PREVIEW(); //打印预览
}
2021.9.23=================
cssdiv置底:position:fixed; bottom:0;
- Map的使用:
Map<String, Object> resultMap = Maps.newHashMap(); resultMap.put("bzHhgl", bzHhglService.get(bzGhxxBusiness.getBzHhgl()));
- equals的使用:
/**
* 修改认领状态
*
* @param bzUnclaimed 认领对象
* @param redirectAttributes
* @return
*/
@RequestMapping("/updateUnclaimedStatus")
public String updateUnclaimedStatus(BzUnclaimed bzUnclaimed, RedirectAttributes redirectAttributes) {
String flag = "1".equals(bzUnclaimedService.updateUnclaimedStatus(bzUnclaimed)) ? "保 存 成 功" : "保 存 失 败";
addMessage(redirectAttributes, flag);
return "redirect:" + Global.getAdminPath() + "/bz/unclaimed/getChaoqiList/?repage";
}
2021.9.26=================
- 数据多次传id的时候,传过去的的id和查的id不一致,最后发现是xml的id写死了,无传什么数据都是同一条数据
SELECT
b.id as "bzRentVehicleId"
FROM
bz_negotiation_consumelist a
LEFT JOIN bz_consumelist_project_relation c ON c.consumelist_id = a.id
LEFT JOIN bz_rent_vehicle b ON b.bz_consumelist_project_relation_id = c.id
WHERE
a.id = '738f92a445b14c8f92a7af0d991e2990' -- 此处应该是前端传过来的id #{sjid}
AND a.del_flag = 0
AND b.del_flag = 0
AND c.del_flag = 0
- jsp判断
<c:if test="${businessFlag.businessFlag eq '9'}">
- isNotEmpty(str)等价于 str != null && str.length > 0
isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length > 0
同理
isEmpty 等价于 str == null || str.length == 0
isBlank 等价于 str == null || str.length == 0 || str.trim().length == 0
str.length > 0 && str.trim().length > 0 —> str.length > 0 - 注意左联表on的条件,每次根据不同id查出的数据是不一样的
--根据bz_consumelist_project_relation_id消费清单查就是唯一的,一开始根据死者id联表查出了多条数据
SELECT b.id AS "bzRentVehicleId"
FROM bz_negotiation_consumelist a
LEFT JOIN bz_consumelist_project_relation c ON c.consumelist_id = a.id
LEFT JOIN bz_rent_vehicle b ON b.bz_consumelist_project_relation_id = c.id
WHERE a.id = '381d76cc8cac4543ac30c10cf53e8cbd'
AND a.del_flag = 0
AND b.del_flag = 0
AND c.del_flag = 0
三目表达式:${bzDeceasedStatistics.businessNumber==null?'0':bzDeceasedStatistics.businessNumber}
- equals
("1".equals(bzUnclaimed.getSolveStatus()))
2021.9.28================= - 因为在控制层传递了多个参数,导致编写xml文件的时候无法识别到dbname报错,在dbname前加上实体表明引用对应的参数即可
<if test="jxcContract.dbName == 'oracle'">'%'||#{jxcContract.contractNum}||'%'</if>
controller层
@RequiresPermissions("contract:jxcContract:view")
@RequestMapping(value = {"list", ""})
public String list(JxcContract jxcContract, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<JxcContract> page = jxcContractService.findPage(new Page<JxcContract>(request, response), jxcContract);
model.addAttribute("page", page);
return "modules/jxc/contract/jxcContractList";
}
service层
public Page<JxcContract> findPage(Page<JxcContract> page, JxcContract jxcContract) {
List<JxcContract> jxcContractDatas = dao.getJxcContractDatas(jxcContract, UserUtils.getUser().getOffice().getId());
for (JxcContract contract : jxcContractDatas) {
Office office = officeDao.get(contract.getContractUnit() == null ? "" : contract.getContractUnit());
if (!StringUtils.isEmpty(office)) {
contract.setOffice(office);
}
contract.setStartDate(contract.getStartDate().substring(0, 10));
contract.setEndDate(contract.getEndDate().substring(0, 10));
}
page.setCount(jxcContractDatas.size());
page.setList(jxcContractDatas);
return page;
}
dao层
List<JxcContract> getJxcContractDatas(@Param("jxcContract") JxcContract jxcContract, @Param("officeId") String officeId);
xml层
<select id="getJxcContractDatas" resultType="com.thinkgem.jeesite.modules.jxc.entity.contract.JxcContract">
SELECT
a.id AS "id",
a.contract_num AS "contractNum",
a.contract_unit AS "contractUnit",
a.contract_money AS "contractMoney",
a.contract_context AS "contractContext",
a.start_date AS "startDate",
a.end_date AS "endDate",
a.create_by AS "createBy.id",
a.create_date AS "createDate",
a.update_by AS "updateBy.id",
a.update_date AS "updateDate",
a.del_flag AS "delFlag",
a.remarks AS "remarks"
FROM
jxc_contract a
WHERE
a.del_flag = '1'
<if test='officeId != "2" and officeId != "9ee0da697e72421d9dbed3aa5b87a441" '>
and a.contract_unit = #{officeId}
</if>
<if test="jxcContract.contractNum != null and jxcContract.contractNum != ''">
AND a.contract_num LIKE
<if test="jxcContract.dbName == 'oracle'">'%'||#{jxcContract.contractNum}||'%'</if>
<if test="jxcContract.dbName == 'mssql'">'%'+#{jxcContract.contractNum}+'%'</if>
<if test="jxcContract.dbName == 'mysql'">concat('%',#{jxcContract.contractNum},'%')</if>
</if>
ORDER BY
a.update_date DESC
LIMIT 30;
</select>
- @Param注解
作用:用注解来简化xml配置的时候(比如Mybatis的Mapper.xml中的sql参数引入),@Param注解的作用是给参数命名,参数命名后就能根据名字得到参数值,正确的将参数传入sql语句中(一般通过#{}的方式,${}会有sql注入的问题)。
2021.10.9=================
事务回滚
事务是一组组合成逻辑工作单元的操作,虽然系统中可能会出错,但事务将控制和维护事务中每个操作的一致性和完整性。
- DML(insert、update、delete)
- mysql commit提交事务确认后,才能对真实的表数据进行改变。
- 事务回滚(rollback)
失败的结束,将所有的DML语句操作历史记录全部清空。 - “start transaction”语句开启事务。
- 注意:如果事务中所有sql语句执行正确则需要自己手动提交commit;否则有任何一条执行错误,需要自己提交一条rollback,这时会回滚所有操作,而不是commit会给你自动判断和回滚。
- update student set Sname = ‘中国’ WHERE SId = ‘01’
update 表名 set 字段 = 新值 where 条件
Linux常用命令
- 如果mysql数据库需要导入数据表命令如下:
命令: source /xxx/xxxx/xxxx/jt.sql;
2.mysql启动命令 [root@localhost src]# systemctl start mariadb
3.ls查看当前目录下有的东西
4.cd 进入下一个目录
5.pwd 当前目录所在的位置路径
6.java -jar 8091.jar &运行项目
7.查询java服务,命令: jps
8.杀死进程:kill PID号 kill -9 PID号强制关闭
9.创建脚本:命令: vim start.sh
10.启动脚本:sh start.sh
11.日志查看命令:ctrl+c 结束查看;more 输出文档所有的内容,分页输出,空格浏览下一屏,q退出;cat 输出文件所有的内容;tail 用于显示文件后几行,使用频繁;
tail -10 nginx.conf 查看nginx.conf的最后10行
12.解压压缩文件:tar -xvf 压缩包
13.删除安装文件:rm -f nginx-1.21.3.tar.gz - mv nginx-1.19.4 nginx-source
15.关闭任意服务: ps -ef |grep 服务名称(nginx)
16.开放端口之后,记得重启防火墙
- 数据结构: 数据结构是指相互之间存在着一种或多种关系的数据元素的集合和该集合中数据元素之间的关系组成 。
常用的数据结构有:数组,栈,链表,队列,树,图,堆,散列表等
数据结构
数据结构是计算机存储、组织数据的方式。数据结构是指相互之间存在一种或多种特定关系的数据元素的集合。通常情况下,精心选择的数据结构可以带来更高的运行或者存储效率。数据结构往往同高效的检索算法和索引技术有关。
- 数据结构: 数据结构是指相互之间存在着一种或多种关系的数据元素的集合和该集合中数据元素之间的关系组成 。
常用的数据结构有:数组,栈,链表,队列,树,图,堆,散列表等 - 栈的特点是:先进后出,取出元素叫出栈,放入元素叫入栈
- 队列:先进先出,取出元素叫出队,反之叫入队
- 链表:链表是物理存储单元上非连续的、非顺序的存储结构,数据元素的逻辑顺序是通过链表的指针地址实现(单链表、双向链表、循环链表),添加删除很快
2021.10.15==============
- 文档导出
jsp
//已挂账查询导出
function exportAccount(){
var arr = new Array();
if ($(".unclaimedId:checked").length == 0){
$.jBox.alert("请至少选择一条数据导出!")
return false;
}else {
//获取到当前CheckBox选择到的id
$(".unclaimedId:checked").each(function (){
if ($(this).attr("checked") == "checked"){
arr.push($(this).val());
}
});
window.location.href ="${ctx}/bz/unclaimed/clearance/exportAccount?ids=" + arr;
}
}
controller层
@RequestMapping("/exportAccount")
public String exportFile(BzUnclaimedClearance bzUnclaimedClearance, String[] ids,RedirectAttributes redirectAttributes, HttpServletRequest request, HttpServletResponse response) {
// try {
// String fileName = "无人认领已收敛信息" + DateUtils.getDate("yyyyMMdd") + ".xlsx";
// List<BzUnclaimedClearance> list = bzUnclaimedClearanceService.printquery(bzUnclaimedClearance,ids);
// new ExportExcel("无人认领已收敛信息统计表", BzUnclaimedClearance.class).setDataList(list).write(response,fileName).dispose();
// return null;
// }catch (IOException a){
// addMessage(redirectAttributes,"导出无人认领已收敛信息!失败信息"+ a.getMessage());
// }
// return "redirect:" + Global.getAdminPath() + "/bz/unclaimed/queryUnclaimedConvergence?repage";
//需要导出的数据
List<BzUnclaimedClearance> bzUnclaimedClearances = bzUnclaimedClearanceService.getprintnAccount(ids);
//日期格式
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//创建新的来存导出数据的实体类
List<BzUnclaimedExportAccount> bzUnclaimedExportAccounts = new ArrayList<>();
//遍历查出来的数据
if(bzUnclaimedClearances.size()>0 && bzUnclaimedClearances != null){
Integer i = 1;
for (BzUnclaimedClearance u : bzUnclaimedClearances){
//创建新的对象来存值
BzUnclaimedExportAccount b = new BzUnclaimedExportAccount();
//判断不为空的话就赋值给他
if (u.getSerialNumber()!=null){
b.setSerialNumber(u.getSerialNumber());
}
if (u.getActualName()!=null){
b.setActualName(u.getActualName());
}
if (u.getClearanceName()!=null){
b.setClearanceName(u.getClearanceName());
}
if (u.getTransportContact()!=null){
b.setTransportContact(u.getTransportContact());
}
if (u.getUnitName()!=null){
b.setUnitName(u.getUnitName());
}
if(u.getDocumentsNo()!=null){
b.setDocumentsNo(u.getDocumentsNo());
}
if (u.getAmount()!=null){
b.setAmount(u.getAmount());
}
if (u.getClassificationDate()!=null){
b.setClassificationDate(dateFormat.format(u.getClassificationDate()));
}
if (u.getDeathDate()!=null){
b.setDeathDate(dateFormat.format(u.getDeathDate()));
}
if (u.getActualFuneralDate()!=null){
b.setActualFuneralDate(dateFormat.format(u.getActualFuneralDate()));
}
if (u.getSkeletonType()!=null){
b.setSkeletonType(u.getSkeletonType());
}
if (u.getManualNum()!=null){
b.setManualNum(u.getManualNum());
}
if (u.getPaymentDate()!=null){
b.setPaymentDate(dateFormat.format(u.getPaymentDate()));
}
//序号
b.setNumber(i.toString());
i++;
//存入集合里面
bzUnclaimedExportAccounts.add(b);
}
}
String fileName = "无人认领已挂账信息" + DateUtils.getDate("yyyyMMdd") + ".xlsx";
String[] titleName = {"无人认领已挂账信息统计表"};
String[] sheetName = {"无人认领已挂账信息统计表"};
ExportMultiExcel exportMultiExcel = new ExportMultiExcel(titleName, sheetName, BzUnclaimedExportAccount.class);
//给导出页面赋值
exportMultiExcel.setDataList(bzUnclaimedExportAccounts);
try {
exportMultiExcel.write(response,fileName).dispose();
}catch (IOException e){
addMessage(redirectAttributes,"导出无人认领已挂账信息!失败信息"+e.getMessage());
e.printStackTrace();
}
return null;
}
service层
public List<BzUnclaimedClearance> getprintnAccount(String[] ids) {
List<BzUnclaimedClearance> list1 = new ArrayList<>();
try {
if (ids != null && ids.length > 0) {
List<String> list = Arrays.asList(ids);//该方法是将数组转化成list集合
list1 = dao.getprintnAccount(list);
}
} catch (Exception e) {
e.printStackTrace();
}
return list1;
}
实体类层
/**
* @author lwh
* 无人认领已挂账导出
*/
public class BzUnclaimedExportAccount extends DataEntity<BzUnclaimedExportAccount> {
@ExcelField(title ="序号", align = 2, sort = 1)
private String number;
@ExcelField(title ="死者编号", align = 2, sort = 2)
private String serialNumber;
@ExcelField(title ="死者姓名", align = 2, sort = 3)
private String actualName;
private String sex;
private String age;
//清仓名称
@ExcelField(title ="清仓名称", align = 2, sort = 4)
private String clearanceName = "无人认领";
//接运联系
@ExcelField(title ="接运联系", align = 2, sort = 5)
private String transportContact;
//单位名称
private String unitName;
@ExcelField(title ="收费单据号", align = 2, sort = 6)
private String documentsNo;
@ExcelField(title ="单据金额", align = 2, sort = 7)
private BigDecimal amount = BigDecimal.ZERO;
//分类日期
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ExcelField(title ="分类日期", align = 2, sort = 8)
private String classificationDate;
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ExcelField(title ="死亡日期", align = 2, sort = 9)
private String deathDate;
private String deathPlace;
//实际殡葬日期
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@ExcelField(title ="实际殡葬日期", align = 2, sort = 10)
private String actualFuneralDate;
//尸骨类别
@ExcelField(title ="尸骨类别", align = 2, sort = 11)
private String skeletonType;
//经办人
@ExcelField(title ="经办人工号", align = 2, sort = 12)
private String manualNum;
//结算日期
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@ExcelField(title ="收款日期", align = 2, sort = 13)
private String paymentDate;
//出殡日期
private Date startDate;
private Date endDate;
//死亡开始结束日期
private Date startDeathDate;
private Date endDeathDate;
//开始结束收款日期
private Date startPaymentDate;
private Date endPaymentDate;
//单位编号
private String unitNo;
//总金额
private BigDecimal amountSum;
//委办单位编号`在这里插入代码片`
private String commissionUnitNo;
//结算单据号
private String settleMentNo;
//经办日期
private Date negotiationTime;
-
window.location.href = url; 打开当前路径
-
window.open(url);打开新窗口
2021.10.18==============
- mybatis动态sql
- 实体判断的时候,如果实体里面的属性可以 无需判断实体是否为空,如果实体里面注入了其他实体,直接判断其实体是否为空就行,不用用原来的实体点他获取值,因为他是属于实体的属性可以直接判断
- 在后台塞值的时候先判断是否为空,空的话就塞值,不为空就不用塞值,默认值就行
<choose>
<when test="beginTransportDate != null and beginTransportDate !='' and endTransportDate != null and endTransportDate !=''">
and (DATE_FORMAT(a.transport_date, '%Y-%m-%d') between DATE_FORMAT(#{beginTransportDate}, '%Y-%m-%d') and DATE_FORMAT(#{endTransportDate}, '%Y-%m-%d'))
</when>
<otherwise>
<if test="beginTransportDate != null and beginTransportDate !=''">
and DATE_FORMAT(a.transport_date, '%Y-%m-%d') = DATE_FORMAT(#{beginTransportDate}, '%Y-%m-%d')
</if>
<if test="endTransportDate != null and endTransportDate !=''">
and DATE_FORMAT(a.transport_date, '%Y-%m-%d') = DATE_FORMAT(#{endTransportDate}, '%Y-%m-%d')
</if>
</otherwise>
</choose>
------------------------------------------------------------------------2021年10月26日-----
- 下拉框,在controller注入service
controller层
//收敛单位查询
BzSignUnit bzSignUnit = new BzSignUnit();
List<BzSignUnit> bzConvergences = bzSignUnitService.findList(bzSignUnit);
model.addAttribute("bzConvergences",bzConvergences);
jsp页面
<div class="control-group">
<label class="control-label">捐献单位:</label>
<form:select path="donateUnit" htmlEscape="false" maxlength="60" autocomplete="off" class="input-xlarge required">
<form:option value="" label="" />
<form:options items="${bzConvergences}" itemLabel="name" itemValue="name" htmlEscape="false"/>
</form:select>
<span class="help-inline"><font color="red">*</font> </span>
</div>
if ("17".equals(relation.getBusinessFlag()) || "1".equals(relation.getDelFlag())){
------------------------------------------------------------------------2021年11月1日-----
1 . 时间转成自己想要的格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
String deathTime = sdf.format(bzDeceased.getDeadDate());
resultMap.put("DeadDate",deathTime);
2 . 前端判断不为空就进去<td> <c:if test="${not empty bzDeceased.commission}">${bzDeceased.commission.commissionPhone }</c:if></td>
3 . 下拉框选择并传值
<li><label>业务分类:</label>
<form:select path="serviceType" class="input-medium">
<form:option value="" label=""/>
<form:options items="${fns:getDictList('service_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:select>
</li>
- 通过判断改变当前onclick点击事件,通过this传当前值,在方法内定义一个属性值接收。val获取,()后面加内容就是更改他的值,不加就算获取他的值,获取对象是不用"#"的,直接$(属性).val()获取即可
<input style="margin-top: 5px" class="btn btn-primary" type="button" onclick="printTableData(this)" value="隐藏消费协议书" />
//隐藏协议书打印
var i = 1;
function printTableData(obj){
if(i == 1){
$("#xys").css('display','none');
$(obj).val('显示消费协议书');
i = 2;
}else if(i == 2){
$("#xys").css('display','');
$(obj).val('隐藏消费协议书');
i =1;
}
------------------------------------------------------------------------2021年11月3日-----
面试题
线程不安全
- synchronized(同步方法 同步代码块)
内置锁也叫互斥锁,可以保证线程的原子性,当线程进入方法时,会自动获得一个锁,一旦锁被获得,其他线程必须等待获得锁的线程执行完代码释放锁,会降低程序的执行效率 - ThreadLocal
为每个线程提供局部变量,解决线程安全问题 - Get和Post在面试中一般都会问到,一般的区别:
(1)post更安全(不会作为url的一部分,不会被缓存、保存在服务器日志、以及浏览器浏览记录中)
(2)post发送的数据更大(get有url长度限制)
(3)post能发送更多的数据类型(get只能发送ASCII字符)
(4)post比get慢
(5)post用于修改和写入数据,get一般用于搜索排序和筛选之类的操作(淘宝,支付宝的搜索查询都是get提交),目的是资源的获取,读取数据 - 最直观的区别就是GET把参数包含在URL中,POST通过request body传递参数。
- cookie和session的区别?
- Cookie和Session都是会话技术,Cookie是运行在客户端,Session是运行在服务器端。
- session是基于Cookie技术实现,重启浏览器后再次访问原有的连接依然会创建一个新的session,
因为Cookie在关闭浏览器后就会消失,但是原来服务器的Session还在,只有等到了销毁的时间会自动销毁
-
mysql默认一级缓存 当执行SQL查询中间发生了增删改的操作,MyBatis会把SqlSession的缓存清空。
7.隐藏一个input,可以通过id获取他的值<input type="hidden" id="deathDateVal1" value='<fmt:formatDate value="${not empty bzHhgl.hhDate?bzHhgl.hhDate:bzGhxxBusiness.misHhDate}" pattern="yyyy MM dd"/>'> LODOP.ADD_PRINT_TEXT(161,172,131,25,$("#deathDateVal1").val());
-
三目表达式
- 三目运算符是我们经常在代码中使用的,a= (b==null?0:1)
- LODOP.ADD_PRINT_TEXT(213,95,449,30,“死者姓名:”+(objDece.bzDeceased.actualName?objDece.bzDeceased.actualName:‘’)
- x ? y : z;
其中x为boolean类型表达式,先计算x的值,若为true,则整个三目运算符的结果是表达式y的值,否则就是z的值。
=2021.11.8================ - Java中continue的用法
总的来说,可以用一句话来概括,就是跳出当前迭代,重新从循环的最开始执行程序。 - 默认排序是升序asc
- readOnly=true表明所注解的方法或类只是读取数据。
readOnly=false表明所注解的方法或类是增加,删除,修改数据。 - java传的参数要一一对应,才能传到对应的值
- 默认值下拉框的值
- 注意报错提示这里明显写着id不能为空,第一时间应该去查看你对应的数据的id是否为空
=2021.11.16================
<c:if test="${bzDeceased.transportType == '3'}">
< a href="javascript:void(0);" onclick="printRlzm3D('${bzDeceased.id}')">手牌打印</ a>
</c:if>
model.addAttribute("date", new Date());
=2021.11.18================
- 在xml判断条件的时候,记得如果在实体里面的先判断实体是否为空,再判断实体下的属性是否为空,一层层判断下去,否则属性空了的话,会导致整条sql查不出数据
public abstract class DataEntity<T> extends BaseEntity<T> {
private static final long serialVersionUID = 1L;
@Expose
protected String remarks; // 备注
protected User createBy; // 创建者 这个是下面判断的第一层实体
protected Date createDate; // 创建日期
protected User updateBy; // 更新者
protected Date updateDate; // 更新日期
protected String delFlag; // 删除标记(0:正常;1:删除;2:审核)
public class User extends DataEntity<User> {
private static final long serialVersionUID = 1L;
private Office company; // 归属公司
private Office office; // 归属部门
private String loginName;// 登录名
private String password;// 密码
private String no; // 工号 这个是下面sql判断实体下的属性不为空
private String name; // 姓名
private String email; // 邮箱
private String phone; // 电话
private String mobile; // 手机
private String userType = "2";// 用户类型
private String loginIp; // 最后登陆IP
private Date loginDate; // 最后登陆日期
private String loginFlag; // 是否允许登陆
<if test="createBy != null">
<if test="createBy.no != null and createBy.no != ''">
AND sysUser.no = #{createBy.no}
</if>
</if>
- dao.xml编写sql的时候,if条件不用加and,注意子查询 里面面查询的数据是否有自己需要的数据,没有的话查出来再运行
select
sysUser.name as "createBy.name",
sysUser.no as "createBy.no",
dece.id AS "bzDeceased.id",
dece.actual_name AS "bzDeceased.actualName",
dece.serial_number AS "bzDeceased.serialNumber",
temp.totalPrice AS "allTotalPrice"
from
(
SELECT
nego.deceased_id AS "deceasedId",
rela.create_date AS "createDate",
rela.create_by AS "createBy",
SUM(rela.total_price - rela.reduction_money) AS "totalPrice"
FROM
bz_consumelist_project_relation rela
left join bz_negotiation_consumelist nego on nego.id = rela.consumelist_id and nego.del_flag = '0'
where
rela.del_flag = '0'
AND rela.`status` != '5'
AND rela.`status`!= '1'
GROUP BY nego.deceased_id,rela.create_by
) temp
left join sys_user sysUser on sysUser.id = temp.createBy and sysUser.del_flag = '0'
LEFT JOIN bz_deceased dece on dece.id = temp.deceasedId and dece.del_flag = '0'
where temp.totalPrice >20000
<if test="beginCreateDate != null and beginCreateDate != '' and endCreateDate != null and endCreateDate != ''">
and (DATE_FORMAT(temp.createDate,'%Y-%m-%d') between DATE_FORMAT(#{beginCreateDate},'%Y-%m-%d') and DATE_FORMAT(#{endCreateDate},'%Y-%m-%d'))
</if>
<if test="beginCreateDate != null and beginCreateDate != '' and (endCreateDate == '' or endCreateDate == null) ">
and DATE_FORMAT(temp.createDate,'%Y-%m-%d') = DATE_FORMAT(#{beginCreateDate},'%Y-%m-%d')
</if>
<if test="(beginCreateDate != null or beginCreateDate != '') and endCreateDate == '' and endCreateDate == null ">
and DATE_FORMAT(temp.createDate,'%Y-%m-%d') = DATE_FORMAT(#{endCreateDate},'%Y-%m-%d')
</if>
<if test="createBy != null">
<if test="createBy.no != null and createBy.no != ''">
AND sysUser.no = #{createBy.no}
</if>
</if>
GROUP BY sysUser.no, dece.actual_name
- 多个排序加个逗号分开即可
GROUP BY sysUser.no, dece.actual_name
=2021.11.19================
- 谨记写代码无论后台还是sql多做判空,防止空指针
Date date = new Date();
if (bzConsumelistProjectRelation.getBzYsgl() != null){
if(bzConsumelistProjectRelation.getBzYsgl().getBeginBzYsglDate() == null){
bzConsumelistProjectRelation.getBzYsgl().setBeginBzYsglDate(date);
}
if(bzConsumelistProjectRelation.getBzYsgl().getEndBzYsglDate() == null){
bzConsumelistProjectRelation.getBzYsgl().setEndBzYsglDate(date);
}
}else{
BzYsgl bzYsgl = new BzYsgl();//创建一个新实体接收前端传过来的值,否则直接get会空指针
bzYsgl.setBeginBzYsglDate(date);//把前端传过来的值set进新实体里面
bzYsgl.setEndBzYsglDate(date);//把存值实体塞进对应的实体里面
bzConsumelistProjectRelation.setBzYsgl(bzYsgl);
}
<if test="bzYsgl != null">
<if test="bzYsgl.beginBzYsglDate != null and bzYsgl.beginBzYsglDate != '' and bzYsgl.endBzYsglDate != null and bzYsgl.endBzYsglDate != ''">
and (DATE_FORMAT(temp.bzYsglDate,'%Y-%m-%d') between DATE_FORMAT(#{bzYsgl.beginBzYsglDate},'%Y-%m-%d') and DATE_FORMAT(#{bzYsgl.endBzYsglDate},'%Y-%m-%d'))
</if>
<if test="bzYsgl.beginBzYsglDate != null and bzYsgl.beginBzYsglDate != '' and (bzYsgl.endBzYsglDate == '' or bzYsgl.endBzYsglDate == null) ">
and DATE_FORMAT(temp.bzYsglDate,'%Y-%m-%d') = DATE_FORMAT(#{bzYsgl.beginBzYsglDate},'%Y-%m-%d')
</if>
<if test="(bzYsgl.beginBzYsglDate != null or bzYsgl.beginBzYsglDate != '') and bzYsgl.endBzYsglDate == '' and bzYsgl.endBzYsglDate == null ">
and DATE_FORMAT(temp.bzYsglDate,'%Y-%m-%d') = DATE_FORMAT(#{bzYsgl.endBzYsglDate},'%Y-%m-%d')
</if>
</if>
<if test="createBy != null">
<if test="createBy.no != null and createBy.no != ''">
AND sysUser.no = #{createBy.no}
</if>
</if>
- 传输数据比较多的情况下,可以创建map来存数据
List<BzConsumelistProjectRelation> bzConsumelistProjectRelations = (List<BzConsumelistProjectRelation>)map.get("relations");
controller层
Map<String,Object> map = bzConsumelistProjectRelationService.queryBusinessTwentyThousand(bzConsumelistProjectRelation);
model.addAttribute("list",map.get("relations"));
model.addAttribute("count",map.get("count"));
model.addAttribute("totalAmount",map.get("totalAmount"));
service层
public Map<String, Object> queryBusinessTwentyThousand(BzConsumelistProjectRelation bzConsumelistProjectRelation) {
Map<String, Object> map = new HashedMap();
List<BzConsumelistProjectRelation> relations = dao.queryBusinessTwentyThousand(bzConsumelistProjectRelation);
map.put("relations", relations);
map.put("count", relations.size());
BigDecimal totalAmount = BigDecimal.ZERO;
if (relations != null && relations.size() > 0) {
for (BzConsumelistProjectRelation relation : relations) {
if (StringUtils.isNotBlank(relation.getAllTotalPrice())) {
totalAmount = totalAmount.add(new BigDecimal(relation.getAllTotalPrice()));
}
}
}
map.put("totalAmount", totalAmount);
return map;
}
=2021.11.19================
-
f12查看请求方式与请求的参数,如果没有参数在最后是没有的
-
idea生成模块关系图,注意切勿连线,会改变模块之间的继承关系报错
=2021.12.1================ -
打印表格居中
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<meta name="decorator" content="default" />
<script src="${ctxStatic}/code/createQrcode.js"></script>
<script src="${ctxStatic}/lodop/LodopFuncs.js" type="text/javascript"></script>
<script src="${ctxStatic}/Calculation.js" type="text/javascript"></script>
<style media="print">
@page {
size: auto;
margin: 0 auto;
}
.Btnprint {
display:none;
}
</style>
<script type="text/javascript">
var currDate = "";
$(document).ready(function() {
cbdate();
//去掉页面右上角的菜单栏图案
$("#btnMenu").css("display", "none");
//时间
var date = new Date();
$("#applydate").html(date.getFullYear()+"年"+date.getMonth()+"月"+date.getDate()+"日");
});
function printTable() {
window.print();
}
function ToString(str) {
var num = parseFloat(str);
var strOutput = "",
strUnit = '仟佰拾亿仟佰拾万仟佰拾元角分';
num += "00";
var intPos = num.indexOf('.');
if (intPos >= 0){
num = num.substring(0, intPos) + num.substr(intPos + 1, 2);
}
strUnit = strUnit.substr(strUnit.length - num.length);
for (var i=0; i < num.length; i++){
strOutput += '零壹贰叁肆伍陆柒捌玖'.substr(num.substr(i,1),1) + strUnit.substr(i,1);
}
return strOutput.replace(/零角零分$/, '整').replace(/零[仟佰拾]/g, '零').replace(/零{2,}/g, '零').replace(/零([亿|万])/g, '$1').replace(/零+元/, '元').replace(/亿零{0,3}万/, '亿').replace(/^元/, "零元")
}
async function generateCode(){
var str = "${onlineWork}"+"?source="+$("#documentsNo").html() + "&state=1003";
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: str,
width: 128,
height: 128,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
var canvas = $("#qrcode").find("canvas")[0];
}
function cbdate(){
var date = new Date($("#cbdate").val())
$("#cbdatetd").html((date.getMonth()+1)+"月"+date.getDate()+"日 "+date.getHours()+"时");
}
var LODOP;
//打印
function printTable() {// 障眼法
/* $("#printBtn").hide();
window.print();
$("#printBtn").show(); */
LODOP=getLodop();
LODOP.PRINT_INIT("广州市殡仪馆遗体捐献登记表");
LODOP.SET_PRINT_STYLE("FontSize",18);
LODOP.SET_PRINT_STYLE("Bold",0);
LODOP.ADD_PRINT_HTM("1.8%","-0.5%","100%","100%",document.getElementById("printContent").innerHTML);
LODOP.SET_PRINT_PAGESIZE(1,0,0,"A4");
// LODOP.PRINT_DESIGN(); //打印设计
LODOP.PRINT(); //直接打印
// LODOP.PREVIEW(); //打印预览
}
</script>
<body>
<br>
<div id="printContent" style="float: right;width: 80%">
<h1 style="padding-left: 200px;">
<font style="font-size: 20px;font-weight: bolder">广州市殡仪馆遗体捐献登记表<span style="font-weight: normal;">(随死者档案)</span></font></h1>
<table class="customTable" border="1" style="width:760px;text-align:center;border-collapse:collapse;margin-left: 10px;">
<tr style="height: 50px">
<td style="text-align: center" width="100px">
死者编号
</td>
<td style="text-align: center" width="300px" colspan="2">
${bzdonate.serialNumber}
</td>
<td style="text-align: center" width="100px">
性别
</td>
<td style="text-align: center" width="300px" colspan="2">
${fns:getDictLabel(bzdonate.gender,'sex','')}
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
死者姓名
</td>
<td style="text-align: center" width="300px" colspan="2">
${bzdonate.actualName}
</td>
<td style="text-align: center" width="100px">
年龄
</td>
<td style="text-align: center" width="300px" colspan="2">
${bzdonate.age}
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
运入地址
</td>
<td style="text-align: center" width="300px" colspan="2">
${bzdonate.position}
</td>
<td style="text-align: center" width="100px">
运入日期
</td>
<td style="text-align: center" width="300px" colspan="2">
<fmt:formatDate value="${bzdonate.registerDate}" pattern="yyyy-MM-dd"/>
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
殡殓日期
</td>
<td style="text-align: center" width="300px" colspan="2">
<fmt:formatDate value="${bzdonate.bzYsglDate}" pattern="yyyy-MM-dd"/> ${bzdonate.bzCbbcGbhapBdate}
</td>
<td style="text-align: center" width="100px">
遗体数量
</td>
<td style="text-align: center" width="300px" colspan="2">
1
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
经办业务员
</td>
<td style="text-align: left" width="300px" colspan="5" >
${bzdonate.createBy.name}
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
防腐员签名
</td>
<td style="text-align: center" width="140px">
</td>
<td style="text-align: center" width="125px">
运输部司机签名
</td>
<td style="text-align: center" width="140px">
</td>
<td style="text-align: center" width="100px">
送遗体日期
</td>
<td style="text-align: center" width="180px">
<fmt:formatDate value="${bzdonate.boneDate}" pattern="yyyy-MM-dd HH:mm"/>
</td>
</tr>
<%--<div>--%>
<%-- --------------------------------------------------------------------------%>
<%-- --------------------------------------------------------------------------%>
<%--</div>--%>
<tr style="height: 50px">
<td style="text-align: center" width="120px">
接收单位名称
</td>
<td style="text-align: left" width="300px" colspan="5">
${bzdonate.donateUnit}
</td>
</tr>
<tr style="height: 50px;font-size: 15px">
<td style="text-align: center" width="170px">
接收单位人员签收
</td>
<td style="text-align: center" width="300px" colspan="2">
</td>
<td style="text-align: center" width="100px">
接收日期
</td>
<td style="text-align: center" width="300px" colspan="2">
</td>
</tr>
<div style="width: 100%;float: right;padding-left: 900px;padding-top:200px;position: fixed;">
<input class="btn btn-primary Btnprint" type="button" onclick="printTable(this)" value="打印捐献登记表"/>
<a class="btn btn-primary Btnprint" id="printHhglClose" href="javascript:window.opener=null;window.open('','_self');window.close();">关闭当前窗口</a>
</div>
</table>
<br>
<br>
<div style="margin-left: 35px">
-----------------------------------------------------------------------------------------------------------------------------------
</div>
<br>
<br>
<h1 style="padding-left: 200px;">
<font style="font-size: 20px;font-weight: bolder">广州市殡仪馆遗体捐献登记表<span style="font-weight: normal;">(随死者档案)</span></font></h1>
<table class="customTable" border="1" style="width:760px;text-align:center;border-collapse:collapse;margin-left:10px;">
<tr style="height: 50px">
<td style="text-align: center" width="100px">
死者编号
</td>
<td style="text-align: center" width="300px" colspan="2">
${bzdonate.serialNumber}
</td>
<td style="text-align: center" width="100px">
性别
</td>
<td style="text-align: center" width="300px" colspan="2">
${fns:getDictLabel(bzdonate.gender,'sex','')}
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
死者姓名
</td>
<td style="text-align: center" width="300px" colspan="2">
${bzdonate.actualName}
</td>
<td style="text-align: center" width="100px">
年龄
</td>
<td style="text-align: center" width="300px" colspan="2">
${bzdonate.age}
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
运入地址
</td>
<td style="text-align: center" width="300px" colspan="2">
${bzdonate.position}
</td>
<td style="text-align: center" width="100px">
运入日期
</td>
<td style="text-align: center" width="300px" colspan="2">
<fmt:formatDate value="${bzdonate.registerDate}" pattern="yyyy-MM-dd"/>
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
殡殓日期
</td>
<td style="text-align: center" width="300px" colspan="2">
<fmt:formatDate value="${bzdonate.bzYsglDate}" pattern="yyyy-MM-dd"/> ${bzdonate.bzCbbcGbhapBdate}
</td>
<td style="text-align: center" width="100px">
遗体数量
</td>
<td style="text-align: center" width="300px" colspan="2">
1
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
经办业务员
</td>
<td style="text-align: left" width="300px" colspan="5" >
${bzdonate.createBy.name}
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="100px">
防腐员签名
</td>
<td style="text-align: center" width="150px">
</td>
<td style="text-align: center" width="125px">
运输部司机签名
</td>
<td style="text-align: center" width="150px">
</td>
<td style="text-align: center" width="100px">
送遗体日期
</td>
<td style="text-align: center" width="180px">
<fmt:formatDate value="${bzdonate.boneDate}" pattern="yyyy-MM-dd HH:mm"/>
</td>
</tr>
<tr style="height: 50px">
<td style="text-align: center" width="120px">
接收单位名称
</td>
<td style="text-align: left" width="300px" colspan="5">
${bzdonate.donateUnit}
</td>
</tr>
<tr style="height: 50px;font-size: 15px">
<td style="text-align: center" width="170px">
接收单位人员签收
</td>
<td style="text-align: center" width="300px" colspan="2">
</td>
<td style="text-align: center" width="100px">
接收日期
</td>
<td style="text-align: center" width="300px" colspan="2">
</td>
</tr>
</table>
</div>
</body>
</head>
</html>
=2021.12.3================
- jsp页面名字和路径最好不是一致,否则可能访问不到,报404,页面不存在
LODOP.SET_PRINT_MODE("PRINT_DUPLEX",1);//0-不控制 1-不双面 2-双面(长边装订) 3-小册子双面(短边装订_长边水平)
function cbdate(){ var date = new Date($("#cbdate").val()) $("#cbdatetd").html((date.getMonth()+1)+"月"+date.getDate()+"日 "+date.getHours()+"时"); }
- 页面给按钮显示数量,并赋予点击时间
<input id="pageSize" name="pageSize" type="button" readonly="readonly" style="color: red;float: right"
onclick="dealUnclaimed()"
value="已处理:${dealSize}"/>
function dealUnclaimed() {
var beginDeathDate = $("#beginDeathDate").val();
var endDeathDate = $("#endDeathDate").val();
window.location.href = "${ctx}/bz/unclaimed/getUnclaimedSituation?status=1&beginDeathDate=" + beginDeathDate + "&endDeathDate=" + endDeathDate;
}
=2021.12.11================
-
方法名与跳转的jsp页面不要一致,可能会导致无法跳转页面
-
后台传值前端jsp接收
model.addAttribute("bzUnclaimeddata",bzUnclaimeddata); 后台传数据,jsp前台<c:forEach items="${list}" var="bzUnclaimed" varStatus="status"> 遍历用${bzUnclaimeddata.counts}获取值,否则获取不到值, 可以通过一个一个值传直接在前端获取${counts}
=2021.12.14================
- 更新数据库字段
- 先塞值进去再update他的值,否则没值的话更新会报错
- || 或 &&与
controller
//办理业务方式是清仓取灰并且骨灰处理方式是取灰就保存更新
if ("27".equals(bzDeceased.getWorkStyle()) && "2".equals(bzDeceased.getAshesFlow())){
bzDeceased.setClearanceTime(new Date());
bzDeceasedService.updateClearanceTime(bzDeceased);
}
service
@Transactional(readOnly = false, rollbackFor = Exception.class)
public void updateClearanceTime(BzDeceased bzDeceased) {
dao.updateClearanceTime(bzDeceased);
}
dao
void updateClearanceTime(BzDeceased bzDeceased);
xml
<update id="updateClearanceTime">
update bz_deceased set
clearance_time = #{clearanceTime}
WHERE id = #{id}
</update>
=2021.12.15================
- 事务什么时候会失效?
- 如使用mysql且引擎是MyISAM,则事务会不起作用,原因是MyISAM不支持事务,可以改成InnoDB引擎
- @Transaction只能用于public的方法上,否则事务会失效,如果要用在非public上,可以开启AspectJ代理模式
- 数据库不支持事务 (Mysql的Myisam引擎)
- init 失败 在controller 路径重复
CheckBox传值:<td>
<input id="idNo" name="input_id" class="unclaimedId" type="checkbox"
value="${bzDeceased.id}_${bzDeceased.documentsNo}"
style="display: inline-block; width:20px;height: 20px;">
</td>
=2021.12.24================
- 遍历总金额
controller层
public Page<BzUnclaimedClearance> getUnclaimedOnstage(Page<BzUnclaimedClearance> page, BzUnclaimedClearance bzUnclaimedClearance) {
BigDecimal sumAmount = new BigDecimal(0.00);
List<BzUnclaimedClearance> bzUnclaimedClearances = dao.getUnclaimedOnstage(bzUnclaimedClearance);
for (BzUnclaimedClearance bzUnclaimedClearance1 : bzUnclaimedClearances){
sumAmount = sumAmount.add(bzUnclaimedClearance1.getAmount());
}
page.setFuncName(sumAmount.toString());
page.setList(bzUnclaimedClearances);
page.setCount(bzUnclaimedClearances.size());
return page;
}
dao层
List<BzUnclaimedClearance> getUnclaimedOnstage(BzUnclaimedClearance bzUnclaimedClearance);
=2021.12.30================
- 当返回类型是String 的时候,xml返回类型改为resultType=“java.lang.String”
- 静态方法只能访问静态成员,因为非静态方法的调用要先创建对象,在调用静态方法时可能对象并没有被初始化
- 定义全局变量:private String byh = “”;以便调动
- 事务管理对于企业应用来说是至关重要的,即使出现异常情况,它也可以保证数据的一致性。
spring支持编程式事务管理和声明式事务管理两种方式。
=2022.1.14================
main方法中获取文件:String pfxFile = ClassLoader.getSystemResource("test_ct.pfx").getPath();
- 包名,方法名,类名
- 处理异常
foreach 遍历数组 模糊查询
- 通过实体接受到前台传来的值,判断他是否为空以防止空指针,如果不为空的话,就进入方法,获取到他的值
- 在BzDeceased的实体添加一个 String[] place添加get、set方法,以便获取存值
bzDeceasedController层
if (bzDeceased.getDeathplace() != " " && bzDeceased.getDeathplace() != null){
String deadplace=bzDeceased.getDeathplace(); //定义一个string类型,获取到前端传来的值
String[] place = deadplace.split(" "); //定义一个数组string[],通过数组,截取掉空格
bzDeceased.setPlace(place); //把place集合的值,传到bzDeceased对象,可在xml直接循环调用
}
bzDeceased实体类
private String[] place; //死亡地点
public String[] getPlace() {
return place;
}
public void setPlace(String[] place) {
this.place = place;
}
bzDeceaseDao.xml
<if test="place != null and place != ''"> //id代表数组里面的值,close表示查询关闭的区间,collection表示list数组
<foreach collection="place" item="id" index="index" open="and (" close=")" separator="or">
a.deathPlace LIKE
<if test="dbName == 'oracle'">'%'||#{id}||'%'</if>
<if test="dbName == 'mssql'">'%'+#{id}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{id},'%')</if>
</foreach>
</if>
前端jsp如何循环
var heightLeft = 205;
var heithtRight = 205;
for(var i=0;i<invoiceList.length;i++){
if(i%2==0){
LODOP.ADD_PRINT_TEXT(heightLeft,36,30,25,i+1);
LODOP.ADD_PRINT_TEXT(heightLeft,70,123,25,invoiceList[i].projectName);
LODOP.ADD_PRINT_TEXT(heightLeft,192,30,25,invoiceList[i].number);
LODOP.ADD_PRINT_TEXT(heightLeft,222,80,25,"4"+i);
heightLeft+=30;
}else{
LODOP.ADD_PRINT_TEXT(heithtRight,323,30,25,i+1);
LODOP.ADD_PRINT_TEXT(heithtRight,369,120,25,invoiceList[i].projectName);
LODOP.ADD_PRINT_TEXT(heithtRight,490,30,25,invoiceList[i].number);
LODOP.ADD_PRINT_TEXT(heithtRight,530,90,25,"d"+i);
heithtRight+=30;
}
//height +=30;
}
css样式
- html, body{ height: 100%; } 固定高百分比,防止不同分辨率屏幕炸掉
- 先在总的div加入100%;height: 100%固定,再在下面的table给固定的px,可以在页面修改不影响整体了
- page-break-after:always; 结束这个,强行跳到下一页
- 修改元素的行间距(line-height:40px;)
- 修改元素字间距(letter-spacing:1px;)
- margin:10px 5px 15px 20px;上外边距是 10px,右外边距是 5px,下外边距是 15px,左外边距是 20px
- cssdiv置底:position:fixed; bottom:0;
<style> *{ font-family: "黑体"; } table th,td{ font-size: 120%; height: 20px; } </style>
- css下划线:style=“text-decoration: underline”
- HTML的div旋转:transform: rotate(270deg)
- 打印换页:style=“page-break-after:always”
ajax
# Ajax
尚硅谷
异步请求,**无刷新获取数据**
ajax发的就是http请求
ajax优点:
- 可以无需刷新页面与服务器端进行 通宵
- 允许你根据用户事件来更新部分页面内容
ajax缺点:
- 没有浏览历史,不能回退
- 存在跨域问题
- SEO不友好(爬虫 他只有响应体,就是http的包
## HTTP
- http协议【超文本传输协议】,协议详细规定了浏览器和万维网服务之间互相通信的规则
- 约定,规则
- 请求 报文
- 重点是格式与参数
- 行 请求类型(get、post)(URL)(http/1.1)
- 头 (HOST:atgigu.com)(Cookie:name=guigu)都是名字:值
- 空行
- 体 (如果是get请求,体为空)(如果是post请求,可以不为空) username=admin&passwoed=admin
- 响应 报文
- 行 (http/1.1 200 ok)
- 头 (content-length:2048)
-
- 空行
- 体 <html>
<hrad>
</head>
<body>
<h>两位好</h>
</body>
</html>
### xml简介
HTML来存放数据,xml来传输数据
HTML都是预定义标签,xml没有预定义标签
**xml现在已经被json取代了**
=========================================
格式
$.ajax({
type:"请求类型",
url:"请求地址", ${pageContext.request.contextPath}
dataType:"JSON",数据格式,
async:true,
data:{
传给后台的数据,键值对方式,id选择器 'name': $("#name").val()
},
success:function(){
} //服务器返回的数据都封装在data里面,或者状态
})
=====================================================
$.ajax({
type:"post",
url: "${ctx}/business/outtransport/bzOutTransport/find",
dataType:"JSON",
async:true,
data:{
'jobName':$("#jobName").val(),
'jobNumber': $("#jobNumber").val(),
'id':$("#id").val()
},
success:function (data){
console.log(data)
if(data.flag == '1'){
$.jBox.tip(data.content, 'success');
}else{
$.jBox.tip(data.content, 'error');
}
setTimeout(function () {
window.parent.window.jBox.close();
},1000);
}
})
},{buttonsFocus:1, closed:function(){
if (typeof closed == 'function') {
closed();
}
}});
top.$('.jbox-body .jbox-icon').css('top','55px');
return false;
}
function examine(id) {
top.$.jBox.open("iframe:${ctx}/business/outtransport/bzOutTransport/examine?id="+id,
"您的审核意见", 650, 190, {
buttons: { "关闭":true}, submit: function (v, h, f) {
if (v == "ok") {
} else if (v == "clear") {
}
}, loaded: function (h) {
$(".jbox-content", top.document).css("overflow-y", "hidden");
}, opacity: 0.5, persistent: true, top: '5%'
})
}
<c:if test="${bzOutTransport.transportType eq 1}">
<a onclick="examine('${bzOutTransport.id}')" href="javascript:void(0)">审核</a>
</c:if>
在这里插入图片描述
选择器
id选择器唯一,只有一个
- 通过 id 来查找 HTML 元素
返回 id="intro" 的元素:
jQuery
var myElement = $("#id01");
<!DOCTYPE html>
<html>
<body>
<h1>通过 id 查找 HTML 元素</h1>
<p id="id01">Hello World!</p>
<p id="id02">Hello China!</p>
<p id="id03">Hello Shanghai!</p>
<p id="demo"></p>
<script>
var myElement = document.getElementById("id03");
document.getElementById("demo").innerHTML = "段落 id03 的文本是:" + myElement.innerHTML;
</script>
</body>
</html>
class类选择器不唯一,可以有多个
- 通过类名来查找 HTML 元素
返回 class="intro" 的所有元素。
jQuery
var myElements = $(".intro");
<!DOCTYPE html>
<html>
<head>
<script src="/jquery/jquery.min.js"></script>
</head>
<body>
<h1>通过类名查找 HTML 元素</h1>
<p class="intro">Hello World!</p>
<p class="intro">Hello China!</p>
<p class="intro">Hello Shanghai!</p>
<p id="demo"></p>
<script>
$(document).ready(function() {
var myElements = $(".intro");
$("#demo").text("类名为 intro 的第三段文本是:" + myElements[2].innerHTML);
});
</script>
</body>
</html>
1、class 通过id获取到,增加或移除他的class元素
$("#ages").removeClass('hide');
$("#age").addClass('required');
<span id="ages" class="hide"><font color="red">*</font> </span>
2、css
$("#commissionPhones").css('display','none');隐藏
$("#commissionNames").css('display','inline');显示
<span id="ages" style="display: none"><font color="red">*</font> </span>
form表单
path="实体类对应哪个名字"等同于id的作用
<form:hidden path="id"/> 记得加上id,确认是查询这条数据,和后台那的值是一样的
<div class="control-group">
<form:form id="searchForm" modelAttribute="bzOutTransport" action="${ctx}/business/outtransport/bzOutTransport/find" method="post" class="breadcrumb form-search">
<form:hidden path="id"/>
姓名:<form:input path="jobName" type='text' value="${bzOutTransport.jobName}"/>
工号:<form:input path="jobNumber" type='text' value="${bzOutTransport.jobNumber}"/>
<input type="button" value="保 存" onclick="saveAudit()" class="btn btn-primary">
<%-- 审核状态:--%>
<%-- <form:select path="auditStatus" class="input-medium clean flowerType" style="width:140px;" onchange="handleType(this)">--%>
<%-- <form:option value="">请选择</form:option>--%>
<%-- <form:options items="${fns:getAuditStatus()}" itemLabel="name" itemValue="type" htmlEscape="false"/>--%>
<%-- </form:select>--%>
<%-- </br>--%>
<%-- </br>--%>
<%-- 请输入您的审核意见:<form:textarea path="auditOpinion" type='text' value="${bzOutTransport.auditOpinion}"/>--%>
<%-- <input type="submit" value="保存" class="btn btn-primary" >--%>
<%-- <input id="btnSubmit" class="btn btn-primary" onclick="saveAntiseptic()" type="button" value="保 存">--%>
</form:form>
</div>
表单提交可以直接点击按钮就提交 submit
jsp创建数组,拆值循环出来
var number = (invoice.amount)*100;//反正就是总金额
var array = new Array();//最终获取到的,每位数上的数字组成的数组
//只要number>1,就一直做循环
//因为在循环体里面,number是每次都在被/
// 10,number小于1就代表了,连个位数都没了,就不用记了
//举例,123,第一次进循环,除以10了之后就是12,第二次就是1,第三次就0了
for(;number>=1;)
{
//怕出现错误,先转了数据类型再说
var i = parseInt(number);
//把现在的这个位数上的数字,通过取余数的操作取出来,并塞到array里面
//这样就能拿到每个位数上的数字
//举例,123,这里就是current=3了,然后塞到数组里面就行
var current = parseInt(number%10);
array.push(current);
//当前位数已经被存进array了,就没有留下的必要,小数点往左移一格,缩小10倍,去拿下一个位数
number = parseInt(number/10);
}
//var arraylenght = (array.reverse()); 数组倒序
var left = 430;
for (var i = 0;i<array.length;i++){
LODOP.ADD_PRINT_TEXT(253,left,30,25,ToString(array[i]).substr(0,1));
LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
left -=37;
}
//最后拿出来array,array.size是所要获取的数组
JavaScript如何调用函数
数字小写转大写
function ToString(str) {
var num = parseFloat(str);
var strOutput = "",
strUnit = '仟佰拾亿仟佰拾万仟佰拾元角分';
num += "00";
var intPos = num.indexOf('.');
if (intPos >= 0){
num = num.substring(0, intPos) + num.substr(intPos + 1, 2);
}
strUnit = strUnit.substr(strUnit.length - num.length);
for (var i=0; i < num.length; i++){
strOutput += '零壹贰叁肆伍陆柒捌玖'.substr(num.substr(i,1),1) + strUnit.substr(i,1);
}
return strOutput.replace(/零角零分$/, '整').replace(/零[仟佰拾]/g, '零').replace(/零{2,}/g, '零').replace(/零([亿|万])/g, '$1').replace(/零+元/, '元').replace(/亿零{0,3}万/, '亿').replace(/^元/, "零元"
}
在tostring里面放入值即可转变成大写
LODOP.ADD_PRINT_TEXT(463,68,350,25,"合计人民币(大写):"+ToString(invoice.amount.toFixed(2)));
LODOP.SET_PRINT_STYLEA(0,"FontSize",11);
LODOP.ADD_PRINT_TEXT(463,530,200,25,"(小写):¥"+invoice.amount.toFixed(2));
jsp获取当前时间
先导入命名空间
<jsp:useBean id="now" class="java.util.Date" scope="page"/>
<%--获取当前时间--%>
<input type="hidden" id="nowDate" value='<fmt:formatDate value="${now}" pattern="yyyy MM dd"/>'>
根据id获取他的值
$("#nowDate").val()
生成序号
<varStatus="asd">
${asd.count}还有一个.index是从0开始.count直接从1开始
JavaScript常用方法代码
关闭当前窗口:<a class="btn btn-primary" href="javascript:window.opener=null;window.open('','_self');window.close();" style="margin-top: 5px;" >关闭当前窗口</a>
页面开始加载,进入方法
$(document).ready(function() {
$("#jedx").html(ToString($("#zje").html()));
generateCode();
amount();
});
function amount(){
var amount = accSub(${negotiationConsumelist.amount},${reductionM}); 后台传过来的值可以直接获取,有表单元素的话,需要在后面加.val获取他的值
var total = '合计:¥'+amount+'元';
$(".total").text(total) 赋值到下面的单元格中
}
<td colspan="3" class="total"></td> 给上面绑定一个class
1.去掉页面右上角的菜单栏图案: $("#btnMenu").css("display", "none");
2.jBox弹窗:$.jBox.tip('遗体状况不能为空', 'error');
3.清除输入框内容:<li class="btns"><input id="btnClean" type="reset" class="btn btn-primary" value="清除"/></li>
$(document).ready(function() {
//点击"清除"
$(":reset").click(function(){
var resetArr = $(this).parents("form").find(":text");
for(var i=0; i<resetArr.length; i++){
resetArr.eq(i).val("");
}
return false;
});
});
4.<a class="btn btn-primary" href="javascript:window.opener=null;window.open('','_self');window.close();">关闭当前窗口</ a>
5.<span style="color: red;">
共${list.size()} 条记录
</span>
6.class="active":不要高亮
7.打印的时候隐藏打印按钮,在class后面加上这个属性Btnprint即可:
<style media="print">
@page {
size: auto;
margin: 0 auto;
}
.Btnprint {
display:none;
}
</style>
<input class="btn btn-primary Btnprint" type="button" onclick="printTable()" value="打印"/>
HTML标签
1. class="btn btn-primary 蓝色确认按钮
2. autocomplete="off" input关闭提示记录
3.< a href="javascript:history.go(-1)" class="Btnprint" style="font-weight: bolder;font-size: 18px">返回上一步</ a>
4. 输入框背景字:placeholder="日 期"
JavaScript函数总结
- .toFixed() 要保留最后几位小数
- .reverse() 数组倒序
- parseInt()函数可解析一个字符串,并返回一个整数
for(;number>=1;)
条件为真的话就一直循环- <c:if> 标签,<c:if>标签判断表达式的值,如果表达式的值为 true 则执行其主体内容。
- accSub() 精度减法运算,记得引入js
- text()用于html元素文本内容的存取
- val()用于input元素内容的存取
- html()不但可以用于html元素文本内容的存取,还可以用于html内容的存取
<s:set var="transportType" value="${bzDeceased.transportType}"/>
<c:if test="${transportType==2}">
${fns:getDictLabel(bzDeceased.transportType, 'transport_type', '')}
(${bzDeceased.transportFee})
</c:if>
<c:if test="${not empty bzServiceItem.productId}">
<span style="${bzServiceItem.stockCount>0?'color: #18a859;':'color: #A60000;'}font-size: 16px;">
(${bzServiceItem.stockCount>0?"有库存":"无库存"})
</span>
</c:if>
1. &allowMultiQueries=true配置文件URL加上可以执行多条sql
2. <c:if test="${not empty bzDeceased.commission}">${bzDeceased.commission.commissionName }</c:if>
3. id:jobName选择器: 'jobName':$("#jobName").val()
4. String hour = gbhapEdate.substring(0, 2); 截取时间 后台