112 lines
3.8 KiB
Java
112 lines
3.8 KiB
Java
package com.budwk.app;
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
import com.budwk.app.sys.views.View_user;
|
|
import com.budwk.app.zhgh.dayofficework.honor.models.Honor;
|
|
import lombok.Data;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.nutz.boot.test.junit4.NbJUnit4Runner;
|
|
import org.nutz.dao.Cnd;
|
|
import org.nutz.dao.Dao;
|
|
import org.nutz.ioc.loader.annotation.Inject;
|
|
import org.nutz.ioc.loader.annotation.IocBean;
|
|
|
|
import java.io.File;
|
|
import java.util.List;
|
|
|
|
@IocBean
|
|
@RunWith(NbJUnit4Runner.class)
|
|
public class HonorTest {
|
|
|
|
@Inject
|
|
private Dao dao;
|
|
|
|
@Test
|
|
public void importData() {
|
|
List<HonorImport> honors = ExcelImportUtil.importExcel(new File("C:\\Users\\jug\\Desktop\\njnu\\巾帼表彰.xlsx"), HonorImport.class, new ImportParams());
|
|
System.out.println(honors.size());
|
|
|
|
List<Honor> list = honors.stream().map(v -> {
|
|
Honor honor = new Honor();
|
|
|
|
if (v.getIdentity().equals("优秀工会干部")) {
|
|
honor.setHonorType("8a8b455b964a41f2bbf18a4896cbd83e");
|
|
honor.setPrize("68b9db0712bd43a88cccb557593e2072");
|
|
}
|
|
|
|
if (v.getIdentity().equals("工会积极分子")) {
|
|
honor.setHonorType("8a8b455b964a41f2bbf18a4896cbd83e");
|
|
honor.setPrize("18e64fa01e0d446bb5f2be478c450aba");
|
|
}
|
|
|
|
if (v.getIdentity().equals("工会先进集体")) {
|
|
honor.setUnitName(v.getUnitName());
|
|
honor.setHonorType("6b9e26a9467f49ae88fbd3951377e0f8");
|
|
honor.setPrize("5b3a0f27b1034b8f998d47dcecd8f2a2");
|
|
}
|
|
|
|
if(v.getIdentity().equals("巾帼文明岗")){
|
|
honor.setUnitName(v.getUserName());
|
|
honor.setUnionName(v.getUnitName());
|
|
honor.setHonorType("6b9e26a9467f49ae88fbd3951377e0f8");
|
|
honor.setPrize("c1fa5b363adc420c902fd5ab9f697cfa");
|
|
}
|
|
|
|
if(v.getIdentity().equals("巾帼建功先进个人")){
|
|
honor.setHonorType("8a8b455b964a41f2bbf18a4896cbd83e");
|
|
honor.setPrize("6ee171a4650a4966b3626375d68202fa");
|
|
}
|
|
|
|
|
|
if (v.getIdentity().equals("优秀工会干部") || v.getIdentity().equals("工会积极分子") || v.getIdentity().equals("巾帼建功先进个人")) {
|
|
View_user viewUser = dao.fetch(View_user.class, Cnd.where("username", "=", v.getUserName()));
|
|
if (viewUser != null) {
|
|
honor.setUserId(viewUser.getId());
|
|
honor.setUserName(viewUser.getUsername());
|
|
honor.setUserSex(viewUser.getSex());
|
|
}else{
|
|
honor.setUserName(v.getUserName());
|
|
}
|
|
honor.setUnitName(v.getUnitName());
|
|
honor.setGrantDate(v.getTime());
|
|
}
|
|
return honor;
|
|
}).toList();
|
|
|
|
dao.insert(list);
|
|
|
|
|
|
// List<Honor> list = dao.query(Honor.class, Cnd.where(Honor::getHonorType, "=", "8a8b455b964a41f2bbf18a4896cbd83e"));
|
|
//
|
|
// for (Honor honor : list) {
|
|
// View_user viewUser = dao.fetch(View_user.class, Cnd.where("username", "=", honor.getUserName()));
|
|
// if (viewUser != null) {
|
|
// honor.setLoginName(viewUser.getLoginname());
|
|
// }
|
|
// }
|
|
// dao.update(list,"loginName");
|
|
|
|
}
|
|
|
|
|
|
@Data
|
|
public static class HonorImport {
|
|
@Excel(name = "姓名")
|
|
private String userName;
|
|
|
|
@Excel(name = "单位")
|
|
private String unitName;
|
|
|
|
@Excel(name = "身份")
|
|
private String identity;
|
|
|
|
@Excel(name = "时间")
|
|
private String time;
|
|
|
|
}
|
|
|
|
}
|