Commit 4a973dde authored by zsh's avatar zsh 🇨🇳

Merge branch 'Shen' into 'master'

Shen

See merge request !13
parents 13445401 99f58bd3
......@@ -49,6 +49,9 @@ public class PensionOrderDTO implements Serializable {
@ApiModelProperty(value = "预约时间")
private Date appointmentTime;
@ApiModelProperty(value = "取消原因")
private String cancelReason;
@ApiModelProperty(value = "备注")
private String remark;
......
......@@ -55,6 +55,10 @@ public class PensionOrderEntity extends BaseEntity {
* 预约时间
*/
private Date appointmentTime;
/**
* 取消原因
*/
private String cancelReason;
/**
* 备注
*/
......
......@@ -4,6 +4,8 @@ import io.hmit.common.dao.BaseDao;
import io.hmit.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 用户
*
......@@ -15,4 +17,7 @@ public interface UserDao extends BaseDao<UserEntity> {
UserEntity getUserByMobile(String mobile);
UserEntity getUserByUserId(Long userId);
List<Long> getAllOrganizationStaff(Long userId);
}
package io.hmit.modules.serviceOrder.controller;
import com.sun.xml.internal.bind.v2.TODO;
import io.hmit.annotation.Login;
import io.hmit.annotation.LoginUser;
import io.hmit.common.constant.Constant;
......@@ -15,6 +14,7 @@ import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
import io.hmit.modules.serviceOrder.dto.ReservationDTO;
import io.hmit.modules.serviceOrder.service.PensionOrderService;
import io.hmit.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -39,6 +39,9 @@ public class PensionOrderController {
@Autowired
private PensionOrderService pensionOrderService;
@Autowired
private UserService userService;
@Login
@GetMapping("page")
@ApiOperation("全部订单(志愿者)")
......@@ -259,6 +262,8 @@ public class PensionOrderController {
public Result reservationOrder(@ApiIgnore @LoginUser UserEntity user,@RequestBody ReservationDTO dto){
PensionOrderDTO data = new PensionOrderDTO().assemblePensionOrder(dto,user);
data.setCommunityId(user.getCommunityId());
data.setCommunityName(user.getCommunityName());
pensionOrderService.reservation(data);
return new Result();
}
......@@ -296,4 +301,42 @@ public class PensionOrderController {
return new Result();
}
/**
* 本机构全部人员
*/
@Login
@GetMapping("organizationStaff")
@ApiOperation(value = "本机构全部人员(机构)")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
})
public Result<PageData<UserEntity>> organizationStaff(@ApiIgnore @LoginUser UserEntity user,
@ApiIgnore @RequestParam Map<String, Object> params){
PageData<UserEntity> page = userService.getOrganizationAllUsers(params, user.getId());
return new Result<PageData<UserEntity>>().ok(page);
}
/**
* 机构处理
*/
@Login
@GetMapping("organizationHandle")
@ApiOperation(value = "机构处理(机构)", notes = "传参为1(派单)时,recipient_id必传")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "订单ID", paramType = "query", required = true, dataType="long") ,
@ApiImplicitParam(name = "status", value = "处理状态: 5接单 1派单 3取消", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = "recipient_id", value = "接单服务人员ID", paramType = "query", dataType="long")
})
public Result organizationHandle(@ApiIgnore @LoginUser UserEntity user,
@ApiIgnore @RequestParam Map<String, Object> params){
Boolean result = pensionOrderService.organizationHandle(params, user.getId());
if (!result) {
return new Result().error();
}
return new Result();
}
}
......@@ -52,6 +52,9 @@ public class PensionOrderDTO implements Serializable {
@ApiModelProperty(value = "预约时间")
private Date appointmentTime;
@ApiModelProperty(value = "取消原因")
private String cancelReason;
@ApiModelProperty(value = "备注")
private String remark;
......
......@@ -55,6 +55,10 @@ public class PensionOrderEntity extends BaseEntity {
* 预约时间
*/
private Date appointmentTime;
/**
* 取消原因
*/
private String cancelReason;
/**
* 备注
*/
......
......@@ -47,4 +47,7 @@ public interface PensionOrderService extends CrudService<PensionOrderEntity, Pen
//查询机构订单
PageData<PensionOrderDTO> getOrganizationOrder(Map<String, Object> params, Long userId);
Boolean organizationHandle(Map<String, Object> params, Long userId);
}
......@@ -6,19 +6,21 @@ import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData;
import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils;
import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dao.PensionOrderDao;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
import io.hmit.modules.serviceOrder.dto.PensionOrderServiceDTO;
import io.hmit.modules.serviceOrder.dto.ReservationDTO;
import io.hmit.modules.serviceOrder.entity.PensionOrderEntity;
import io.hmit.modules.serviceOrder.service.PensionOrderService;
import io.hmit.modules.serviceOrder.service.PensionOrderServiceService;
import io.hmit.modules.serviceOrder.service.PensionOrganizationService;
import io.hmit.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -50,6 +52,9 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
@Autowired
private PensionOrganizationService pensionOrganizationService;
@Autowired
private UserService userService;
//查询全部订单
@Override
public PageData<PensionOrderDTO> getAllOrderPage(Map<String, Object> params, Long userId) {
......@@ -106,7 +111,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
@Override
public PageData<PensionOrderDTO> getElderAllOrderOrByStatusPage(Map<String, Object> params, Long creator, Integer status) {
IPage<PensionOrderEntity> page = getPage(params, Constant.CREATE_DATE, false);
// IPage<PensionOrderEntity> page = getPage(params, Constant.CREATE_DATE, false);
List<PensionOrderDTO> list = new ArrayList<>();
if (null == status) {
list = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, status);
......@@ -118,8 +123,8 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
list.addAll(list1);
list.addAll(list2);
}
page.setTotal(list.size());
return getPageData(list, page.getTotal(), PensionOrderDTO.class);
// page.setTotal(list.size());
return getPageData(getSubList(params, list), list.size(), PensionOrderDTO.class);
}
@Override
......@@ -139,7 +144,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
@Override
public PageData<PensionOrderDTO> getOrganizationOrder(Map<String, Object> params, Long userId) {
//登录->查询登录人员所属机构ID->机构ID查询服务ID(List)->服务ID + 状态查询订单(List)
IPage<PensionOrderEntity> page = getPage(params, Constant.CREATE_DATE, false);
// IPage<PensionOrderEntity> page = getPage(params, Constant.CREATE_DATE, false);
List<Long> serviceIds = pensionOrganizationService.findServiceIdListByServiceUserId(userId);
Integer status = null;
if (null != params.get("status")) {
......@@ -150,8 +155,68 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
List<PensionOrderDTO> list = pensionOrderDao.getAllOrderByServiceId(id, status);
result.addAll(list);
}
page.setTotal(result.size());
return getPageData(result, page.getTotal(), PensionOrderDTO.class);
// page.setTotal(result.size());
return getPageData(getSubList(params, result), result.size(), PensionOrderDTO.class);
}
@Override
public Boolean organizationHandle(Map<String, Object> params, Long userId) {
//userId 可用于校验是否属于本机构的订单,暂未使用
Long orderId = Long.parseLong(params.get("id").toString());
PensionOrderEntity pensionOrderEntity = pensionOrderDao.selectById(orderId);
Integer status = Integer.parseInt(params.get("status").toString());
if (status == 5) {//接单
if (pensionOrderEntity.getStatus() == 0) {
pensionOrderEntity.setStatus(5);
pensionOrderEntity.setStatusName(Constant.OrderStatus.HAND_OUT.getMessage());
update(ConvertUtils.sourceToTarget(pensionOrderEntity, PensionOrderDTO.class));
}else {
return false;
}
}else if (status == 1){ //派单
Long recipient_id = Long.parseLong(params.get("recipient_id").toString());
if (pensionOrderEntity.getStatus() == 5) {
pensionOrderEntity.setStatus(1);
pensionOrderEntity.setStatusName(Constant.OrderStatus.ORDER.getMessage());
UserEntity recipient = userService.getUserByUserId(recipient_id);
pensionOrderEntity.setOrderRecipientId(recipient_id);
pensionOrderEntity.setOrderRecipientName(recipient.getUsername());
pensionOrderEntity.setOrderRecipientPhone(recipient.getMobile());
pensionOrderEntity.setOrderRecipientTime(new Date());
update(ConvertUtils.sourceToTarget(pensionOrderEntity, PensionOrderDTO.class));
}else {
return false;
}
}else if (status == 3) {
if (pensionOrderEntity.getStatus() != 2 && pensionOrderEntity.getStatus() != 4) {
pensionOrderEntity.setStatus(3);
pensionOrderEntity.setStatusName(Constant.OrderStatus.CANCEL.getMessage());
update(ConvertUtils.sourceToTarget(pensionOrderEntity, PensionOrderDTO.class));
} else {
return false;
}
}
return true;
}
//对List进行手动分页
private List<PensionOrderDTO> getSubList(Map<String, Object> params, List<PensionOrderDTO> list){
Integer pageNum = Integer.parseInt(params.get("page").toString());
Integer pageSize = Integer.parseInt(params.get("limit").toString());
Integer count = list.size();
Integer pageNo = (pageNum - 1) * pageSize;
List<PensionOrderDTO> list2 ;
if (pageNo+pageSize > count) {
if (pageNo > count){
list2 = new ArrayList<>();
}else {
list2 = list.subList(pageNo, count);
}
}else {
list2 = list.subList(pageNo, pageNo+pageSize);
}
return list2;
}
}
package io.hmit.service;
import io.hmit.common.page.PageData;
import io.hmit.common.service.BaseService;
import io.hmit.dto.LoginDTO;
import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
import java.util.Map;
......@@ -24,4 +26,7 @@ public interface UserService extends BaseService<UserEntity> {
* @return 返回登录信息
*/
Map<String, Object> login(LoginDTO dto);
PageData<UserEntity> getOrganizationAllUsers(Map<String, Object> params, Long userId);
}
package io.hmit.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.hmit.common.constant.Constant;
import io.hmit.common.exception.ErrorCode;
import io.hmit.common.exception.HmitException;
import io.hmit.common.page.PageData;
import io.hmit.common.service.impl.BaseServiceImpl;
import io.hmit.common.validator.AssertUtils;
import io.hmit.dao.UserDao;
......@@ -14,7 +17,9 @@ import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
......@@ -23,6 +28,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
@Autowired
private TokenService tokenService;
@Autowired
private UserDao userDao;
@Override
public UserEntity getByMobile(String mobile) {
return baseDao.getUserByMobile(mobile);
......@@ -54,4 +62,17 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
return map;
}
@Override
public PageData<UserEntity> getOrganizationAllUsers(Map<String, Object> params, Long userId) {
IPage<UserEntity> page = getPage(params, Constant.CREATE_DATE, false);
List<Long> serviceIds = userDao.getAllOrganizationStaff(userId);
List<UserEntity> list = new ArrayList<>();
for (Long id : serviceIds) {
UserEntity userEntity = userDao.selectById(id);
list.add(userEntity);
}
page.setTotal(list.size());
return getPageData(list, page.getTotal(), UserEntity.class);
}
}
\ No newline at end of file
......@@ -10,4 +10,10 @@
<select id="getUserByUserId" resultType="io.hmit.entity.UserEntity">
select * from tb_user where id = #{value}
</select>
<select id="getAllOrganizationStaff" resultType="Long">
SELECT user_id FROM pension_organization_user
WHERE organization_id = (SELECT organization_id FROM pension_organization_user
WHERE user_id = #{userId});
</select>
</mapper>
\ No newline at end of file
......@@ -35,7 +35,7 @@
SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
po.appointment_person, po.appointment_phone, po.appointment_time, po.remark,
po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
po.act_price, po.community_name, po.community_id, po.dept_id,
po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason,
po.creator, po.creator_name, po.creator_tel, po.create_date
FROM pension_order po
WHERE po.id = #{orderId} AND po.status = #{status}
......@@ -45,7 +45,7 @@
SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
po.appointment_person, po.appointment_phone, po.appointment_time, po.remark,
po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
po.act_price, po.community_name, po.community_id, po.dept_id,
po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason,
po.creator, po.creator_name, po.creator_tel, po.create_date,
ps.icon
FROM pension_order po, pension_service ps
......@@ -71,7 +71,7 @@
SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
po.appointment_person, po.appointment_phone, po.appointment_time, po.remark,
po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
po.act_price, po.community_name, po.community_id, po.dept_id,
po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason,
po.creator, po.creator_name, po.creator_tel, po.create_date,
ps.icon
FROM pension_order po, pension_service ps
......@@ -88,7 +88,7 @@
SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
po.appointment_person, po.appointment_phone, po.appointment_time, po.remark,
po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
po.act_price, po.community_name, po.community_id, po.dept_id,
po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason,
po.creator, po.creator_name, po.creator_tel, po.create_date,
ps.icon
FROM pension_order po, pension_service ps
......@@ -99,7 +99,7 @@
SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
po.appointment_person, po.appointment_phone, po.appointment_time, po.remark,
po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
po.act_price, po.community_name, po.community_id, po.dept_id,
po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason,
po.creator, po.creator_name, po.creator_tel, po.create_date,
ps.icon
FROM pension_order po, pension_service ps
......@@ -110,7 +110,7 @@
SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
po.appointment_person, po.appointment_phone, po.appointment_time, po.remark,
po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
po.act_price, po.community_name, po.community_id, po.dept_id,
po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason,
po.creator, po.creator_name, po.creator_tel, po.create_date,
ps.icon
FROM pension_order po, pension_service ps
......@@ -124,7 +124,7 @@
SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
po.appointment_person, po.appointment_phone, po.appointment_time, po.remark,
po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
po.act_price, po.community_name, po.community_id, po.dept_id,
po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason,
po.creator, po.creator_name, po.creator_tel, po.create_date,
ps.icon
FROM pension_order po, pension_service ps, tb_user tu
......@@ -135,7 +135,7 @@
SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
po.appointment_person, po.appointment_phone, po.appointment_time, po.remark,
po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
po.act_price, po.community_name, po.community_id, po.dept_id,
po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason,
po.creator, po.creator_name, po.creator_tel, po.create_date,
ps.icon
FROM pension_order po, pension_service ps, tb_user tu
......@@ -147,7 +147,7 @@
SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
po.appointment_person, po.appointment_phone, po.appointment_time, po.remark,
po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
po.act_price, po.community_name, po.community_id, po.dept_id,
po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason,
po.creator, po.creator_name, po.creator_tel, po.create_date,
ps.icon
FROM pension_order po, pension_service ps
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment