package com.kakarote.crm9.erp.oa.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.util.TypeUtils;
import com.jfinal.aop.Before;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.SqlPara;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.kakarote.crm9.common.config.paragetter.BasePageRequest;
import com.kakarote.crm9.common.constant.BaseConstant;
import com.kakarote.crm9.erp.admin.entity.AdminExamineLog;
import com.kakarote.crm9.erp.admin.entity.AdminUser;
import com.kakarote.crm9.erp.admin.service.AdminFieldService;
import com.kakarote.crm9.erp.admin.service.AdminFileService;
import com.kakarote.crm9.erp.crm.entity.CrmBusiness;
import com.kakarote.crm9.erp.crm.entity.CrmContacts;
import com.kakarote.crm9.erp.crm.entity.CrmContract;
import com.kakarote.crm9.erp.crm.entity.CrmCustomer;
import com.kakarote.crm9.erp.oa.common.OaEnum;
import com.kakarote.crm9.erp.oa.entity.*;
import com.kakarote.crm9.utils.*;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
public class OaExamineService{
//添加日志
@Inject
private OaActionRecordService oaActionRecordService;
@Inject
private AdminFileService adminFileService;
@Inject
private AdminFieldService adminFieldService;
public R myInitiate(BasePageRequest<Void> request){
JSONObject jsonObject = request.getJsonObject();
Long userId = BaseUtil.getUser().getUserId();
if(request.getPageType() == 0){
List<Record> recordList = Db.find(Db.getSqlPara("oa.examine.myInitiate", Kv.by("userId", userId).set("categoryId", jsonObject.getInteger("categoryId")).set("status", jsonObject.getInteger("checkStatus")).set("startTime", jsonObject.getDate("startTime")).set("endTime", jsonObject.getDate("endTime"))));
transfer(recordList);
return R.ok().put("data", recordList);
}else{
Page<Record> recordList = Db.paginate(request.getPage(), request.getLimit(), Db.getSqlPara("oa.examine.myInitiate", Kv.by("userId", userId).set("categoryId", jsonObject.getInteger("categoryId")).set("status", jsonObject.getInteger("checkStatus")).set("startTime", jsonObject.getDate("startTime")).set("endTime", jsonObject.getDate("endTime"))));
transfer(recordList.getList());
return R.ok().put("data", recordList);
}
}
public R myOaExamine(BasePageRequest<OaExamine> request){
Long userId = BaseUtil.getUser().getUserId();
JSONObject jsonObject = request.getJsonObject();
if(request.getPageType() == 0){
List<Record> recordList = Db.find(Db.getSqlPara("oa.examine.myOaExamine", Kv.by("userId", userId).set("categoryId", jsonObject.getInteger("categoryId")).set("status", jsonObject.getInteger("status")).set("startTime", jsonObject.getDate("startTime")).set("endTime", jsonObject.getDate("endTime"))));
transfer(recordList);
return R.ok().put("data", recordList);
}else{
Page<Record> recordList = Db.paginate(request.getPage(), request.getLimit(), Db.getSqlPara("oa.examine.myOaExamine", Kv.by("userId", userId).set("categoryId", jsonObject.getInteger("categoryId")).set("status", jsonObject.getInteger("status")).set("startTime", jsonObject.getDate("startTime")).set("endTime", jsonObject.getDate("endTime"))));
transfer(recordList.getList());
return R.ok().put("data", recordList);
}
}
public void transfer(List<Record> recordList){
recordList.forEach(record -> {
setRelation(record);
record.set("createUser", Db.findFirst("select user_id,realname,img from 72crm_admin_user where user_id = ?", record.getLong("create_user_id")));
String batchId = record.getStr("batch_id");
adminFileService.queryByBatchId(batchId, record);
setCountRecord(record);
List<Integer> roles = BaseUtil.getUser().getRoles();
Map<String,Integer> permission = new HashMap<>();
Long createUserId = record.getLong("create_user_id");
Integer examineStatus = record.getInt("examine_status");
Long userId = BaseUtil.getUser().getUserId();
if((userId.equals(BaseConstant.SUPER_ADMIN_USER_ID) && (examineStatus == 4 || examineStatus == 2)) || (createUserId.equals(BaseUtil.getUser().getUserId()) && (examineStatus == 4 || examineStatus == 2))){
permission.put("isUpdate", 1);
}else{
permission.put("isUpdate", 0);
}
if(roles.contains(BaseConstant.SUPER_ADMIN_ROLE_ID) && examineStatus != 1){
permission.put("isDelete", 1);
}else{
permission.put("isDelete", 0);
}
if(((userId.equals(BaseConstant.SUPER_ADMIN_USER_ID) || userId.equals(record.getLong("create_user_id"))) && (examineStatus == 0 || examineStatus == 3)) && examineStatus != 4){
permission.put("isChecked", 1);
}else{
permission.put("isChecked", 0);
}
record.set("permission", permission);
});
}
private void setCountRecord(Record record){
Integer examineId = record.getInt("examine_id");
String categoryTitle = record.getStr("categoryTitle");
Integer count = Db.queryInt("select count(*) as count from 72crm_oa_examine_travel where examine_id = ?", examineId);
StringBuilder causeTitle = new StringBuilder();
if(count > 0){
causeTitle.append(count);
switch(categoryTitle){
case "出差审批":
causeTitle.append("个行程,共");
if(record.get("duration") != null){
causeTitle.append(record.getInt("duration"));
}else{
causeTitle.append(0);
}
causeTitle.append("天。");
break;
case "差旅报销":
causeTitle.append("个报销事项,共");
if(record.get("money") != null){
causeTitle.append(record.getInt("money"));
}else{
causeTitle.append(0);
}
causeTitle.append("元。");
break;
default:
break;
}
}
record.set("causeTitle", causeTitle.toString());
}
@Before(Tx.class)
public R setOaExamine(JSONObject jsonObject){
AdminUser user = BaseUtil.getUser();
OaExamine oaExamine = jsonObject.getObject("oaExamine", OaExamine.class);
boolean oaAuth = AuthUtil.isOaAuth(OaEnum.EXAMINE_TYPE_KEY.getTypes(), oaExamine.getExamineId());
if(oaAuth){
return R.noAuth();
}
if(oaExamine.getStartTime() != null && oaExamine.getEndTime() != null){
if((oaExamine.getStartTime().compareTo(oaExamine.getEndTime())) == 1){
return R.error("审批结束时间早于开始时间");
}
}
boolean bol;
String batchId = StrUtil.isNotEmpty(oaExamine.getBatchId()) ? oaExamine.getBatchId() : IdUtil.simpleUUID();
adminFieldService.save(jsonObject.getJSONArray("field"), batchId);
oaExamine.setBatchId(batchId);
String checkUserIds = jsonObject.getString("checkUserId");
Integer categoryId = oaExamine.getCategoryId();
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
悟空CRM-基于jfinal+vue+ElementUI的前后端分离CRM系统。悟空CRM云服务完全免费,且不限人数。悟空云正式上线,包含客户关系管理系统(CRM)人力资源管理系统(CRM)、财务管理系统(FS)、无代码平台、SCRM。悟空软件长期为企业提供企业管理软件(CRM/HRM/OA/ERP等)的研发、实施、营销、咨询、培训、服务于一体的信息化服务。悟空软件以高科技为起点,以技术为核心、以完善的售后服务为后盾,秉承稳固与发展、求实与创新的精神,已为国内外上千家企业提供服务。
资源推荐
资源详情
资源评论
收起资源包目录
悟空CRM-基于jfinal+vue+ElementUI的前后端分离CRM系统 (2001个子文件)
.babelrc 241B
72crm.bat 1KB
app.2d20ef02.css 331KB
chunk-libs.0651b7d6.css 216KB
chunk-d1e2.609582a4.css 181KB
chunk-53f9.8b61604c.css 169KB
chunk-37f0.24e6afa4.css 153KB
chunk-4398.68d24dc3.css 147KB
chunk-78d8.bfa695ca.css 143KB
chunk-61e0.a57b2d4d.css 141KB
chunk-c6ff.9cf4d241.css 139KB
chunk-4510.22996d17.css 138KB
chunk-7e8d.4f3b7b4c.css 137KB
chunk-bbd0.56ec5335.css 134KB
chunk-ac90.0ec48e0f.css 134KB
chunk-0d2b.5de66b45.css 134KB
chunk-3bd9.c3b8efe2.css 134KB
chunk-0a4f.eb936862.css 134KB
chunk-69ba.ae375285.css 122KB
chunk-496b.80763c98.css 118KB
chunk-526a.cc6efeee.css 112KB
chunk-588f.0b3c51b2.css 111KB
chunk-ef6a.bfe53092.css 111KB
chunk-33b6.3a7195c6.css 99KB
animate.css 79KB
chunk-635a.e5b9c043.css 30KB
chunk-6023.2f09d0e0.css 26KB
iconfont.css 22KB
chunk-4bf7.9ce02bc3.css 19KB
chunk-787b.7aaf1a2a.css 12KB
chunk-2e97.7e0e574c.css 10KB
chunk-0af6.d8a09fe6.css 10KB
chunk-65db.184ef3fa.css 9KB
chunk-2a51.65e0169f.css 8KB
chunk-5a53.9213ce21.css 8KB
chunk-d98f.d4b26d2e.css 8KB
chunk-418f.1e62ac24.css 7KB
chunk-0846.e59f2540.css 7KB
chunk-5a52.ba0243d7.css 7KB
chunk-1940.0e872fb3.css 7KB
chunk-4390.9ec8521e.css 6KB
chunk-7c06.bc883968.css 6KB
chunk-9e65.4b423c36.css 5KB
chunk-3c4a.fd97a392.css 4KB
chunk-8e89.7d60a6f3.css 4KB
chunk-3033.3a94b0df.css 3KB
chunk-2196.67a05b27.css 3KB
chunk-4a80.96c4b10c.css 3KB
chunk-c0da.8bb90675.css 3KB
chunk-622e.4d0f790a.css 3KB
chunk-1845.4ce9d415.css 3KB
chunk-f67d.5953427b.css 3KB
chunk-03f8.457b1dd7.css 3KB
chunk-2012.58af01a6.css 3KB
chunk-4656.2aac3aaa.css 3KB
chunk-1a72.39999aa7.css 3KB
chunk-59d8.eb0822a6.css 3KB
chunk-765a.3284544e.css 3KB
chunk-ec43.4d75d403.css 3KB
chunk-d05e.e889ef28.css 3KB
chunk-f7fb.2ebaddbc.css 3KB
chunk-ede9.f1f15cc8.css 3KB
chunk-0aa1.d0650d6a.css 3KB
chunk-5691.f563fadf.css 3KB
chunk-3c44.ba974c97.css 3KB
chunk-e84f.ecd179ac.css 3KB
chunk-027b.62f161b8.css 3KB
chunk-46e631.a1125a74.css 3KB
chunk-46e631a.a1125a74.css 3KB
chunk-46e63.a1125a74.css 3KB
chunk-46e6.a1125a74.css 3KB
chunk-2a3d.b6c606b3.css 3KB
chunk-8a74.eaa25ef4.css 3KB
index.css 3KB
index.css 3KB
chunk-dfa3.d718ac02.css 3KB
chunk-b65d.b44d49f3.css 3KB
chunk-7ce0.1060ae65.css 2KB
chunk-ac95.35d73b8c.css 2KB
chunk-4fdb.0838ada9.css 2KB
chunk-c7dc.fa44ea8a.css 2KB
chunk-e3c9.b046ab26.css 2KB
chunk-56a3.6c5ef240.css 2KB
chunk-2995.d4e3ac37.css 1KB
chunk-64a4.a44218a1.css 1KB
chunk-546c.33336add.css 1KB
chunk-ce98.57786e94.css 916B
chunk-a2cf.517c8a5f.css 862B
chunk-d27d.969fe213.css 862B
chunk-8cda.7c5a50f2.css 862B
chunk-7b89.821864c2.css 862B
chunk-5dd4.1b2038ee.css 401B
chunk-7caa.1aa22858.css 208B
.DS_Store 6KB
.editorconfig 257B
iconfont.eot 24KB
.eslintignore 37B
1.gif 475KB
401.gif 160KB
loading.gif 381B
共 2001 条
- 1
- 2
- 3
- 4
- 5
- 6
- 21
资源评论
- zyhd822024-10-21感谢资源主分享的资源解决了我当下的问题,非常有用的资源。
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7361
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功