近期的工作是在出入库时填写出入库记录。
首先是科室库出库记录的第一层
ReagentOutBill outBill = new ReagentOutBill();
Date timeNow = new Date();
Long time1 = new Date().getTime();
Random ne2 = new Random();//实例化一个random的对象ne
int x2 = ne2.nextInt(999 - 100 + 1) + 100;//为变量赋随机值100-999
String random_order2 = String.valueOf(x2);
String billCode = time1 + random_order2;
String creater =stockMapper.findhead(name);
outBill.setBillCode(billCode);
outBill.setBillType("2");
outBill.setBillDate(timeNow);
outBill.setBillStatus(true);
outBill.setBillCreator(creater);
outBill.setBranchName(name);
outBill.setUpdateTime(timeNow);
outBill.setCreateTime(timeNow);
outBill.setApplicationDate(timeNow);
outBill.setApplicationUser(stock.getapplier());
outBillMapper.insert(outBill);
首先创建一个ReagentOutBill 类型的outBill ,通过date方法获取当前世界,然后根据时间和随机数生成一个随机的编号。
根据库名找到科室账号的使用者
<select id="findhead" resultType="java.lang.String">
select head
from reagent_branch
where branch_name = #{name,jdbcType=VARCHAR}
依次填入记录编号,类型等数据,然后使用outBillMapper.insert(outBill)写入。
<insert id="insert" parameterType="jp.co.nss.hrm.backend.model.ReagentOutBill">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into reagent_out_bill (bill_code, bill_type, bill_date,
bill_status, bill_creator, remark,
branch_name, application_date, application_user,
create_time, create_by, update_time,
update_by, delete_flag, delete_time,
delete_by)
values (#{billCode,jdbcType=VARCHAR}, #{billType,jdbcType=VARCHAR}, #{billDate,jdbcType=DATE},
#{billStatus,jdbcType=BIT}, #{billCreator,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{branchName,jdbcType=VARCHAR}, #{applicationDate,jdbcType=DATE}, #{applicationUser,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{createBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{updateBy,jdbcType=VARCHAR}, #{deleteFlag,jdbcType=TINYINT}, #{deleteTime,jdbcType=TIMESTAMP},
#{deleteBy,jdbcType=VARCHAR})