Commit 7083680e LN

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/resources/messages.properties
2 个父辈 663a1e1f 96ade4a7
...@@ -100,7 +100,7 @@ public class DataInitManager { ...@@ -100,7 +100,7 @@ public class DataInitManager {
operator = roleManager.save(operator); operator = roleManager.save(operator);
log.info("创建默认角色:" + operator.toString()); log.info("创建默认角色:" + operator.toString());
admin = new User(userName, "admin@neotel.tech", "zh-CN", role.getId(), "$2a$10$Egp1/gvFlt7zhlXVfEFw4OfWQCGPw0ClmMcc6FjTnvXNRVf9zdMRa", true, true, new Date(), groupIds, "",""); admin = new User(userName, "admin@neotel.tech", "zh-CN", role.getId(), "$2a$10$Egp1/gvFlt7zhlXVfEFw4OfWQCGPw0ClmMcc6FjTnvXNRVf9zdMRa", true, true, new Date(), groupIds, "","","");
admin = userManager.save(admin); admin = userManager.save(admin);
log.info("创建默认用户:" + admin.toString()); log.info("创建默认用户:" + admin.toString());
......
...@@ -218,4 +218,9 @@ public class Constants { ...@@ -218,4 +218,9 @@ public class Constants {
*/ */
public static final String Cache_DefLanguage = "Cache_DefLanguage"; public static final String Cache_DefLanguage = "Cache_DefLanguage";
/**
* 是否扫描登录
*/
public static final String Cache_QRCodeLogin = "Cache_QRCodeLogin";
} }
...@@ -89,7 +89,7 @@ public class DateUtil { ...@@ -89,7 +89,7 @@ public class DateUtil {
SimpleDateFormat df; SimpleDateFormat df;
Date date; Date date;
df = new SimpleDateFormat(aMask); df = new SimpleDateFormat(aMask);
df.setLenient(false);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("converting '" + strDate + "' to date with mask '" + aMask + "'"); log.debug("converting '" + strDate + "' to date with mask '" + aMask + "'");
} }
......
...@@ -111,7 +111,7 @@ public class UserCodeUtil { ...@@ -111,7 +111,7 @@ public class UserCodeUtil {
String langu=""; String langu="";
String roleId=""; String roleId="";
User user=new User(username,email,langu,roleId,"",true User user=new User(username,email,langu,roleId,"",true
,false,new Date(),new HashSet<>(),"",""); ,false,new Date(),new HashSet<>(),"","","");
user.setId(id); user.setId(id);
user.setCreateDate(createData); user.setCreateDate(createData);
list.add(user); list.add(user);
......
...@@ -674,6 +674,7 @@ public class BarcodeRule { ...@@ -674,6 +674,7 @@ public class BarcodeRule {
b.setBarcode(reelId); b.setBarcode(reelId);
codeBean.setCodeStr(reelId); codeBean.setCodeStr(reelId);
partNumber = partNumber.trim();
b.setPartNumber(partNumber); b.setPartNumber(partNumber);
b.setAmount(quantity); b.setAmount(quantity);
b.setProduceDate(produceDate); b.setProduceDate(produceDate);
......
...@@ -376,6 +376,7 @@ public class OrderController { ...@@ -376,6 +376,7 @@ public class OrderController {
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.MPN",locale,"MPN"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.MPN",locale,"MPN")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.side",locale,"面别"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.side",locale,"面别")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.tableNo",locale,"台车号"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.tableNo",locale,"台车号")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.slotNum",locale,"站位编号")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.feederInfo",locale,"站位信息"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.feederInfo",locale,"站位信息")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.needReelCount",locale,"需求盘数"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.needReelCount",locale,"需求盘数")));
header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.outReelCount",locale,"已出盘数"))); header.add(Lists.newArrayList(MessageUtils.getText("smfcore.order.outReelCount",locale,"已出盘数")));
...@@ -405,6 +406,7 @@ public class OrderController { ...@@ -405,6 +406,7 @@ public class OrderController {
data.add(orderItem.getMpn()); data.add(orderItem.getMpn());
data.add(orderItem.getSide()); data.add(orderItem.getSide());
data.add(orderItem.getTableNo()); data.add(orderItem.getTableNo());
data.add(orderItem.getSlotNum());
data.add(orderItem.getFeederInfo()); data.add(orderItem.getFeederInfo());
data.add(orderItem.getNeedReelCount()); data.add(orderItem.getNeedReelCount());
data.add(orderItem.getOutReelCount()); data.add(orderItem.getOutReelCount());
......
...@@ -69,6 +69,9 @@ public class OrderItemDto { ...@@ -69,6 +69,9 @@ public class OrderItemDto {
private int totalOutReelCount = 0; private int totalOutReelCount = 0;
@ApiModelProperty("站位编号")
private String slotNum = "";
// Inventory Quantity // Inventory Quantity
// Inventory Reel / Bundle count // Inventory Reel / Bundle count
// Insufficient Quantity // Insufficient Quantity
......
...@@ -219,6 +219,7 @@ public class MaterialBoxController { ...@@ -219,6 +219,7 @@ public class MaterialBoxController {
subBarcode.setHostBarcodeId(barcode.getId()); subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(newCount); subBarcode.setAmount(newCount);
subBarcode.setPutInTime(System.currentTimeMillis()); subBarcode.setPutInTime(System.currentTimeMillis());
subBarcode.setPosName(barcode.getBarcode());
barcodeManager.saveBarcode(subBarcode); barcodeManager.saveBarcode(subBarcode);
finishTask(barcode, opQty, currentTask, subBarcode, subBarcode.getAmount()); finishTask(barcode, opQty, currentTask, subBarcode, subBarcode.getAmount());
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount()); log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
...@@ -419,6 +420,7 @@ public class MaterialBoxController { ...@@ -419,6 +420,7 @@ public class MaterialBoxController {
subBarcode.setHostBarcodeId(barcode.getId()); subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(oldAmount + opQty); subBarcode.setAmount(oldAmount + opQty);
subBarcode.setPutInTime(System.currentTimeMillis()); subBarcode.setPutInTime(System.currentTimeMillis());
subBarcode.setPosName(barcode.getBarcode());
subBarcode = barcodeManager.save(subBarcode); subBarcode = barcodeManager.save(subBarcode);
finishTask(barcode, opType, currentTask, subBarcode, opQty); finishTask(barcode, opType, currentTask, subBarcode, opQty);
...@@ -441,6 +443,7 @@ public class MaterialBoxController { ...@@ -441,6 +443,7 @@ public class MaterialBoxController {
subBarcode.setHostBarcodeId(barcode.getId()); subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setAmount(newAmount); subBarcode.setAmount(newAmount);
subBarcode.setPosName(barcode.getBarcode());
subBarcode = barcodeManager.save(subBarcode); subBarcode = barcodeManager.save(subBarcode);
finishTask(barcode, opType, currentTask,subBarcode, opQty); finishTask(barcode, opType, currentTask,subBarcode, opQty);
...@@ -535,6 +538,7 @@ public class MaterialBoxController { ...@@ -535,6 +538,7 @@ public class MaterialBoxController {
subBarcode.updateSluggishTime(dataCache.getPNsluggishDay(barcode.getPartNumber())); subBarcode.updateSluggishTime(dataCache.getPNsluggishDay(barcode.getPartNumber()));
subBarcode.setCheckOutDate(null, ""); subBarcode.setCheckOutDate(null, "");
subBarcode.setHostBarcodeId(barcode.getId()); subBarcode.setHostBarcodeId(barcode.getId());
subBarcode.setPosName(barcode.getBarcode());
subBarcode = barcodeManager.save(subBarcode); subBarcode = barcodeManager.save(subBarcode);
return subBarcode; return subBarcode;
} }
......
...@@ -540,21 +540,54 @@ public class StoragePosController { ...@@ -540,21 +540,54 @@ public class StoragePosController {
putInTime=dateFormat.format(pos.getBarcode().getPutInDate()); putInTime=dateFormat.format(pos.getBarcode().getPutInDate());
} }
Barcode barcode = pos.getBarcode();
List<Object> data = new ArrayList<>(); List<Object> data = new ArrayList<>();
data.add(pos.getBarcode().getBarcode()); data.add(barcode.getBarcode());
data.add(pos.getBarcode().getPartNumber()); data.add(barcode.getPartNumber());
data.add(proDate); data.add(proDate);
data.add(expireDate); data.add(expireDate);
data.add(pos.getBarcode().getBatch()); data.add(barcode.getBatch());
data.add(pos.getPosName()); data.add(pos.getPosName());
data.add(pos.getBarcode().getLockName()); data.add(barcode.getLockName());
data.add(pos.getBarcode().getAmount()); data.add(barcode.getAmount());
data.add(pos.getBarcode().getPlateSize()+"X"+pos.getBarcode().getHeight()); data.add(barcode.getPlateSize()+"X"+barcode.getHeight());
data.add(pos.getW()); data.add(pos.getW());
data.add(pos.getH()); data.add(pos.getH());
data.add(putInTime); data.add(putInTime);
data.add(dateFormat.format(pos.getBarcode().getPutInDate())); data.add(dateFormat.format(barcode.getPutInDate()));
dataList.add(data); dataList.add(data);
//处理barcode信息
List<Barcode> subCodeList = barcode.getSubCodeList();
if (subCodeList != null && !subCodeList.isEmpty()){
for (Barcode subCode : subCodeList) {
String subCodeProDate = subCode.getProduceDate() == null ? "" : dateFormat.format(subCode.getProduceDate());
String subCodeExpireDate = subCode.getExpireDate() == null ? "" : dateFormat.format(subCode.getExpireDate());
String subCodePutInTime = (subCode.getPutInTime() == -1) ? "" : dateFormat.format(new Date(subCode.getPutInTime()));
if(ObjectUtil.isNotEmpty(subCodePutInTime)){
subCodePutInTime=dateFormat.format(subCode.getPutInDate());
}
List<Object> subData = new ArrayList<>();
subData.add(subCode.getBarcode());
subData.add(subCode.getPartNumber());
subData.add(subCodeProDate);
subData.add(subCodeExpireDate);
subData.add(subCode.getBatch());
subData.add(pos.getPosName()+"("+barcode.getBarcode()+")");
subData.add(subCode.getLockName());
subData.add(subCode.getAmount());
subData.add(subCode.getPlateSize()+"X"+subCode.getHeight());
subData.add(pos.getW());
subData.add(pos.getH());
subData.add(subCodePutInTime);
subData.add(dateFormat.format(subCode.getPutInDate()));
dataList.add(subData);
}
}
} }
return dataList; return dataList;
} }
......
...@@ -94,6 +94,11 @@ public class SettingsController { ...@@ -94,6 +94,11 @@ public class SettingsController {
defLanguage = "zh"; defLanguage = "zh";
} }
dto.setDefLanguage(defLanguage); dto.setDefLanguage(defLanguage);
Boolean QRCodeLogin = dataCache.getCache(Constants.Cache_QRCodeLogin);
if (QRCodeLogin == null){
QRCodeLogin = false;
}
dto.setQRCodeLogin(QRCodeLogin);
return dto; return dto;
} }
...@@ -109,10 +114,12 @@ public class SettingsController { ...@@ -109,10 +114,12 @@ public class SettingsController {
dataCache.updateCache(Constants.BACKUP_MONTH_KEY,sysSettingsDto.getBackUpMonth()); dataCache.updateCache(Constants.BACKUP_MONTH_KEY,sysSettingsDto.getBackUpMonth());
dataCache.updateCache(Constants.CACHE_closeWorkOrder,sysSettingsDto.isCloseWorkOrder()); dataCache.updateCache(Constants.CACHE_closeWorkOrder,sysSettingsDto.isCloseWorkOrder());
dataCache.updateCache(Constants.Cache_DefLanguage,sysSettingsDto.getDefLanguage()); dataCache.updateCache(Constants.Cache_DefLanguage,sysSettingsDto.getDefLanguage());
dataCache.updateCache(Constants.Cache_QRCodeLogin,sysSettingsDto.isQRCodeLogin());
log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob()+",sluggishDay="+sysSettingsDto.getSluggishDay() log.info("更改系统设置:stopout=" + sysSettingsDto.isStopOut() + ",stopjob=" + sysSettingsDto.isStartJob()+",sluggishDay="+sysSettingsDto.getSluggishDay()
+",expiresDay="+sysSettingsDto.getExpiresDay()+",capacityWarn="+sysSettingsDto.getCapacityWarn()+",backUpMonth="+sysSettingsDto.getBackUpMonth() +",expiresDay="+sysSettingsDto.getExpiresDay()+",capacityWarn="+sysSettingsDto.getCapacityWarn()+",backUpMonth="+sysSettingsDto.getBackUpMonth()
+",缺料不自动关闭工单="+sysSettingsDto.isCloseWorkOrder() +",缺料不自动关闭工单="+sysSettingsDto.isCloseWorkOrder()
+"默认语言为:"+sysSettingsDto.getDefLanguage()); +"默认语言为:"+sysSettingsDto.getDefLanguage()
+"是否扫码登录:"+sysSettingsDto.isQRCodeLogin());
return ResultBean.newOkResult("保存成功"); return ResultBean.newOkResult("保存成功");
} }
...@@ -334,4 +341,15 @@ public class SettingsController { ...@@ -334,4 +341,15 @@ public class SettingsController {
} }
return ResultBean.newOkResult(""); return ResultBean.newOkResult("");
} }
@ApiOperation("判断是否扫码登录")
@GetMapping("/QRCodeLogin")
@AnonymousAccess
public ResultBean QRCodeLogin() {
Boolean QRCodeLogin = dataCache.getCache(Constants.Cache_QRCodeLogin);
if (QRCodeLogin == null){
QRCodeLogin = false;
}
return ResultBean.newOkResult(QRCodeLogin);
}
} }
...@@ -33,4 +33,7 @@ public class SysSettingsDto implements Serializable { ...@@ -33,4 +33,7 @@ public class SysSettingsDto implements Serializable {
@ApiModelProperty("默认语言") @ApiModelProperty("默认语言")
private String defLanguage = "zh"; private String defLanguage = "zh";
@ApiModelProperty("是否扫码登录")
private boolean QRCodeLogin = false;
} }
...@@ -80,10 +80,8 @@ public class DEIF20861Controller { ...@@ -80,10 +80,8 @@ public class DEIF20861Controller {
} }
Map<String, Object> itemMap = new HashMap<>(); Map<String, Object> itemMap = new HashMap<>();
itemMap.put("cid", storage.getCid()); itemMap.put("cid", storage.getCid());
String reelSize = shelfType.replace("smallReel", "7").replace("bigReel", "15"); String reelSize = shelfType.replace("smallReel", "7").replace("bigReel", "15");
String s = StringUtil.join(reelSize); itemMap.put("reelSize", reelSize);
itemMap.put("reelSize", s);
itemMap.put("status", shelfS); itemMap.put("status", shelfS);
itemMap.put("hSerial", hserial); itemMap.put("hSerial", hserial);
...@@ -180,6 +178,7 @@ public class DEIF20861Controller { ...@@ -180,6 +178,7 @@ public class DEIF20861Controller {
} }
String outShelfStatus = equipStatus.getData().getOrDefault("outShelfStatus", "").toString(); String outShelfStatus = equipStatus.getData().getOrDefault("outShelfStatus", "").toString();
String inShelfStatus = equipStatus.getData().getOrDefault("inShelfStatus", "").toString(); String inShelfStatus = equipStatus.getData().getOrDefault("inShelfStatus", "").toString();
String shelfType = equipStatus.getData().getOrDefault("shelfType", "").toString();
if(status==1&&(!equipStatus.timeOut())){ if(status==1&&(!equipStatus.timeOut())){
if(ObjectUtil.isEmpty(outShelfStatus)){ if(ObjectUtil.isEmpty(outShelfStatus)){
outShelfStatus="IDLE"; outShelfStatus="IDLE";
...@@ -194,7 +193,8 @@ public class DEIF20861Controller { ...@@ -194,7 +193,8 @@ public class DEIF20861Controller {
} }
Map<String, Object> itemMap = new HashMap<>(); Map<String, Object> itemMap = new HashMap<>();
itemMap.put("cid", equipment.getCid()); itemMap.put("cid", equipment.getCid());
itemMap.put("reelSize", "7,15"); String reelSize = shelfType.replace("smallReel", "7").replace("bigReel", "15");
itemMap.put("reelSize", reelSize);
itemMap.put("inShelfStatus", inShelfStatus); itemMap.put("inShelfStatus", inShelfStatus);
itemMap.put("outShelfStatus", outShelfStatus); itemMap.put("outShelfStatus", outShelfStatus);
...@@ -204,4 +204,5 @@ public class DEIF20861Controller { ...@@ -204,4 +204,5 @@ public class DEIF20861Controller {
EquipStatusUtil.UpdateAgvInfo("",JsonUtil.toJsonStr(paramMap), JsonUtil.toJsonStr(bean),"OK"); EquipStatusUtil.UpdateAgvInfo("",JsonUtil.toJsonStr(paramMap), JsonUtil.toJsonStr(bean),"OK");
return bean; return bean;
} }
} }
...@@ -51,13 +51,21 @@ public class NeotelApi extends BaseSmfApiListener { ...@@ -51,13 +51,21 @@ public class NeotelApi extends BaseSmfApiListener {
paramMap.put("reelId", task.getBarcode()); paramMap.put("reelId", task.getBarcode());
paramMap.put("location", task.getPosName()); paramMap.put("location", task.getPosName());
paramMap.put("source", "SMF"); paramMap.put("source", "SMF");
paramMap.put("fullCode", "");
paramMap.put("partNum", "");
paramMap.put("vendor", "");
paramMap.put("qty", 0);
paramMap.put("produceDate", "");
paramMap.put("batch", "");
Barcode barcode = barcodeManager.findByBarcode(task.getBarcode()); Barcode barcode = barcodeManager.findByBarcode(task.getBarcode());
String fullCode = "";
if (barcode != null) { if (barcode != null) {
fullCode = barcode.getFullCode(); paramMap.put("fullCode", barcode.getFullCode());
paramMap.put("partNum", barcode.getPartNumber());
paramMap.put("vendor", barcode.getProvider());
paramMap.put("qty", barcode.getAmount());
paramMap.put("produceDate", barcode.getProduceDate());
paramMap.put("batch", barcode.getBatch());
} }
paramMap.put("fullCode", fullCode);
try { try {
requestParams = JsonUtil.toJsonStr(paramMap); requestParams = JsonUtil.toJsonStr(paramMap);
log.info(task.getBarcode() + "入库通知,参数" + requestParams); log.info(task.getBarcode() + "入库通知,参数" + requestParams);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
package com.neotel.smfcore.security.rest; package com.neotel.smfcore.security.rest;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.*; import com.neotel.smfcore.common.utils.*;
import com.neotel.smfcore.core.api.SmfApi; import com.neotel.smfcore.core.api.SmfApi;
import com.neotel.smfcore.security.annotation.AnonymousDeleteMapping; import com.neotel.smfcore.security.annotation.AnonymousDeleteMapping;
...@@ -28,6 +29,8 @@ import com.neotel.smfcore.security.rest.bean.dto.OnlineUserDto; ...@@ -28,6 +29,8 @@ import com.neotel.smfcore.security.rest.bean.dto.OnlineUserDto;
import com.neotel.smfcore.security.service.OnlineUserService; import com.neotel.smfcore.security.service.OnlineUserService;
import com.neotel.smfcore.security.rest.bean.dto.AuthUserDto; import com.neotel.smfcore.security.rest.bean.dto.AuthUserDto;
import com.neotel.smfcore.security.rest.bean.dto.JwtUserDto; import com.neotel.smfcore.security.rest.bean.dto.JwtUserDto;
import com.neotel.smfcore.security.service.manager.IUserManager;
import com.neotel.smfcore.security.service.po.User;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -39,6 +42,8 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio ...@@ -39,6 +42,8 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -70,6 +75,12 @@ public class AuthorizationController { ...@@ -70,6 +75,12 @@ public class AuthorizationController {
@Resource @Resource
private LoginProperties loginProperties; private LoginProperties loginProperties;
@Autowired
private IUserManager userManager;
@Autowired
private UserDetailsService userDetailsService;
@ApiOperation("登录授权") @ApiOperation("登录授权")
@AnonymousPostMapping(value = "/login") @AnonymousPostMapping(value = "/login")
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception { public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
...@@ -161,6 +172,60 @@ public class AuthorizationController { ...@@ -161,6 +172,60 @@ public class AuthorizationController {
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@ApiOperation("扫码登录授权")
@AnonymousPostMapping(value = "/QRCodeLogin")
public ResponseEntity<Object> QRCodeLogin(@RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
String code = authUser.getCode();
if (StringUtils.isEmpty(code)) {
throw new ValidateException("smfcore.valueCanotNull", "{0}不能为空", new String[]{"code"});
}
//取第一位是id信息
String id = code.substring(0, code.indexOf("-"));
User user = userManager.get(id);
if (user == null) {
throw new ValidateException("smfcore.valueNotExist", "{0}[{1}]不存在", new String[]{"userId", id});
}
//判断与登录是否一致
String loginCode = user.getLoginCode();
if (!code.equals(loginCode)){
throw new ValidateException("smfcore.login.codeError", "登录码[{0}]错误", new String[]{code});
}
// 生成令牌与第三方系统获取令牌方式
UserDetails userDetails = userDetailsService.loadUserByUsername(user.getUsername());
Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
String token = tokenProvider.createToken(authentication);
final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal();
// 保存在线信息
String ip = StringUtils.getIp(request);
String browser = StringUtils.getBrowser(request);
String address = StringUtils.getCityInfo(ip);
OnlineUserDto onlineUserDto = null;
try {
long seconds = onlineUserService.properties.getTokenValidityInSeconds() / 1000;
Date exTime = DateUtil.addSeconds(new Date(), new Long(seconds).intValue());
onlineUserDto = new OnlineUserDto(jwtUserDto.getUsername(), browser, ip, address, EncryptUtils.desEncrypt(token), new Date(), exTime,jwtUserDto.getImageStr());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
OnlineUserService.onlineUserMap.put(onlineUserService.properties.getOnlineKey() + token, onlineUserDto);
// 返回 token 与 用户信息
Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
put("token", properties.getTokenStartWith() + token);
put("user", jwtUserDto);
}};
if (loginProperties.isSingleLogin()) {
//踢掉之前已经登录的token
onlineUserService.checkLoginOnUser(user.getUsername(), token);
}
//重新登陆时清理调试模式状态
SecurityUtils.updateToDebugModel(user.getUsername(), false);
return ResponseEntity.ok(authInfo);
}
@AnonymousGetMapping(value = "/code") @AnonymousGetMapping(value = "/code")
public ResponseEntity<Object> getCode() { public ResponseEntity<Object> getCode() {
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
*/ */
package com.neotel.smfcore.security.rest; package com.neotel.smfcore.security.rest;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
import com.neotel.smfcore.common.bean.PageData; import com.neotel.smfcore.common.bean.PageData;
import com.neotel.smfcore.common.bean.ResultBean; import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.csv.CsvReader; import com.neotel.smfcore.common.csv.CsvReader;
...@@ -358,4 +360,26 @@ public class UserController { ...@@ -358,4 +360,26 @@ public class UserController {
return ResultBean.newOkResult("smfcore.exitDebugModel.ok","已退出调试模式",new String[]{}, false); return ResultBean.newOkResult("smfcore.exitDebugModel.ok","已退出调试模式",new String[]{}, false);
} }
@ApiOperation("生成用户授权的二维码")
@PostMapping(value = "/userQrcode")
//@AnonymousAccess
public ResultBean userQrcode(@RequestBody Map<String, String> paramMap) {
String id = paramMap.get("id");
if (StringUtils.isEmpty(id)) {
return ResultBean.newErrorResult(-1, "smfcore.valueCanotNull", "{0}不能为空", new String[]{"id"});
}
User user = userManager.get(id);
//用户登录的授权code
String loginCode = user.getLoginCode();
if (StringUtils.isEmpty(loginCode)) {
loginCode = id + "-" + Md5Utls.getMd5(id, user.getCreateDate());
user.setLoginCode(loginCode);
userManager.save(user);
}
QrConfig config = new QrConfig();
byte[] codeBytes = QrCodeUtil.generatePng(loginCode, config);
return ResultBean.newOkResult(codeBytes);
}
} }
...@@ -64,6 +64,8 @@ public class User extends BasePo implements Serializable { ...@@ -64,6 +64,8 @@ public class User extends BasePo implements Serializable {
*/ */
private String imageStr; private String imageStr;
private String loginCode;
public boolean hasGroup(String groupId) { public boolean hasGroup(String groupId) {
if (groupId == null || groupId.equals("") || groupId.equals("-1")) { if (groupId == null || groupId.equals("") || groupId.equals("-1")) {
......
...@@ -436,5 +436,6 @@ smfcore.virtual.boxInPos=[{0}]\u5DF2\u5728\u5E93\u4F4D[{1}]\u4E2D,\u8BF7\u5148\u ...@@ -436,5 +436,6 @@ smfcore.virtual.boxInPos=[{0}]\u5DF2\u5728\u5E93\u4F4D[{1}]\u4E2D,\u8BF7\u5148\u
smfcore.virtual.quantityError=\u53D6\u51FA\u6570\u91CF\u5E94\u4E3A[{0}] smfcore.virtual.quantityError=\u53D6\u51FA\u6570\u91CF\u5E94\u4E3A[{0}]
smfcode.virtual.enter=\u8BF7\u626B\u63CF\u6216\u8F93\u5165\u6761\u7801\u540E\u6309\u56DE\u8F66\u786E\u8BA4 smfcode.virtual.enter=\u8BF7\u626B\u63CF\u6216\u8F93\u5165\u6761\u7801\u540E\u6309\u56DE\u8F66\u786E\u8BA4
smfcore.auth.expire=\u6388\u6743\u5DF2\u8FC7\u671F smfcore.auth.expire=\u6388\u6743\u5DF2\u8FC7\u671F
smfcore.order.slotNum=\u7AD9\u4F4D\u7F16\u53F7
smfcore.reelPosMove.paramerror=\u53C2\u6570\u4E0D\u5B8C\u6574 smfcore.reelPosMove.paramerror=\u53C2\u6570\u4E0D\u5B8C\u6574
smfcore.reelPosMove.posIsNull=\u5E93\u4F4D[{1}]\u4E3A\u7A7A smfcore.reelPosMove.posIsNull=\u5E93\u4F4D[{1}]\u4E3A\u7A7A
...@@ -425,4 +425,5 @@ smfcore.equipment.view.ncgroup=Neo Counter ...@@ -425,4 +425,5 @@ smfcore.equipment.view.ncgroup=Neo Counter
smfcore.virtual.boxInPos=[{0}] befindet sich bereits im Lagerplatz [{1}]. Bitte entnehmen Sie es zuerst smfcore.virtual.boxInPos=[{0}] befindet sich bereits im Lagerplatz [{1}]. Bitte entnehmen Sie es zuerst
smfcore.virtual.quantityError=Die zu entnehmende Menge sollte [{0}] betragen smfcore.virtual.quantityError=Die zu entnehmende Menge sollte [{0}] betragen
smfcode.virtual.enter=Bitte scannen Sie den Barcode oder geben Sie ihn ein und best\u00E4tigen Sie mit Enter smfcode.virtual.enter=Bitte scannen Sie den Barcode oder geben Sie ihn ein und best\u00E4tigen Sie mit Enter
smfcore.auth.expire=Die Autorisierung ist abgelaufen
\ No newline at end of file \ No newline at end of file
smfcore.auth.expire=Die Autorisierung ist abgelaufen
smfcore.order.slotNum=Standnummer
\ No newline at end of file \ No newline at end of file
...@@ -426,4 +426,5 @@ smfcore.equipment.view.ncgroup=Neo Counter ...@@ -426,4 +426,5 @@ smfcore.equipment.view.ncgroup=Neo Counter
smfcore.virtual.boxInPos=[{0}] is already in location [{1}]. Please remove it first smfcore.virtual.boxInPos=[{0}] is already in location [{1}]. Please remove it first
smfcore.virtual.quantityError=The quantity to be removed should be [{0}] smfcore.virtual.quantityError=The quantity to be removed should be [{0}]
smfcode.virtual.enter=Please scan or enter the barcode, then press Enter smfcode.virtual.enter=Please scan or enter the barcode, then press Enter
smfcore.auth.expire=Authorization has expired
\ No newline at end of file \ No newline at end of file
smfcore.auth.expire=Authorization has expired
smfcore.order.slotNum=Station Number
\ No newline at end of file \ No newline at end of file
...@@ -425,4 +425,5 @@ smfcore.equipment.view.ncgroup=Neo Counter ...@@ -425,4 +425,5 @@ smfcore.equipment.view.ncgroup=Neo Counter
smfcore.virtual.boxInPos=[{0}] est d\u00E9j\u00E0 dans l'emplacement [{1}]. Veuillez d'abord le retirer smfcore.virtual.boxInPos=[{0}] est d\u00E9j\u00E0 dans l'emplacement [{1}]. Veuillez d'abord le retirer
smfcore.virtual.quantityError=La quantit\u00E9 \u00E0 retirer doit \u00EAtre [{0}] smfcore.virtual.quantityError=La quantit\u00E9 \u00E0 retirer doit \u00EAtre [{0}]
smfcode.virtual.enter=Veuillez scanner ou saisir le code-barres, puis appuyer sur Entr\u00E9e smfcode.virtual.enter=Veuillez scanner ou saisir le code-barres, puis appuyer sur Entr\u00E9e
smfcore.auth.expire=L'autorisation a expir\u00E9
\ No newline at end of file \ No newline at end of file
smfcore.auth.expire=L'autorisation a expir\u00E9
smfcore.order.slotNum=num\u00E9ro de position
\ No newline at end of file \ No newline at end of file
...@@ -422,4 +422,5 @@ smfcore.equipment.view.ncgroup=Neo Counter ...@@ -422,4 +422,5 @@ smfcore.equipment.view.ncgroup=Neo Counter
smfcore.virtual.boxInPos=[{0}] \u306F\u65E2\u306B\u30ED\u30B1\u30FC\u30B7\u30E7\u30F3 [{1}] \u306B\u3042\u308A\u307E\u3059\u3002\u5148\u306B\u53D6\u308A\u51FA\u3057\u3066\u304F\u3060\u3055\u3044 smfcore.virtual.boxInPos=[{0}] \u306F\u65E2\u306B\u30ED\u30B1\u30FC\u30B7\u30E7\u30F3 [{1}] \u306B\u3042\u308A\u307E\u3059\u3002\u5148\u306B\u53D6\u308A\u51FA\u3057\u3066\u304F\u3060\u3055\u3044
smfcore.virtual.quantityError=\u53D6\u308A\u51FA\u3057\u6570\u91CF\u306F[{0}]\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 smfcore.virtual.quantityError=\u53D6\u308A\u51FA\u3057\u6570\u91CF\u306F[{0}]\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059
smfcode.virtual.enter=\u30D0\u30FC\u30B3\u30FC\u30C9\u3092\u30B9\u30AD\u30E3\u30F3\u3001\u307E\u305F\u306F\u5165\u529B\u5F8C\u3001Enter\u30AD\u30FC\u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044 smfcode.virtual.enter=\u30D0\u30FC\u30B3\u30FC\u30C9\u3092\u30B9\u30AD\u30E3\u30F3\u3001\u307E\u305F\u306F\u5165\u529B\u5F8C\u3001Enter\u30AD\u30FC\u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044
smfcore.auth.expire = \u8A8D\u8A3C\u304C\u671F\u9650\u5207\u308C\u3067\u3059
\ No newline at end of file \ No newline at end of file
smfcore.auth.expire = \u8A8D\u8A3C\u304C\u671F\u9650\u5207\u308C\u3067\u3059
smfcore.order.slotNum = \u30B9\u30BF\u30F3\u30C9\u756A\u53F7
\ No newline at end of file \ No newline at end of file
...@@ -422,4 +422,5 @@ smfcore.equipment.view.ncgroup=Neo Counter ...@@ -422,4 +422,5 @@ smfcore.equipment.view.ncgroup=Neo Counter
smfcore.virtual.boxInPos=[{0}]\u5DF2\u5728\u5E93\u4F4D[{1}]\u4E2D,\u8BF7\u5148\u53D6\u51FA smfcore.virtual.boxInPos=[{0}]\u5DF2\u5728\u5E93\u4F4D[{1}]\u4E2D,\u8BF7\u5148\u53D6\u51FA
smfcore.virtual.quantityError=\u53D6\u51FA\u6570\u91CF\u5E94\u4E3A[{0}] smfcore.virtual.quantityError=\u53D6\u51FA\u6570\u91CF\u5E94\u4E3A[{0}]
smfcode.virtual.enter=\u8BF7\u626B\u63CF\u6216\u8F93\u5165\u6761\u7801\u540E\u6309\u56DE\u8F66\u786E\u8BA4 smfcode.virtual.enter=\u8BF7\u626B\u63CF\u6216\u8F93\u5165\u6761\u7801\u540E\u6309\u56DE\u8F66\u786E\u8BA4
smfcore.auth.expire=\u6388\u6743\u5DF2\u8FC7\u671F
\ No newline at end of file \ No newline at end of file
smfcore.auth.expire=\u6388\u6743\u5DF2\u8FC7\u671F
smfcore.order.slotNum=\u7AD9\u4F4D\u7F16\u53F7
\ No newline at end of file \ No newline at end of file
...@@ -422,4 +422,5 @@ smfcore.equipment.view.ncgroup=Neo Counter ...@@ -422,4 +422,5 @@ smfcore.equipment.view.ncgroup=Neo Counter
smfcore.virtual.boxInPos=[{0}]\u5DF2\u5728\u5EAB\u4F4D[{1}]\u4E2D,\u8ACB\u5148\u53D6\u51FA smfcore.virtual.boxInPos=[{0}]\u5DF2\u5728\u5EAB\u4F4D[{1}]\u4E2D,\u8ACB\u5148\u53D6\u51FA
smfcore.virtual.quantityError=\u53D6\u51FA\u6578\u91CF\u61C9\u70BA[{0}] smfcore.virtual.quantityError=\u53D6\u51FA\u6578\u91CF\u61C9\u70BA[{0}]
smfcode.virtual.enter=\u8ACB\u6383\u63CF\u6216\u8F38\u5165\u689D\u78BC\u5F8C\u6309\u56DE\u8ECA\u78BA\u8A8D smfcode.virtual.enter=\u8ACB\u6383\u63CF\u6216\u8F38\u5165\u689D\u78BC\u5F8C\u6309\u56DE\u8ECA\u78BA\u8A8D
smfcore.auth.expire = \u6388\u6B0A\u5DF2\u904E\u671F
\ No newline at end of file \ No newline at end of file
smfcore.auth.expire = \u6388\u6B0A\u5DF2\u904E\u671F
smfcore.order.slotNum = \u7AD9\u4F4D\u7DE8\u865F
\ No newline at end of file \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!