手动调试
This commit is contained in:
parent
1e405e2264
commit
02ecb6e6ba
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.base.basic.mapper;
|
||||
|
||||
import com.bonus.base.basic.domain.TbPeople;
|
||||
import com.bonus.base.basic.domain.TbPeopleDto;
|
||||
import com.bonus.base.screen.vo.PeoplePositionVo;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -79,5 +80,7 @@ public interface TbPeopleMapper {
|
|||
* @return
|
||||
*/
|
||||
SysUser getUserById(Long userId);
|
||||
|
||||
TbPeople queryByName1(TbPeopleDto tbPeople);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -347,12 +347,6 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
@Override
|
||||
public AjaxResult importTbPeople(MultipartFile file) {
|
||||
String fileName = file.getOriginalFilename();
|
||||
File tempFile = null;
|
||||
try {
|
||||
tempFile = File.createTempFile("upload_", ".tmp");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (fileName != null) {
|
||||
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
if (!Constants.XLSX.equalsIgnoreCase(fileExtension)) {
|
||||
|
|
@ -360,11 +354,9 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
return AjaxResult.error("导入失败:文件后缀名不符合要求,必须为xlsx结尾");
|
||||
}
|
||||
}
|
||||
InputStream inputStream = null;
|
||||
Workbook workbook = null;
|
||||
try {
|
||||
inputStream = file.getInputStream();
|
||||
workbook = new XSSFWorkbook(inputStream);
|
||||
InputStream inputStream = file.getInputStream();
|
||||
Workbook workbook = new XSSFWorkbook(inputStream);
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
// 得到Excel的行数
|
||||
int totalRows = sheet.getPhysicalNumberOfRows();
|
||||
|
|
@ -391,35 +383,30 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
List<TbPeopleDto> tbPeopleList = util.importExcel(file.getInputStream());
|
||||
int result = 0;
|
||||
for (TbPeopleDto tbPeople : tbPeopleList) {
|
||||
List<TbPeople> peopleList = tbPeopleDao.queryByName(tbPeople);
|
||||
if (CollectionUtils.isNotEmpty(peopleList)) {
|
||||
for (TbPeople people : peopleList) {
|
||||
if (StringUtils.isNotBlank(people.getIdCard()) && StringUtils.isNotBlank(tbPeople.getIdCard())) {
|
||||
if (Objects.equals(Sm4Utils.decode(people.getIdCard()), tbPeople.getIdCard())) {
|
||||
//进行更新操作
|
||||
TbPeople dto = new TbPeople();
|
||||
dto.setId(people.getId());
|
||||
dto.setUpdateUser(SecurityUtils.getUserId());
|
||||
dto.setDelFlag(0);
|
||||
dto.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
dto.setIdCard(Sm4Utils.encode(tbPeople.getIdCard()));
|
||||
dto.setSex(tbPeople.getGender());
|
||||
dto.setRelName(tbPeople.getRelName());
|
||||
dto.setPostCode(tbPeople.getPostCode());
|
||||
result += tbPeopleDao.update(dto);
|
||||
} else {
|
||||
//新增操作
|
||||
TbPeople dto = new TbPeople();
|
||||
dto.setCreateUser(SecurityUtils.getUserId());
|
||||
dto.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
dto.setIdCard(Sm4Utils.encode(tbPeople.getIdCard()));
|
||||
dto.setSex(tbPeople.getGender());
|
||||
dto.setRelName(tbPeople.getRelName());
|
||||
dto.setPostCode(tbPeople.getPostCode());
|
||||
result += tbPeopleDao.insert(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
//List<TbPeople> peopleList = tbPeopleDao.queryByName(tbPeople);
|
||||
TbPeople people = tbPeopleDao.queryByName1(tbPeople);
|
||||
if (people != null) {
|
||||
//进行更新操作
|
||||
TbPeople dto = new TbPeople();
|
||||
dto.setId(people.getId());
|
||||
dto.setUpdateUser(SecurityUtils.getUserId());
|
||||
dto.setDelFlag(0);
|
||||
dto.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
dto.setIdCard(tbPeople.getIdCard());
|
||||
dto.setSex(tbPeople.getGender());
|
||||
dto.setRelName(tbPeople.getRelName());
|
||||
dto.setPostCode(tbPeople.getPostCode());
|
||||
result += tbPeopleDao.update(dto);
|
||||
} else {
|
||||
//新增操作
|
||||
TbPeople dto = new TbPeople();
|
||||
dto.setCreateUser(SecurityUtils.getUserId());
|
||||
dto.setRelPhone(Sm4Utils.encode(tbPeople.getRelPhone()));
|
||||
dto.setIdCard(tbPeople.getIdCard());
|
||||
dto.setSex(tbPeople.getGender());
|
||||
dto.setRelName(tbPeople.getRelName());
|
||||
dto.setPostCode(tbPeople.getPostCode());
|
||||
result += tbPeopleDao.insert(dto);
|
||||
}
|
||||
}
|
||||
if (result > 0) {
|
||||
|
|
@ -427,27 +414,6 @@ public class TbPeopleServiceImpl implements TbPeopleService {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (workbook != null) {
|
||||
try {
|
||||
// 关闭工作簿
|
||||
workbook.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
// 关闭输入流
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 删除临时文件
|
||||
if (tempFile != null && tempFile.exists()) {
|
||||
tempFile.delete();
|
||||
}
|
||||
}
|
||||
return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,5 +156,19 @@
|
|||
<select id="getUserById" resultType="com.bonus.system.api.domain.SysUser">
|
||||
select user_id as userId, user_name as userName, password as password from sys_user where user_id = #{userId}
|
||||
</select>
|
||||
<select id="queryByName1" resultType="com.bonus.base.basic.domain.TbPeople">
|
||||
select tp.id as id,
|
||||
tp.team_id as teamId,
|
||||
tp.rel_name as relName,
|
||||
tp.rel_phone as relPhone,
|
||||
tp.id_card as idCard,
|
||||
tp.post_code as postCode,
|
||||
tp.sex as sex
|
||||
from tb_people tp
|
||||
where tp.del_flag = '0'
|
||||
<if test="idCard != null and idCard != ''">
|
||||
and tp.id_card = #{idCard}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue