Commit 0ac32b72 by tangzhaoqian

清理多余类、代码优化

parent 99ab5e9e
package cn.timer.api.config.page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
public class SimplePageBuilder {
/**
* 以常量的形式存储,在实际的运用中应该从properties文件中取得,思路都一样
*/
public static final int size = 10;
@SuppressWarnings("deprecation")
public static Pageable generate(int page, int size, Sort sort) {
if (sort == null)
return new PageRequest(page, size);
return new PageRequest(page, size, sort);
}
public static Pageable generate(int page) {
return generate(page, size, null);
}
public static Pageable generate(int page, Sort sort) {
return generate(page, size, sort);
}
}
package cn.timer.api.config.sort;
import java.util.ArrayList;
import java.util.List;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
public class SimpleSortBuilder {
/**
* 调用的时候使用SimpleSortBuilder.generateSort("name","xh_d");表示先以name升序,之后以xh降序
*/
@SuppressWarnings("deprecation")
public static Sort generateSort(String... fields) {
List<Order> orders = new ArrayList<Order>();
for(String f:fields) {
orders.add(generateOrder(f));
}
return new Sort(orders);
}
@SuppressWarnings("deprecation")
private static Order generateOrder(String f) {
Order order = null;
String[] ff = f.split("_");
if(ff.length>=2) {
if(ff[1].equals("d")) {
order = new Order(Direction.DESC,ff[0]);
} else {
order = new Order(Direction.ASC,ff[0]);
}
return order;
}
order = new Order(f);
return order;
}
}
......@@ -439,13 +439,7 @@ public class LoginController {
@ApiOperationSupport(order = 6)
@Log(title = "企业注册", businessType = BusinessType.INSERT)
public Result<String> register(@RequestBody EntRegisterDto entRegisterDto) throws Exception{
// 事务回滚
/*
* DefaultTransactionDefinition def = new DefaultTransactionDefinition();
* def.setName("register");
* def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
* TransactionStatus status = transactionManager.getTransaction(def);
*/
try {
String phone = entRegisterDto.getPhone();
String username = entRegisterDto.getUsername();
......
......@@ -94,6 +94,7 @@ public class SpmkController {
private SpmkService spmkService;
@Autowired
private ZzglBmgwMService zzglBmgwMService;
@Autowired
private SpmkApprovalTemplateGMapper spmkApprovalTemplateGMapper;
@Autowired
......@@ -115,8 +116,6 @@ public class SpmkController {
private boolean ISFIRST = true; // 第一次启动审批流程
//TODO 审批模板组
/**
* 新增或编辑-审批模板组
......@@ -280,7 +279,7 @@ public class SpmkController {
}
spmkApprovalG.setOrgCode(userBean.getOrgCode());
return spmkApprovalG.insertOrUpdate() ? ResultUtil.data(spmkApprovalG, "操作成功!") : ResultUtil.error();
return spmkApprovalG.insertOrUpdate() ? ResultUtil.data(spmkApprovalG) : ResultUtil.error();
}
......@@ -293,7 +292,7 @@ public class SpmkController {
public Result<Object> deleteAgById(@PathVariable int id){
if (spmkCustomApprovalMapper.selectCount(new QueryWrapper<SpmkCustomApproval>().lambda().eq(SpmkCustomApproval::getApprovalGId, id)) > 0 )
return ResultUtil.error("审批组存在 自定义审批不可直接删除!");
return ResultUtil.error("审批组存在 自定义审批,不可直接删除!");
return SpmkApprovalG.builder().id(id).build().deleteById() ? ResultUtil.success() : ResultUtil.error("没有找到该对象");
......@@ -309,7 +308,7 @@ public class SpmkController {
List<Integer> depts = zzglBmgwMService.empNumupGetDepts(userBean.getOrgCode(), userBean.getEmpNum());
System.out.println(depts);
return ResultUtil.data(spmkApprovalGMapper.selectListAgInCaByAdmin(userBean.getOrgCode(), userBean.getEmpNum(), depts),"操作成功!");
return ResultUtil.data(spmkApprovalGMapper.selectListAgInCaByAdmin(userBean.getOrgCode(), userBean.getEmpNum(), depts));
}
......@@ -321,7 +320,7 @@ public class SpmkController {
@ApiOperationSupport(order = 11)
public Result<Object> selectListAg(@CurrentUser UserBean userBean){
return ResultUtil.data(spmkService.selectListAg(userBean) ,"操作成功!");
return ResultUtil.data(spmkService.selectListAg(userBean));
}
/**
......@@ -332,7 +331,7 @@ public class SpmkController {
@ApiOperationSupport(order = 12)
public Result<Object> ranksAg(@Validated({Ranks.class}) @RequestBody ValidList<SpmkApprovalG> list){
if (list == null || (list != null && list.size() <= 0)) {
if (list == null || list.size() <= 0) {
return ResultUtil.success();
}
......@@ -398,7 +397,7 @@ public class SpmkController {
// 清空前端不需要的字段再返回,节省流量
ca.setFroms(null);
ca.setRouter(null);
return ResultUtil.data(ca, "操作成功!");
return ResultUtil.data(ca);
}
......@@ -435,7 +434,7 @@ public class SpmkController {
.build();
BeanUtil.copyProperties(ca, caD,"froms","router");
caD.setInitiatorConfigs(listIc);
return ResultUtil.data(caD,"操作成功!");
return ResultUtil.data(caD);
}
/**
......@@ -544,7 +543,7 @@ public class SpmkController {
List<YgglMainEmp> listYgglMainEmp = RouterUtils.selectOtherlistent(userBean.getOrgCode(), deptId);
if (deptId != null && (listYgglMainEmp == null || listYgglMainEmp.size() == 0)) {
return ResultUtil.data(new ArrayList<SpmkApproveSummary>(), "操作成功!");
return ResultUtil.data(new ArrayList<SpmkApproveSummary>());
}
List<Integer> empNums = new ArrayList<Integer>();
......@@ -558,7 +557,7 @@ public class SpmkController {
List<SpmkApproveSummary> listAs = pageAs.getRecords();
return ResultUtil.data(pageAs, listAs, "操作成功!");
return ResultUtil.data(pageAs, listAs);
}
//TODO 审批详情
......@@ -573,7 +572,7 @@ public class SpmkController {
SpmkApproveDetailDto adD = spmkService.selectApproveDetailByAsId(id);
return ResultUtil.data(adD, "操作成功!");
return ResultUtil.data(adD);
}
//TODO 审批人审批
......@@ -682,7 +681,7 @@ public class SpmkController {
IPage<SpmkApproveSummary> pageAs = spmkApproveSummaryMapper.selectPageByQueryForEmpNum(page, mySummaryQueryDto);
List<SpmkApproveSummary> listAs = pageAs.getRecords();
return ResultUtil.data(pageAs, listAs, "操作成功!");
return ResultUtil.data(pageAs, listAs);
}
//TODO 撤销审批
......@@ -770,6 +769,6 @@ public class SpmkController {
List<SpmkIcon> spmkIcons = SpmkIcon.builder().build().selectAll();
return ResultUtil.data(spmkIcons,"获取图标列表成功");
return ResultUtil.data(spmkIcons,"生成 审批组 和 自定义审批成功");
}
}
......@@ -24,10 +24,8 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNode;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.StrUtil;
......@@ -107,10 +105,10 @@ public class ZzglController {
.eq(ZzglBmgwM::getOrgCode, orgCode).list();
// 构建node列表
List<TreeNode<String>> nodeList = CollUtil.newArrayList();
zzglBmgwMs.forEach(z -> {
nodeList.add(new TreeNode<>(Convert.toStr(z.getId()), Convert.toStr(z.getUpId()), z.getName(), 0));
});
// List<TreeNode<String>> nodeList = CollUtil.newArrayList();
// zzglBmgwMs.forEach(z -> {
// nodeList.add(new TreeNode<>(Convert.toStr(z.getId()), Convert.toStr(z.getUpId()), z.getName(), 0));
// });
//配置
TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
......@@ -277,10 +275,11 @@ public class ZzglController {
@Log(title = "删除岗位", businessType = BusinessType.DELETE)
public Result<Integer> deldepts(@CurrentUser UserBean userBean, @RequestBody List<Integer> ids) {
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build();
UpdateWrapper<YgglMainEmp> updateWrapper = new UpdateWrapper<YgglMainEmp>();
updateWrapper.set("bmgw_id", null).in("bmgw_id", ids);
zzglLogDgjlMapper.insertbydeldept(ids, userBean.getEmpNum());
ygglMainEmp.update(updateWrapper);
ygglMainEmp.update(new UpdateWrapper<YgglMainEmp>().lambda()
.set(YgglMainEmp::getBmgwId, null)
.in(YgglMainEmp::getBmgwId, ids));
zzglBmgwMMapper.deleteBatchIds(ids);
return ResultUtil.success();
......@@ -298,13 +297,12 @@ public class ZzglController {
Integer dpetId = upEmpDeptDto.getDpetId();
List<Integer> empNums = upEmpDeptDto.getEmpNum();
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build();
// zzglLogDgjlMapper
UpdateWrapper<YgglMainEmp> updateWrapper = new UpdateWrapper<YgglMainEmp>();
updateWrapper.set("bmgw_id", dpetId).eq("org_code", userBean.getOrgCode()).in("emp_num", empNums);
zzglLogDgjlMapper.insertbyaddemp(empNums, userBean.getEmpNum(), dpetId, userBean.getOrgCode(),
dpetId == null || dpetId == 0 ? "岗位删除员工" : upEmpDeptDto.getIsdg() == null ? "岗位添加员工" : "员工调岗");
ygglMainEmp.update(updateWrapper);
// zzglLogDgjlMapper.insert
ygglMainEmp.update(new UpdateWrapper<YgglMainEmp>().lambda()
.set(YgglMainEmp::getBmgwId, dpetId)
.eq(YgglMainEmp::getOrgCode, userBean.getOrgCode()).in(YgglMainEmp::getEmpNum, empNums));
return ResultUtil.success();
}
......@@ -315,11 +313,12 @@ public class ZzglController {
empNums.add(empNum);
YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build();
UpdateWrapper<YgglMainEmp> updateWrapper = new UpdateWrapper<YgglMainEmp>();
updateWrapper.set("bmgw_id", dpetId).eq("org_code", orgCode).in("emp_num", empNum);
zzglLogDgjlMapper.insertbyaddemp(empNums, empNum, dpetId, orgCode,
dpetId == null || dpetId == 0 ? "岗位删除员工" : upEmpDeptDto.getIsdg() == null ? "岗位添加员工" : "员工调岗");
ygglMainEmp.update(updateWrapper);
ygglMainEmp.update(new UpdateWrapper<YgglMainEmp>().lambda()
.set(YgglMainEmp::getBmgwId, dpetId)
.eq(YgglMainEmp::getOrgCode, orgCode)
.in(YgglMainEmp::getEmpNum, empNum));
}
/**
......@@ -458,7 +457,6 @@ public class ZzglController {
@ApiOperation(value = "删除-菜单权限", httpMethod = "DELETE", notes = "接口发布说明")
public Result<List<ZzglMenu>> deletePostMenus(@Validated @RequestBody Integer id) {
return zzglMenuMapper.deleteById(id) > 0 ? ResultUtil.success() : ResultUtil.error();
}
......
......@@ -2,10 +2,6 @@ package cn.timer.api.manager.factory;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.hutool.extra.spring.SpringUtil;
import cn.timer.api.bean.qyzx.QyzxOperLog;
import cn.timer.api.controller.qyzx.service.QyzxOperLogService;
import cn.timer.api.utils.AddressUtils;
......
......@@ -511,36 +511,7 @@ public class DateFormatUtils {
}
public static void main(String[] args) throws ParseException {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd EE");
System.out.println(df.format(new Date()));
//System.out.println(DateFormatUtils.getWeekNowDay());
/*
* System.out.println(getSystemDateByYYYYMMDDHHMMSSSSS());
* System.out.println(getSystemYY()); System.out.println(getSystemMM());
* System.out.println(getSystemDateByyymmdd());
*/
/*
* Long day = countAge("2015-10-20"); System.out.println(day.toString());
*/
/*
* Date date = getSystemDate(); System.out.println(date.toString());
*/
String s1 = "2008-01-25 09:12:11";
String s2 = "2008-01-25 09:12:09";
/*
* java.text.DateFormat df=new
* java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); java.util.Calendar
* c1=java.util.Calendar.getInstance(); java.util.Calendar
* c2=java.util.Calendar.getInstance(); try { c1.setTime(df.parse(s1));
* c2.setTime(df.parse(s2)); }catch(java.text.ParseException e){
* System.err.println("格式不正确"); } int result=c1.compareTo(c2); if(result==0)
* System.out.println("c1相等c2"); else if(result<0) System.out.println("c1小于c2");
* else System.out.println("c1大于c2");
*/
Date d1 = convertToDate(s2, "yyyy-MM-dd HH:mm:ss");
Date d2 = convertToDate(s1, "yyyy-MM-dd HH:mm:ss");
System.out.println(DateDifferentExample(d1, d2));
}
}
\ No newline at end of file
package cn.timer.api.utils;
import javax.servlet.http.HttpSession;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSONObject;
/**
* @author Eangaie
* @date 2018/10/12 0012 下午 14:53 网络请求,RestTemplate工具类
*/
@Component
public class RestTemplateUtil {
@Autowired
private RestTemplate restTemplate;
@Autowired
private HttpSession session;
/**
* 发送GET请求
*
* @param url
* @param param
* @return
*/
public JSONObject GetData(String url, T param) {
// 请勿轻易改变此提交方式,大部分的情况下,提交方式都是表单提交
HttpHeaders headers = new HttpHeaders();
headers.add("appid", "4438775940");
headers.add("grantType", "refresh_token");
headers.add("refreshToken", "8b58973c290cc848b67ff0017cd424ff");
session.setAttribute("Content-Type", "application/json");
session.setAttribute("X-Tsign-Open-App-Id", "4438775940");
session.setAttribute("X-Tsign-Open-Token", "token");
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
@SuppressWarnings("unused")
HttpEntity<T> httpEntity = new HttpEntity<T>(param, headers);
return restTemplate.getForEntity(url, JSONObject.class, param).getBody();
}
/**
* 发送POST-JSON请求
*
* @param url
* @param param
* @return
*/
public String PostJsonData(String url, JSONObject param) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
@SuppressWarnings("unused")
HttpEntity<JSONObject> requestEntity = new HttpEntity<JSONObject>(param, headers);
return restTemplate.postForEntity(url, param, String.class).getBody();
}
/**
* 发送POST 表单请求
*
* @param url
* @param param
* @return
*/
public String PostFormData(String url, MultiValueMap<String, String> param) {
// 请勿轻易改变此提交方式,大部分的情况下,提交方式都是表单提交
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
return restTemplate.postForEntity(url, param, String.class).getBody();
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ import org.springframework.stereotype.Service;
import lombok.Data;
/**
* @author Exrickx
* @author Tang
* 前后端交互数据标准
*/
@Service("result")
......
......@@ -96,6 +96,19 @@ public class ResultUtil<T> {
}
@SuppressWarnings("rawtypes")
public Result<T> setData(T t1, T t2) {
this.result.setCurrent(((IPage) t1).getCurrent());
this.result.setPages(((IPage) t1).getPages());
this.result.setSize(((IPage) t1).getSize());
this.result.setTotal(((IPage) t1).getTotal());
this.result.setData(t2);
this.result.setCode(STATUS_CODE_SUCCESS);
this.result.setMessage(MESSAGE_SUCCESS);
return this.result;
}
@SuppressWarnings("rawtypes")
public Result<T> setData2(T t1, T t2, String msg) {
this.result.setCurrent((long) ((com.github.pagehelper.Page) t1).getPageNum());
......@@ -140,6 +153,11 @@ public class ResultUtil<T> {
return new ResultUtil<T>().setData(t);
}
public static <T> Result<T> data(T t1, T t2) {
return new ResultUtil<T>().setData(t1, t2);
}
public static <T> Result<T> data(T t1, T t2, String msg) {
return new ResultUtil<T>().setData(t1, t2, msg);
......
package cn.timer.api.utils;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.util.List;
/**
* 反序列化
*
* @author Administrator
*/
public class SerializationUtils {
@SuppressWarnings("unchecked")
public static List<Object> toSerialization(byte[] object) {
try {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(object);
ObjectInputStream in;
in = new ObjectInputStream(byteArrayInputStream);
List<Object> objectlist = (List<Object>) in.readObject();
in.close();
return objectlist;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static Object toSerializationObject(byte[] object) {
try {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(object);
ObjectInputStream in;
in = new ObjectInputStream(byteArrayInputStream);
Object objectlist = (Object) in.readObject();
in.close();
return objectlist;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 数据库驱动-->
<classPathEntry location="C:\Users\Administrator\.m2\repository\mysql\mysql-connector-java\5.1.37\mysql-connector-java-5.1.37.jar"/>
<context id="DB2Tables" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://120.24.172.51:3306/youlingrc-8timer201" userId="tang1" password="Tang123456!"/>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="com.eighttimer.service.bean" targetProject="D:\Tang\com.8timer.www\src">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="mapping" targetProject="D:\Tang\com.8timer.www\src">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.eighttimer.service.dao" targetProject="D:\Tang\com.8timer.www\src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
<table tableName="test" domainObjectName="Test" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment