Commit 31b54800 authored by zoujintao's avatar zoujintao

【ID1003045】 排班管理

parent 2b5256cb
......@@ -19,6 +19,7 @@ public class DutyStaffEntity extends DomainObject {
private String userId;
private String onduty;
private Date updateTime;
private Integer order;
public Date getUpdateTime() {
return updateTime;
......@@ -51,4 +52,12 @@ public class DutyStaffEntity extends DomainObject {
public void setOnduty(String onduty) {
this.onduty = onduty;
}
public Integer getOrder() {
return order;
}
public void setOrder(Integer order) {
this.order = order;
}
}
......@@ -520,7 +520,7 @@ public class UserController extends BaseController {
UserEntity userEntity = (UserEntity) httpRequest.getSession().getAttribute(SessionConstants.THREAD_USER_KEY);
//获取更新前用户信息
UserEntity oldEntity = user.getById(entity.getId());
UserEntity tempOldEntity=(UserEntity)oldEntity.clone();
UserEntity tempOldEntity = (UserEntity) oldEntity.clone();
oldEntity.setUpdateUserid(entity.getId());
oldEntity.setUpdateUsername(entity.getName());
oldEntity.setUpdateTime(new Date());
......@@ -557,7 +557,7 @@ public class UserController extends BaseController {
//改变用户名需要同步给im
String env = MemoryPropertyPlaceholderConfigurer.getContextProperty("system.env");
if ("production".equalsIgnoreCase(env) && !oldEntity.getRealName().equals(entity.getRealName())) {
if(org.apache.commons.lang.StringUtils.isNotBlank(oldEntity.getAccId())){
if (org.apache.commons.lang.StringUtils.isNotBlank(oldEntity.getAccId())) {
String token = getImToken();
List<NameValuePair> cornetInParam = new ArrayList<>();
cornetInParam.add(new BasicNameValuePair("accid", oldEntity.getAccId()));
......@@ -568,32 +568,33 @@ public class UserController extends BaseController {
}
//获取用户的头像
AttachmentListResponse headImgRes = attachmentInterface.queryByResourceIdAndResouceType(String.valueOf(id), "hgs_user_headImg");
String headImgURL=null;
String headImgURL = null;
if (null != headImgRes.getObjectList() && !headImgRes.getObjectList().isEmpty()) {
BaseAttachment attachment = (BaseAttachment) headImgRes.getObjectList().get(0);
headImgURL=attachment.getRemotePath();
headImgURL = attachment.getRemotePath();
}
//调用团立方接口,同步修改的数据团立方,修改手机号或者姓名才发送数据
JsonConfig jsonConfig=new JsonConfig();
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerDefaultValueProcessor(Integer.class, new DefaultValueProcessor() {
@Override
public Object getDefaultValue(Class type) {
return null;
}});
}
});
jsonConfig.registerDefaultValueProcessor(String.class, new DefaultValueProcessor() {
@Override
public Object getDefaultValue(Class type) {
return null;
}
});
if(!entity.getRealName().equals(tempOldEntity.getRealName())||!entity.getMobile().equals(tempOldEntity.getMobile())) {
MessageDto mdto=new MessageDto();
if (!entity.getRealName().equals(tempOldEntity.getRealName()) || !entity.getMobile().equals(tempOldEntity.getMobile())) {
MessageDto mdto = new MessageDto();
mdto.setUserId(entity.getId());
mdto.setAccid(oldEntity.getAccId());
mdto.setName(entity.getRealName());
mdto.setTel(entity.getMobile());
mdto.setAvatar(headImgURL);
String messObj = JSONObject.fromObject(mdto,jsonConfig).toString();
String messObj = JSONObject.fromObject(mdto, jsonConfig).toString();
logger.info("******SYNC_TO_TRL*******" + messObj);
String res = HttpClientUtil.doPostJson(tlfSendMessageUrl, messObj, "");
logger.info("******SYNC_TO_TRL_RESULT*******" + res);
......@@ -657,7 +658,7 @@ public class UserController extends BaseController {
}
//针对该用户在平台管理中是否有客户进行判断设置值
int countInfo = customer.queryCountById(userEntity.getId());
userVo.setHasCustomersInPlatform(countInfo>0);
userVo.setHasCustomersInPlatform(countInfo > 0);
lstUserVo.add(userVo);
}
}
......@@ -1124,23 +1125,23 @@ public class UserController extends BaseController {
/**
* 根据id获取用户的绑定楼盘信息
*
* @param id 账户页面表单对象唯一标识
* @param id 账户页面表单对象唯一标识
* @return 用户的绑定信息结果
*/
@RequestMapping(value = "/bindPeople/{id}",method = RequestMethod.GET)
@RequestMapping(value = "/bindPeople/{id}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public HResult getBindPeopleInfo(@PathVariable String id) {
HResult result = new HResult();
try {
Map<String, String> paramMap =new HashMap<>();
paramMap.put("userId",id);
Map<String, String> paramMap = new HashMap<>();
paramMap.put("userId", id);
//通过http调用接口获取用户绑定楼盘信息
String res=HttpUtil.simpleGet(tlfBandPeopleUrl,paramMap,null);
HResult finalInfo=JSON.parse(res,HResult.class);
result.setStatus(finalInfo.getStatus());
result.setData(finalInfo.getData());
logger.info(id+" bindpeopleInfo:"+finalInfo.getData());
String res = HttpUtil.simpleGet(tlfBandPeopleUrl, paramMap, null);
HResult finalInfo = JSON.parse(res, HResult.class);
result.setStatus(finalInfo.getStatus());
result.setData(finalInfo.getData());
logger.info(id + " bindpeopleInfo:" + finalInfo.getData());
} catch (Exception e) {
result.setStatus(-1);
result.setErrorMessage("获取绑定用户信息失败");
......@@ -1151,9 +1152,12 @@ public class UserController extends BaseController {
}
@RequestMapping(value = "pblist", method = RequestMethod.GET)
public String pbList( HttpServletRequest request, Model model) {
public String pbList(HttpServletRequest request, Model model) {
//共多少条数据,今日新增多少条
String cityCode = (String) request.getSession().getAttribute(SessionConstants.SESSION_CITY_KEY);
if (cityCode.equals("zb")) {
return getAutoUrl("pblist");
}
List<UserEntity> users = this.user.getDutyUserByCity(cityCode);
List<UserVo> collect = users.stream().map(i -> {
......@@ -1165,4 +1169,46 @@ public class UserController extends BaseController {
model.addAttribute("users", collect);
return getAutoUrl("pblist");
}
@RequestMapping(value = "/deleteDutyById/{userId}")
public void deleteDutyById(@PathVariable Integer userId) {
//共多少条数据,今日新增多少条
user.deleteDutyById(userId);
}
/**
* 新增的时候通过city查询用户
*
* @param model
* @param request
* @return
*/
@RequestMapping(value = "/userByCity")
public String userByCity(Model model, HttpServletRequest request) {
String cityCode = (String) request.getSession().getAttribute(SessionConstants.SESSION_CITY_KEY);
List<UserEntity> userByCity = user.getUserByCity(cityCode);
model.addAttribute("userByCity", userByCity);
return getAutoUrl("plform");
}
@RequestMapping(value = "/addDuty/{id_name}/{order}")
public void addDuty( @PathVariable("id_name") String id_name,
@PathVariable("order") Integer order) {
user.addDuty(id_name, order);
}
@RequestMapping(value = "/pbelist/{userId}")
public String pbelist(Model model, @PathVariable Integer userId) {
DutyStaffEntity entity = user.pbelist(userId);
model.addAttribute("entity", entity);
return getAutoUrl("pleform");
}
@RequestMapping(value = "/updateDuty/{userId}/{order}")
public void updateDuty( @PathVariable Integer userId, @PathVariable Integer order) {
user.updateDuty(order, userId);
}
}
<%@include file="/WEB-INF/common/layouts/common.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<html>
<head>
<title>排班新增</title>
</head>
<style type="text/css">
.img-show {
width: 160px;
height: 120px;
border: 1px solid #ccc;
padding: 2px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
}
</style>
<body>
<%@include file="/WEB-INF/common/layouts/topbar.jsp" %>
<form id="input_form" class="form-horizontal valid"
<%-- action="${ctx}/user/pblist"
method="get"--%>>
<!-- 面包屑 end -->
<house365:flushMessage/>
<div class="row${fluid}">
<div class="span12">
<input type="hidden" id="entity_onduty"
name="entity.onduty" class="required" maxlength="24"
value="${entity.onduty}"/>
<div class="row-fluid">
<div class="span6 control-group">
<label class="control-label">ID:</label>
<div class="controls">
<input type="text" id="entity_userId" disabled="disabled"
name="entity.userId" class="required" maxlength="24"
value="${entity.userId}"/>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6 control-group">
<label class="control-label">姓名:</label>
<div class="controls">
<input type="text" id="entity_name" disabled="disabled"
name="entity.name" class="required" maxlength="24"
value="${entity.name}"/>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6 control-group">
<label class="control-label">排序值:</label>
<div class="controls">
<input type="text" id="entity_order"
name="entity.order" class="required" maxlength="24"
value="${entity.order}"/>
</div>
</div>
</div>
<div class="row-fluid">
<div class="portlet-header">
<div class="operation-btn col-md-offset-4 col-lg-offset-4col-xl-offset-4">
<%-- <a href="${ctx}/user/pbelist/${userId}" class="btn gray"><i
class="icon-mail-reply"></i>&nbsp;恢复原来值</a>--%>
<button class="btn blue btn col-lg-pull-12" onclick="save(${entity.userId},${entity.onduty})">
&nbsp;确认
</button>
<a href="${ctx}/user/pblist" class="btn gray"><i
class="icon-mail-reply"></i>&nbsp;返回</a>
</div>
</div>
</div>
</div>
</div>
</form>
<script language="javascript" type="text/javascript" src="${ctx}/resources/customize/js/layer.js"></script>
<script type="text/javascript">
function save(userId,onduty) {
var order = document.getElementById("entity_order").value;
if(onduty==1){
alert("当天值日不可修改!!!")
return;
}
if (order == "") {
alert("排序值不能为null!!!")
return;
}
$.ajax({
url: '${ctx}/user/updateDuty/' + userId + '/' + order,
type: 'GET',
contentType: 'application/json',
data: '',
dataType: 'json',
cache: false,
async:false,
success: function () {
alert("修改成功!!!")
location.href = '${ctx}/user/pblist'
},
error:function(){
alert("修改成功!!!")
location.href = '${ctx}/user/pblist'
}
});
}
</script>
</body>
</html>
<%@include file="/WEB-INF/common/layouts/common.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<html>
<head>
<title>排班新增</title>
</head>
<style type="text/css">
.img-show {
width: 160px;
height: 120px;
border: 1px solid #ccc;
padding: 2px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
}
</style>
<body>
<%@include file="/WEB-INF/common/layouts/topbar.jsp" %>
<form id="input_form" class="form-horizontal valid"
<%--action="${ctx}/user/pblist"
method="get"--%>>
<!-- 面包屑 end -->
<house365:flushMessage/>
<div class="row${fluid}">
<div class="span12">
<div class="row-fluid">
<div class="span6 control-group">
<label class="control-label">选择员工<span style="color: red;">*</span>:</label>
<div class="controls">
<select name="name" id="select" style="width: 95%">
<option value="0">==请选择==</option>
<c:forEach items="${userByCity}" var="var" varStatus="vs">
<option value="${var.id}_${var.realName}"> ${var.realName} ${var.position}</option>
</c:forEach>
</select>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6 control-group">
<label class="control-label">排序值<span style="color: #ff0000;">*</span>:</label>
<div class="controls">
<input type="text" id="order"
name="order" class="required" maxlength="64"
value="${order}"/>
</div>
</div>
</div>
<div class="portlet-header">
<div class="row-fluid">
<div class="operation-btn span18">
<a href="${ctx}/user/pblist" class="btn gray"><i
class="icon-mail-reply"></i>&nbsp;返回</a>
<button class="btn blue btn col-lg-pull-12" onclick="save1()">
&nbsp;确认
</button>
</div>
</div>
</div>
</div>
</div>
</form>
<script language="javascript" type="text/javascript" src="${ctx}/resources/customize/js/layer.js"></script>
<script type="text/javascript">
function save1() {
var order = document.getElementById("order").value;
var myselect = document.getElementById("select");
var index=myselect.selectedIndex;
var id_name =myselect.options[index].value
if (order == "") {
alert("排序值不能为null!!!")
}
$.ajax({
url: '${ctx}/user/addDuty/' + id_name + '/' + order,
type: 'GET',
contentType: 'application/json',
data: '',
dataType: 'json',
cache: false,
async:false,
success: function () {
alert("增加成功!!!")
location.href = '${ctx}/user/pblist'
},
error:function(){
alert("增加成功!!!")
location.href = '${ctx}/user/pblist'
}
});
}
</script>
</body>
</html>
......@@ -200,4 +200,13 @@ public interface IUser extends IService {
*/
List<UserEntity> getUserByCity(String cityCode);
void deleteDutyById(Integer userId);
void addDuty(String id_name ,Integer order);
void updateDutyStaff(DutyStaffEntity entity);
void updateDuty(Integer order,Integer id);
DutyStaffEntity pbelist(Integer userId);
}
......@@ -4,8 +4,10 @@ import com.house365.beans.entity.DutyStaffEntity;
import com.house365.beans.entity.RequestLoginEntity;
import com.house365.beans.entity.UserEntity;
import com.house365.beans.entity.UserSimpleEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -27,8 +29,6 @@ public interface UserMapper {
UserEntity getLimitLoginById(String name);
void updateDutyStaff(DutyStaffEntity staff);
List<DutyStaffEntity> getOndutyById(Integer uid);
void addRequestLoginInfo(RequestLoginEntity requestlogin);
......@@ -41,7 +41,7 @@ public interface UserMapper {
RequestLoginEntity getRequestLoginInfoById(Integer id);
List<DutyStaffEntity> getDutyByCondition(Map<String,Object> map);
List<DutyStaffEntity> getDutyByCondition(Map<String, Object> map);
List<UserEntity> queryManagers(Map<String, Object> map);
......@@ -49,7 +49,7 @@ public interface UserMapper {
List<UserEntity> getManagerByPid(Map<String, Object> map);
void updateUserStatus(Map<String,Object> map);
void updateUserStatus(Map<String, Object> map);
String getCityById(String userId);
......@@ -57,4 +57,16 @@ public interface UserMapper {
List<UserEntity> getUserByCity(Map<String, Object> map);
void deleteDutyById(Integer userId);
void addDuty(@Param("name")String name,@Param("userId") Integer userId, @Param("updateTime")Date updateTime, @Param("order")Integer order);
void updateDutyStaff(DutyStaffEntity staff);
DutyStaffEntity selectBuyDutyId(Integer userId);
void updateDuty(@Param("order")Integer order,@Param("userId") Integer userId,@Param("updateTime")Date updateTime);
void updateDutyOnduty(@Param("userId") Integer userId,@Param("updateTime")Date updateTime,@Param("onduty") Integer onduty);
}
......@@ -132,7 +132,6 @@ public class UserImpl implements IUser {
}
@Override
public List<LabelEntity> getCustomerLabelById(LabelEntity labelentity) {
return labelmapper.getCustomerLabelById(labelentity);
......@@ -452,7 +451,7 @@ public class UserImpl implements IUser {
* @return 删除账户响应
*/
@Override
public UserResponse deleteUserById(Integer id,int userId) {
public UserResponse deleteUserById(Integer id, int userId) {
UserResponse response = new UserResponse();
try {
// 插入delete_user表
......@@ -721,7 +720,7 @@ public class UserImpl implements IUser {
}
@Override
public List<UserEntity> getManagerByPid(Integer uid, String managername){
public List<UserEntity> getManagerByPid(Integer uid, String managername) {
Map<String, Object> map = new HashMap<>();
map.put("id", uid);
map.put("realName", managername);
......@@ -1145,15 +1144,49 @@ public class UserImpl implements IUser {
@Override
public List<UserEntity> getDutyUserByCity(String cityCode) {
Map<String,Object> param = new HashMap<>();
param.put("cityCode",cityCode);
Map<String, Object> param = new HashMap<>();
param.put("cityCode", cityCode);
return userMapper.getDutyUserByCity(param);
}
@Override
public List<UserEntity> getUserByCity(String cityCode) {
Map<String,Object> param = new HashMap<>();
param.put("cityCode",cityCode);
Map<String, Object> param = new HashMap<>();
param.put("cityCode", cityCode);
return userMapper.getUserByCity(param);
}
@Override
public void deleteDutyById(Integer userId) {
userMapper.deleteDutyById(userId);
}
@Override
public void addDuty(String id_name, Integer order) {
String[] split = id_name.split("_");
Integer userId = Integer.valueOf(split[0]);
String name = split[1];
DutyStaffEntity dutyStaffEntity = userMapper.selectBuyDutyId(userId);
if (dutyStaffEntity != null) {
return;
}
userMapper.addDuty(name, userId, new Date(), order);
}
@Override
public void updateDutyStaff(DutyStaffEntity entity) {
userMapper.updateDutyStaff(entity);
}
@Override
public void updateDuty(Integer order, Integer id) {
userMapper.updateDuty(order, id, new Date());
}
@Override
public DutyStaffEntity pbelist(Integer userId) {
return userMapper.selectBuyDutyId(userId);
}
}
......@@ -4,12 +4,16 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.house365.beans.entity.*;
import com.house365.beans.system.Page;
import com.house365.commons.system.HttpClientUtil;
import com.house365.web.util.DateTimeUtils;
import com.house365.web.util.MemoryPropertyPlaceholderConfigurer;
import com.house365.ws.beans.request.DepartmentListRequest;
import com.house365.ws.beans.response.DepartmentListResponse;
import com.house365.ws.cached.RedisUtilsInterface;
import com.house365.ws.dao.mapper.*;
import com.house365.ws.interfaces.server.ICustomerProject;
import com.house365.ws.interfaces.server.IDepartment;
import com.house365.ws.service.interfaces.*;
import com.house365.ws.util.Constant;
import com.house365.ws.util.OperateLogUtils;
......@@ -95,33 +99,44 @@ public class StaffDuty implements IStaffDuty {
@Value("${CRM.CUSTOMERQUERY.URL}")
private String crmQueryUrl;
@Autowired
IDepartment department;
@Override
public void updateDutyStaff() {
List<DutyStaffEntity> list = usermapper.getStaffDutyList();
Map<String, Object> searchParams = new HashMap<>();
Page page = new Page(1000);
DepartmentListRequest listRequest = new DepartmentListRequest();
searchParams.put("EQ_parentId", 1);
listRequest.setOrderColumn("orderNum");
listRequest.setOrderMode("asc");
listRequest.setSearchParams(searchParams);
listRequest.setPaging(page);
List<DepartmentEntity> departmentList = department.getDepartmentList(listRequest).getObjectList();
Date date = new Date();
if (CollectionUtils.isNotEmpty(list)) {
int size = list.size();
for (int i = 0; i < size; i++) {
DutyStaffEntity staff = list.get(i);
if ("1".equals(staff.getOnduty()) && staff.getId() == list.size()) {
staff.setOnduty("0");
staff.setUpdateTime(date);
usermapper.updateDutyStaff(staff);
list.get(0).setOnduty("1");//循环到第一个轮询值日
list.get(0).setUpdateTime(date);
usermapper.updateDutyStaff(list.get(0));
break;
} else if ("1".equals(staff.getOnduty()) && staff.getId() != list.size()) {
staff.setOnduty("0");
staff.setUpdateTime(date);
usermapper.updateDutyStaff(staff);
list.get(i + 1).setOnduty("1");//下一个轮询值日
list.get(i + 1).setUpdateTime(date);
usermapper.updateDutyStaff(list.get(i + 1));
break;
for (DepartmentEntity department : departmentList) {
searchParams.clear();
searchParams.put("cityCode", department.getDescripition());
List<UserEntity> dutyUserByCity = usermapper.getDutyUserByCity(searchParams);
if (CollectionUtils.isNotEmpty(dutyUserByCity)) {
int size = dutyUserByCity.size();
for (int i = 0; i < size; i++) {
UserEntity userEntity = dutyUserByCity.get(i);
if (userEntity.getEnabled()) {
UserEntity entity = null;
if (i < (size - 1)) {
entity = dutyUserByCity.get(i + 1);
} else {
entity = dutyUserByCity.get(0);
}
usermapper.updateDutyOnduty(userEntity.getId(), date, 0);
usermapper.updateDutyOnduty(entity.getId(), date, 1);
}
}
}
}
}
......
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