From 12c86527701af61593ab16aa322c3f7dd08aa019 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 19 三月 2024 17:34:33 +0800
Subject: [PATCH] 报备、添加运维人员增加账号
---
ycl-server/src/main/java/com/ycl/platform/service/impl/YwPeopleServiceImpl.java | 57 ++++
ycl-server/src/main/java/com/ycl/platform/mapper/ReportMapper.java | 19 +
ycl-server/src/main/java/com/ycl/platform/controller/YwPointController.java | 7
ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java | 163 +++++++++++++
ycl-pojo/src/main/java/com/ycl/platform/domain/form/ReportForm.java | 58 ++++
ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml | 4
ycl-pojo/src/main/java/com/ycl/platform/domain/entity/Report.java | 55 ++++
ycl-pojo/src/main/java/com/ycl/platform/domain/query/ReportQuery.java | 23 +
ycl-server/src/main/java/com/ycl/platform/service/ReportService.java | 65 +++++
ycl-pojo/src/main/java/com/ycl/platform/domain/entity/YwPeople.java | 3
ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java | 75 ++++++
ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java | 11
ycl-server/src/main/resources/mapper/zgyw/ReportMapper.xml | 19 +
ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java | 44 +++
ycl-pojo/src/main/java/com/ycl/platform/domain/vo/ReportVO.java | 56 ++++
ycl-server/src/main/java/com/ycl/platform/service/YwPointService.java | 8
16 files changed, 651 insertions(+), 16 deletions(-)
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/Report.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/Report.java
new file mode 100644
index 0000000..208afb5
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/Report.java
@@ -0,0 +1,55 @@
+package com.ycl.platform.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.time.LocalDateTime;
+import com.ycl.platform.base.AbsEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 鎶ュ
+ *
+ * @author xp
+ * @since 2024-03-19
+ */
+@Data
+@Accessors(chain = true)
+@TableName("t_report")
+@ApiModel(value = "Report瀵硅薄", description = "鎶ュ")
+public class Report extends AbsEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("杩愮淮鍗曚綅ID")
+ @TableField("unit_id")
+ private Integer unitId;
+
+ @ApiModelProperty("杩愮淮浜哄憳ID")
+ @TableField("people_id")
+ private Integer peopleId;
+
+ @ApiModelProperty("鐐逛綅ID")
+ @TableField("point_id")
+ private Integer pointId;
+
+ @ApiModelProperty("瀹℃牳鏃堕棿")
+ @TableField("auditing_time")
+ private LocalDateTime auditingTime;
+
+ @ApiModelProperty("鎶ュ鍐呭")
+ @TableField("report_content")
+ private String reportContent;
+
+ @ApiModelProperty("涓婃姤鏉愭枡")
+ @TableField("report_materials")
+ private String reportMaterials;
+
+ @ApiModelProperty("鏁呴殰绫诲瀷")
+ @TableField("error_type")
+ private String errorType;
+
+
+}
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/YwPeople.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/YwPeople.java
index ffb7220..81e387b 100644
--- a/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/YwPeople.java
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/entity/YwPeople.java
@@ -51,4 +51,7 @@
@TableField("remark")
private String remark;
+ @TableField("user_id")
+ private Long userId;
+
}
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/form/ReportForm.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/form/ReportForm.java
new file mode 100644
index 0000000..208918b
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/form/ReportForm.java
@@ -0,0 +1,58 @@
+package com.ycl.platform.domain.form;
+
+import com.ycl.system.domain.group.Update;
+import com.ycl.system.domain.group.Add;
+import com.ycl.platform.base.AbsForm;
+import com.ycl.platform.domain.entity.Report;
+import java.time.LocalDateTime;
+import org.springframework.beans.BeanUtils;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import org.springframework.lang.NonNull;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 鎶ュ琛ㄥ崟
+ *
+ * @author xp
+ * @since 2024-03-19
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "Report琛ㄥ崟", description = "鎶ュ琛ㄥ崟")
+public class ReportForm extends AbsForm {
+
+ private Integer unitId;
+
+ private Integer peopleId;
+
+ @NotNull(message = "鐐逛綅涓嶈兘涓虹┖", groups = {Add.class, Update.class})
+ @ApiModelProperty("鐐逛綅")
+ private Integer pointId;
+
+ @ApiModelProperty("瀹℃牳鏃堕棿")
+ private LocalDateTime auditingTime;
+
+ @NotBlank(message = "鎶ュ鍐呭涓嶈兘涓虹┖", groups = {Add.class, Update.class})
+ @ApiModelProperty("鎶ュ鍐呭")
+ private String reportContent;
+
+ @NotBlank(message = "涓婃姤鏉愭枡涓嶈兘涓虹┖", groups = {Add.class, Update.class})
+ @ApiModelProperty("涓婃姤鏉愭枡")
+ private String reportMaterials;
+
+ @ApiModelProperty("鏁呴殰绫诲瀷")
+ private String errorType;
+
+ public static Report getEntityByForm(@NonNull ReportForm form, Report entity) {
+ if(entity == null) {
+ entity = new Report();
+ }
+ BeanUtils.copyProperties(form, entity);
+ return entity;
+ }
+
+}
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/query/ReportQuery.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/query/ReportQuery.java
new file mode 100644
index 0000000..4c14366
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/query/ReportQuery.java
@@ -0,0 +1,23 @@
+package com.ycl.platform.domain.query;
+
+import com.ycl.platform.base.AbsQuery;
+import java.util.List;
+import org.springframework.lang.NonNull;
+import jakarta.validation.constraints.NotBlank;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 鎶ュ鏌ヨ
+ *
+ * @author xp
+ * @since 2024-03-19
+ */
+@Data
+@Accessors(chain = true)
+@ApiModel(value = "Report鏌ヨ", description = "鎶ュ鏌ヨ")
+public class ReportQuery extends AbsQuery {
+}
+
diff --git a/ycl-pojo/src/main/java/com/ycl/platform/domain/vo/ReportVO.java b/ycl-pojo/src/main/java/com/ycl/platform/domain/vo/ReportVO.java
new file mode 100644
index 0000000..0fbc203
--- /dev/null
+++ b/ycl-pojo/src/main/java/com/ycl/platform/domain/vo/ReportVO.java
@@ -0,0 +1,56 @@
+package com.ycl.platform.domain.vo;
+
+import com.ycl.platform.base.AbsVo;
+import com.ycl.platform.domain.entity.Report;
+import java.util.List;
+import java.time.LocalDateTime;
+import org.springframework.lang.NonNull;
+import org.springframework.beans.BeanUtils;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 鎶ュ灞曠ず
+ *
+ * @author xp
+ * @since 2024-03-19
+ */
+@Data
+@Accessors(chain = true)
+public class ReportVO extends AbsVo {
+
+ /** 杩愮淮鍗曚綅ID */
+ private Integer unitId;
+ private String unitName;
+
+ /** 杩愮淮浜哄憳ID */
+ private Integer peopleId;
+ private String peopleName;
+
+ /** 鐐逛綅ID */
+ private Integer pointId;
+ private String pointName;
+
+ /** 瀹℃牳鏃堕棿 */
+ private LocalDateTime auditingTime;
+
+ /** 鎶ュ鍐呭 */
+ private String reportContent;
+
+ /** 涓婃姤鏉愭枡 */
+ private String reportMaterials;
+
+ /** 鏁呴殰绫诲瀷 */
+ private String errorType;
+
+ public static ReportVO getVoByEntity(@NonNull Report entity, ReportVO vo) {
+ if(vo == null) {
+ vo = new ReportVO();
+ }
+ BeanUtils.copyProperties(entity, vo);
+ return vo;
+ }
+
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java b/ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java
new file mode 100644
index 0000000..0fab314
--- /dev/null
+++ b/ycl-server/src/main/java/com/ycl/platform/controller/ReportController.java
@@ -0,0 +1,75 @@
+package com.ycl.platform.controller;
+
+import com.ycl.system.domain.group.Update;
+import com.ycl.system.domain.group.Add;
+import org.springframework.validation.annotation.Validated;
+import lombok.RequiredArgsConstructor;
+import java.util.List;
+import org.springframework.validation.annotation.Validated;
+import jakarta.validation.constraints.NotEmpty;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import com.ycl.platform.service.ReportService;
+import com.ycl.system.Result;
+import com.ycl.platform.domain.form.ReportForm;
+import com.ycl.platform.domain.query.ReportQuery;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 鎶ュ 鍓嶇鎺у埗鍣�
+ *
+ * @author xp
+ * @since 2024-03-19
+ */
+@Validated
+@RequiredArgsConstructor
+@Api(value = "鎶ュ", tags = "鎶ュ绠$悊")
+@RestController
+@RequestMapping("/report")
+public class ReportController {
+
+ private final ReportService reportService;
+
+ @PostMapping
+ @ApiOperation(value = "娣诲姞", notes = "娣诲姞")
+ public Result add(@RequestBody @Validated(Add.class) ReportForm form) {
+ return reportService.add(form);
+ }
+
+ @PutMapping
+ @ApiOperation(value = "淇敼", notes = "淇敼")
+ public Result update(@RequestBody @Validated(Update.class) ReportForm form) {
+ return reportService.update(form);
+ }
+
+ @DeleteMapping("/{id}")
+ @ApiOperation(value = "ID鍒犻櫎", notes = "ID鍒犻櫎")
+ public Result removeById(@PathVariable("id") String id) {
+ return reportService.removeById(id);
+ }
+
+ @DeleteMapping("/batch")
+ @ApiOperation(value = "鎵归噺鍒犻櫎", notes = "鎵归噺鍒犻櫎")
+ public Result remove(@RequestBody @NotEmpty(message = "璇烽�夋嫨鏁版嵁") List<String> ids) {
+ return reportService.remove(ids);
+ }
+
+ @PostMapping("/page")
+ @ApiOperation(value = "鍒嗛〉", notes = "鍒嗛〉")
+ public Result page(ReportQuery query) {
+ return reportService.page(query);
+ }
+
+ @GetMapping("/{id}")
+ @ApiOperation(value = "璇︽儏", notes = "璇︽儏")
+ public Result detail(@PathVariable("id") String id) {
+ return reportService.detail(id);
+ }
+
+ @GetMapping("/list")
+ @ApiOperation(value = "鍒楄〃", notes = "鍒楄〃")
+ public Result list() {
+ return reportService.all();
+ }
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/controller/YwPointController.java b/ycl-server/src/main/java/com/ycl/platform/controller/YwPointController.java
index 1203544..7bdf1b4 100644
--- a/ycl-server/src/main/java/com/ycl/platform/controller/YwPointController.java
+++ b/ycl-server/src/main/java/com/ycl/platform/controller/YwPointController.java
@@ -3,6 +3,7 @@
import com.ycl.platform.domain.form.BatchEditPointForm;
import com.ycl.system.domain.group.Update;
import com.ycl.system.domain.group.Add;
+import jakarta.validation.constraints.NotBlank;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import lombok.RequiredArgsConstructor;
@@ -87,4 +88,10 @@
public Result list() {
return ywPointService.all();
}
+
+ @GetMapping("/select")
+ @ApiOperation(value = "鐐逛綅涓嬫媺", notes = "鐐逛綅涓嬫媺")
+ public Result select(@NotBlank(message = "璇疯緭鍏ョ偣浣�") String keyword) {
+ return ywPointService.select(keyword);
+ }
}
diff --git a/ycl-server/src/main/java/com/ycl/platform/mapper/ReportMapper.java b/ycl-server/src/main/java/com/ycl/platform/mapper/ReportMapper.java
new file mode 100644
index 0000000..802abaf
--- /dev/null
+++ b/ycl-server/src/main/java/com/ycl/platform/mapper/ReportMapper.java
@@ -0,0 +1,19 @@
+package com.ycl.platform.mapper;
+
+import com.ycl.platform.domain.entity.Report;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ycl.platform.domain.vo.ReportVO;
+import com.ycl.platform.domain.form.ReportForm;
+import java.util.List;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 鎶ュ Mapper 鎺ュ彛
+ *
+ * @author xp
+ * @since 2024-03-19
+ */
+@Mapper
+public interface ReportMapper extends BaseMapper<Report> {
+
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java b/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java
index 2260119..16e18a6 100644
--- a/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java
+++ b/ycl-server/src/main/java/com/ycl/platform/mapper/YwPointMapper.java
@@ -1,11 +1,15 @@
package com.ycl.platform.mapper;
+import com.ycl.platform.base.BaseSelect;
import com.ycl.platform.domain.entity.YwPoint;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ycl.platform.domain.vo.YwPointVO;
import com.ycl.platform.domain.form.YwPointForm;
import java.util.List;
+
+import com.ycl.system.Result;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
/**
* 杩愮淮鐐逛綅 Mapper 鎺ュ彛
@@ -16,4 +20,11 @@
@Mapper
public interface YwPointMapper extends BaseMapper<YwPoint> {
+ /**
+ * 涓嬫媺鏁版嵁
+ * @param keyword
+ * @param unitId
+ * @return
+ */
+ List<BaseSelect> selectData(@Param("keyword") String keyword, @Param("unitId") Integer unitId);
}
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/ReportService.java b/ycl-server/src/main/java/com/ycl/platform/service/ReportService.java
new file mode 100644
index 0000000..c8690b1
--- /dev/null
+++ b/ycl-server/src/main/java/com/ycl/platform/service/ReportService.java
@@ -0,0 +1,65 @@
+package com.ycl.platform.service;
+
+import com.ycl.platform.domain.entity.Report;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ycl.system.Result;
+import com.ycl.platform.domain.form.ReportForm;
+import com.ycl.platform.domain.query.ReportQuery;
+import java.util.List;
+
+/**
+ * 鎶ュ 鏈嶅姟绫�
+ *
+ * @author xp
+ * @since 2024-03-19
+ */
+public interface ReportService extends IService<Report> {
+
+ /**
+ * 娣诲姞
+ * @param form
+ * @return
+ */
+ Result add(ReportForm form);
+
+ /**
+ * 淇敼
+ * @param form
+ * @return
+ */
+ Result update(ReportForm form);
+
+ /**
+ * 鎵归噺鍒犻櫎
+ * @param ids
+ * @return
+ */
+ Result remove(List<String> ids);
+
+ /**
+ * id鍒犻櫎
+ * @param id
+ * @return
+ */
+ Result removeById(String id);
+
+ /**
+ * 鍒嗛〉鏌ヨ
+ * @param query
+ * @return
+ */
+ Result page(ReportQuery query);
+
+ /**
+ * 鏍规嵁id鏌ユ壘
+ * @param id
+ * @return
+ */
+ Result detail(String id);
+
+ /**
+ * 鍒楄〃
+ * @return
+ */
+ Result all();
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/YwPointService.java b/ycl-server/src/main/java/com/ycl/platform/service/YwPointService.java
index 6aa4057..e9603bd 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/YwPointService.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/YwPointService.java
@@ -77,4 +77,12 @@
* @return
*/
Result batchEdit(BatchEditPointForm form);
+
+ /**
+ * 鐐逛綅涓嬫媺
+ *
+ * @param keyword
+ * @return
+ */
+ Result select(String keyword);
}
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
new file mode 100644
index 0000000..7e759e5
--- /dev/null
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
@@ -0,0 +1,163 @@
+package com.ycl.platform.service.impl;
+
+import com.ycl.platform.domain.entity.Region;
+import com.ycl.platform.domain.entity.Report;
+import com.ycl.platform.domain.entity.YwPeople;
+import com.ycl.platform.domain.entity.YwUnit;
+import com.ycl.platform.mapper.RegionMapper;
+import com.ycl.platform.mapper.ReportMapper;
+import com.ycl.platform.mapper.YwPeopleMapper;
+import com.ycl.platform.mapper.YwUnitMapper;
+import com.ycl.platform.service.ReportService;
+import com.ycl.system.Result;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ycl.platform.domain.form.ReportForm;
+import com.ycl.platform.domain.vo.ReportVO;
+import com.ycl.platform.domain.query.ReportQuery;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ycl.system.page.PageUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.beans.BeanUtils;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
+import java.util.ArrayList;
+import java.util.stream.Collectors;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * 鎶ュ 鏈嶅姟瀹炵幇绫�
+ *
+ * @author xp
+ * @since 2024-03-19
+ */
+@Service
+@RequiredArgsConstructor
+public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
+
+ private final ReportMapper reportMapper;
+ private final YwUnitMapper unitMapper;
+ private final YwPeopleMapper peopleMapper;
+ private final RegionMapper regionMapper;
+
+ /**
+ * 娣诲姞
+ * @param form
+ * @return
+ */
+ @Override
+ public Result add(ReportForm form) {
+ Report entity = ReportForm.getEntityByForm(form, null);
+ if(baseMapper.insert(entity) > 0) {
+ return Result.ok("娣诲姞鎴愬姛");
+ }
+ return Result.error("娣诲姞澶辫触");
+ }
+
+ /**
+ * 淇敼
+ * @param form
+ * @return
+ */
+ @Override
+ public Result update(ReportForm form) {
+
+ Report entity = baseMapper.selectById(form.getId());
+
+ // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
+ Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+ BeanUtils.copyProperties(form, entity);
+ if (baseMapper.updateById(entity) > 0) {
+ return Result.ok("淇敼鎴愬姛");
+ }
+ return Result.error("淇敼澶辫触");
+ }
+
+ /**
+ * 鎵归噺鍒犻櫎
+ * @param ids
+ * @return
+ */
+ @Override
+ public Result remove(List<String> ids) {
+ if(baseMapper.deleteBatchIds(ids) > 0) {
+ return Result.ok("鍒犻櫎鎴愬姛");
+ }
+ return Result.error("鍒犻櫎澶辫触");
+ }
+
+ /**
+ * id鍒犻櫎
+ * @param id
+ * @return
+ */
+ @Override
+ public Result removeById(String id) {
+ if(baseMapper.deleteById(id) > 0) {
+ return Result.ok("鍒犻櫎鎴愬姛");
+ }
+ return Result.error("鍒犻櫎澶辫触");
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ
+ * @param query
+ * @return
+ */
+ @Override
+ public Result page(ReportQuery query) {
+
+ IPage<Report> page = new LambdaQueryChainWrapper<>(baseMapper)
+ .orderByDesc(Report::getCreateTime)
+ .page(PageUtil.getPage(query, Report.class));
+
+ List<ReportVO> vos = page.getRecords().stream()
+ .map(
+ entity -> {
+ ReportVO vo = ReportVO.getVoByEntity(entity, null);
+ YwUnit unit = unitMapper.selectById(vo.getUnitId());
+ vo.setUnitName(unit.getUnitName());
+ YwPeople ywPeople = peopleMapper.selectById(vo.getPeopleId());
+ vo.setPeopleName(ywPeople.getYwPersonName());
+ Region region = regionMapper.selectById(vo.getPointId());
+ vo.setPointName(region.getFullName());
+ return vo;
+ }
+ )
+ .collect(Collectors.toList());
+ return Result.ok().data(vos).total(page.getTotal());
+ }
+
+ /**
+ * 鏍规嵁id鏌ユ壘
+ * @param id
+ * @return
+ */
+ @Override
+ public Result detail(String id) {
+
+ Report entity = baseMapper.selectById(id);
+ Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+ ReportVO vo = ReportVO.getVoByEntity(entity, null);
+ return Result.ok().data(vo);
+ }
+
+ /**
+ * 鍒楄〃
+ * @return
+ */
+ @Override
+ public Result all() {
+ List<Report> entities = baseMapper.selectList(null);
+ List<ReportVO> vos = entities.stream()
+ .map(
+ entity -> ReportVO.getVoByEntity(entity, null)
+ )
+ .collect(Collectors.toList());
+ return Result.ok().data(vos);
+ }
+}
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPeopleServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPeopleServiceImpl.java
index 485bc30..53a6c0a 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPeopleServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPeopleServiceImpl.java
@@ -13,9 +13,13 @@
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ycl.system.entity.SysUser;
+import com.ycl.system.mapper.SysUserMapper;
import com.ycl.system.page.PageUtil;
+import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.Objects;
@@ -37,6 +41,8 @@
private final YwPeopleMapper ywPeopleMapper;
private final YwUnitMapper ywUnitMapper;
+ private final PasswordEncoder passwordEncoder;
+ private final SysUserMapper sysUserMapper;
/**
* 娣诲姞
@@ -44,8 +50,15 @@
* @return
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public Result add(YwPeopleForm form) {
+ // 涓鸿繍缁翠汉鍛樻坊鍔犺处鍙�
+ SysUser sysUser = new SysUser();
+ fullUser(sysUser, form);
+ sysUserMapper.insertUser(sysUser);
+
YwPeople entity = YwPeopleForm.getEntityByForm(form, null);
+ entity.setUserId(sysUser.getUserId());
entity.setAddWay("manual");
if(baseMapper.insert(entity) > 0) {
return Result.ok("娣诲姞鎴愬姛");
@@ -54,17 +67,37 @@
}
/**
+ * 璧嬪�紆ser
+ * @param sysUser
+ * @param form
+ */
+ public void fullUser(SysUser sysUser, YwPeopleForm form) {
+ sysUser.setUserName(form.getYwPersonAccount());
+ sysUser.setPassword(passwordEncoder.encode("123456"));
+ sysUser.setStatus("0");
+ sysUser.setDelFlag("0");
+ sysUser.setFirstLogin((short) 0);
+ sysUser.setNickName(form.getYwPersonName());
+ }
+
+ /**
* 淇敼
* @param form
* @return
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public Result update(YwPeopleForm form) {
YwPeople entity = baseMapper.selectById(form.getId());
-
// 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+
+ SysUser sysUser = sysUserMapper.selectUserById(entity.getUserId());
+ sysUser.setUserName(form.getYwPersonAccount());
+ sysUser.setNickName(form.getYwPersonName());
+ sysUserMapper.updateUser(sysUser);
+
BeanUtils.copyProperties(form, entity);
if (baseMapper.updateById(entity) > 0) {
return Result.ok("淇敼鎴愬姛");
@@ -78,11 +111,16 @@
* @return
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public Result remove(List<String> ids) {
- if(baseMapper.deleteBatchIds(ids) > 0) {
- return Result.ok("鍒犻櫎鎴愬姛");
- }
- return Result.error("鍒犻櫎澶辫触");
+ List<YwPeople> list = new LambdaQueryChainWrapper<>(baseMapper)
+ .select(YwPeople::getUserId)
+ .in(YwPeople::getId, ids)
+ .list();
+ List<Long> userIds = list.stream().map(YwPeople::getUserId).collect(Collectors.toList());
+ baseMapper.deleteBatchIds(ids);
+ sysUserMapper.deleteUserByIds((Long[]) userIds.toArray());
+ return Result.ok("鍒犻櫎鎴愬姛");
}
/**
@@ -91,11 +129,12 @@
* @return
*/
@Override
+ @Transactional(rollbackFor = Exception.class)
public Result removeById(String id) {
- if(baseMapper.deleteById(id) > 0) {
- return Result.ok("鍒犻櫎鎴愬姛");
- }
- return Result.error("鍒犻櫎澶辫触");
+ YwPeople ywPeople = baseMapper.selectById(id);
+ sysUserMapper.deleteUserById(ywPeople.getUserId());
+ baseMapper.deleteById(id);
+ return Result.ok("鍒犻櫎鎴愬姛");
}
/**
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
index 60cf212..40f9093 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/YwPointServiceImpl.java
@@ -1,9 +1,14 @@
package com.ycl.platform.service.impl;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
+import com.ycl.platform.base.BaseSelect;
+import com.ycl.platform.domain.entity.Region;
+import com.ycl.platform.domain.entity.YwPeople;
import com.ycl.platform.domain.entity.YwPoint;
import com.ycl.platform.domain.entity.YwUnit;
import com.ycl.platform.domain.form.BatchEditPointForm;
+import com.ycl.platform.mapper.RegionMapper;
+import com.ycl.platform.mapper.YwPeopleMapper;
import com.ycl.platform.mapper.YwPointMapper;
import com.ycl.platform.mapper.YwUnitMapper;
import com.ycl.platform.service.YwPointService;
@@ -15,12 +20,13 @@
import com.ycl.platform.domain.query.YwPointQuery;
import java.util.List;
-import com.ycl.system.entity.SysDept;
+import com.ycl.system.entity.SysUser;
import com.ycl.system.service.ISysDeptService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ycl.system.page.PageUtil;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.ycl.utils.SecurityUtils;
+import enumeration.general.RegionLevelEnum;
import org.springframework.stereotype.Service;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
@@ -28,7 +34,6 @@
import java.util.ArrayList;
import java.util.Objects;
import java.util.stream.Collectors;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.util.StringUtils;
@@ -44,11 +49,11 @@
public class YwPointServiceImpl extends ServiceImpl<YwPointMapper, YwPoint> implements YwPointService {
private final YwPointMapper ywPointMapper;
- @Autowired
- private ISysDeptService deptService;
- @Autowired
- private YwUnitService unitService;
+ private final ISysDeptService deptService;
+ private final YwUnitService unitService;
private final YwUnitMapper ywUnitMapper;
+ private final RegionMapper regionMapper;
+ private final YwPeopleMapper ywPeopleMapper;
/**
* 娣诲姞
@@ -194,4 +199,29 @@
.collect(Collectors.toList());
return Result.ok().data(vos);
}
+
+ @Override
+ public Result select(String keyword) {
+ Long userId = SecurityUtils.getUserId();
+ // 鑾峰彇褰撳墠杩愮淮浜哄憳鐨勮繍缁村崟浣�
+ YwPeople people = new LambdaQueryChainWrapper<>(ywPeopleMapper)
+ .eq(YwPeople::getUserId, userId)
+ .one();
+ Integer unitId = null;
+ if (Objects.nonNull(people)) {
+ unitId = people.getBelongUnit();
+ }
+
+ List<Region> list = new LambdaQueryChainWrapper<>(regionMapper)
+ .eq(Region::getRegionLevel, RegionLevelEnum.STREET)
+ .like(Region::getFullName, keyword)
+ .list();
+ List<BaseSelect> data = list.stream().map(item -> {
+ BaseSelect baseSelect = new BaseSelect();
+ baseSelect.setId(item.getId());
+ baseSelect.setValue(item.getFullName());
+ return baseSelect;
+ }).collect(Collectors.toList());
+ return Result.ok().data(data);
+ }
}
diff --git a/ycl-server/src/main/resources/mapper/zgyw/ReportMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/ReportMapper.xml
new file mode 100644
index 0000000..8e237d6
--- /dev/null
+++ b/ycl-server/src/main/resources/mapper/zgyw/ReportMapper.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ycl.platform.mapper.ReportMapper">
+
+ <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+ <resultMap id="BaseResultMap" type="com.ycl.platform.domain.vo.ReportVO">
+ <result column="id" property="id" />
+ <result column="create_time" property="createTime" />
+ <result column="update_time" property="updateTime" />
+ <result column="unit_id" property="unitId" />
+ <result column="people_id" property="peopleId" />
+ <result column="point_id" property="pointId" />
+ <result column="auditing_time" property="auditingTime" />
+ <result column="report_content" property="reportContent" />
+ <result column="report_materials" property="reportMaterials" />
+ <result column="error_type" property="errorType" />
+ </resultMap>
+
+</mapper>
diff --git a/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml b/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml
index c77e645..270f10d 100644
--- a/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml
+++ b/ycl-server/src/main/resources/mapper/zgyw/YwPointMapper.xml
@@ -13,4 +13,8 @@
<result column="remark" property="remark" />
</resultMap>
+ <select id="selectData" resultType="com.ycl.platform.base.BaseSelect">
+
+ </select>
+
</mapper>
--
Gitblit v1.8.0