提交 68d782d7 作者: 张小凤

Commpany(add)

上级 96965dd1
package com.mmc.pms.auth.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author small
* @Date 2023/7/4 10:55
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CompanyInfoDTO {
private static final long serialVersionUID = 3247519744829926132L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "单位类型,0科比特,1加盟公司", example = "0")
private Integer companyType;
@ApiModelProperty(value = "单位名称", example = "科比特")
private String companyName;
@ApiModelProperty(value = "单位全称", example = "浙江科比特创新科技有限公司")
private String fullName;
@ApiModelProperty(value = "省份名称", example = "广东省")
private String province;
@ApiModelProperty(value = "城市名称", example = "深圳市")
private String city;
@ApiModelProperty(value = "县区名称", example = "南山区")
private String district;
@ApiModelProperty(value = "详细地址", example = "西丽街道万科云城国际创新谷6栋")
private String address;
@ApiModelProperty(value = "联系人", example = "lx")
private String companyUserName;
@ApiModelProperty(value = "联系电话", example = "13925255742")
private String phoneNum;
@ApiModelProperty(value = "备注")
private String remark;
}
package com.mmc.pms.auth.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
/**
* @Author small
* @Date 2023/7/4 10:04
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CompanyInfoVO {
private static final long serialVersionUID = 3247519744829926132L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "单位类型,0科比特,1加盟公司", example = "0")
private Integer companyType;
@ApiModelProperty(value = "单位名称", example = "科比特")
private String companyName;
@ApiModelProperty(value = "单位全称", example = "浙江科比特创新科技有限公司")
private String fullName;
@ApiModelProperty(value = "省份名称", example = "广东省")
private String province;
@ApiModelProperty(value = "城市名称", example = "深圳市")
private String city;
@ApiModelProperty(value = "县区名称", example = "南山区")
private String district;
@ApiModelProperty(value = "详细地址", example = "西丽街道万科云城国际创新谷6栋")
private String address;
@ApiModelProperty(value = "联系人", example = "lx")
private String companyUserName;
@ApiModelProperty(value = "联系电话", example = "13925255742")
private String phoneNum;
@ApiModelProperty(value = "备注")
private String remark;
}
......@@ -26,5 +26,6 @@ public class LoginSuccessDTO implements Serializable {
private String phoneNum;
private String userName;
private String nickName;
private CompanyInfoVO companyInfoVO;
// private RoleInfoDTO roleInfo;
}
......@@ -64,8 +64,8 @@ public class BackstageTaskServiceController extends BaseController {
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ServiceDTO.class)})
@GetMapping("queryWorkService")
public ResultBody<ServiceDTO> queryWorkService(
@ApiParam("作业服务id") @RequestParam(value = "id") Integer id) {
return backstageTaskService.queryById(id);
@ApiParam("作业服务id") @RequestParam(value = "id") Integer id,HttpServletRequest request) {
return backstageTaskService.queryById(id,request);
}
@ApiOperation(value = "查询服务管理列表")
......@@ -75,7 +75,7 @@ public class BackstageTaskServiceController extends BaseController {
@Validated(Page.class) @RequestBody ServiceQO param, HttpServletRequest request) {
return ResultBody.success(
backstageTaskService.queryServiceManagerList(
param, this.getUserLoginInfoFromRedis(request).getUserAccountId()));
param, this.getUserLoginInfoFromRedis(request).getUserAccountId(),this.getUserLoginInfoFromRedis(request).getCompanyInfoVO()));
}
@ApiOperation(value = "远程查询作业服务")
......@@ -93,4 +93,14 @@ public class BackstageTaskServiceController extends BaseController {
@ApiParam("分类id") @RequestBody List<Integer> categoriesId) {
return backstageTaskService.getWorkServiceCountByCategoriesId(categoriesId);
}
@ApiOperation(value = "查询作业服务数量——用于后台调用")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@GetMapping("queryWorkServiceCount")
public ResultBody queryWorkServiceCount(
@ApiParam("单位id") @RequestParam(value = "companyId") Integer companyId,HttpServletRequest request) {
return backstageTaskService.queryByIdCount(companyId);
}
}
package com.mmc.pms.dao;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.entity.ServiceDO;
import com.mmc.pms.model.qo.ServiceQO;
import com.mmc.pms.model.work.dto.ServiceDTO;
......@@ -43,4 +44,6 @@ public interface BackstageTaskServiceDao {
Integer batchUpAndDownWorkService(@Param("param") UpAndDownServiceVO param);
Integer getWorkServiceCountByCategoriesId(@Param("categoriesIds") List<Integer> categoriesIds);
Integer queryByIdCount(Integer companyId);
}
......@@ -62,7 +62,8 @@ public class ServiceDO implements Serializable {
private Integer isDeleted;
@ApiModelProperty(value = "单位id")
private Integer unitId;
private Integer companyId;
public ServiceDO(ServiceVO param, Integer accountId) {
this(param);
......@@ -79,7 +80,7 @@ public class ServiceDO implements Serializable {
this.shareCard = param.getShareCard();
this.video = param.getVideo();
this.serviceIntroduction = param.getServiceIntroduction();
this.unitId=param.getUnitId();
this.companyId=param.getCompanyId();
}
public ServiceDO(Integer id, Integer accountId) {
......
......@@ -3,8 +3,11 @@ package com.mmc.pms.feign;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mmc.pms.auth.dto.BUserAccountQO;
import com.mmc.pms.auth.dto.CompanyInfoDTO;
import com.mmc.pms.auth.dto.CompanyInfoVO;
import com.mmc.pms.auth.dto.UserAccountSimpleDTO;
import com.mmc.pms.feign.hystrix.UserAppApiHystrix;
import com.mmc.pms.model.qo.CompanyInfoQO;
import com.mmc.pms.model.qo.UserAccountQO;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections4.CollectionUtils;
......@@ -67,4 +70,17 @@ public interface UserAppApi {
*/
@PostMapping("/userapp/user-account/feignListAppUserAccount")
List<UserAccountSimpleDTO> feignListAppUserAccount(@ApiParam(value = "账号查询QO", required = true) @RequestBody UserAccountQO userAccountQO, @RequestHeader("token") String token);
/**
* 获取单位数据
* @param id
* @param token
* @return
*/
@GetMapping("/userapp/company/getCompanyInfoById")
String getCompanyInfoById(@ApiParam(value = "单位", required = true) @RequestParam Integer id, @RequestHeader("token") String token);
@PostMapping("/userapp/company/listCompanyPage")
String listCompanyPage(@ApiParam(value = "单位查询QO", required = true) @RequestBody CompanyInfoQO companyInfoQO, @RequestHeader("token") String token);
}
package com.mmc.pms.feign.hystrix;
import com.mmc.pms.auth.dto.BUserAccountQO;
import com.mmc.pms.auth.dto.CompanyInfoDTO;
import com.mmc.pms.auth.dto.CompanyInfoVO;
import com.mmc.pms.auth.dto.UserAccountSimpleDTO;
import com.mmc.pms.feign.UserAppApi;
import com.mmc.pms.model.qo.CompanyInfoQO;
import com.mmc.pms.model.qo.UserAccountQO;
import lombok.extern.slf4j.Slf4j;
......@@ -37,4 +40,16 @@ public class UserAppApiHystrix implements UserAppApi {
log.error("熔断:feignListAppUserAccount:{}", userAccountQO);
return null;
}
@Override
public String getCompanyInfoById(Integer id, String token) {
log.error("熔断:feignListAppUserAccount:{}", id);
return null;
}
@Override
public String listCompanyPage(CompanyInfoQO companyInfoQO, String token) {
log.error("熔断:feignListAppUserAccount:{}", companyInfoQO);
return null;
}
}
package com.mmc.pms.model.qo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.domain.Page;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @Author small
* @Date 2023/7/4 13:37
* @Version 1.0
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CompanyInfoQO {
@ApiModelProperty(value = "页码", required = true)
@NotNull(message = "页码不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true)
@NotNull(message = "每页显示数不能为空", groups = Page.class)
@Min(value = 1, groups = Page.class)
private Integer pageSize;
}
......@@ -65,4 +65,10 @@ public class ServiceQO implements Serializable {
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
@ApiModelProperty(value = "部门id", required = true)
private Integer companyId;
@ApiModelProperty(value = "单位类型,0科比特,1加盟公司", required = true)
private Integer companyType;
}
......@@ -73,6 +73,12 @@ public class ServiceDTO implements Serializable {
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "单位id")
private Integer companyId;
@ApiModelProperty(value = "单位名称")
private String companyName;
public ServiceDTO(ServiceVO param, Integer accountId) {
this.id = param.getId();
this.serviceName = param.getServiceName();
......@@ -116,6 +122,24 @@ public class ServiceDTO implements Serializable {
this.accountId = serviceDO.getAccountId();
this.createTime = serviceDO.getCreateTime();
this.updateTime = serviceDO.getUpdateTime();
this.companyId=serviceDO.getCompanyId();
}
public ServiceDTO(ServiceDO serviceDO,String companyName) {
this.id = serviceDO.getId();
this.serviceName = serviceDO.getServiceName();
this.applicationId = serviceDO.getApplicationId();
this.industryId = serviceDO.getIndustryId();
this.displayState = serviceDO.getDisplayState();
this.coverPlan = serviceDO.getCoverPlan();
this.shareCard = serviceDO.getShareCard();
this.video = serviceDO.getVideo();
this.serviceIntroduction = serviceDO.getServiceIntroduction();
this.accountId = serviceDO.getAccountId();
this.createTime = serviceDO.getCreateTime();
this.updateTime = serviceDO.getUpdateTime();
this.companyId=serviceDO.getCompanyId();
this.companyName=companyName;
}
}
......@@ -45,9 +45,12 @@ public class WorkServiceDTO implements Serializable {
@ApiModelProperty(value = "服务介绍")
private String serviceIntroduction;
@ApiModelProperty(value = "公司名称")
@ApiModelProperty(value = "部门名称")
private String companyName;
@ApiModelProperty(value = "部门id")
private Integer companyId;
@ApiModelProperty(value = "评论列表")
private List<InspComtDO> inspComtList;
......
......@@ -69,5 +69,5 @@ public class ServiceVO implements Serializable {
private String serviceIntroduction;
@ApiModelProperty(value = "单位id")
private Integer unitId;
private Integer companyId;
}
package com.mmc.pms.service;
import com.mmc.pms.auth.dto.CompanyInfoVO;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.qo.ServiceQO;
import com.mmc.pms.model.work.dto.ServiceDTO;
......@@ -22,9 +23,9 @@ public interface BackstageTaskService {
ResultBody deleteByIds(List<Integer> ids);
ResultBody<ServiceDTO> queryById(Integer id);
ResultBody<ServiceDTO> queryById(Integer id,HttpServletRequest request);
PageResult queryServiceManagerList(ServiceQO param, Integer userAccountId);
PageResult queryServiceManagerList(ServiceQO param, Integer userAccountId, CompanyInfoVO companyInfoDTO);
PageResult queryWorkServiceList(ServiceQO param, HttpServletRequest request);
......@@ -33,4 +34,6 @@ public interface BackstageTaskService {
ResultBody batchUpAndDownWorkService(UpAndDownServiceVO param);
Integer getWorkServiceCountByCategoriesId(List<Integer> ids);
ResultBody queryByIdCount(Integer id);
}
package com.mmc.pms.service.Impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.HttpMethod;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.mmc.pms.auth.dto.CompanyInfoDTO;
import com.mmc.pms.auth.dto.CompanyInfoVO;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.constant.DateConstant;
import com.mmc.pms.dao.BackstageTaskServiceDao;
......@@ -10,6 +16,7 @@ import com.mmc.pms.entity.Categories;
import com.mmc.pms.entity.InspComtDO;
import com.mmc.pms.entity.ServiceDO;
import com.mmc.pms.feign.UserAppApi;
import com.mmc.pms.model.qo.CompanyInfoQO;
import com.mmc.pms.model.qo.ServiceQO;
import com.mmc.pms.model.work.dto.ServiceDTO;
import com.mmc.pms.model.work.dto.WorkServiceDTO;
......@@ -18,14 +25,21 @@ import com.mmc.pms.model.work.vo.UpAndDownServiceVO;
import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.BackstageTaskService;
import com.mmc.pms.service.InspComtService;
import feign.Feign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.MultiValueMap;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
......@@ -51,6 +65,7 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
@Autowired private RedisTemplate redisTemplate;
@Override
public ResultBody addWorkService(ServiceVO param, Integer userAccountId) {
ServiceDO serviceDO = new ServiceDO(param, userAccountId);
......@@ -74,9 +89,13 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
}
@Override
public ResultBody<ServiceDTO> queryById(Integer id) {
public ResultBody<ServiceDTO> queryById(Integer id,HttpServletRequest request) {
ServiceDO serviceDO = backstageTaskServiceDao.queryById(id);
ServiceDTO serviceDTO = new ServiceDTO(serviceDO);
String token = userAppApi.getCompanyInfoById(serviceDO.getCompanyId(), request.getHeader("token"));
JSONObject jsonObject = JSONObject.parseObject(token);
CompanyInfoDTO companyInfoDTO = JSON.parseObject(String.valueOf((JSONObject) jsonObject.get("result")), CompanyInfoDTO.class);
String companyName = companyInfoDTO.getCompanyName();
ServiceDTO serviceDTO = new ServiceDTO(serviceDO,companyName);
Map<Integer, String> categoriesNameMap =
getCategoriesNameByIds(
Arrays.asList(serviceDTO.getApplicationId(), serviceDTO.getIndustryId()));
......@@ -90,6 +109,8 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
return ResultBody.success(serviceDTO);
}
private Map<Integer, String> getCategoriesNameByIds(List<Integer> ids) {
if (CollectionUtils.isEmpty(ids)) {
return new HashMap<>();
......@@ -107,13 +128,15 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
}
@Override
public PageResult queryServiceManagerList(ServiceQO param, Integer userAccountId) {
public PageResult queryServiceManagerList(ServiceQO param, Integer userAccountId, CompanyInfoVO companyInfoVO) {
int count = backstageTaskServiceDao.count(param);
if (count == 0) {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
param.setCompanyId(companyInfoVO.getId());
param.setCompanyType(companyInfoVO.getCompanyType());
List<ServiceDO> services = backstageTaskServiceDao.queryAllByLimit(param);
List<ServiceDTO> pageList = setApplicationNameAndIndustryName(services);
return PageResult.buildPage(pageNo, param.getPageSize(), count, pageList);
......@@ -140,6 +163,7 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
}
@Override
@Transactional
public PageResult queryWorkServiceList(ServiceQO param, HttpServletRequest request) {
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
......@@ -157,9 +181,9 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
return PageResult.buildPage(param.getPageNo(), param.getPageSize(), count);
}
List<ServiceDO> pageList =
backstageTaskServiceDao.queryPageByLimit(param, categoriesIds, userIds);
backstageTaskServiceDao.queryPageByLimit(param, categoriesIds, userIds);
List<WorkServiceDTO> workServiceDTOList = getWorkServiceDTOS(pageList);
List<WorkServiceDTO> workServiceDTOList = getWorkServiceDTOS(pageList,request);
return PageResult.buildPage(pageNo, param.getPageSize(), count, workServiceDTOList);
}
......@@ -184,16 +208,30 @@ public class BackstageTaskServiceImpl implements BackstageTaskService {
return backstageTaskServiceDao.getWorkServiceCountByCategoriesId(ids);
}
private List<WorkServiceDTO> getWorkServiceDTOS(List<ServiceDO> pageList) {
// 用户暂时无关联公司数据,先用假数据展示
String companyName = "浙江科比特创新科技有限公司";
@Override
public ResultBody queryByIdCount(Integer companyId) {
return ResultBody.success(backstageTaskServiceDao.queryByIdCount( companyId));
}
private List<WorkServiceDTO> getWorkServiceDTOS(List<ServiceDO> pageList,HttpServletRequest request) {
String companyInfoVOS= userAppApi.listCompanyPage(new CompanyInfoQO(1, 100000), request.getHeader("token") );
JSONObject jsonObject = JSON.parseObject(companyInfoVOS);
JSONObject jsonObject1 = JSON.parseObject(String.valueOf(jsonObject.get("result")));
List<CompanyInfoVO> companyInfoList = new Gson().fromJson(new Gson().toJson(jsonObject1.get("list")), new TypeToken<List<CompanyInfoVO>>(){}.getType());
String companyName = "";
List<WorkServiceDTO> workServiceDTOList = new ArrayList<>();
for (ServiceDO item : pageList) {
for (CompanyInfoVO companyInfoVO : companyInfoList) {
if (item.getCompanyId().equals(companyInfoVO.getId())){
companyName=companyInfoVO.getCompanyName();
}
}
List<InspComtDO> inspComtDOS = generateComments(item);
WorkServiceDTO workServiceDTO =
WorkServiceDTO.builder()
.id(item.getId())
.serviceName(item.getServiceName())
.companyId(item.getCompanyId())
.companyName(companyName)
.coverPlan(item.getCoverPlan())
.serviceIntroduction(item.getServiceIntroduction())
......
......@@ -7,8 +7,7 @@ spring:
password: MMC@2022&MYSQL
redis:
database: 1
host: r-wz9ke310fs684hacn1pd.redis.rds.aliyuncs.com
password: MMC@2022&REDIS
host: 127.0.0.1
port: 6379
#连接池
lettuce:
......
......@@ -18,6 +18,7 @@
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="isDeleted" column="is_deleted" jdbcType="INTEGER"/>
<result property="accountId" column="account_id" jdbcType="INTEGER"/>
<result property="companyId" column="company_id" jdbcType="INTEGER"/>
</resultMap>
<!--查询所有-->
......@@ -51,8 +52,9 @@
service_introduction,
create_time,
update_time,
account_id
from service
account_id,
company_id
from service
where id = #{id}
and is_deleted = 0
</select>
......@@ -61,7 +63,7 @@
<select id="queryAllByLimit" resultMap="ServiceMap" parameterType="com.mmc.pms.model.qo.ServiceQO">
select
id, service_name, application_id, industry_id, display_state, cover_plan, share_card, video,
service_introduction, create_time, update_time, account_id
service_introduction, create_time, update_time, account_id,company_id
from service
<where>
is_deleted = 0
......@@ -77,6 +79,9 @@
<if test="displayState != null">
and display_state = #{displayState}
</if>
<if test="companyType==1 and companyId!=null">
and company_id = #{companyId}
</if>
</where>
order by create_time desc
limit #{pageNo}, #{pageSize}
......@@ -106,9 +111,9 @@
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true" parameterType="com.mmc.pms.entity.ServiceDO">
insert into service(service_name, application_id, industry_id, display_state, cover_plan, share_card, video,
service_introduction, account_id,unit_id)
service_introduction, account_id,company_id)
values (#{serviceName}, #{applicationId}, #{industryId}, #{displayState}, #{coverPlan}, #{shareCard},
#{video}, #{serviceIntroduction}, #{accountId},#{unitId})
#{video}, #{serviceIntroduction}, #{accountId},#{companyId})
</insert>
<!--通过主键修改数据-->
......@@ -148,8 +153,8 @@
<if test="accountId != null">
account_id = #{accountId},
</if>
<if test="unitId != null">
unit_id = #{unitId},
<if test="companyId != null">
company_id = #{companyId},
</if>
</set>
where id = #{id}
......@@ -203,7 +208,7 @@
<select id="queryPageByLimit" resultType="com.mmc.pms.entity.ServiceDO">
select
id, service_name, application_id, industry_id, display_state, cover_plan, share_card, video,
service_introduction, create_time, update_time, account_id
service_introduction, create_time, update_time, account_id,company_id
from service
<where>
is_deleted = 0 and display_state = 0
......@@ -286,4 +291,8 @@
</if>
</where>
</select>
<select id="queryByIdCount" resultType="java.lang.Integer">
select count(1) from service where company_id=#{companyId}
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论