From 4768aa55d4d732c9fbf5c69bae9a5ddff008f43f Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Wed, 24 Aug 2022 13:01:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=B7=A5=E4=BD=9C=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E3=80=911.=E4=B8=80=E4=BA=9B=E5=AD=97=E6=AE=B5=E7=9A=84?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=9B2.=E5=AE=8C=E6=88=90=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=B1=BB=E5=9E=8B=E7=9A=84curd=EF=BC=9B3.=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E8=AE=B0=E5=BD=95-=E8=BF=98=E6=9C=89=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=AF=BC=E5=87=BA=E6=B2=A1=E5=81=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/redis/RedisKeys.java | 1 - .../WorkdiaryServiceQueryFormDTO.java | 18 ++++- .../dto/result/WorkdiaryServiceRecordDTO.java | 4 +- ...r.java => WorkdiaryServiceController.java} | 25 ++++-- .../WorkdiaryServiceTypeController.java | 40 ---------- .../epmet/dao/WorkdiaryServiceTypeDao.java | 9 ++- .../entity/WorkdiaryServiceRecordEntity.java | 2 +- .../entity/WorkdiaryServiceTypeEntity.java | 2 +- .../WorkdiaryServiceRecordService.java | 3 + .../service/WorkdiaryServiceTypeService.java | 5 +- .../WorkdiaryServiceRecordServiceImpl.java | 78 ++++++++++++++++++- .../impl/WorkdiaryServiceTypeServiceImpl.java | 50 ++++++++++-- .../db/migration/workdiary_service.sql | 4 +- .../mapper/WorkdiaryServiceTypeDao.xml | 8 +- 14 files changed, 182 insertions(+), 67 deletions(-) rename epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/{WorkdiaryServiceRecordController.java => WorkdiaryServiceController.java} (86%) delete mode 100755 epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceTypeController.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 4c18a3ea55..bb7edb3e2a 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -871,5 +871,4 @@ public class RedisKeys { public static String getDhToken() { return rootPrefix.concat("dh:token"); } - } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/workdiaryservice/WorkdiaryServiceQueryFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/workdiaryservice/WorkdiaryServiceQueryFormDTO.java index 28d967b175..2f5a628916 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/workdiaryservice/WorkdiaryServiceQueryFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/workdiaryservice/WorkdiaryServiceQueryFormDTO.java @@ -1,10 +1,26 @@ package com.epmet.dto.form.workdiaryservice; +import com.epmet.commons.tools.dto.form.PageFormDTO; import lombok.Data; +/** + * 工作日志-服务 + */ @Data -public class WorkdiaryServiceQueryFormDTO { +public class WorkdiaryServiceQueryFormDTO extends PageFormDTO { + private String id; + private Short serviceType; + private String gridId; + private String applicantName; + private String applicantAddress; + private String serviceContent; + private String applicantMobile; + private String principalName; + //@DateTimeFormat + //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:sss", timezone = "GMT+8") + //private Date serviceTime; + private String remark; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/WorkdiaryServiceRecordDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/WorkdiaryServiceRecordDTO.java index 825c4e76e3..95fcdcc88a 100755 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/WorkdiaryServiceRecordDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/WorkdiaryServiceRecordDTO.java @@ -30,6 +30,7 @@ public class WorkdiaryServiceRecordDTO implements Serializable { * 服务类型 */ private Short serviceType; + private String serviceTypeName; /** * 单位ID @@ -40,6 +41,7 @@ public class WorkdiaryServiceRecordDTO implements Serializable { * 网格ID */ private String gridId; + private String gridName; /** * 组织ID path @@ -74,7 +76,7 @@ public class WorkdiaryServiceRecordDTO implements Serializable { /** * 服务时间 */ - private Date serviceTime; + private String serviceTime; /** * 负责人姓名 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceRecordController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceController.java similarity index 86% rename from epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceRecordController.java rename to epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceController.java index fc8fea3b39..282f6be973 100755 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceRecordController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceController.java @@ -1,6 +1,7 @@ package com.epmet.controller; import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.dto.form.PageFormDTO; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; @@ -20,19 +21,20 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import javax.validation.constraints.NotNull; import java.util.List; import java.util.Map; /** - * 工作日志(服务)-记录 + * 工作日志(服务) * * @author generator generator@elink-cn.com * @since v1.0.0 2022-08-23 */ @RestController @RequestMapping("workdiaryService") -public class WorkdiaryServiceRecordController { +public class WorkdiaryServiceController { @Autowired private WorkdiaryServiceRecordService workdiaryServiceRecordService; @@ -42,12 +44,21 @@ public class WorkdiaryServiceRecordController { /** * 记录-分页 - * @param params * @return */ @RequestMapping("/record/page") - public Result> recordPage(@RequestBody WorkdiaryServiceQueryFormDTO input){ - PageData page = workdiaryServiceRecordService.page(null); + public Result> recordPage(@RequestBody WorkdiaryServiceQueryFormDTO query){ + String gridId = query.getGridId(); + Short serviceType = query.getServiceType(); + String applicantName = query.getApplicantName(); + String applicantAddress = query.getApplicantAddress(); + String serviceContent = query.getServiceContent(); + String applicantMobile = query.getApplicantMobile(); + Integer pageNo = query.getPageNo(); + Integer pageSize = query.getPageSize(); + + PageData page = workdiaryServiceRecordService.page( + gridId, serviceType, applicantName, applicantAddress, serviceContent, applicantMobile, pageNo, pageSize); return new Result>().ok(page); } @@ -116,8 +127,8 @@ public class WorkdiaryServiceRecordController { * @return */ @RequestMapping("/serviceType/page") - public Result> serviceTypePage(@RequestParam Map params){ - PageData page = workdiaryServiceTypeService.page(params); + public Result> serviceTypePage(@RequestBody PageFormDTO input){ + PageData page = workdiaryServiceTypeService.page(input.getPageNo(), input.getPageSize()); return new Result>().ok(page); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceTypeController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceTypeController.java deleted file mode 100755 index 8d473d494b..0000000000 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkdiaryServiceTypeController.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.epmet.controller; - -import com.epmet.commons.tools.aop.NoRepeatSubmit; -import com.epmet.commons.tools.page.PageData; -import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.validator.AssertUtils; -import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.commons.tools.validator.group.AddGroup; -import com.epmet.commons.tools.validator.group.UpdateGroup; -import com.epmet.commons.tools.validator.group.DefaultGroup; -import com.epmet.dto.ActSummaryDTO; -import com.epmet.dto.WorkdiaryServiceTypeDTO; -import com.epmet.entity.WorkdiaryServiceTypeExcel; -import com.epmet.service.WorkdiaryServiceTypeService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; -import java.util.Map; - - -/** - * 工作日志(服务)-服务类型 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2022-08-23 - */ -@RestController -@RequestMapping("workdiaryServiceType") -public class WorkdiaryServiceTypeController { - - - - - - - -} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceTypeDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceTypeDao.java index fe37602384..5997be4147 100755 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceTypeDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/WorkdiaryServiceTypeDao.java @@ -3,6 +3,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.entity.WorkdiaryServiceTypeEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 工作日志(服务)-服务类型 @@ -12,5 +13,11 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface WorkdiaryServiceTypeDao extends BaseDao { - + + /** + * 该客户最大的type是啥 + * @param customerId + * @return + */ + Short getMaxType(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceRecordEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceRecordEntity.java index 35ea3e19dd..4b74496fd6 100755 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceRecordEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceRecordEntity.java @@ -74,7 +74,7 @@ public class WorkdiaryServiceRecordEntity extends BaseEpmetEntity { /** * 服务时间 */ - private Date serviceTime; + private String serviceTime; /** * 负责人姓名 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeEntity.java index 2f3258503b..868fb4e001 100755 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/WorkdiaryServiceTypeEntity.java @@ -39,6 +39,6 @@ public class WorkdiaryServiceTypeEntity extends BaseEpmetEntity { /** * 是否启用。0:禁用,1:启用 */ - private Integer enabled; + private Short enabled; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceRecordService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceRecordService.java index ee543708a3..47671ea202 100755 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceRecordService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceRecordService.java @@ -26,6 +26,9 @@ public interface WorkdiaryServiceRecordService extends BaseService page(Map params); + PageData page(String gridId, Short serviceType, String applicantName, String applicantAddress, + String serviceContent, String applicantMobile, Integer pageNo, Integer pageSize); + /** * 默认查询 * diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceTypeService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceTypeService.java index 88318950a4..4d969e1337 100755 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceTypeService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkdiaryServiceTypeService.java @@ -19,12 +19,11 @@ public interface WorkdiaryServiceTypeService extends BaseService * @author generator * @date 2022-08-23 */ - PageData page(Map params); + PageData page(Integer pageNo, Integer pageSize); /** * 默认查询 @@ -36,6 +35,8 @@ public interface WorkdiaryServiceTypeService extends BaseService list(Map params); + List list(Integer pageNo, Integer pageSize); + /** * 单条查询 * diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceRecordServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceRecordServiceImpl.java index 3211ae09b1..b38bd0d85b 100755 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceRecordServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceRecordServiceImpl.java @@ -1,16 +1,32 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.EpmetRequestHolder; +import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.dao.WorkdiaryServiceRecordDao; +import com.epmet.dao.WorkdiaryServiceTypeDao; +import com.epmet.dto.IcResiUserDTO; +import com.epmet.dto.WorkdiaryServiceTypeDTO; import com.epmet.dto.result.WorkdiaryServiceRecordDTO; import com.epmet.entity.WorkdiaryServiceRecordEntity; +import com.epmet.entity.WorkdiaryServiceTypeEntity; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.redis.WorkdiaryServiceRecordRedis; import com.epmet.service.WorkdiaryServiceRecordService; +import com.epmet.service.WorkdiaryServiceTypeService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,6 +35,8 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; /** * 工作日志(服务)-记录 @@ -27,11 +45,17 @@ import java.util.Map; * @since v1.0.0 2022-08-23 */ @Service -public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl implements WorkdiaryServiceRecordService { +public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl implements WorkdiaryServiceRecordService, ResultDataResolver { @Autowired private WorkdiaryServiceRecordRedis workdiaryServiceRecordRedis; + @Autowired + private WorkdiaryServiceTypeDao workdiaryServiceTypeDao; + + @Autowired + private EpmetUserOpenFeignClient userOpenFeignClient; + @Override public PageData page(Map params) { IPage page = baseDao.selectPage( @@ -41,6 +65,31 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl page(String gridId, Short serviceType, String applicantName, String applicantAddress, + String serviceContent, String applicantMobile, Integer pageNo, Integer pageSize) { + + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(StringUtils.isNotBlank(gridId), WorkdiaryServiceRecordEntity::getGridId, gridId); + query.eq(serviceType != null, WorkdiaryServiceRecordEntity::getServiceType, serviceType); + query.like(StringUtils.isNotBlank(applicantName), WorkdiaryServiceRecordEntity::getApplicantName, applicantName); + query.like(StringUtils.isNotBlank(applicantAddress), WorkdiaryServiceRecordEntity::getApplicantAddress, applicantAddress); + query.like(StringUtils.isNotBlank(serviceContent), WorkdiaryServiceRecordEntity::getServiceContent, serviceContent); + query.like(StringUtils.isNotBlank(applicantMobile), WorkdiaryServiceRecordEntity::getApplicantMobile, applicantMobile); + + // 查找类型列表 + List stList = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).list(1, 100); + Map stMap = stList.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceType, WorkdiaryServiceTypeDTO::getServiceTypeName)); + + // 查找服务记录 + PageHelper.startPage(pageNo, pageSize); + List list = baseDao.selectList(query) + .stream() + .map(e -> convertEntity2DTO(e, stMap)) + .collect(Collectors.toList()); + return new PageData<>(list, new PageInfo<>(list).getTotal(), pageSize); + } + @Override public List list(Map params) { List entityList = baseDao.selectList(getWrapper(params)); @@ -60,13 +109,24 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl entity.setOrgIdPath(gi.getPids().concat(":").concat(gi.getId()))); + + IcResiUserDTO applicant = getResultDataOrThrowsException(userOpenFeignClient.getIcResiUserDTO(dto.getApplicantId()), ServiceConstant.EPMET_USER_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "未找到申请人信息"); + + if (applicant != null) { + entity.setApplicantName(applicant.getName()); + } insert(entity); } @@ -84,4 +144,18 @@ public class WorkdiaryServiceRecordServiceImpl extends BaseServiceImpl stMap) { + + if (stMap == null || stMap.size() == 0) { + // 查找类型列表 + List list = SpringContextUtils.getBean(WorkdiaryServiceTypeService.class).list(1, 100); + stMap = list.stream().collect(Collectors.toMap(WorkdiaryServiceTypeDTO::getServiceType, WorkdiaryServiceTypeDTO::getServiceTypeName)); + } + + WorkdiaryServiceRecordDTO d = ConvertUtils.sourceToTarget(entity, WorkdiaryServiceRecordDTO.class); + Optional.ofNullable(CustomerOrgRedis.getGridInfo(entity.getGridId())).ifPresent((gridInfo) -> d.setGridName(gridInfo.getAgencyName() + gridInfo.getGridName())); + d.setServiceTypeName(stMap.get(entity.getServiceType())); + return d; + } + } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceTypeServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceTypeServiceImpl.java index 2058e93c47..e81f8b7c30 100755 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceTypeServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkdiaryServiceTypeServiceImpl.java @@ -1,16 +1,23 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.utils.EpmetRequestHolder; import com.epmet.dao.WorkdiaryServiceTypeDao; import com.epmet.dto.WorkdiaryServiceTypeDTO; import com.epmet.entity.WorkdiaryServiceTypeEntity; import com.epmet.redis.WorkdiaryServiceTypeRedis; import com.epmet.service.WorkdiaryServiceTypeService; +import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 工作日志(服务)-服务类型 @@ -31,14 +39,13 @@ public class WorkdiaryServiceTypeServiceImpl extends BaseServiceImpl page(Map params) { - IPage page = baseDao.selectPage( - getPage(params, FieldConstant.CREATED_TIME, false), - getWrapper(params) - ); - return getPageData(page, WorkdiaryServiceTypeDTO.class); + public PageData page(Integer pageNo, Integer pageSize) { + List list = list(pageNo, pageSize); + return new PageData<>(list, new PageInfo<>(list).getTotal(), pageSize); } @Override @@ -48,6 +55,20 @@ public class WorkdiaryServiceTypeServiceImpl extends BaseServiceImpl list(Integer pageNo, Integer pageSize) { + LambdaQueryWrapper stQuery = new LambdaQueryWrapper<>(); + stQuery.eq(WorkdiaryServiceTypeEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); + List ds = baseDao.selectList(stQuery).stream().map((e) -> { + WorkdiaryServiceTypeDTO d = new WorkdiaryServiceTypeDTO(); + d.setServiceType(e.getServiceType()); + d.setServiceTypeName(e.getServiceTypeName()); + d.setEnabled(e.getEnabled()); + return d; + }).collect(Collectors.toList()); + return ds; + } + private QueryWrapper getWrapper(Map params){ String id = (String)params.get(FieldConstant.ID_HUMP); @@ -66,8 +87,23 @@ public class WorkdiaryServiceTypeServiceImpl extends BaseServiceImpl query = new LambdaQueryWrapper<>(); + query.eq(WorkdiaryServiceTypeEntity::getCustomerId, customerId); + query.eq(WorkdiaryServiceTypeEntity::getServiceTypeName, dto.getServiceTypeName()); + if (baseDao.selectCount(query) > 0) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "已存在该类别", "已存在该类别"); + } + WorkdiaryServiceTypeEntity entity = ConvertUtils.sourceToTarget(dto, WorkdiaryServiceTypeEntity.class); - insert(entity); + entity.setCustomerId(customerId); + entity.setEnabled(Short.valueOf("1")); + synchronized (this) { + Short max = baseDao.getMaxType(customerId); + entity.setServiceType(++max); + insert(entity); + } } @Override diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/workdiary_service.sql b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/workdiary_service.sql index ebb1138369..d825fba47e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/workdiary_service.sql +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/workdiary_service.sql @@ -3,7 +3,7 @@ CREATE TABLE `workdiary_service_record` ( `ID` varchar(64) NOT NULL COMMENT '主键', `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', - `SERVICE_TYPE` tinyint(1) NOT NULL COMMENT '服务类型', + `SERVICE_TYPE` tinyint(3) NOT NULL COMMENT '服务类型', `AGENCY_ID` varchar(32) NOT NULL COMMENT '单位ID', `GRID_ID` varchar(32) NOT NULL COMMENT '网格ID', `ORG_ID_PATH` varchar(255) NOT NULL COMMENT '组织ID path', @@ -31,7 +31,7 @@ CREATE TABLE `workdiary_service_type` ( `ID` varchar(64) NOT NULL COMMENT '主键', `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', - `SERVICE_TYPE` tinyint(1) NOT NULL COMMENT '服务类型', + `SERVICE_TYPE` tinyint(3) NOT NULL COMMENT '服务类型', `SERVICE_TYPE_NAME` varchar(32) NOT NULL COMMENT '服务类型名称', `ENABLED` tinyint(1) NOT NULL COMMENT '是否启用。0:禁用,1:启用', `DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识 0.未删除 1.已删除', diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceTypeDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceTypeDao.xml index d3fd24730d..b62d6f86c6 100755 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceTypeDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/WorkdiaryServiceTypeDao.xml @@ -17,5 +17,11 @@ - + + \ No newline at end of file