今日の大きなポイントを記録します。
参考記事:
https://blog.csdn.net/weixin_44538107/article/details/87740611
https://blog.csdn.net/jianqiangdexiaohai/article/details/81240176
シリアル番号は、プロジェクトプロセス中に自動的に生成される必要があります。データベースでは生成されませんが、バックグラウンドコードで生成されます。シリアル番号に対するお客様の要件に応じて、仕様と組み合わせに準拠している必要があります。繰り返しなくても明確で理解しやすいです。したがって、上記の2つの記事のコードを参照した後、それぞれのビジネスニーズに応じてそれらを適合させ
ます。1最初にデータベースから既存の最大数を照会します
。2それをNO +現在の時刻形式の文字列に結合します
。3最大数かどうかを判断します。最大数は存在し、最大数は
4日の時刻を含めるかどうかにあります。最大数が存在しない場合は、最初の数を直接生成します。NO2016012700015
最大数が存在し、時刻が含まれる場合は、最大数に1を加算します。コードを形成する
注:次のコードデモは、OPP20190801のような世代であり、日数が不足しています。
以下はControllerメソッドです。2つの記事のそれぞれで使用されているJsonクラスは不明であるため、私のプロジェクトの詳細に基づいて少し調整されています。プロジェクトはspringbootとbootstrap + vueです。上記の記事のようにjsonデータ値の転送を行う場合、独自のプロジェクトのパッケージ戻り値Rタイプと組み合わせて、フロントデスクがリクエストを開始し、requestメソッドがjson文字列をフロントデスクに返してページ割り当てを実行します。
@RequestMapping("/getCommentCode")
//@RequiresPermissions("tbusinesschance:save")
public R getCommentCode(){
List<String> bhList = new ArrayList<String>();
String currentMonth = null;
int month = Calendar.getInstance().get(Calendar.MONTH) + 1;
if(month < 10) {
currentMonth = "0" + month;
} else {
currentMonth = month + "";
}
List<TBusinesschanceEntity> partList = tBusinesschanceService.getPartList(currentMonth);
for (TBusinesschanceEntity tBusinesschanceEntity : partList) {
bhList.add(tBusinesschanceEntity.getBusinesschanceid());
}
String max_code = "";//最新编号
String comment_code = "";//做好的编号
if(bhList.size() > 0) {//得到该月最新(最大号)的一个编号
max_code = bhList.get(0);
}
// 时间字符串产生方式
SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
// 组合流水号前一部分,时间字符串,如:201907
String bcid_pfix = format.format(new Date());
//判断数据库是否有数据
if (max_code != null && max_code.contains(bcid_pfix)) {
// 从OOP20190803 截取字符串最后2位,结果:03
String uid_end = max_code.substring(9);//substring(8)
// 把String类型的03转化为int类型的3
int endNum = Integer.parseInt(uid_end);
// 结果4
int tmpNum = endNum + 1; // 100 + 1 + 1 = 结果102
//已经加了1 再给他在拼成OOP20190804
comment_code = "OOP" + bcid_pfix + ("0" + tmpNum);
} else {
//数据库没数据时,输出OOP20190801
comment_code = "OOP" + bcid_pfix + "01";
}
return R.ok().put("comment_code", comment_code);
}
Js Code
no parameters -Get request
to $( "#businesschanceid")Val(r.comment_code);;値が割り当てられたページ
function getCommentCode(){
$.ajax({
type: "GET",
url: baseURL + "tbusinesschance/getCommentCode",
contentType: "application/json",
//data: JSON.stringify(ids),
success: function(r){
if(r.code == 0){
$("#businesschanceid").val(r.comment_code);
}else{
alert(r.msg);
}
}
});
}
このようにして、htmlページで定義されたIDが前面と背面と相互作用します。
xmlファイルにSQLステートメント を書く際の問題について話させ
てください。それについて話したいのですが、最初に、他の人に基づいて変更の段落をコピーしました。
<select id="queryList" resultType="xxx.server.businesschance.entity.TBusinesschanceEntity">
select * from t_businesschance bc
<where>
bc.`isdel`="1"
1 <if test="businesschanceid !=null and businesschanceid.trim() != ''">
2 and bc.`businesschanceid like concat('%',#{value},'%')
------------------------------这里想要的效果是-----------------------------
Controller传来的value(eg:07) 让businesschanceid 做模糊查询查询出所有是该位是07的编号。
可是不知test的值是否要与下面bc.`businesschanceid #{value} 一样,所以不论怎么改,照网上
搜的更改方法改了_parameter 都是报 here is no getter for property named 'businesschanceid' in 'class xxx.User'。 实在xml里写sql语句不太会所以这里出错了好久。
后来调整了sql的写法,然后就对了。
</if>
</where>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
以下は変更されたSQLです
<!-- 查询编号集合 -->
<select id="getPartList" resultType="com.rlc.modules.server.businesschance.entity.TBusinesschanceEntity">
select * from t_businesschance tbc
<where>
tbc.businesschanceid like concat('_______',#{value},'__')
order by tbc.id desc
---------------------------不在这里用人家的模板,而是简单写了,就对了。不在报 here is no getter for property named 'businesschanceid' in xxx.xxx了
这里的这个错误如果有高手了解,还请告知以下。感谢!!!!!!!
</where>
</select>