Merge remote-tracking branch '惠信/dev_zhangke' into develop
# Conflicts: # nflg-wms-admin/src/main/java/com/nflg/wms/admin/service/UserControllerService.java
This commit is contained in:
commit
8500640600
|
|
@ -104,31 +104,6 @@ public class ComponentPackingController {
|
|||
VUtil.trueThrowBusinessError(StrUtil.isBlank(result.getHeadDTO().getWbstk())
|
||||
|| result.getHeadDTO().getWbstk().equalsIgnoreCase("C"))
|
||||
.throwMessage("此交货单已完成了过账");
|
||||
result.getHeadDTO().setGStreen("setGStreen");
|
||||
result.getHeadDTO().setGStrSuppl2("setGStrSuppl2");
|
||||
result.getHeadDTO().setTelNumber("setTelNumber");
|
||||
result.getHeadDTO().setCnum("setCnum");
|
||||
result.getHeadDTO().setHuodh("setHuodh");
|
||||
result.getHeadDTO().setBname("setBname");
|
||||
result.getHeadDTO().setMaktx("setMaktx");
|
||||
result.getHeadDTO().setMatnr("setMatnr");
|
||||
result.getHeadDTO().setSernr("setSernr");
|
||||
result.getHeadDTO().setUname("setUname");
|
||||
result.getHeadDTO().setXnum("setXnum");
|
||||
result.getHeadDTO().setZchep("setZchep");
|
||||
result.getHeadDTO().setZjshz("setZjshz");
|
||||
result.getHeadDTO().setZjshz("setZjshz");
|
||||
for (ZWM3A19ITEMDTO itemDTO : result.getItemDTOList())
|
||||
{
|
||||
itemDTO.setAtwrt("setAtwrt");
|
||||
itemDTO.setLgort("setLgort");
|
||||
itemDTO.setLgobe("setLgobe");
|
||||
itemDTO.setLgpbe("setLgpbe");
|
||||
itemDTO.setPotx2("setPotx2");
|
||||
itemDTO.setZatwrt("setZatwrt");
|
||||
itemDTO.setZtext("setZtext");
|
||||
itemDTO.setZxiah("setZxiah");
|
||||
}
|
||||
return ApiResult.success(result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.nflg.wms.common.pojo.ApiResult;
|
|||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.qo.*;
|
||||
import com.nflg.wms.common.pojo.vo.RoleSimpleVO;
|
||||
import com.nflg.wms.common.pojo.vo.UserSupplierItemVO;
|
||||
import com.nflg.wms.common.pojo.vo.UserSupplierVO;
|
||||
import com.nflg.wms.repository.entity.DictionaryItem;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
|
|
@ -34,7 +35,7 @@ public class SupplierController extends BaseController {
|
|||
* 获取供应商类别列表
|
||||
*/
|
||||
@GetMapping("/getTypeList")
|
||||
public ApiResult<List<DictionaryItem>> getTypeList(){
|
||||
public ApiResult<List<DictionaryItem>> getTypeList() {
|
||||
return ApiResult.success(userControllerService.getTypeList());
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +78,7 @@ public class SupplierController extends BaseController {
|
|||
*/
|
||||
@PostMapping("enable")
|
||||
public ApiResult<Void> enable(@Valid @RequestBody EnableQO request) {
|
||||
userControllerService.enable(request);
|
||||
userControllerService.enableSupplier(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -86,8 +87,8 @@ public class SupplierController extends BaseController {
|
|||
* @param request 请求参数
|
||||
*/
|
||||
@PostMapping("authorizeRole")
|
||||
public ApiResult<Void> authorizeRole(@Valid @RequestBody AuthorizeRoleQO request) {
|
||||
userControllerService.authorizeRole(request);
|
||||
public ApiResult<Void> authorizeRole(@Valid @RequestBody AuthorizeRolesQO request) {
|
||||
userControllerService.authorizeRoles(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -100,14 +101,14 @@ public class SupplierController extends BaseController {
|
|||
return ApiResult.success(userControllerService.getAuthorizeRole(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 开通账号
|
||||
*/
|
||||
@PostMapping("enableLogin")
|
||||
public ApiResult<Void> enableLogin(@Valid @RequestBody SupplierLoginQO request) {
|
||||
userControllerService.enableSupplierLogin(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
// /**
|
||||
// * 开通账号
|
||||
// */
|
||||
// @PostMapping("enableLogin")
|
||||
// public ApiResult<Void> enableLogin(@Valid @RequestBody SupplierLoginQO request) {
|
||||
// userControllerService.enableSupplierLogin(request);
|
||||
// return ApiResult.success();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 批量开通账号
|
||||
|
|
@ -127,6 +128,15 @@ public class SupplierController extends BaseController {
|
|||
return ApiResult.success(userControllerService.searchSupplier(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索供应商的详情信息
|
||||
* @param id 供应商ID
|
||||
*/
|
||||
@GetMapping("item")
|
||||
public ApiResult<UserSupplierItemVO> getItem(@Valid @RequestParam Long id) {
|
||||
return ApiResult.success(userControllerService.getSupplierItem(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入供应商
|
||||
* @param file 文件
|
||||
|
|
@ -134,7 +144,7 @@ public class SupplierController extends BaseController {
|
|||
@Transactional
|
||||
@PostMapping("import")
|
||||
public ApiResult importFromExcel(HttpServletResponse response, @RequestParam(value = "file") MultipartFile file) throws IOException {
|
||||
return userControllerService.importSupplier(response,file);
|
||||
return userControllerService.importSupplier(response, file);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -142,7 +152,7 @@ public class SupplierController extends BaseController {
|
|||
* @param ids 选中的id集合
|
||||
*/
|
||||
@PostMapping("export")
|
||||
public void exportSelect(HttpServletResponse response,@RequestBody(required = false) List<Long> ids) throws Exception {
|
||||
userControllerService.exportSupplier(response,ids);
|
||||
public void exportSelect(HttpServletResponse response, @RequestBody(required = false) List<Long> ids) throws Exception {
|
||||
userControllerService.exportSupplier(response, ids);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.nflg.wms.common.pojo.dto.SupplierExcelExportDTO;
|
|||
import com.nflg.wms.common.pojo.dto.UserDTO;
|
||||
import com.nflg.wms.common.pojo.qo.*;
|
||||
import com.nflg.wms.common.pojo.vo.RoleSimpleVO;
|
||||
import com.nflg.wms.common.pojo.vo.UserSupplierItemVO;
|
||||
import com.nflg.wms.common.pojo.vo.UserSupplierVO;
|
||||
import com.nflg.wms.common.pojo.vo.UserVO;
|
||||
import com.nflg.wms.common.util.*;
|
||||
|
|
@ -36,6 +37,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.ttzero.excel.entity.ListSheet;
|
||||
import org.ttzero.excel.entity.Workbook;
|
||||
|
|
@ -306,105 +308,195 @@ public class UserControllerService {
|
|||
return request.getNewPassword();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public String addSupplier(@Valid SupplierAddQO request) {
|
||||
if (StrUtil.isNotBlank(request.getLoginName())) {
|
||||
VUtil.trueThrowBusinessError(uService.lambdaQuery().eq(User::getUserCode, request.getLoginName()).exists())
|
||||
.throwMessage("登录账号已存在");
|
||||
}
|
||||
VUtil.trueThrowBusinessError(userSupplierService.lambdaQuery().eq(UserSupplier::getSupplierCode, request.getCode()).exists())
|
||||
.throwMessage("供应商编码已存在");
|
||||
private Long addUser(String uName, String uPhone, Integer enable, String avatar,
|
||||
String remark, String loginName, String pwd, Boolean mustResetPwd, List<Long> roleIds) {
|
||||
Long useId = 0L;
|
||||
User user = new User()
|
||||
.setUserName(request.getUserName())
|
||||
.setPhone(request.getPhone())
|
||||
.setState(request.getEnable() ? 1 : 2)
|
||||
.setAvatar(request.getAvatar())
|
||||
.setRemark(request.getRemark())
|
||||
.setUserName(uName)
|
||||
.setPhone(uPhone)
|
||||
.setState(enable)
|
||||
.setAvatar(avatar)
|
||||
.setRemark(remark)
|
||||
.setUserCode(loginName)
|
||||
.setPassword(PASSWORDENCODER.encode(pwd))
|
||||
.setCreateBy(UserUtil.getUserName())
|
||||
.setMustResetPwd(mustResetPwd)
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
String pwd = null;
|
||||
if (StrUtil.isNotBlank(request.getLoginName())) {
|
||||
pwd = RandomUtil.randomString(6);
|
||||
user.setUserCode(request.getLoginName());
|
||||
user.setPassword(PASSWORDENCODER.encode(pwd));
|
||||
}
|
||||
uService.add(user);
|
||||
userSupplierService.add(new UserSupplier()
|
||||
.setUserId(user.getId())
|
||||
.setSupplierCode(request.getCode())
|
||||
.setSupplierName(request.getName())
|
||||
.setAbbreviation(request.getAbbreviation())
|
||||
.setAbbreviation1(request.getAbbreviation1())
|
||||
.setAbbreviation2(request.getAbbreviation2())
|
||||
.setTypeId(request.getTypeId()));
|
||||
if (CollectionUtil.isNotEmpty(request.getRoleIds())) {
|
||||
userRoleMapService.saveBatch(request.getRoleIds().stream().map(roleId -> new UserRoleMap()
|
||||
useId = user.getId();
|
||||
//保存用户角色
|
||||
if (CollectionUtil.isNotEmpty(roleIds)) {
|
||||
userRoleMapService.saveBatch(roleIds.stream().map(roleId -> new UserRoleMap()
|
||||
.setUserId(user.getId())
|
||||
.setRoleId(roleId))
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
return useId;
|
||||
}
|
||||
|
||||
|
||||
private void enableUser(Long userId, Integer state) {
|
||||
uService.lambdaUpdate().eq(User::getId, userId)
|
||||
.set(User::getState, state)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public String addSupplier(@Valid SupplierAddQO request) {
|
||||
// 验证供应商是否存在
|
||||
VUtil.trueThrowBusinessError(userSupplierService.lambdaQuery().eq(UserSupplier::getSupplierCode, request.getSupplierCode()).exists())
|
||||
.throwMessage("供应商编码已存在");
|
||||
String pwd = "";
|
||||
Long useId = 0L;
|
||||
//判断是否开通了账户
|
||||
if (request.getIsOpenAccount()) // 开通账户
|
||||
{
|
||||
VUtil.trueThrowBusinessError(uService.lambdaQuery().eq(User::getUserCode, request.getSupplierCode()).exists())
|
||||
.throwMessage("登录账号已存在");
|
||||
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(request.getRoleIds()))
|
||||
.throwMessage("必须设置供应商的权限");
|
||||
|
||||
pwd = RandomUtil.randomString(6);
|
||||
useId = addUser(request.getSupplierName(), request.getPciPhone(), request.getEnable() ? 1 : 2,
|
||||
request.getAvatar(), request.getRemark(), request.getSupplierCode(), pwd, request.getEnableMustResetPwd(),
|
||||
request.getRoleIds());
|
||||
}
|
||||
userSupplierService.add(new UserSupplier()
|
||||
.setUserId(useId)
|
||||
.setSupplierCode(request.getSupplierCode())
|
||||
.setSupplierName(request.getSupplierName())
|
||||
.setAbbreviation(request.getAbbreviation())
|
||||
.setAbbreviation1(request.getAbbreviation1())
|
||||
.setAbbreviation2(request.getAbbreviation2())
|
||||
.setPciName(request.getPciName())
|
||||
.setPciPhone(request.getPciPhone())
|
||||
.setState(request.getEnable() ? 1 : 2)
|
||||
.setIsOpenAccount(request.getIsOpenAccount())
|
||||
.setDefaultLanguage(request.getDefaultLanguage())
|
||||
.setAvatar(request.getAvatar())
|
||||
.setRemark(request.getRemark())
|
||||
.setCreateBy(UserUtil.getUserName())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setTypeId(request.getTypeId()));
|
||||
return pwd;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public String updateSupplier(@Valid SupplierUpdateQO request) {
|
||||
VUtil.trueThrowBusinessError(userSupplierService.lambdaQuery()
|
||||
.eq(UserSupplier::getSupplierCode, request.getSupplierCode())
|
||||
.ne(UserSupplier::getId, request.getId())
|
||||
.exists())
|
||||
.throwMessage("供应商编码已存在");
|
||||
//首先判断是否是已经开通过
|
||||
UserSupplier userSupplier = userSupplierService.getById(request.getId());
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(userSupplier) || StrUtil.isBlank(userSupplier.getSupplierCode()))
|
||||
.throwMessage("供应商不存在");
|
||||
String pwd = "";
|
||||
Long useId = 0L;
|
||||
useId = userSupplier.getUserId();
|
||||
//判断是否开通了账户
|
||||
if (request.getIsOpenAccount()) // 开通账户
|
||||
{
|
||||
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(request.getRoleIds()))
|
||||
.throwMessage("必须设置供应商的权限");
|
||||
//判断之前是否开通过账户
|
||||
if (useId.equals(0L)) //未开通过
|
||||
{
|
||||
VUtil.trueThrowBusinessError(uService.lambdaQuery()
|
||||
.eq(User::getUserCode, request.getSupplierCode())
|
||||
.exists())
|
||||
.throwMessage("登录账号已存在");
|
||||
pwd = RandomUtil.randomString(6);
|
||||
useId = addUser(request.getSupplierName(), request.getPciPhone(), request.getEnable() ? 1 : 2,
|
||||
request.getAvatar(), request.getRemark(), request.getSupplierCode(), pwd, request.getEnableMustResetPwd(),
|
||||
request.getRoleIds());
|
||||
} else {
|
||||
// 删除之前的角色信息
|
||||
userRoleMapService.remove(new LambdaQueryWrapper<UserRoleMap>().eq(UserRoleMap::getUserId, userSupplier.getUserId()));
|
||||
//保存用户角色
|
||||
userRoleMapService.saveBatch(request.getRoleIds().stream().map(roleId -> new UserRoleMap()
|
||||
.setUserId(userSupplier.getUserId())
|
||||
.setRoleId(roleId))
|
||||
.collect(Collectors.toSet()));
|
||||
//修改下用户的信息
|
||||
uService.lambdaUpdate().eq(User::getId, request.getId())
|
||||
.set(User::getState, 1)
|
||||
.set(User::getUserName, request.getSupplierName())
|
||||
.set(User::getPhone, request.getPciPhone())
|
||||
.set(User::getLanguageCode, request.getDefaultLanguage())
|
||||
.set(User::getAvatar, request.getAvatar())
|
||||
.set(User::getRemark, request.getRemark())
|
||||
.update();
|
||||
}
|
||||
} else {
|
||||
//判断之前是否是开通过账号的
|
||||
if (!useId.equals(0L)) //开通过
|
||||
{
|
||||
//将账户状态修改为启用状态
|
||||
enableUser(request.getId(), 2);
|
||||
// 删除角色信息
|
||||
userRoleMapService.remove(new LambdaQueryWrapper<UserRoleMap>().eq(UserRoleMap::getUserId, userSupplier.getUserId()));
|
||||
}
|
||||
}
|
||||
userSupplierService.lambdaUpdate()
|
||||
.eq(UserSupplier::getId, request.getId())
|
||||
.set(UserSupplier::getIsOpenAccount, request.getIsOpenAccount())
|
||||
.set(UserSupplier::getDefaultLanguage, request.getDefaultLanguage())
|
||||
.set(UserSupplier::getAvatar, request.getAvatar())
|
||||
.set(UserSupplier::getRemark, request.getRemark())
|
||||
.set(UserSupplier::getUpdateBy, UserUtil.getUserName())
|
||||
.set(UserSupplier::getUpdateTime, LocalDateTime.now())
|
||||
.set(UserSupplier::getTypeId, request.getTypeId())
|
||||
.set(UserSupplier::getSupplierCode, request.getSupplierCode())
|
||||
.set(UserSupplier::getState, request.getEnable() ? 1 : 2)
|
||||
.set(UserSupplier::getPciPhone, request.getPciPhone())
|
||||
.set(UserSupplier::getPciName, request.getPciName())
|
||||
.set(UserSupplier::getAbbreviation2, request.getAbbreviation2())
|
||||
.set(UserSupplier::getAbbreviation1, request.getAbbreviation1())
|
||||
.set(UserSupplier::getAbbreviation, request.getAbbreviation())
|
||||
.set(UserSupplier::getSupplierName, request.getSupplierName())
|
||||
.set(UserSupplier::getUserId, useId)
|
||||
.update();
|
||||
|
||||
return pwd;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public String updateSupplier(@Valid SupplierUpdateQO request) {
|
||||
if (StrUtil.isNotBlank(request.getLoginName())) {
|
||||
VUtil.trueThrowBusinessError(uService.lambdaQuery()
|
||||
.eq(User::getUserCode, request.getLoginName())
|
||||
.ne(User::getId, request.getId())
|
||||
.exists())
|
||||
.throwMessage("登录账号已存在");
|
||||
public void enableSupplier(@Valid @RequestBody EnableQO request) {
|
||||
UserSupplier userSupplier = userSupplierService.getById(request.getId());
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(userSupplier) || StrUtil.isBlank(userSupplier.getSupplierCode()))
|
||||
.throwMessage("供应商不存在");
|
||||
if (request.getEnable()) {
|
||||
if (userSupplier.getIsOpenAccount()) {
|
||||
enableUser(request.getId(), 2);
|
||||
}
|
||||
} else {
|
||||
enableUser(request.getId(), 1);
|
||||
}
|
||||
VUtil.trueThrowBusinessError(userSupplierService.lambdaQuery()
|
||||
.eq(UserSupplier::getSupplierCode, request.getCode())
|
||||
.ne(UserSupplier::getUserId, request.getId())
|
||||
.exists())
|
||||
.throwMessage("供应商编码已存在");
|
||||
User user=new User()
|
||||
.setId(request.getId())
|
||||
.setUserName(request.getUserName())
|
||||
.setPhone(request.getPhone())
|
||||
.setState(request.getEnable() ? 1 : 2)
|
||||
.setAvatar(request.getAvatar())
|
||||
.setRemark(request.getRemark())
|
||||
.setUpdateBy(UserUtil.getUserName())
|
||||
.setUpdateTime(LocalDateTime.now());
|
||||
String pwd = null;
|
||||
if (StrUtil.isNotBlank(request.getLoginName())) {
|
||||
pwd = RandomUtil.randomString(6);
|
||||
user.setUserCode(request.getLoginName());
|
||||
user.setPassword(PASSWORDENCODER.encode(pwd));
|
||||
}
|
||||
uService.update(user);
|
||||
userSupplierService.update(new UserSupplier()
|
||||
.setUserId(request.getId())
|
||||
.setSupplierCode(request.getCode())
|
||||
.setSupplierName(request.getName())
|
||||
.setAbbreviation(request.getAbbreviation())
|
||||
.setAbbreviation1(request.getAbbreviation1())
|
||||
.setAbbreviation2(request.getAbbreviation2())
|
||||
.setTypeId(request.getTypeId()));
|
||||
userRoleMapService.remove(new LambdaQueryWrapper<UserRoleMap>().eq(UserRoleMap::getUserId, request.getId()));
|
||||
if (CollectionUtil.isNotEmpty(request.getRoleIds())) {
|
||||
userRoleMapService.saveBatch(request.getRoleIds().stream().map(roleId -> new UserRoleMap()
|
||||
.setUserId(request.getId())
|
||||
.setRoleId(roleId))
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
return pwd;
|
||||
userSupplierService.lambdaUpdate().set(UserSupplier::getState, request.getEnable() ? 1 : 2)
|
||||
.set(UserSupplier::getUpdateBy, UserUtil.getUserName())
|
||||
.set(UserSupplier::getUpdateTime, LocalDateTime.now())
|
||||
.eq(UserSupplier::getId, request.getId())
|
||||
.update();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteSupplier(@Valid @NotNull Long id) {
|
||||
uService.delete(id);
|
||||
UserSupplier userSupplier = userSupplierService.getById(id);
|
||||
if (!userSupplier.getUserId().equals(0L)) {
|
||||
userRoleMapService.deleteByUser(id);
|
||||
uService.delete(id);
|
||||
StpUtil.logout(id);
|
||||
}
|
||||
userSupplierService.remove(new LambdaQueryWrapper<UserSupplier>().eq(UserSupplier::getUserId, id));
|
||||
userRoleMapService.deleteByUser(id);
|
||||
StpUtil.logout(id);
|
||||
}
|
||||
|
||||
public IPage<UserSupplierVO> searchSupplier(@Valid UserSupplierSearchQO request) {
|
||||
IPage<UserSupplierVO> pu = userSupplierService.search(request);
|
||||
pu.getRecords().forEach(userVO -> userVO.setRoleIds(userRoleMapService.getAuthorizeRole(userVO.getId())));
|
||||
// pu.getRecords().forEach(userVO -> userVO.setRoleIds(userRoleMapService.getAuthorizeRole(userVO.getId())));
|
||||
return pu;
|
||||
}
|
||||
|
||||
|
|
@ -434,56 +526,43 @@ public class UserControllerService {
|
|||
} else {
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode(getResultName(file.getOriginalFilename()), StandardCharsets.UTF_8));
|
||||
try(ByteArrayOutputStream osOut = new ByteArrayOutputStream()) {
|
||||
try (ByteArrayOutputStream osOut = new ByteArrayOutputStream()) {
|
||||
new Workbook()
|
||||
.addSheet(new ListSheet<>(data))
|
||||
.writeTo(osOut);
|
||||
try (ByteArrayInputStream isIn = new ByteArrayInputStream(osOut.toByteArray())) {
|
||||
return ApiResult.error(STATE.DataNoCheckPass, "导入文件失败", fileUploadService.upload("temp/" + DateTimeUtil.format(LocalDate.now(), "yyyyMMdd") + "/" + IdUtil.fastUUID() + ".xlsx", isIn));
|
||||
try(ByteArrayInputStream isIn = new ByteArrayInputStream(osOut.toByteArray())) {
|
||||
return ApiResult.error(STATE.DataNoCheckPass, "导入文件失败", fileUploadService.upload("temp/" + DateTimeUtil.format(LocalDate.now(), "yyyyMMdd") + "/" + IdUtil.fastUUID() + ".xlsx", isIn, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
return ApiResult.error(STATE.BusinessError, "保存文件出错");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getResultName(String name){
|
||||
int index=name.lastIndexOf(".");
|
||||
return name.substring(0,index)+"_结果"+"."+name.substring(index+1);
|
||||
private String getResultName(String name) {
|
||||
int index = name.lastIndexOf(".");
|
||||
return name.substring(0, index) + "_结果" + "." + name.substring(index + 1);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public boolean updateCheckAndImport(List<SupplierExcelDTO> data) {
|
||||
List<DictionaryItem> suppliersCategory = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_SUPPLIERS_CATEGORY);
|
||||
List<User> users = new ArrayList<>();
|
||||
List<UserSupplier> userSuppliers = new ArrayList<>();
|
||||
for (SupplierExcelDTO dto : data) {
|
||||
User user = new User();
|
||||
UserSupplier userSupplier = new UserSupplier();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (Objects.isNull(dto.getSupplierCode())) {
|
||||
sb.append("供应商编号不能为空;");
|
||||
}else if(data.stream().filter(item->StrUtil.equals(item.getSupplierCode(),dto.getSupplierCode())).count()>1){
|
||||
} else if (data.stream().filter(item -> StrUtil.equals(item.getSupplierCode(), dto.getSupplierCode())).count() > 1) {
|
||||
sb.append("供应商编号重复;");
|
||||
} else {
|
||||
userSupplier = userSupplierService.lambdaQuery().eq(UserSupplier::getSupplierCode, dto.getSupplierCode()).one();
|
||||
if (Objects.isNull(userSupplier)) {
|
||||
userSupplier = new UserSupplier();
|
||||
user = new User();
|
||||
user.setId(IdUtil.getSnowflakeNextId());
|
||||
user.setCreateBy(UserUtil.getUserName());
|
||||
user.setCreateTime(LocalDateTime.now());
|
||||
userSupplier.setUserId(user.getId());
|
||||
userSupplier.setSupplierCode(dto.getSupplierCode());
|
||||
} else {
|
||||
user = uService.getById(userSupplier.getUserId());
|
||||
user.setUpdateBy(UserUtil.getUserName());
|
||||
user.setUpdateTime(LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isBlank(dto.getSupplierName())) {
|
||||
sb.append("供应商名称不能为空;");
|
||||
}else {
|
||||
} else {
|
||||
userSupplier.setSupplierName(dto.getSupplierName());
|
||||
}
|
||||
if (StrUtil.isBlank(dto.getTypeName())) {
|
||||
|
|
@ -496,27 +575,25 @@ public class UserControllerService {
|
|||
userSupplier.setTypeId(type.getId());
|
||||
}
|
||||
}
|
||||
userSupplier.setUserId(0L);
|
||||
userSupplier.setAbbreviation(dto.getAbbreviation());
|
||||
userSupplier.setAbbreviation1(StringUtil.toPinYin(dto.getAbbreviation()));
|
||||
userSupplier.setAbbreviation2(StringUtil.getPinYinFirstLetter(dto.getAbbreviation()));
|
||||
user.setUserName(dto.getUserName());
|
||||
user.setPhone(dto.getPhone());
|
||||
user.setRemark(dto.getRemark());
|
||||
if (StrUtil.isNotBlank(dto.getUserCode())) {
|
||||
if (uService.lambdaQuery().eq(User::getUserCode, dto.getUserCode())
|
||||
.ne(Objects.nonNull(user.getId()), User::getId, user.getId())
|
||||
.exists()) {
|
||||
sb.append("登录账号已存在;");
|
||||
} else {
|
||||
user.setUserCode(dto.getUserCode());
|
||||
}
|
||||
}
|
||||
userSupplier.setPciName(dto.getUserName());
|
||||
userSupplier.setPciPhone(dto.getPhone());
|
||||
userSupplier.setDefaultLanguage("");
|
||||
userSupplier.setAvatar("");
|
||||
userSupplier.setState(1);
|
||||
userSupplier.setIsOpenAccount(false);
|
||||
userSupplier.setRemark(dto.getRemark());
|
||||
userSupplier.setCreateBy(UserUtil.getUserName());
|
||||
userSupplier.setCreateTime(LocalDateTime.now());
|
||||
userSupplier.setUpdateBy(UserUtil.getUserName());
|
||||
userSupplier.setUpdateTime(LocalDateTime.now());
|
||||
dto.setResult(sb.toString());
|
||||
users.add(user);
|
||||
userSuppliers.add(userSupplier);
|
||||
}
|
||||
if (data.stream().noneMatch(it -> StrUtil.isNotBlank(it.getResult()))) {
|
||||
uService.saveOrUpdateBatch(users);
|
||||
userSupplierService.saveOrUpdateBatch(userSuppliers);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -524,7 +601,7 @@ public class UserControllerService {
|
|||
}
|
||||
|
||||
public void exportSupplier(HttpServletResponse response, List<Long> ids) throws IOException {
|
||||
List<VUserSupplier> users = CollectionUtil.isNotEmpty(ids)?vUserSupplierService.listByIds(ids):new ArrayList<>();
|
||||
List<VUserSupplier> users = CollectionUtil.isNotEmpty(ids) ? vUserSupplierService.listByIds(ids) : new ArrayList<>();
|
||||
List<DictionaryItem> suppliersCategory = dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_SUPPLIERS_CATEGORY);
|
||||
List<SupplierExcelExportDTO> datas = users.stream().map(vu -> {
|
||||
SupplierExcelExportDTO dto = new SupplierExcelExportDTO();
|
||||
|
|
@ -541,11 +618,11 @@ public class UserControllerService {
|
|||
}).collect(Collectors.toList());
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("供应商导出.xlsx", StandardCharsets.UTF_8));
|
||||
if (CollectionUtil.isEmpty(datas)){
|
||||
if (CollectionUtil.isEmpty(datas)) {
|
||||
datas.add(new SupplierExcelExportDTO()
|
||||
.setSupplierCode("(必填)供应商编号")
|
||||
.setSupplierName("(必填)供应商名称")
|
||||
.setTypeName("(必填)供应商类别")
|
||||
.setSupplierCode("供应商编号")
|
||||
.setSupplierName("供应商名称")
|
||||
.setTypeName("供应商类别")
|
||||
.setUserName("负责人姓名")
|
||||
.setUserCode("登录账号,不填则不开通账号")
|
||||
.setPhone("负责人电话")
|
||||
|
|
@ -562,28 +639,91 @@ public class UserControllerService {
|
|||
}
|
||||
|
||||
public UserDTO getUserInfo() {
|
||||
VUser vUser=vUserService.getById(UserUtil.getUserId());
|
||||
return Convert.convert(UserDTO.class,vUser);
|
||||
VUser vUser = vUserService.getById(UserUtil.getUserId());
|
||||
return Convert.convert(UserDTO.class, vUser);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void enableSupplierLoginBatch(@Valid SupplierLoginBatchQO request) {
|
||||
if (StrUtil.isBlank(request.getPassword())) {
|
||||
request.setPassword(RandomUtil.randomString(6));
|
||||
}
|
||||
request.setPassword(PASSWORDENCODER.encode(request.getPassword()));
|
||||
for (Long id : request.getIds()) {
|
||||
UserSupplier userSupplier = userSupplierService.getByUserId(id);
|
||||
User user = uService.getById(id);
|
||||
if (Objects.nonNull(userSupplier) && Objects.nonNull(user)) {
|
||||
user.setUserCode(userSupplier.getSupplierCode());
|
||||
user.setPassword(request.getPassword());
|
||||
user.setMustResetPwd(user.getEnableMustResetPwd());
|
||||
user.setUpdateBy(UserUtil.getUserName());
|
||||
user.setUpdateTime(LocalDateTime.now());
|
||||
uService.updateById(user);
|
||||
userRoleMapService.authorize(id, request.getRoleIds());
|
||||
// 判断存在是否已开通的账号
|
||||
List<UserSupplier> userSuppliers = userSupplierService.lambdaQuery()
|
||||
.in(UserSupplier::getId, request.getIds())
|
||||
.list();
|
||||
|
||||
Long iCount = userSuppliers.stream().filter(it -> it.getIsOpenAccount().equals(true)).count();
|
||||
VUtil.trueThrowBusinessError(iCount > 0)
|
||||
.throwMessage("存在已开通的供应商");
|
||||
|
||||
Long iCount1 = userSuppliers.stream().filter(it -> it.getState().equals(2)).count();
|
||||
VUtil.trueThrowBusinessError(iCount1 > 0)
|
||||
.throwMessage("存在已被禁用的供应商");
|
||||
|
||||
List<Long> userIds = userSuppliers.stream()
|
||||
.filter(it -> it.getUserId() > 0)
|
||||
.map(UserSupplier::getUserId)
|
||||
.toList();
|
||||
//找到已经开通过的账号,修改密码
|
||||
if (CollectionUtil.isNotEmpty(userIds)) {
|
||||
for (Long userId : userIds) {
|
||||
UserSupplier userSupplier = userSuppliers.stream()
|
||||
.filter(it -> it.getUserId().equals(userId))
|
||||
.findFirst().orElse(null);
|
||||
if (Objects.isNull(userSupplier)) {
|
||||
continue;
|
||||
}
|
||||
uService.lambdaUpdate().eq(User::getId, userSupplier.getId())
|
||||
.set(User::getState, 1)
|
||||
.set(User::getUserName, userSupplier.getSupplierName())
|
||||
.set(User::getPhone, userSupplier.getPciPhone())
|
||||
.set(User::getLanguageCode, userSupplier.getDefaultLanguage())
|
||||
.set(User::getAvatar, userSupplier.getAvatar())
|
||||
.set(User::getRemark, userSupplier.getRemark())
|
||||
.update();
|
||||
|
||||
userSupplierService.lambdaUpdate()
|
||||
.set(UserSupplier::getIsOpenAccount, true)
|
||||
.eq(UserSupplier::getId, userSupplier.getId())
|
||||
.update();
|
||||
}
|
||||
userRoleMapService.authorizes(userIds, request.getRoleIds());
|
||||
}
|
||||
|
||||
List<Long> ids = userSuppliers.stream()
|
||||
.filter(it -> it.getUserId().equals(0L))
|
||||
.map(UserSupplier::getId)
|
||||
.toList();
|
||||
|
||||
for (Long id : ids) {
|
||||
UserSupplier userSupplier = userSuppliers.stream().filter(it ->
|
||||
it.getId().equals(id)).findFirst().orElse(null);
|
||||
if (Objects.isNull(userSupplier)) {
|
||||
continue;
|
||||
}
|
||||
Long userId = addUser(userSupplier.getSupplierName(), userSupplier.getPciPhone(), userSupplier.getState(),
|
||||
userSupplier.getAvatar(), userSupplier.getRemark(), userSupplier.getSupplierCode(), request.getPassword(),
|
||||
true,
|
||||
request.getRoleIds());
|
||||
|
||||
userSupplierService.lambdaUpdate()
|
||||
.set(UserSupplier::getUserId, userId)
|
||||
.set(UserSupplier::getIsOpenAccount, true)
|
||||
.eq(UserSupplier::getId, userSupplier.getId())
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
public void authorizeRoles(@Valid AuthorizeRolesQO request) {
|
||||
userRoleMapService.authorizes(request.getUserId(), request.getRoleIds());
|
||||
}
|
||||
|
||||
public UserSupplierItemVO getSupplierItem(@Valid Long id) {
|
||||
UserSupplierItemVO vo = new UserSupplierItemVO();
|
||||
vo.setSupplierItem(Convert.convert(UserSupplierVO.class, userSupplierService.getById(id)));
|
||||
List<RoleSimpleVO> roleSimpleV = userRoleMapService.getAuthorizeRole(vo.getSupplierItem().getUserId());
|
||||
if (CollectionUtil.isNotEmpty(roleSimpleV)) {
|
||||
List<Long> ids = roleSimpleV.stream().map(RoleSimpleVO::getId).toList();
|
||||
vo.setRoleIds(ids);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,12 @@ public class SupplierExcelDTO {
|
|||
*/
|
||||
@ExcelColumn("*供应商类别")
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 登录账号
|
||||
*/
|
||||
@ExcelColumn("登录账号")
|
||||
private String userCode;
|
||||
//
|
||||
// /**
|
||||
// * 登录账号
|
||||
// */
|
||||
// @ExcelColumn("登录账号")
|
||||
// private String userCode;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AuthorizeRolesQO {
|
||||
|
||||
//用户id
|
||||
@NotNull
|
||||
private List<Long> userId;
|
||||
|
||||
//角色id列表
|
||||
private List<Long> roleIds;
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BarcodeLessReceivingQO {
|
||||
/**
|
||||
* 送货单项目ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 本次收货数量
|
||||
*/
|
||||
private BigDecimal receiptQty;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batchNumber;
|
||||
|
||||
/**
|
||||
* 序列号
|
||||
*/
|
||||
private String serialNumbers;
|
||||
|
||||
|
||||
/**
|
||||
* 库存地点
|
||||
*/
|
||||
private String receivedWarehouse;
|
||||
|
||||
|
||||
/**
|
||||
* 是否质检
|
||||
*/
|
||||
private Boolean isQuality;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BarcodeLessReceivingSearchQO {
|
||||
/**
|
||||
* 送货单Id
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
|
|
@ -13,13 +13,13 @@ public class SupplierAddQO {
|
|||
* 编码
|
||||
*/
|
||||
@NotBlank
|
||||
private String code;
|
||||
private String supplierCode;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@NotBlank
|
||||
private String name;
|
||||
private String supplierName;
|
||||
|
||||
/**
|
||||
* 供应商简称
|
||||
|
|
@ -39,12 +39,12 @@ public class SupplierAddQO {
|
|||
/**
|
||||
* 负责人姓名
|
||||
*/
|
||||
private String userName;
|
||||
private String pciName;
|
||||
|
||||
/**
|
||||
* 负责人电话
|
||||
*/
|
||||
private String phone;
|
||||
private String pciPhone;
|
||||
|
||||
/**
|
||||
* 供应商类别
|
||||
|
|
@ -68,21 +68,23 @@ public class SupplierAddQO {
|
|||
@NotNull
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 登录账号
|
||||
*/
|
||||
private String loginName;
|
||||
|
||||
/**
|
||||
* 角色ID列表
|
||||
*/
|
||||
private List<Long> roleIds;
|
||||
|
||||
/**
|
||||
* 是否开通账号
|
||||
*/
|
||||
@NotNull
|
||||
private Boolean isOpenAccount;
|
||||
|
||||
/**
|
||||
* 默认语言
|
||||
*/
|
||||
@NotBlank
|
||||
private String languageCode;
|
||||
private String defaultLanguage;
|
||||
|
||||
/**
|
||||
* 初始化密码后是否强制要求登录后重设密码
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BarcodeLessReceivingVO {
|
||||
|
||||
/**
|
||||
* 项ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 送货单ID
|
||||
*/
|
||||
private String orderId;
|
||||
/**
|
||||
* 采购订单号
|
||||
*/
|
||||
private String poNum;
|
||||
|
||||
/**
|
||||
* 采购订单行号
|
||||
*/
|
||||
private String poLineNumber;
|
||||
|
||||
/**
|
||||
* 送货单行号
|
||||
*/
|
||||
private String lineNumber;
|
||||
|
||||
/**
|
||||
* 送货单号
|
||||
*/
|
||||
private String noteNum;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
private String itemCode;
|
||||
|
||||
/**
|
||||
* 物料描述
|
||||
*/
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String uomCode;
|
||||
/**
|
||||
* 未收货数量
|
||||
*/
|
||||
private BigDecimal unRecieveQty;
|
||||
|
||||
/**
|
||||
* 送货数量
|
||||
*/
|
||||
private BigDecimal deliveryQty;
|
||||
|
||||
/**
|
||||
* 本次收货数量
|
||||
*/
|
||||
private BigDecimal receiptQty;
|
||||
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
private String batchNumber;
|
||||
|
||||
/**
|
||||
* 序列号
|
||||
*/
|
||||
private String serialNumbers;
|
||||
|
||||
/**
|
||||
* 工厂
|
||||
*/
|
||||
private String iuCode;
|
||||
|
||||
/**
|
||||
* 库存地点
|
||||
*/
|
||||
private String receivedWarehouse;
|
||||
|
||||
/**
|
||||
* 制造商
|
||||
*/
|
||||
private String supplierNum;
|
||||
|
||||
|
||||
/**
|
||||
* 是否质检
|
||||
*/
|
||||
private Boolean isQuality;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -3,10 +3,12 @@ package com.nflg.wms.common.pojo.vo;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SRMOrderItemVO {
|
||||
|
||||
private Long id;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Data
|
||||
@Accessors
|
||||
public class UserSupplierItemVO {
|
||||
//所属角色
|
||||
private Collection<Long> roleIds;
|
||||
|
||||
private UserSupplierVO supplierItem;
|
||||
|
||||
// private Collection<Long> roleIds;
|
||||
}
|
||||
|
|
@ -7,13 +7,12 @@ import java.util.Collection;
|
|||
|
||||
@Data
|
||||
public class UserSupplierVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
* 用户id
|
||||
*/
|
||||
private String avatar;
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 供应商编号
|
||||
|
|
@ -35,45 +34,50 @@ public class UserSupplierVO {
|
|||
*/
|
||||
private String abbreviation1;
|
||||
|
||||
/**
|
||||
* 供应商类别,字典项id
|
||||
*/
|
||||
private Long typeId;
|
||||
|
||||
/**
|
||||
* 简称全拼
|
||||
*/
|
||||
private String abbreviation2;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
* 是否开通账号
|
||||
*/
|
||||
private String userName;
|
||||
private Boolean isOpenAccount;
|
||||
|
||||
/**
|
||||
* 用户密码,BCrypt
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 邮箱地址
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 状态,1-启用,2:禁用
|
||||
* 代理商状态 1 启用 2 禁用
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 供应商类别id
|
||||
* 负责人姓名
|
||||
*/
|
||||
private Long typeId;
|
||||
private String pciName;
|
||||
|
||||
/**
|
||||
* 供应商类别名称
|
||||
* 负责人电话
|
||||
*/
|
||||
private String typeName;
|
||||
private String pciPhone;
|
||||
|
||||
/**
|
||||
* 默认语言
|
||||
*/
|
||||
private String defaultLanguage;
|
||||
|
||||
/**
|
||||
* 默认头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
|
|
@ -95,26 +99,4 @@ public class UserSupplierVO {
|
|||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 用户工号
|
||||
*/
|
||||
private String userCode;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 默认语言
|
||||
*/
|
||||
private String languageCode;
|
||||
|
||||
/**
|
||||
* 初始化密码后是否强制要求登录后重设密码
|
||||
*/
|
||||
private Boolean enableMustResetPwd;
|
||||
|
||||
//所属角色
|
||||
private Collection<RoleSimpleVO> roleIds;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@ import lombok.ToString;
|
|||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* 供应商
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
|
|
@ -55,13 +56,70 @@ public class UserSupplier implements Serializable {
|
|||
*/
|
||||
private String abbreviation1;
|
||||
|
||||
/**
|
||||
* 供应商类别,字典项id
|
||||
*/
|
||||
private Long typeId;
|
||||
|
||||
/**
|
||||
* 简称全拼
|
||||
*/
|
||||
private String abbreviation2;
|
||||
|
||||
/**
|
||||
* 供应商类别
|
||||
* 是否开通账号
|
||||
*/
|
||||
private Long typeId;
|
||||
private Boolean isOpenAccount;
|
||||
|
||||
/**
|
||||
* 代理商状态 1 启用 2 禁用
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 负责人姓名
|
||||
*/
|
||||
private String pciName;
|
||||
|
||||
/**
|
||||
* 负责人电话
|
||||
*/
|
||||
private String pciPhone;
|
||||
|
||||
/**
|
||||
* 默认语言
|
||||
*/
|
||||
private String defaultLanguage;
|
||||
|
||||
/**
|
||||
* 默认头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 最后更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,4 +32,6 @@ public interface IUserRoleMapService extends IService<UserRoleMap> {
|
|||
List<RoleSimpleVO> getAuthorizeRole(@Valid @NotNull Long userId);
|
||||
|
||||
void authorize(Long userId, List<Long> roleIds);
|
||||
|
||||
void authorizes(List<Long> userIds, List<Long> roleIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import jakarta.annotation.Resource;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -34,19 +35,19 @@ public class UserRoleMapServiceImpl extends ServiceImpl<UserRoleMapMapper, UserR
|
|||
@Transactional
|
||||
@Override
|
||||
public void authorize(UserAuthorizeQO request, String userName) {
|
||||
List<UserRoleMap> olds=lambdaQuery().eq(UserRoleMap::getRoleId, request.getRoleId()).list();
|
||||
List<UserRoleMap> olds = lambdaQuery().eq(UserRoleMap::getRoleId, request.getRoleId()).list();
|
||||
if (CollectionUtil.isNotEmpty(request.getUserIds())) {
|
||||
olds.removeIf(map -> request.getUserIds().contains(map.getUserId()));
|
||||
}
|
||||
removeByIds(olds);
|
||||
auditLogService.addDelete(UserRoleMap.class,olds,userName);
|
||||
auditLogService.addDelete(UserRoleMap.class, olds, userName);
|
||||
if (CollectionUtil.isNotEmpty(request.getUserIds())) {
|
||||
request.getUserIds().removeIf(userId -> olds.stream().anyMatch(o -> o.getUserId().equals(userId)));
|
||||
List<UserRoleMap> datas = request.getUserIds().stream().map(userId -> new UserRoleMap()
|
||||
.setRoleId(request.getRoleId())
|
||||
.setUserId(userId)).collect(Collectors.toList());
|
||||
saveBatch(datas);
|
||||
auditLogService.addInsert(UserRoleMap.class,datas,userName);
|
||||
auditLogService.addInsert(UserRoleMap.class, datas, userName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,4 +82,20 @@ public class UserRoleMapServiceImpl extends ServiceImpl<UserRoleMapMapper, UserR
|
|||
saveBatch(datas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void authorizes(List<Long> userIds, List<Long> roleIds) {
|
||||
remove(new LambdaQueryWrapper<UserRoleMap>().in(UserRoleMap::getUserId, userIds));
|
||||
List<UserRoleMap> batchs = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(roleIds)) {
|
||||
for (Long userId : userIds) {
|
||||
List<UserRoleMap> datas = roleIds.stream().map(roleId -> new UserRoleMap()
|
||||
.setUserId(userId)
|
||||
.setRoleId(roleId)).collect(Collectors.toList());
|
||||
batchs.addAll(datas);
|
||||
}
|
||||
saveBatch(batchs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@
|
|||
<mapper namespace="com.nflg.wms.repository.mapper.UserSupplierMapper">
|
||||
|
||||
<select id="search" resultType="com.nflg.wms.common.pojo.vo.UserSupplierVO">
|
||||
select *
|
||||
from v_user_supplier
|
||||
select a.id,user_id,supplier_code,supplier_name,abbreviation,abbreviation1,type_id,abbreviation2,
|
||||
is_open_account,"state",pci_name,pci_phone,default_language,avatar,remark,
|
||||
di.name AS type_name,a.create_by,a.create_time,a.update_by,a.update_time
|
||||
from user_supplier a
|
||||
LEFT JOIN dictionary_item di ON a.type_id = di.id
|
||||
<where>
|
||||
<if test="request.name!=null and request.name!=''">
|
||||
and (supplier_name like concat('%', #{request.name}, '%')
|
||||
|
|
@ -16,10 +19,10 @@
|
|||
and supplier_code like concat('%', #{request.code}, '%')
|
||||
</if>
|
||||
<if test="request.startDate != null">
|
||||
and create_time >= #{request.startDate}
|
||||
and a.create_time >= #{request.startDate}
|
||||
</if>
|
||||
<if test="request.endDate != null">
|
||||
and create_time <= #{request.endDate}
|
||||
and a.create_time <= #{request.endDate}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class CodeGeneratorTest {
|
|||
)
|
||||
.strategyConfig(builder -> {
|
||||
builder
|
||||
.addInclude("wms_component_outbound") //只生成指定表
|
||||
.addInclude("user_supplier") //只生成指定表
|
||||
.entityBuilder().idType(IdType.ASSIGN_ID)
|
||||
.enableLombok()
|
||||
.enableChainModel()
|
||||
|
|
|
|||
Loading…
Reference in New Issue