|
@@ -9,6 +9,7 @@ import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.pj.current.satoken.StpUserUtil;
|
|
|
import com.pj.tb_goods_transit.TbGoodsTransit;
|
|
|
import com.pj.tb_people.TbPeople;
|
|
@@ -35,9 +36,11 @@ import javax.swing.filechooser.FileSystemView;
|
|
|
*/
|
|
|
@Service
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
-public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implements IService<TbGroup>{
|
|
|
+public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implements IService<TbGroup> {
|
|
|
|
|
|
- /** 底层 Mapper 对象 */
|
|
|
+ /**
|
|
|
+ * 底层 Mapper 对象
|
|
|
+ */
|
|
|
@Autowired
|
|
|
TbGroupMapper tbGroupMapper;
|
|
|
@Autowired
|
|
@@ -45,32 +48,44 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
|
|
|
@Autowired
|
|
|
private MethodGroupService methodGroupService;
|
|
|
- /** 增 */
|
|
|
- void add(TbGroup t){
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 增
|
|
|
+ */
|
|
|
+ void add(TbGroup t) {
|
|
|
save(t);
|
|
|
}
|
|
|
|
|
|
- /** 删 */
|
|
|
- void delete(Long id){
|
|
|
+ /**
|
|
|
+ * 删
|
|
|
+ */
|
|
|
+ void delete(Long id) {
|
|
|
removeById(id);
|
|
|
}
|
|
|
|
|
|
- /** 改 */
|
|
|
- void update(TbGroup t){
|
|
|
+ /**
|
|
|
+ * 改
|
|
|
+ */
|
|
|
+ void update(TbGroup t) {
|
|
|
updateById(t);
|
|
|
|
|
|
}
|
|
|
|
|
|
- /** 查 */
|
|
|
- TbGroup getById(String id){
|
|
|
+ /**
|
|
|
+ * 查
|
|
|
+ */
|
|
|
+ TbGroup getById(String id) {
|
|
|
return super.getById(id);
|
|
|
}
|
|
|
|
|
|
- /** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
|
|
|
- List<TbGroup> getList(SoMap so) {
|
|
|
- return tbGroupMapper.getList(so);
|
|
|
+ /**
|
|
|
+ * 查集合 - 根据条件(参数为空时代表忽略指定条件)
|
|
|
+ */
|
|
|
+ List<TbGroup> getList(SoMap so) {
|
|
|
+ return tbGroupMapper.getList(so);
|
|
|
}
|
|
|
- public int setLeader(Long groupId,Long leaderId){
|
|
|
+
|
|
|
+ public int setLeader(Long groupId, Long leaderId) {
|
|
|
// 获取当前登录用户id
|
|
|
Long loginId = StpUserUtil.getLoginIdAsLong();
|
|
|
// 获取互助组信息
|
|
@@ -78,19 +93,19 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
// 获取边民信息
|
|
|
TbPeople tbPeople = tbPeopleMapper.selectById(leaderId);
|
|
|
// 如果互助组不存在则抛异常
|
|
|
- if (Objects.isNull(tbGroup)){
|
|
|
+ if (Objects.isNull(tbGroup)) {
|
|
|
throw new RuntimeException("该互助组不存在");
|
|
|
}
|
|
|
// 如果边民不存在
|
|
|
- if (Objects.isNull(tbPeople)){
|
|
|
+ if (Objects.isNull(tbPeople)) {
|
|
|
throw new RuntimeException("该用户不存在");
|
|
|
}
|
|
|
// 如果互助组被锁定则抛异常
|
|
|
- if(tbGroup.getIsLock()==1){
|
|
|
+ if (tbGroup.getIsLock() == 1) {
|
|
|
throw new RuntimeException("该互助组已被锁定");
|
|
|
}
|
|
|
// 如果边民不存在则抛异常
|
|
|
- if (tbPeople.getIsLock()==1){
|
|
|
+ if (tbPeople.getIsLock() == 1) {
|
|
|
throw new RuntimeException("该用户已被锁定");
|
|
|
}
|
|
|
// 设置互助组组长
|
|
@@ -103,22 +118,23 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
int line = tbGroupMapper.updateById(tbGroup);
|
|
|
return line;
|
|
|
}
|
|
|
- public int AddGroupPeople(Long groupId,Long [] peopleIds){
|
|
|
+
|
|
|
+ public int AddGroupPeople(Long groupId, Long[] peopleIds) {
|
|
|
// 获取当前登录用户id
|
|
|
// Long loginId = StpUserUtil.getLoginIdAsLong();
|
|
|
- int line=0;
|
|
|
+ int line = 0;
|
|
|
// 获取互助组信息
|
|
|
TbGroup tbGroup = tbGroupMapper.selectById(groupId);
|
|
|
// 如果互助组不存在则抛异常
|
|
|
- if (Objects.isNull(tbGroup)){
|
|
|
+ if (Objects.isNull(tbGroup)) {
|
|
|
throw new RuntimeException("该互助组不存在");
|
|
|
}
|
|
|
// 如果互助组被锁定则抛异常
|
|
|
- if(tbGroup.getIsLock()==1){
|
|
|
+ if (tbGroup.getIsLock() == 1) {
|
|
|
throw new RuntimeException("该互助组已被锁定");
|
|
|
}
|
|
|
// 如果互助组被删除则抛异常
|
|
|
- if(tbGroup.getDeleteStatus()==1){
|
|
|
+ if (tbGroup.getDeleteStatus() == 1) {
|
|
|
throw new RuntimeException("该互助组已被删除");
|
|
|
}
|
|
|
List<Long> list = Arrays.asList(peopleIds);
|
|
@@ -130,28 +146,29 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
// 写入更新者id
|
|
|
// tbPeople.setUpdateBy(String.valueOf(loginId));
|
|
|
int i = tbPeopleMapper.updateById(tbPeople);
|
|
|
- line= i + 1;
|
|
|
+ line = i + 1;
|
|
|
}
|
|
|
return line;
|
|
|
|
|
|
}
|
|
|
- public int DelGroupPeople(Long groupId,Long [] peopleIds){
|
|
|
+
|
|
|
+ public int DelGroupPeople(Long groupId, Long[] peopleIds) {
|
|
|
|
|
|
// 获取当前登录用户id
|
|
|
Long loginId = StpUserUtil.getLoginIdAsLong();
|
|
|
- int line=0;
|
|
|
+ int line = 0;
|
|
|
// 获取互助组信息
|
|
|
TbGroup tbGroup = tbGroupMapper.selectById(groupId);
|
|
|
// 如果互助组不存在则抛异常
|
|
|
- if (Objects.isNull(tbGroup)){
|
|
|
+ if (Objects.isNull(tbGroup)) {
|
|
|
throw new RuntimeException("该互助组不存在");
|
|
|
}
|
|
|
// 如果互助组被锁定则抛异常
|
|
|
- if(tbGroup.getIsLock()==1){
|
|
|
+ if (tbGroup.getIsLock() == 1) {
|
|
|
throw new RuntimeException("该互助组已被锁定");
|
|
|
}
|
|
|
// 如果互助组被删除则抛异常
|
|
|
- if(tbGroup.getDeleteStatus()==1){
|
|
|
+ if (tbGroup.getDeleteStatus() == 1) {
|
|
|
throw new RuntimeException("该互助组已被删除");
|
|
|
}
|
|
|
List<Long> list = Arrays.asList(peopleIds);
|
|
@@ -163,10 +180,11 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
// 写入更新者id
|
|
|
tbPeople.setUpdateBy(String.valueOf(loginId));
|
|
|
int i = tbPeopleMapper.updateById(tbPeople);
|
|
|
- line= i + 1;
|
|
|
+ line = i + 1;
|
|
|
}
|
|
|
return line;
|
|
|
}
|
|
|
+
|
|
|
public int isLock(TbGroupDto tbGroupDto) {
|
|
|
// 获取当前登录用户id
|
|
|
Long loginId = StpUserUtil.getLoginIdAsLong();
|
|
@@ -177,18 +195,45 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
throw new RuntimeException("该互助组不存在");
|
|
|
}
|
|
|
// 如果互助组被删除则抛异常
|
|
|
- if (tbGroup.getDeleteStatus()==1) {
|
|
|
+ if (tbGroup.getDeleteStatus() == 1) {
|
|
|
throw new RuntimeException("该互助组已被删除");
|
|
|
}
|
|
|
- BeanUtils.copyProperties(tbGroupDto,tbGroup);
|
|
|
+ BeanUtils.copyProperties(tbGroupDto, tbGroup);
|
|
|
// 写入更新者id
|
|
|
tbGroup.setUpdateBy(String.valueOf(loginId));
|
|
|
// 更新互助组信息
|
|
|
int line = tbGroupMapper.updateById(tbGroup);
|
|
|
return line;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据互助组id查看组内成员
|
|
|
+ *
|
|
|
+ * @author loovi
|
|
|
+ * @date
|
|
|
+ */
|
|
|
+ public AjaxJson getMemberListByGroupId(Long id) {
|
|
|
+ SoMap so = SoMap.getRequestSoMap();
|
|
|
+ so.set("groupId",id);
|
|
|
+ List<TbPeople> list = tbPeopleMapper.getMemberListByGroupId(so.startPage());
|
|
|
+ return AjaxJson.getPageData(so.getDataCount(), list);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *组长查看互助组内成员
|
|
|
+ *
|
|
|
+ * @author loovi
|
|
|
+ * @date
|
|
|
+ */
|
|
|
+ public AjaxJson getMemberListByLeaderId(Long id){
|
|
|
+ SoMap so = SoMap.getRequestSoMap();
|
|
|
+ so.set("leaderId",id);
|
|
|
+ List<TbPeople> list = tbPeopleMapper.getMemberListByLeaderId(so.startPage());
|
|
|
+ return AjaxJson.getPageData(so.getDataCount(), list);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导入
|
|
|
+ *
|
|
|
* @param file excel文件
|
|
|
* @return
|
|
|
* @throws IOException
|
|
@@ -197,7 +242,7 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
System.out.println("\n开始执行文件上传....\n");
|
|
|
|
|
|
//判空
|
|
|
- if(file.isEmpty()) return "文件为空,无法执行上传...";
|
|
|
+ if (file.isEmpty()) return "文件为空,无法执行上传...";
|
|
|
//获取文件上传数据
|
|
|
HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
|
|
|
//获取第一页sheet
|
|
@@ -210,18 +255,19 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
count = methodGroupService.importMethod(row, sheet, count);
|
|
|
wb.close();
|
|
|
System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
|
|
|
- return "上传完成,共上传" + count + "条" + "数据。";
|
|
|
+ return "上传完成,共上传" + count + "条" + "数据。";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导出 excel文件
|
|
|
+ *
|
|
|
* @param keyword
|
|
|
* @return
|
|
|
*/
|
|
|
- public String outportExcel(String keyword,String filepath) throws IOException {
|
|
|
+ public String outportExcel(String keyword, String filepath) throws IOException {
|
|
|
System.out.println("\n开始执行文件导出....\n");
|
|
|
//导出的文件的路径
|
|
|
- if(filepath == null || filepath.trim().equals("")){
|
|
|
+ if (filepath == null || filepath.trim().equals("")) {
|
|
|
// 获取当前用户的桌面路径
|
|
|
FileSystemView fileSystemView = FileSystemView.getFileSystemView();
|
|
|
filepath = fileSystemView.getHomeDirectory().getPath();
|
|
@@ -229,7 +275,7 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
filepath = filepath + "\\互助组数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
|
|
|
//根据需求查询数据
|
|
|
List<TbGroup> selectedList = tbGroupMapper.selectList(new LambdaQueryWrapper<TbGroup>().eq(StringUtils.isNoneBlank(keyword), TbGroup::getName, keyword));
|
|
|
- if(selectedList.size() == 0)return "没有可导出的数据。";
|
|
|
+ if (selectedList.size() == 0) return "没有可导出的数据。";
|
|
|
//建立excel对象封装数据
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
//创建excel表格右下角的sheet页名称
|
|
@@ -261,24 +307,24 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
for (int i = 0; i < selectedList.size(); i++) {
|
|
|
HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
sheetRow.createCell(0).setCellValue(i + 1);
|
|
|
- sheetRow.createCell(1).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
|
|
|
- sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
|
|
|
- sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null")? "": selectedList.get(i).getDetailAddress() + "");
|
|
|
- sheetRow.createCell(4).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
|
|
|
- sheetRow.createCell(5).setCellValue((selectedList.get(i).getLeaderId() + "").equals("null")? "": selectedList.get(i).getLeaderId() + "");
|
|
|
- sheetRow.createCell(6).setCellValue((selectedList.get(i).getLeaderName() + "").equals("null")? "": selectedList.get(i).getLeaderName() + "");
|
|
|
- sheetRow.createCell(7).setCellValue((selectedList.get(i).getLeaderPhone() + "").equals("null")? "": selectedList.get(i).getLeaderPhone() + "");
|
|
|
- sheetRow.createCell(8).setCellValue((selectedList.get(i).getCode() + "" ).equals("null")? "": selectedList.get(i).getCode() + "");
|
|
|
- sheetRow.createCell(9).setCellValue((selectedList.get(i).getLeftPrice() + "").equals("null")? "": selectedList.get(i).getLeftPrice() + "");
|
|
|
+ sheetRow.createCell(1).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null") ? "" : selectedList.get(i).getAddressIds() + "");
|
|
|
+ sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddress() + "").equals("null") ? "" : selectedList.get(i).getAddress() + "");
|
|
|
+ sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null") ? "" : selectedList.get(i).getDetailAddress() + "");
|
|
|
+ sheetRow.createCell(4).setCellValue((selectedList.get(i).getName() + "").equals("null") ? "" : selectedList.get(i).getName() + "");
|
|
|
+ sheetRow.createCell(5).setCellValue((selectedList.get(i).getLeaderId() + "").equals("null") ? "" : selectedList.get(i).getLeaderId() + "");
|
|
|
+ sheetRow.createCell(6).setCellValue((selectedList.get(i).getLeaderName() + "").equals("null") ? "" : selectedList.get(i).getLeaderName() + "");
|
|
|
+ sheetRow.createCell(7).setCellValue((selectedList.get(i).getLeaderPhone() + "").equals("null") ? "" : selectedList.get(i).getLeaderPhone() + "");
|
|
|
+ sheetRow.createCell(8).setCellValue((selectedList.get(i).getCode() + "").equals("null") ? "" : selectedList.get(i).getCode() + "");
|
|
|
+ sheetRow.createCell(9).setCellValue((selectedList.get(i).getLeftPrice() + "").equals("null") ? "" : selectedList.get(i).getLeftPrice() + "");
|
|
|
|
|
|
//公共字段
|
|
|
- sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
|
|
|
- sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
|
|
|
- sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
|
|
|
- sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
|
|
|
- sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null")? "": selectedList.get(i).getUpdateBy() + "");
|
|
|
- sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null")? "": selectedList.get(i).getUpdateName() + "");
|
|
|
- sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null")? "": selectedList.get(i).getDeleteStatus() + "");
|
|
|
+ sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null") ? "" : selectedList.get(i).getCreateTime() + "");
|
|
|
+ sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null") ? "" : selectedList.get(i).getCreateBy() + "");
|
|
|
+ sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null") ? "" : selectedList.get(i).getCreateName() + "");
|
|
|
+ sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null") ? "" : selectedList.get(i).getUpdateTime() + "");
|
|
|
+ sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null") ? "" : selectedList.get(i).getUpdateBy() + "");
|
|
|
+ sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null") ? "" : selectedList.get(i).getUpdateName() + "");
|
|
|
+ sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null") ? "" : selectedList.get(i).getDeleteStatus() + "");
|
|
|
count += 1;
|
|
|
}
|
|
|
//建立输出流,输出文件
|
|
@@ -293,5 +339,5 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
|
|
|
return "数据导出完成!共导出 " + count + " 条数据。";
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
+
|