..
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
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.models.Sys_union;
|
||||
import com.budwk.app.sys.models.Sys_unit;
|
||||
import com.budwk.app.sys.views.View_user;
|
||||
import com.budwk.app.zhgh.dayofficework.rest.models.RestActSignUp;
|
||||
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;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean
|
||||
@RunWith(NbJUnit4Runner.class)
|
||||
public class RestTest {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Test
|
||||
public void importData() {
|
||||
List<Rest> rests = ExcelImportUtil.importExcel(new File("C:\\Users\\jug\\Desktop\\njnu\\疗休养.xlsx"), Rest.class, new ImportParams());
|
||||
|
||||
List<Sys_unit> units = dao.query(Sys_unit.class, Cnd.where(Sys_unit::getUnitLevel, "=", 2));
|
||||
Map<String, Sys_unit> unitMap = units.stream().collect(Collectors.toMap(v -> v.getName(), v -> v));
|
||||
|
||||
List<Sys_union> unions = dao.query(Sys_union.class, Cnd.NEW());
|
||||
Map<String, Sys_union> unionMap = unions.stream().collect(Collectors.toMap(v -> v.getId(), v -> v));
|
||||
|
||||
|
||||
List<RestActSignUp> list = rests.stream().map(v -> {
|
||||
RestActSignUp sign = new RestActSignUp();
|
||||
sign.setRestActId(v.getRestActId());
|
||||
|
||||
View_user viewUser = dao.fetch(View_user.class, Cnd.where(View_user::getUsername, "=", v.getUserName()));
|
||||
if (viewUser != null) {
|
||||
sign.setUserId(viewUser.getId());
|
||||
sign.setUserName(viewUser.getUsername());
|
||||
sign.setLoginName(viewUser.getLoginname());
|
||||
// sign.setUnitId(viewUser.getUnitId());
|
||||
// sign.setUnitName(viewUser.getUnitName());
|
||||
// sign.setUnionId(viewUser.getUnionId());
|
||||
// sign.setUnionName(viewUser.getUnionName());
|
||||
|
||||
sign.setUnitName(viewUser.getUnitName());
|
||||
|
||||
Sys_unit sysUnit = unitMap.get(v.getUnitName());
|
||||
|
||||
if (sysUnit == null) {
|
||||
System.out.println(v.getUnitName());
|
||||
throw new RuntimeException("没有此单位");
|
||||
}
|
||||
|
||||
sign.setUnitId(sysUnit.getId());
|
||||
sign.setUnionId(sign.getUnionId());
|
||||
sign.setUnionName(unionMap.get(sysUnit.getUnionId()).getName());
|
||||
|
||||
} else {
|
||||
sign.setUserName(v.getUserName());
|
||||
}
|
||||
sign.setAge(v.getAge());
|
||||
sign.setBatch(v.getBatch());
|
||||
return sign;
|
||||
}).toList();
|
||||
|
||||
// String s = list.stream().filter(v -> v.getLoginName() == null).map(v -> v.getUserName()).collect(Collectors.joining(","));
|
||||
// System.out.println(s);
|
||||
|
||||
dao.insert(list);
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Rest {
|
||||
@Excel(name = "姓名")
|
||||
private String userName;
|
||||
|
||||
@Excel(name = "单位")
|
||||
private String unitName;
|
||||
|
||||
@Excel(name = "身份")
|
||||
private String identity;
|
||||
|
||||
@Excel(name = "时间")
|
||||
private String time;
|
||||
|
||||
@Excel(name = "活动ID")
|
||||
private String restActId;
|
||||
|
||||
@Excel(name = "批次")
|
||||
private String batch;
|
||||
|
||||
@Excel(name = "年龄")
|
||||
private Integer age;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.budwk.app;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.budwk.app.zhgh.dayofficework.warmthCondolence.models.WarmthCondolence;
|
||||
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.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@IocBean
|
||||
@RunWith(NbJUnit4Runner.class)
|
||||
public class WarmthCondolenceTest {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@Test
|
||||
public void importData() {
|
||||
// List<Warmth> list = ExcelImportUtil.importExcel(new File("C:\\Users\\jug\\Desktop\\njnu\\送温暖.xlsx"), Warmth.class, new ImportParams());
|
||||
//
|
||||
// List<WarmthCondolence> list1 = list.stream().map(v -> {
|
||||
// WarmthCondolence condolence = new WarmthCondolence();
|
||||
// String userName = v.getUserName();
|
||||
// View_user viewUser = dao.fetch(View_user.class, Cnd.where(View_user::getUsername, "=", userName));
|
||||
// if (viewUser != null) {
|
||||
// condolence.setUserName(viewUser.getUsername());
|
||||
// condolence.setLoginName(viewUser.getLoginname());
|
||||
// condolence.setSex(viewUser.getSex());
|
||||
// condolence.setBirthday(viewUser.getBirthday());
|
||||
// condolence.setMobile(viewUser.getMobile());
|
||||
// condolence.setUnitName(viewUser.getUnitName());
|
||||
// condolence.setUnitId(viewUser.getUnitId());
|
||||
// condolence.setUnionName(viewUser.getUnionName());
|
||||
// condolence.setUnionId(viewUser.getUnionId());
|
||||
// }else{
|
||||
// condolence.setUserName(userName);
|
||||
// }
|
||||
// condolence.setAmount(v.getMoney());
|
||||
//
|
||||
// if(v.getYear().equals("2019")){
|
||||
// condolence.setNoticeId("1");
|
||||
// } else if (v.getYear().equals("2020")) {
|
||||
// condolence.setNoticeId("2");
|
||||
// }else if (v.getYear().equals("2021")) {
|
||||
// condolence.setNoticeId("3");
|
||||
// }else if (v.getYear().equals("2022")) {
|
||||
// condolence.setNoticeId("4");
|
||||
// }else if (v.getYear().equals("2023")) {
|
||||
// condolence.setNoticeId("5");
|
||||
// }else if (v.getYear().equals("2024")) {
|
||||
// condolence.setNoticeId("6");
|
||||
// }
|
||||
//
|
||||
// return condolence;
|
||||
// }).toList();
|
||||
//
|
||||
// System.out.println(list1);
|
||||
// dao.insert(list1);
|
||||
|
||||
|
||||
List<WarmthCondolence> list = dao.query(WarmthCondolence.class, Cnd.NEW());
|
||||
Map<String, List<WarmthCondolence>> map = list.stream().collect(Collectors.groupingBy(WarmthCondolence::getNoticeId));
|
||||
|
||||
map.forEach((k, v) -> {
|
||||
if (k.equals("1")) {
|
||||
// 编号 格式为20190001开始
|
||||
int i = 1;
|
||||
for (WarmthCondolence v1 : v) {
|
||||
v1.setNo("2019" + String.format("%04d", i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (k.equals("2")) {
|
||||
// 编号 20200001开始
|
||||
int i = 1;
|
||||
for (WarmthCondolence v1 : v) {
|
||||
v1.setNo("2020" + String.format("%04d", i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (k.equals("3")) {
|
||||
// 编号 20210001开始
|
||||
int i = 1;
|
||||
for (WarmthCondolence v1 : v) {
|
||||
v1.setNo("2021" + String.format("%04d", i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (k.equals("4")) {
|
||||
// 编号 20220001开始
|
||||
int i = 1;
|
||||
for (WarmthCondolence v1 : v) {
|
||||
v1.setNo("2022" + String.format("%04d", i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (k.equals("5")) {
|
||||
// 编号 20230001开始
|
||||
int i = 1;
|
||||
for (WarmthCondolence v1 : v) {
|
||||
v1.setNo("2023" + String.format("%04d", i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (k.equals("6")) {
|
||||
// 编号 20240001开始
|
||||
int i = 1;
|
||||
for (WarmthCondolence v1 : v) {
|
||||
v1.setNo("2024" + String.format("%04d", i));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
dao.update(v,"no");
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Warmth {
|
||||
|
||||
@Excel(name = "姓名")
|
||||
private String userName;
|
||||
|
||||
@Excel(name = "单位")
|
||||
private String unitName;
|
||||
|
||||
@Excel(name = "补助金(元)")
|
||||
private BigDecimal money;
|
||||
|
||||
@Excel(name = "年度")
|
||||
private String year;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user