添加redission

This commit is contained in:
mx 2024-09-13 10:07:29 +08:00
parent 69db5da7fc
commit 9911e26d6c
12 changed files with 257 additions and 291 deletions

View File

@ -1,93 +0,0 @@
# staffing
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin http://192.168.18.119:88/deliverproject/flexible_staffing/staffing.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](http://192.168.18.119:88/deliverproject/flexible_staffing/staffing/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

View File

@ -792,7 +792,7 @@ create table st_employee_fund_record (
should_price varchar(30) comment '应发金额',
real_price varchar(30) comment '实发金额',
pay_way int(1) comment '发薪方式0微信转账',
pay_account int(1) comment '签到账户0微信钱包',
pay_account varchar(50) comment '签到账户存储openId',
pay_time datetime comment '发薪时间',
transfer_no varchar(100) comment '转账订单号',
update_time datetime comment '更新时间',

View File

@ -1,5 +1,6 @@
package com.staffing.web.controller.custom;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
@ -63,26 +64,27 @@ public class StEmployeeFundRecordController extends BaseController
public void export(HttpServletResponse response, StEmployeeFundRecord stEmployeeFundRecord)
{
List<StEmployeeFundRecord> list = stEmployeeFundRecordService.selectStEmployeeFundRecordList(stEmployeeFundRecord);
List<StEmployeeFundRecord> export = new ArrayList<>();
for (StEmployeeFundRecord employeeFundRecord : list) {
if (employeeFundRecord.getPayStatus() == 0){
employeeFundRecord.setPayStatusStr("未发");
}else if (employeeFundRecord.getPayStatus() == 1){
employeeFundRecord.setPayStatusStr("已发");
continue;
}else if (employeeFundRecord.getPayStatus() == 2){
employeeFundRecord.setPayStatusStr("发放失败");
}
if (employeeFundRecord.getPayWay() != null){
employeeFundRecord.setPayWayStr("微信转账");
employeeFundRecord.setPayAccountStr("微信钱包");
}
if (employeeFundRecord.getStTaskSign() != null){
employeeFundRecord.setRemark(employeeFundRecord.getStTaskSign().getRemark());
}
export.add(employeeFundRecord);
}
ExcelUtil<StEmployeeFundRecord> util = new ExcelUtil<StEmployeeFundRecord>(StEmployeeFundRecord.class);
util.exportExcel(response, list, "员工资金流水数据");
util.exportExcel(response, export, "员工资金流水数据");
}
/**
@ -137,24 +139,6 @@ public class StEmployeeFundRecordController extends BaseController
{
ExcelUtil<StEmployeeFundRecord> util = new ExcelUtil<>(StEmployeeFundRecord.class);
List<StEmployeeFundRecord> records = util.importExcel(file.getInputStream());
for (StEmployeeFundRecord employeeFundRecord : records) {
if (employeeFundRecord.getPayStatusStr().equals("未发")){
employeeFundRecord.setPayStatus(0l);
}else if (employeeFundRecord.getPayStatusStr().equals("已发")){
employeeFundRecord.setPayStatus(1l);
}else if (employeeFundRecord.getPayStatusStr().equals("发放失败")){
employeeFundRecord.setPayStatus(2l);
}
employeeFundRecord.setPayWay(0l);
employeeFundRecord.setPayAccount(0l);
StTaskSign stTaskSign = new StTaskSign();
stTaskSign.setTaskId(employeeFundRecord.getTaskId());
stTaskSign.setEmployeeId(employeeFundRecord.getEmployeeId());
stTaskSign.setRemark(employeeFundRecord.getRemark());
taskSignService.updateStTaskSignByTaskIdAndEmId(stTaskSign);
}
String message = stEmployeeFundRecordService.importRecord(records);
return success(message);

View File

@ -87,7 +87,7 @@ public class MerchantTaskController extends BaseController
*/
@PutMapping("/editSign")
@PreAuthorize("@ss.hasPermi('task:edit')")
public AjaxResult edit(@RequestBody StTaskSign updateStTaskSign)
public AjaxResult signUp(@RequestBody StTaskSign updateStTaskSign)
{
return toAjax(stTaskSignService.signUp(updateStTaskSign));
}

View File

@ -87,6 +87,42 @@ spring:
max-active: 8
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1ms
redisson:
# 传输模式
transportMode: "NIO"
# 单节点配置
singleServerConfig:
# 连接空闲超时,单位:毫秒
idleConnectionTimeout: 10000
# 连接超时,单位:毫秒
connectTimeout: 10000
# 命令等待超时,单位:毫秒
timeout: 3000
# 命令失败重试次数,如果尝试达到 retryAttempts命令失败重试次数 仍然不能将命令发送至某个指定的节点时,将抛出错误。
# 如果尝试在此限制之内发送成功,则开始启用 timeout命令等待超时 计时。
retryAttempts: 3
# 命令重试发送时间间隔,单位:毫秒
retryInterval: 1500
# 密码
password: 12345
# 客户端名称
clientName: null
# 单个连接最大订阅数量
subscriptionsPerConnection: 5
# 节点地址
address: redis://192.168.18.119:6378
# 发布和订阅连接的最小空闲连接数
subscriptionConnectionMinimumIdleSize: 1
# 发布和订阅连接池大小
subscriptionConnectionPoolSize: 50
# 最小空闲连接数
connectionMinimumIdleSize: 32
# 连接池大小
connectionPoolSize: 64
# 数据库编号
database: 7
# DNS监测时间间隔单位毫秒
dnsMonitoringInterval: 5000
# token配置
token:

View File

@ -136,7 +136,21 @@
<version>7.1.0</version> <!-- 或者更高版本 -->
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.13.6</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

View File

@ -53,35 +53,32 @@ public class StEmployeeFundRecord extends BaseEntity
@Excel(name = "日结单价")
private String dayPrice;
/** 应发金额 */
@Excel(name = "应发金额")
/** 应发金额 废弃了realPrice变应发*/
private String shouldPrice;
/** 实发金额 */
@Excel(name = "发金额")
@Excel(name = "发金额")
private String realPrice;
/** 发薪方式 */
@Excel(name = "发薪方式")
// @Excel(name = "发薪方式")
private String payWayStr;
private Long payWay;
/** 发薪账户 */
@Excel(name = "发薪账户")
private String payAccountStr;
private Long payAccount;
private String payAccount;
/** 发薪时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "发薪时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date payTime;
/** 发放状态 0未发 1已发 2发放失败*/
/** 发放状态 0未发 1已发 2发放失败 3发放中*/
private Long payStatus;
@Excel(name = "发放状态(未发/已发/发放失败)")
@Excel(name = "发放状态")
private String payStatusStr;
//转账订单号
@ -109,14 +106,6 @@ public class StEmployeeFundRecord extends BaseEntity
this.payWayStr = payWayStr;
}
public String getPayAccountStr() {
return payAccountStr;
}
public void setPayAccountStr(String payAccountStr) {
this.payAccountStr = payAccountStr;
}
public StTaskSign getStTaskSign() {
return stTaskSign;
}
@ -241,12 +230,12 @@ public class StEmployeeFundRecord extends BaseEntity
{
return payWay;
}
public void setPayAccount(Long payAccount)
public void setPayAccount(String payAccount)
{
this.payAccount = payAccount;
}
public Long getPayAccount()
public String getPayAccount()
{
return payAccount;
}

View File

@ -145,20 +145,24 @@ public class StEmployeeFundRecordServiceImpl implements IStEmployeeFundRecordSer
{
try
{
record.setUpdateTime(new Date());
// 验证是否存在这个用户
StEmployeeFundRecord stEmployeeFundRecords = stEmployeeFundRecordMapper.selectStEmployeeFundRecordByUidAndTaskId(record.getTaskId(), record.getEmployeeId());
if (stEmployeeFundRecords == null) {
stEmployeeFundRecordMapper.insertStEmployeeFundRecord(record);
successNum++;
successMsg.append("<br/>" + successNum + "、数据导入成功");
} else{
int i = stEmployeeFundRecordMapper.updateStEmployeeFundRecordByTaskAndUid(record);
StEmployeeFundRecord update = new StEmployeeFundRecord();
update.setRealPrice(record.getRealPrice());
update.setEmployeeId(record.getEmployeeId());
update.setTaskId(record.getTaskId());
update.setUpdateTime(new Date());
// 验证是否存在这条数据,不支持追加数据所以注释掉下边代码
// StEmployeeFundRecord stEmployeeFundRecords = stEmployeeFundRecordMapper.selectStEmployeeFundRecordByUidAndTaskId(record.getTaskId(), record.getEmployeeId());
// if (stEmployeeFundRecords == null) {
// stEmployeeFundRecordMapper.insertStEmployeeFundRecord(record);
// successNum++;
// successMsg.append("<br/>" + successNum + "、数据导入成功");
// } else{
int i = stEmployeeFundRecordMapper.updateStEmployeeFundRecordByTaskAndUid(update);
if (i > 0){
successNum++;
successMsg.append("<br/>" + successNum + "、数据导入成功");
}
successMsg.append("<br/>" + successNum + "、数据导入修改成功");
}
// }
}
catch (Exception e)
{

View File

@ -16,6 +16,8 @@ import com.staffing.custom.domain.StTaskSign;
import com.staffing.custom.mapper.StEmployeeFundRecordMapper;
import com.staffing.custom.mapper.StTaskSignMapper;
import io.minio.ObjectWriteResponse;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -46,6 +48,9 @@ public class StTaskServiceImpl implements IStTaskService
@Autowired
private MinioUtil minioUtil;
@Autowired
private RedissonClient redissonClient;
protected final Logger logger = LoggerFactory.getLogger(StTaskServiceImpl.class);
@Override
@ -274,6 +279,10 @@ public class StTaskServiceImpl implements IStTaskService
@Override
public int updateStTask(StTask stTask)
{
RLock lock = redissonClient.getLock(stTask.getId() + "");
try {
lock.lock();
stTask.setUpdateTime(DateUtils.getNowDate());
StTaskSign param = new StTaskSign();
@ -301,10 +310,16 @@ public class StTaskServiceImpl implements IStTaskService
stTaskSignMapper.deleteStTaskSignById(longStTaskSignEntry.getValue().getId());
}
}
return stTaskMapper.updateStTask(stTask);
}finally {
// 锁被持有
if (lock != null && lock.isLocked()) {
if (lock.isHeldByCurrentThread()) {
// 解锁
lock.unlock();
}
}
}
}
public int generatePrCode(StTask stTask){

View File

@ -12,6 +12,8 @@ import com.staffing.custom.domain.StTask;
import com.staffing.custom.mapper.StEmployeeFundRecordMapper;
import com.staffing.custom.service.IStEmployeeFundRecordService;
import com.staffing.custom.service.IStTaskService;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.staffing.custom.mapper.StTaskSignMapper;
@ -37,6 +39,8 @@ public class StTaskSignServiceImpl implements IStTaskSignService
private IStTaskService stTaskService;
@Autowired
private StEmployeeFundRecordMapper stEmployeeFundRecordMapper;
@Autowired
private RedissonClient redissonClient;
/**
* 查询签到
*
@ -64,13 +68,16 @@ public class StTaskSignServiceImpl implements IStTaskSignService
@Override
public AjaxResult baoming(StTaskSign taskSign)
{
RLock lock = redissonClient.getLock(taskSign.getTaskId() + "");
try{
lock.lock();
SysUser user = SecurityUtils.getLoginUser().getUser();
long userId = user.getUserId();
taskSign.setEmployeeId(userId);
StTask stTask = stTaskService.selectStTaskById(taskSign.getTaskId());
if (stTask.getUseNum() <= stTask.getListSign().size()){
return error();
return error("报名已满");
}
for (StTaskSign stTaskSign : stTask.getListSign()) {
if (stTaskSign.getEmployeeId().equals(taskSign.getEmployeeId())){
@ -81,6 +88,15 @@ public class StTaskSignServiceImpl implements IStTaskSignService
taskSign.setEmployeeName(taskSign.getEmployeeName());
taskSign.setStatus(0);
return AjaxResult.success();
}finally {
// 锁被持有
if (lock != null && lock.isLocked()) {
if (lock.isHeldByCurrentThread()) {
// 解锁
lock.unlock();
}
}
}
}
/**
@ -135,7 +151,7 @@ public class StTaskSignServiceImpl implements IStTaskSignService
stEmployeeFundRecord.setPhone(stTaskSign.getPhone());
stEmployeeFundRecord.setIdCard(stTaskSign.getIdCard());
stEmployeeFundRecord.setDayPrice(stTaskSign.getDayPrice());
stEmployeeFundRecord.setShouldPrice(stTask.getDayPrice());
// stEmployeeFundRecord.setShouldPrice(stTask.getDayPrice());
stEmployeeFundRecord.setRealPrice(stTask.getDayPrice());//默认实发为日结
// stEmployeeFundRecord.setPayWay(0l);
// stEmployeeFundRecord.setPayAccount(0l);

View File

@ -123,13 +123,13 @@
<el-table-column label="日结单价" align="center" prop="dayPrice" />
<el-table-column label="应发金额" align="center" prop="shouldPrice" />
<el-table-column label="发金额" align="center" prop="realPrice" />
<el-table-column label="发薪方式" align="center" prop="payWay">
<template slot-scope="scope">
<dict-tag :options="dict.type.pay_type" :value="scope.row.payWay"/>
</template>
</el-table-column>
<!-- <el-table-column label="应发金额" align="center" prop="shouldPrice" />-->
<el-table-column label="发金额" align="center" prop="realPrice" />
<!-- <el-table-column label="发薪方式" align="center" prop="payWay">-->
<!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.pay_type" :value="scope.row.payWay"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="发薪账户" align="center" prop="payAccount">
<template slot-scope="scope">
<dict-tag :options="dict.type.pay_account" :value="scope.row.payAccount"/>
@ -462,7 +462,7 @@ export default {
handleExport() {
this.download('fund/fund/export', {
...this.queryParams
}, `fund_${new Date().getTime()}.xlsx`)
}, `员工资金流水.xlsx`)
}
, /** 导入按钮操作 */
handleImport() {

View File

@ -241,6 +241,7 @@
<div class="tb-container">
<el-table :data="employeeList" @selection-change="emSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column width="200" property="realName" label="姓名"></el-table-column>
<el-table-column width="200" property="phone" label="手机号"></el-table-column>
<el-table-column width="200" property="idCard" label="身份证号"></el-table-column>
@ -271,13 +272,8 @@
<el-button slot="reference" @click="getEmployeeList" type="primary" >+添加用工人员</el-button>
</el-popover>
</el-form-item>
<el-table v-loading="loading" :data="addEmList" @selection-change="handleSelectionChange">
<!-- <el-table-column label="序号" align="center" prop="useNum" />-->
<el-table-column label="序号">
@ -287,7 +283,7 @@
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<!-- <el-table-column width="200" prop="employeeId" label="emId"/>-->
<el-table-column label="名字" align="center" prop="realName" />
<el-table-column label="手机" align="center" prop="phone" />
<el-table-column label="身份证" align="center" prop="idCard" />
@ -554,11 +550,16 @@
});
},
addEmployee(row){
row["employeeName"] = row["realName"]
row["employeeId"] = row["id"]
this.addEmployeeMap.set(row.phone, row);
this.addEmList = Array.from(this.addEmployeeMap).map(entry => (entry[1]));
},
addBatch(){
for (let i = 0; i < this.emIds.length; i++) {
this.emIds[i]["employeeName"] = this.emIds[i]["realName"]
this.emIds[i]["employeeId"] = this.emIds[i]["id"]
this.addEmployeeMap.set(this.emIds[i].phone, this.emIds[i]);
}
this.addEmList = Array.from(this.addEmployeeMap).map(entry => (entry[1]));
@ -665,10 +666,10 @@
this.addEmList = [];
}
if (this.form.id != null) {
for (let i = 0; i < this.addEmList.length; i++) {
this.addEmList[i]["employeeName"] = this.addEmList[i]["realName"];
this.addEmList[i]["employeeId"] = this.addEmList[i]["id"];
}
// for (let i = 0; i < this.addEmList.length; i++) {
// this.addEmList[i]["employeeName"] = this.addEmList[i]["realName"];
// this.addEmList[i]["employeeId"] = this.addEmList[i]["id"];
// }
this.form.listSign = this.addEmList;
if (this.form.listSign.length > this.form.useNum){
this.$modal.msgError("超出用工数量");
@ -681,10 +682,10 @@
this.getList();
});
} else {
for (let i = 0; i < this.addEmList.length; i++) {
this.addEmList[i]["employeeName"] = this.addEmList[i]["realName"];
this.addEmList[i]["employeeId"] = this.addEmList[i]["id"];
}
// for (let i = 0; i < this.addEmList.length; i++) {
// this.addEmList[i]["employeeName"] = this.addEmList[i]["realName"];
// this.addEmList[i]["employeeId"] = this.addEmList[i]["id"];
// }
this.form.listSign = this.addEmList;
if (this.form.listSign.length > this.form.useNum){
this.$modal.msgError("超出用工数量");