String dpt = employee.getDptName(); char[] crr = dpt.toCharArray(); String str = ""; for (int i = 0; i < 3; i++) { str += StringUtils.getFirstLetter(String.valueOf(crr[i])); } Date time = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyMMdd"); String data = simpleDateFormat.format(time); str += data; ArrayList<Employee> brr = new EmployeeSQL().selectById("___" + data + "__"); if (brr.size() < 10) { str += "0" + (brr.size() + 1); } else { str += brr.size(); } employee.setEmpCode(str);
时间: 2024-02-10 12:33:51 浏览: 35
这段代码看起来是给员工分配一个员工号,其中包括部门名称的前三个字母、当前日期的年月日以及该部门下员工的数量。其中,通过调用 StringUtils.getFirstLetter() 方法获取了部门名称的首字母。如果该部门下员工数量小于 10,则在员工号中添加一个 0。这段代码的执行过程中,还从数据库中查询了以 "___" + data + "__" 为 ID 的员工信息。
相关问题
sql在这里 select f_status, f_type,F_DIV_DEPART,F_SMALL_SENDER, F_DEPT_ID as id, F_VOUCHER_NUMBER as voucherNumber, F_SALE_DEPART as saleDepart, F_SMALL_DEPART as smallDepart, F_SALE_SENDER as UpDeptSender, F_BIG_DEPART as bigDepart, F_DIV_DEPART as division, F_DIV_DEPART as division from dpcrm.T_COMP_SOLVE_REPORT t left join ( SELECT DPT.FID, DPT.FDEPTCODE, DPT.FSTANDARDCODE,DPT.FDEPTNAME, DPT.FPRINCIPAL,DPT.FDEPTLEVEL,DPT.FPARENTID FROM DPCRM.T_ORG_DEPARTMENT DPT START WITH DPT.FID = 796931 CONNECT BY DPT.FID = PRIOR DPT.FPARENTID ORDER BY DPT.FID DESC FETCH FIRST 1 ROWS ONLY ) dpt on t.F_DEPT_ID=dpt.FID where f_type = 'DELIVER' and f_status = '1' and NVL(F_DIV_DEPART,'-') != '空运管理本部' and F_SMALL_SENDER = '796931'
这是一条 SQL 查询语句,它从表 T_COMP_SOLVE_REPORT 中选择 f_status、f_type、F_DIV_DEPART、F_SMALL_SENDER、F_DEPT_ID、F_VOUCHER_NUMBER、F_SALE_DEPART、F_SMALL_DEPART、F_SALE_SENDER、F_BIG_DEPART 和 division 这些列,并且通过左连接查询 T_ORG_DEPARTMENT 表以获取部门信息。查询条件包括 f_type 为 'DELIVER',f_status 为 '1',F_DIV_DEPART 不为 '空运管理本部',F_SMALL_SENDER 为 '796931'。查询结果将返回符合条件的记录集。
帮我翻译以下代码 <select id="getStatisticalInfoDetailCount" resultType="java.lang.Integer"> select count()from(select psi.station_id,cda.cdc as count_device_code,cda.appkey from (select count(dci.device_code) as cdc,dci.appkey from iledproduction.device_code_info dci where CONV(left(dci.device_code,2),16,10) in <foreach collection="manufacturerIdList" item="item" index="index" open="(" close=")" separator=","> #{item} </foreach> <if test="propMap.size>0 and propMap!=null"> <foreach collection="propMap" index="index" item="item"> <if test='index.toString=="device_type"'> and substr(dci.device_code,3,4) = "${item[1]}" </if> <if test='index.toString=="produce_date"'> and STR_TO_DATE(substr(dci.device_code,7,6),'%y%m%d') BETWEEN "${item[1]}" AND DATE_ADD("${item[2]}",INTERVAL 1 DAY) </if> </foreach> </if> and dci.cert_import_status = 1 group by appkey) as cda left join (select s1.station_id as station_id,s1.old_appkey as appkey from iledproduction.appkey_log s1 union (select s2.station_id as station_id,s2.new_appkey as appkey from iledproduction.appkey_log s2) union (select s3.station_id as station_id,s3.appkey as appkey from iledproduction.production_station_info s3) ) psi on cda.appkey = psi.appkey) a left join (select p.,dpt.manufacturer_id,dpt.department_name from iledproduction.production_station_info p ,iledproduction.department dpt where p.department_key=dpt.department_key) ps on a.station_id = ps.station_id <if test="propMap.size>0 and propMap!=null"> <foreach collection="propMap" index="index" item="item"> <if test='index.toString=="manufacturer_id"'> where ps.manufacturer_id = ${item[1]} </if> </foreach> </if> </select>
这段代码是一个SQL查询语句,用于统计满足特定条件的数据行数。以下是代码的翻译:
```sql
<select id="getStatisticalInfoDetailCount" resultType="java.lang.Integer">
SELECT count(*) FROM (
SELECT psi.station_id, cda.cdc AS count_device_code, cda.appkey
FROM (
SELECT count(dci.device_code) AS cdc, dci.appkey
FROM iledproduction.device_code_info dci
WHERE CONV(left(dci.device_code,2),16,10) IN
<foreach collection="manufacturerIdList" item="item" index="index" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="propMap.size>0 and propMap!=null">
<foreach collection="propMap" index="index" item="item">
<if test='index.toString=="device_type"'>
AND substr(dci.device_code,3,4) = "${item[1]}"
</if>
<if test='index.toString=="produce_date"'>
AND STR_TO_DATE(substr(dci.device_code,7,6),'%y%m%d') BETWEEN "${item[1]}" AND DATE_ADD("${item[2]}",INTERVAL 1 DAY)
</if>
</foreach>
</if>
AND dci.cert_import_status = 1
GROUP BY appkey
) AS cda
LEFT JOIN (
SELECT s1.station_id AS station_id, s1.old_appkey AS appkey
FROM iledproduction.appkey_log s1
UNION
SELECT s2.station_id AS station_id, s2.new_appkey AS appkey
FROM iledproduction.appkey_log s2
UNION
SELECT s3.station_id AS station_id, s3.appkey AS appkey
FROM iledproduction.production_station_info s3
) psi ON cda.appkey = psi.appkey
) a
LEFT JOIN (
SELECT p.*, dpt.manufacturer_id, dpt.department_name
FROM iledproduction.production_station_info p, iledproduction.department dpt
WHERE p.department_key = dpt.department_key
) ps ON a.station_id = ps.station_id
<if test="propMap.size>0 and propMap!=null">
<foreach collection="propMap" index="index" item="item">
<if test='index.toString=="manufacturer_id"'>
WHERE ps.manufacturer_id = ${item[1]}
</if>
</foreach>
</if>
</select>
```
希望能对你有所帮助。如果你有任何其他问题,请随时提问。