Commit 52e2754b by YG8999

保洁管理、新增店铺加设备分组

parent 4c299850
......@@ -75,11 +75,7 @@ public class SCleanConsumerController extends BaseController
@PostMapping
public AjaxResult add(@RequestBody SConsumer sConsumer)
{
sConsumer.setRoleType(RoleTypeEnum.CLEANER.getCode());
sConsumer.setAccount(sConsumer.getPhone());
String password = BaseUtil.encryptPassword("12345678", sConsumer.getPhone());
sConsumer.setPwd(password);
return toAjax(sConsumerService.insertSConsumer(sConsumer));
return toAjax(sConsumerService.addCleanConsumer(sConsumer));
}
/**
......@@ -101,6 +97,6 @@ public class SCleanConsumerController extends BaseController
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sConsumerService.deleteSConsumerByIds(ids));
return toAjax(sConsumerService.deleteCleanConsumerByIds(ids));
}
}
......@@ -6,6 +6,9 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import org.springframework.util.AntPathMatcher;
import share.common.constant.Constants;
import share.common.core.text.StrFormatter;
......@@ -611,4 +614,29 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
}
return sb.toString();
}
/**
* 将字符串中的数字与字母分开
* @param str
* @return
*/
public static Map<String,String> spiltStr(String str) {
if (StrUtil.isNotEmpty(str)) {
Map<String, String> map = MapUtil.newHashMap();
String letters = "";
String digits = "";
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (Character.isLetter(c)) {
letters += c;
} else if (Character.isDigit(c)) {
digits += c;
}
}
map.put("letters", letters);
map.put("digits", digits);
return map;
}
return null;
}
}
\ No newline at end of file
......@@ -29,15 +29,15 @@ public class CaptchaConfig
// 验证码图片高度 默认为50
properties.setProperty(KAPTCHA_IMAGE_HEIGHT, "60");
// 验证码文本字符大小 默认为40
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "38");
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_SIZE, "45");
// KAPTCHA_SESSION_KEY
properties.setProperty(KAPTCHA_SESSION_CONFIG_KEY, "kaptchaCode");
// 验证码文本字符长度 默认为5
properties.setProperty(KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4");
// 验证码文本字体样式 默认为new Font("Arial", 1, fontSize), new Font("Courier", 1, fontSize)
properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
// properties.setProperty(KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial,Courier");
// 图片样式 水纹com.google.code.kaptcha.impl.WaterRipple 鱼眼com.google.code.kaptcha.impl.FishEyeGimpy 阴影com.google.code.kaptcha.impl.ShadowGimpy
properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
// properties.setProperty(KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
......
......@@ -60,4 +60,6 @@ public interface SStoreMapper extends BaseMapper<SStore>
* @return 结果
*/
public int deleteSStoreByIds(Long[] ids);
SStore selectByMaxDeviceGroup();
}
......@@ -113,4 +113,13 @@ public interface SConsumerService extends IService<SConsumer>
boolean editSConsumer(SConsumer request);
List<SConsumer> selectUnallocatedList(SConsumerVo sConsumer);
/**
* 添加保洁人员
* @param sConsumer
* @return
*/
int addCleanConsumer(SConsumer sConsumer);
int deleteCleanConsumerByIds(Long[] ids);
}
package share.system.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
......@@ -13,10 +16,12 @@ import org.springframework.stereotype.Service;
import share.common.constant.Constants;
import share.common.constant.SmsConstants;
import share.common.enums.ConsumerCouponUseStatusEnum;
import share.common.enums.RoleTypeEnum;
import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.system.domain.SConsumerCoupon;
import share.system.domain.SRoomPack;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SConsumerVo;
import share.system.mapper.SConsumerMapper;
......@@ -215,4 +220,42 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
public List<SConsumer> selectUnallocatedList(SConsumerVo sConsumer) {
return baseMapper.selectUnallocatedList(sConsumer);
}
@Override
public int addCleanConsumer(SConsumer sConsumer) {
LambdaQueryWrapper<SConsumer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.and((wrapper)->{
wrapper.eq(SConsumer::getPhone, sConsumer.getPhone())
.or()
.eq(SConsumer::getAccount, sConsumer.getPhone());
});
List<SConsumer> list = baseMapper.selectList(queryWrapper);
// 存在用户设置未保洁人员,不存在新增保洁人员
if (list.size() > 0) {
SConsumer consumer = list.get(0);
consumer.setRoleType(RoleTypeEnum.CLEANER.getCode());
return baseMapper.updateSConsumer(consumer);
} else {
sConsumer.setRoleType(RoleTypeEnum.CLEANER.getCode());
sConsumer.setAccount(sConsumer.getPhone());
String password = BaseUtil.encryptPassword("12345678", sConsumer.getPhone());
sConsumer.setPwd(password);
return baseMapper.insertSConsumer(sConsumer);
}
}
@Override
public int deleteCleanConsumerByIds(Long[] ids) {
if (ArrayUtil.isNotEmpty(ids)) {
List<Long> idList = ListUtil.toList(ids);
List<SConsumer> list = baseMapper.selectBatchIds(idList);
list.stream().forEach(sConsumer -> {
sConsumer.setRoleType(RoleTypeEnum.MEMBRO.getCode());
});
updateBatchById(list);
return idList.size();
}
return 0;
}
}
......@@ -3,6 +3,9 @@ package share.system.service.impl;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dianping.openapi.sdk.api.customerauth.session.entity.CustomerKeyShopScopeResponseEntity;
......@@ -82,6 +85,21 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
@Override
public int insertSStore(SStore sStore) {
sStore.setCreateTime(DateUtils.getNowDate());
// 获取最新设备分组
SStore store = baseMapper.selectByMaxDeviceGroup();
if (ObjectUtil.isNotEmpty(store)) {
String deviceGroup = store.getDeviceGroup();
Map<String,String> map = share.common.utils.StringUtils.spiltStr(deviceGroup);
if (ObjectUtil.isNotEmpty(map)) {
String s = ObjectUtil.isNotEmpty(map.get("letters")) ? map.get("letters") : "FFFA";
Integer e = NumberUtil.isInteger(map.get("digits")) ? Integer.parseInt(map.get("digits"))+1 : 10000001;
sStore.setDeviceGroup(StrUtil.concat(true, s, String.valueOf(e)));
} else {
sStore.setDeviceGroup("FFFA10000001");
}
} else {
sStore.setDeviceGroup("FFFA10000001");
}
return baseMapper.insertSStore(sStore);
}
......
......@@ -48,8 +48,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="consumerId != null"> and t1.consumer_id = #{consumerId}</if>
<if test="roomId != null"> and t1.room_id = #{roomId}</if>
<if test="storeId != null"> and t1.store_id = #{storeId}</if>
<if test="createTime != null ">
and DATE_FORMAT(t1.create_time, '%Y-%m-%d') = DATE_FORMAT(#{createTime}, '%Y-%m-%d')
</if>
</where>
ORDER BY create_time DESC
order by create_time desc
</select>
<select id="selectSCleanRecordsById" parameterType="Long" resultMap="SCleanRecordsResult">
......
......@@ -69,6 +69,7 @@
<if test="openEndTime != null "> and open_end_time = #{openEndTime}</if>
<if test="storeType != null "> and store_type = #{storeType}</if>
</where>
order by create_time desc
</select>
<select id="selectSStoreById" parameterType="Long" resultMap="SStoreResult">
......@@ -76,6 +77,10 @@
where id = #{id}
</select>
<select id="selectByMaxDeviceGroup" resultMap="SStoreResult">
<include refid="selectSStoreVo"/> order by device_group desc limit 1
</select>
<insert id="insertSStore" parameterType="SStore" useGeneratedKeys="true" keyProperty="id">
insert into s_store
<trim prefix="(" suffix=")" suffixOverrides=",">
......
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