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