|
|
@@ -16,6 +16,8 @@
|
|
|
*/
|
|
|
package org.springblade.bank.goodsuse.controller;
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -26,6 +28,11 @@ import javax.validation.Valid;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.bank.cardswallow.entity.CardSwallow;
|
|
|
+import org.springblade.bank.keypwd.entity.KeyPwd;
|
|
|
+import org.springblade.bank.postchange.entity.PostChange;
|
|
|
+import org.springblade.bank.sealhandover.entity.SealHandover;
|
|
|
+import org.springblade.bank.userlog.entity.UserLog;
|
|
|
+import org.springblade.bank.userlog.service.IUserLogService;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
@@ -33,7 +40,9 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.modules.system.entity.Dept;
|
|
|
import org.springblade.modules.system.entity.User;
|
|
|
+import org.springblade.modules.system.service.IDeptService;
|
|
|
import org.springblade.modules.system.service.IUserService;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -61,6 +70,8 @@ public class GoodsUseController extends BladeController {
|
|
|
|
|
|
private final IGoodsUseService goodsUseService;
|
|
|
private final IUserService userService;
|
|
|
+ private final IDeptService deptService;
|
|
|
+ private final IUserLogService userLogService;
|
|
|
|
|
|
/**
|
|
|
* 详情
|
|
|
@@ -138,26 +149,54 @@ public class GoodsUseController extends BladeController {
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入goodsUse")
|
|
|
public R submit(@Valid @RequestBody GoodsUse goodsUse) {
|
|
|
|
|
|
- GoodsUse setting = goodsUseService.getOne(new QueryWrapper<>(new GoodsUse()).lambda().eq(GoodsUse::getId, 1L));
|
|
|
- Assert.notNull(setting, "請先設置發佈人!");
|
|
|
+ if (goodsUse.getPersonId() == null || goodsUse.getPersonNo() == null){
|
|
|
+ GoodsUse setting = goodsUseService.getOne(new QueryWrapper<>(new GoodsUse()).lambda().eq(GoodsUse::getId, 1L));
|
|
|
+ Assert.notNull(setting, "請先設置確認人!");
|
|
|
+ goodsUse.setPersonId(setting.getPersonId());
|
|
|
+ goodsUse.setPersonNo(setting.getPersonNo());
|
|
|
+ goodsUse.setPersonName(setting.getPersonName());
|
|
|
+ }
|
|
|
|
|
|
if (StringUtils.isNotBlank(goodsUse.getPersonNo())){
|
|
|
User user = userService.getById(AuthUtil.getUser().getUserId());
|
|
|
if (user.getEhr().equals(goodsUse.getPersonNo())){
|
|
|
- Assert.notNull(null, "發佈人和發起人不能為同一人!");
|
|
|
+ Assert.notNull(null, "確認人和發起人不能為同一人!");
|
|
|
}
|
|
|
}
|
|
|
+ goodsUse.setProcess(2);
|
|
|
|
|
|
- goodsUse.setPersonId(setting.getPersonId());
|
|
|
- goodsUse.setPersonNo(setting.getPersonNo());
|
|
|
- goodsUse.setPersonName(setting.getPersonName());
|
|
|
|
|
|
- goodsUse.setProcess(2);
|
|
|
+ boolean isAdd = goodsUse.getId() == null;
|
|
|
BladeUser currentUser = AuthUtil.getUser();
|
|
|
User user = userService.getById(currentUser.getUserId());
|
|
|
- goodsUse.setFillingDate(DateUtil.now());
|
|
|
- goodsUse.setFillingNo(user.getEhr());
|
|
|
- goodsUse.setFillingName(user.getName());
|
|
|
+ Dept dept = deptService.getById(user.getDeptId());
|
|
|
+ UserLog userLog = new UserLog();
|
|
|
+
|
|
|
+ if (isAdd){
|
|
|
+ goodsUse.setFillingDate(DateUtil.now());
|
|
|
+ goodsUse.setFillingNo(user.getEhr());
|
|
|
+ goodsUse.setFillingName(user.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (goodsUseService.saveOrUpdate(goodsUse)){
|
|
|
+ userLog.setTableName("goodsuse");
|
|
|
+ userLog.setBankNo(dept.getBankNo());
|
|
|
+ userLog.setOrgNo(dept.getOrgNo());
|
|
|
+ userLog.setNewData(JSONUtil.toJsonStr(goodsUse));
|
|
|
+ userLog.setPersonNo(user.getEhr());
|
|
|
+ userLog.setPersonName(user.getName());
|
|
|
+
|
|
|
+ if (isAdd){
|
|
|
+ userLog.setOperationType("add");
|
|
|
+ }else{
|
|
|
+ userLog.setOperationType("edit");
|
|
|
+ GoodsUse old = goodsUseService.getById(goodsUse.getId());
|
|
|
+ userLog.setOldData(JSONUtil.toJsonStr(old));
|
|
|
+ }
|
|
|
+ userLogService.save(userLog);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return R.status(goodsUseService.saveOrUpdate(goodsUse));
|
|
|
}
|
|
|
|
|
|
@@ -169,7 +208,28 @@ public class GoodsUseController extends BladeController {
|
|
|
@ApiOperationSupport(order = 7)
|
|
|
@ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
- return R.status(goodsUseService.deleteLogic(Func.toLongList(ids)));
|
|
|
+ List<Long> idList = Func.toLongList(ids);
|
|
|
+
|
|
|
+ if (goodsUseService.deleteLogic(idList)){
|
|
|
+ // 日誌記錄
|
|
|
+ BladeUser currentUser = AuthUtil.getUser();
|
|
|
+ User user = userService.getById(currentUser.getUserId());
|
|
|
+ Dept dept = deptService.getById(user.getDeptId());
|
|
|
+ idList.forEach(id -> {
|
|
|
+ UserLog userLog = new UserLog();
|
|
|
+ GoodsUse goodsUse = goodsUseService.getById(id);
|
|
|
+
|
|
|
+ userLog.setTableName("goodsuse");
|
|
|
+ userLog.setOperationType("del");
|
|
|
+ userLog.setBankNo(dept.getBankNo());
|
|
|
+ userLog.setOrgNo(dept.getOrgNo());
|
|
|
+ userLog.setOldData(JSONUtil.toJsonStr(goodsUse));
|
|
|
+ userLog.setPersonNo(user.getEhr());
|
|
|
+ userLog.setPersonName(user.getName());
|
|
|
+ userLogService.save(userLog);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return R.status(true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -243,5 +303,21 @@ public class GoodsUseController extends BladeController {
|
|
|
return R.status(goodsUseService.updateById(goodsUse));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据类型,获取最新一条记录
|
|
|
+ */
|
|
|
+ @GetMapping("/getLastByType")
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "获取审批人设置", notes = "")
|
|
|
+ public R getLastByType(@ApiParam(value = "主键集合", required = true) @RequestParam String type) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<GoodsUse> wrapper = new QueryWrapper<>(new GoodsUse()).lambda().eq(GoodsUse::getType, type).orderByDesc(GoodsUse::getCreateTime);
|
|
|
+ wrapper.last("limit " + 2);
|
|
|
+ List<GoodsUse> list = goodsUseService.list(wrapper);
|
|
|
+ if (list != null && list.size() > 0){
|
|
|
+ return R.data(list.get(0));
|
|
|
+ }
|
|
|
+ return R.data(null);
|
|
|
+ }
|
|
|
|
|
|
}
|