Browse Source

修复 错误

zyh
小久哥 3 years ago
parent
commit
7380a37431
  1. 2
      yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
  2. 68
      yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/ListIntToListLongTypeHandler.java
  3. 18
      yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictAspect.java
  4. 4
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsg.java
  5. 269
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java
  6. 4
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgDTO.java
  7. 20
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgType.java
  8. 36
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgTypeEnum.java
  9. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java
  10. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExcelVO.java
  11. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExportReqVO.java
  12. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussPageReqVO.java
  13. 8
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java
  14. 1
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java
  15. 5
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java
  16. 7
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java
  17. 2
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaService.java
  18. 25
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaServiceImpl.java
  19. 7
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java
  20. 3
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java

2
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java

@ -42,7 +42,7 @@ import java.util.Map;
@MapperScans({ @MapperScans({
@MapperScan(basePackages ={"co.yixiang.**.service.mapper", "co.yixiang.config"},sqlSessionFactoryRef = "shangcheng"), @MapperScan(basePackages ={"co.yixiang.**.service.mapper", "co.yixiang.config"},sqlSessionFactoryRef = "shangcheng"),
@MapperScan(basePackages = {"com.zsw.erp.datasource.mappers"},sqlSessionFactoryRef = "erp"), @MapperScan(basePackages = {"com.zsw.erp.datasource.mappers"},sqlSessionFactoryRef = "erp"),
@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class, @MapperScan(basePackages = {"${yudao.info.base-package}", "cn.iocoder.yudao"}, annotationClass = Mapper.class,
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试 lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试
}) })
@Configuration @Configuration

68
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/handler/ListIntToListLongTypeHandler.java

@ -0,0 +1,68 @@
package cn.iocoder.yudao.framework.mybatis.core.handler;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* zyj
*/
@MappedJdbcTypes(JdbcType.VARCHAR) // 数据库中该字段存储的类型
@MappedTypes(List.class) // 需要转换的对象
public class ListIntToListLongTypeHandler extends BaseTypeHandler<List<Long>> {
private static ObjectMapper mObjectMapper = new ObjectMapper();
@Override
public void setNonNullParameter(PreparedStatement preparedStatement, int i, List<Long> longs, JdbcType jdbcType) throws SQLException {
String json = JSONUtil.toJsonStr(longs);
preparedStatement.setObject(i, json);
}
@Override
public List<Long> getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
String value = resultSet.getString(columnName);
return getLongs(value);
}
@Override
public List<Long> getNullableResult(ResultSet resultSet, int i) throws SQLException {
String value = resultSet.getString(i);
return getLongs(value);
}
@Override
public List<Long> getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
String value = callableStatement.getString(i);
return getLongs(value);
}
private List<Long> getLongs(String value) {
if (ObjectUtil.isNotEmpty(value)) {
try {
CollectionType type = mObjectMapper.getTypeFactory().constructCollectionType(ArrayList.class, Long.class);
List<Long> longs = mObjectMapper.readValue(value , type);
return longs;
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
return null;
}
}

18
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dict/DictAspect.java

@ -1,9 +1,11 @@
package cn.iocoder.yudao.module.system.dict; package cn.iocoder.yudao.module.system.dict;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.service.dict.DictDataService; import cn.iocoder.yudao.module.system.service.dict.DictDataService;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature; import com.alibaba.fastjson.parser.Feature;
@ -97,13 +99,15 @@ public class DictAspect {
for (Object record : ((PageResult) ((CommonResult) result).getData()).getList()) { for (Object record : ((PageResult) ((CommonResult) result).getData()).getList()) {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String json="{}"; // 1String json="{}";
try { String json = JSONUtil.toJsonStr(record);
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = mapper.writeValueAsString(record); // try {
} catch (JsonProcessingException e) { // //解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
log.error("json解析失败"+e.getMessage(),e); // json = mapper.writeValueAsString(record);
} // } catch (JsonProcessingException e) {
// log.error("json解析失败"+e.getMessage(),e);
// }
//update-begin--Author:scott -- Date:20211223 ----for:【issues/3303】restcontroller返回json数据后key顺序错乱 ----- //update-begin--Author:scott -- Date:20211223 ----for:【issues/3303】restcontroller返回json数据后key顺序错乱 -----
JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); JSONObject item = JSONObject.parseObject(json, Feature.OrderedField);
//update-end--Author:scott -- Date:20211223 ----for:【issues/3303】restcontroller返回json数据后key顺序错乱 ----- //update-end--Author:scott -- Date:20211223 ----for:【issues/3303】restcontroller返回json数据后key顺序错乱 -----

4
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsg.java

@ -11,9 +11,9 @@ import java.lang.annotation.*;
@Documented @Documented
public @interface FarmMsg { public @interface FarmMsg {
FarmMsgType type() default FarmMsgType.NONE; FarmMsgTypeEnum type() default FarmMsgTypeEnum.NONE;
FarmMsgType operation() default FarmMsgType.NONE; FarmMsgTypeEnum operation() default FarmMsgTypeEnum.NONE;
String title() default ""; String title() default "";

269
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgAspect.java

@ -2,34 +2,39 @@ package cn.iocoder.yudao.module.farm.annotation;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.farm.annotation.FarmMsg;
import cn.iocoder.yudao.module.farm.controller.admin.project.vo.ProjectCreateReqVO; import cn.iocoder.yudao.module.farm.controller.admin.project.vo.ProjectCreateReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.project.vo.ProjectRespVO; import cn.iocoder.yudao.module.farm.controller.admin.project.vo.ProjectRespVO;
import cn.iocoder.yudao.module.farm.controller.admin.project.vo.ProjectUpdateReqVO; import cn.iocoder.yudao.module.farm.controller.admin.project.vo.ProjectUpdateReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskCreateReqVO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskCreateReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskRespVO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskRespVO;
import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskUpdateReqVO; import cn.iocoder.yudao.module.farm.controller.admin.task.vo.TaskUpdateReqVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.logMsg.LogMsgDO; import cn.iocoder.yudao.module.farm.dal.dataobject.discuss.DiscussDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO; import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO; import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.taskCate.TaskCateDO; import cn.iocoder.yudao.module.farm.dal.dataobject.taskCate.TaskCateDO;
import cn.iocoder.yudao.module.farm.dal.mysql.discuss.DiscussMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.logMsg.LogMsgMapper; import cn.iocoder.yudao.module.farm.dal.mysql.logMsg.LogMsgMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.project.ProjectMapper; import cn.iocoder.yudao.module.farm.dal.mysql.project.ProjectMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.task.TaskMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.taskCate.TaskCateMapper; import cn.iocoder.yudao.module.farm.dal.mysql.taskCate.TaskCateMapper;
import cn.iocoder.yudao.module.farm.service.WxCpServiceNoticeService; import cn.iocoder.yudao.module.farm.service.WxCpServiceNoticeService;
import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.cp.api.WxCpMessageService;
import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.message.WxCpMessage; import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*; import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@ -47,11 +52,19 @@ public class FarmMsgAspect {
private TaskCateMapper taskCateMapper; private TaskCateMapper taskCateMapper;
@Resource @Resource
private ProjectMapper projectMapper; private ProjectMapper projectMapper;
@Resource
private DiscussMapper discussMapper;
@Resource
private TaskMapper taskMapper;
@Resource
private CpUserMapper cpUserMapper;
@Resource
private AdminUserMapper adminUserMapper;
@Resource @Resource
private WxCpServiceNoticeService wxCpServiceNoticeService; private WxCpServiceNoticeService wxCpServiceNoticeService;
@Autowired @Resource
private WxCpService wxCpService; private WxCpService wxCpService;
/** /**
@ -67,8 +80,8 @@ public class FarmMsgAspect {
Object object = pjp.proceed(); Object object = pjp.proceed();
if (object instanceof CommonResult){ if (object instanceof CommonResult){
// 只处理接口正常result // 只处理接口正常result
if (farmMsg.type() == FarmMsgType.NONE if (farmMsg.type() == FarmMsgTypeEnum.NONE
|| farmMsg.operation() == FarmMsgType.NONE || farmMsg.operation() == FarmMsgTypeEnum.NONE
|| ((CommonResult<?>) object).getCode()!=0 ){ || ((CommonResult<?>) object).getCode()!=0 ){
return object; return object;
} }
@ -76,15 +89,55 @@ public class FarmMsgAspect {
// 构造一个企业推送消息 // 构造一个企业推送消息
WxCpMessage message = new WxCpMessage(); WxCpMessage message = new WxCpMessage();
if (farmMsg.type() == FarmMsgType.PROJECT){ if (farmMsg.type() == FarmMsgTypeEnum.PROJECT){
if (farmMsg.operation() == FarmMsgType.CREATE){ if (farmMsg.operation() == FarmMsgTypeEnum.CREATE){
Long id = (Long) ((CommonResult<?>) object).getData(); Long id = (Long) ((CommonResult<?>) object).getData();
//处理所需要数据
MethodSignature signature = (MethodSignature) pjp.getSignature();
Method method = signature.getMethod();
FarmMsgDTO farmMsgDTO = this.assembleMsg(method, pjp.getArgs(), (CommonResult<?>) object);
//接受消息的人
String toUserStr = this.assembleCpUserId(farmMsg.type(), id);
//发起人
AdminUserDO adminUser = adminUserMapper.selectOne(AdminUserDO::getId, getLoginUserId());
CpUserDO user = cpUserMapper.selectOne(CpUserDO::getUserId, adminUser.getCpUserId());
StringBuilder description = new StringBuilder()
.append(user.getName())
.append(" ")
.append(farmMsgDTO.getOperation().getDesc())
.append(farmMsgDTO.getType().getDesc())
.append(":")
.append(farmMsgDTO.getTitle())
.append("(其中有你)");
if (!toUserStr.contains("WeiLaiKeQi")){
return object;
}
// 发企业微信 // 发企业微信
// 拼接全部的参与用户 WxCpMessageService wxCpMessageService = wxCpService.getMessageService();
message.setToUser("");
//把主题填充 //消息类型 必填 此处固定为 文本卡片
message.setTitle(""); message.setMsgType("textcard");
wxCpService.getMessageService().send(message); //企业应用id 必填
message.setAgentId(wxCpService.getWxCpConfigStorage().getAgentId());
//消息标题 必填
message.setTitle("回乡农场任务管理更新");
//消息描述 必填
message.setDescription(description.toString());
//点击后跳转链接 必填
message.setUrl("https://www.baidu.com");
//接受消息成员 选填
message.setToUser(toUserStr);
// WxCpMessageSendResult result = wxCpMessageService.send(message);
// log.info("企业微信消息发送结果:{}",result);
System.out.println(message);
} }
// 跟新项目 删除项目 更新任务 删除任务。。。 // 跟新项目 删除项目 更新任务 删除任务。。。
@ -100,107 +153,95 @@ public class FarmMsgAspect {
return object; return object;
} }
// @Before(value = "farmMsgPointCut()")
// public void beforeSaveFarmMsg(JoinPoint joinPoint){
// MethodSignature signature = (MethodSignature) joinPoint.getSignature();
// Method method = signature.getMethod();
// FarmMsg farmMsg = method.getAnnotation(FarmMsg.class);
//
// if (method.getName().startsWith("get")){
// if (farmMsg.type().equals("任务")){
//
// }else if (farmMsg.type().equals("项目")){
//
// }
// }
//
// }
/** /**
* 拦截用户操作日志, 连接点执行完成后记录 如果连接点异常,则不会执行 * @Description 获取需要接受信息的成员
* @param jointPoint 切入点 * @param id 可能是 projectId taskId discussId
**/ **/
public String assembleCpUserId(FarmMsgTypeEnum farmMsgType, Long id){
List<Long> idList = new ArrayList<>();
if (farmMsgType.equals(FarmMsgTypeEnum.PROJECT)){
ProjectDO project = projectMapper.selectOne(ProjectDO::getId, id);
idList.addAll(project.getMembers().toJavaList(Long.class));
}else if (farmMsgType.equals(FarmMsgTypeEnum.TASK)){
TaskDO task = taskMapper.selectOne(TaskDO::getId, id);
idList.add(task.getMainPerson());
idList.addAll(task.getExecutorPerson().toJavaList(Long.class));
}else if (farmMsgType.equals(FarmMsgTypeEnum.DISCUSS)){
DiscussDO discuss = discussMapper.selectOne(DiscussDO::getId, id);
TaskDO task = taskMapper.selectOne(TaskDO::getId, discuss.getId());
idList.add(task.getMainPerson());
idList.addAll(task.getExecutorPerson().toJavaList(Long.class));
}
StringBuilder builder = new StringBuilder();
List<CpUserDO> userList = cpUserMapper.selectList(CpUserDO::getId, idList);
userList.forEach(user ->{
builder.append(user.getUserId()).append("|");
});
return builder.toString().substring(0, builder.length() -1);
}
public FarmMsgDTO assembleMsg(Method method, Object[] objects, Object result){
String title = "";
String msg = "";
// @AfterReturning(value = "farmMsgPointCut()", returning = "result") FarmMsg farmMsg = method.getAnnotation(FarmMsg.class);
// public void afterSaveFarmMsg(JoinPoint jointPoint, Object result){ if (method.getName().startsWith("get")){
// //从切入点通过反射获取切入点方法 for (Object object : objects) {
// MethodSignature signature = (MethodSignature) jointPoint.getSignature(); log.info("after用户{},{},{},{}",getLoginUserId(), farmMsg.type(), farmMsg.title(), object);
// //获取切入点的方法 if (farmMsg.type().equals(FarmMsgTypeEnum.PROJECT)){
// Method method = signature.getMethod(); CommonResult<ProjectRespVO> projectDO = (CommonResult<ProjectRespVO>) result;
// title = projectDO.getData().getName();
// FarmMsgDTO farmMsgDTO = this.assembleMsg(method, jointPoint.getArgs(), result); }
// if (farmMsg.type().equals(FarmMsgTypeEnum.TASK)){
// //插入农场日志信息 CommonResult<TaskRespVO> taskDO = (CommonResult<TaskRespVO>) result;
// LogMsgDO logMsg = LogMsgDO.builder() ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getData().getProjectId());
// .type(farmMsgDTO.getType()) TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getData().getTaskCateId());
// .operation(farmMsgDTO.getOperation()) title = project.getName();
// .title(farmMsgDTO.getTitle()) msg = taskCate.getName();
// .msg(farmMsgDTO.getMsg()) }
// .userId(getLoginUserId()) }
// .build(); }
// logMsgMapper.insert(logMsg);
// } if (method.getName().startsWith("update")){
for (Object object : objects) {
// public FarmMsgDTO assembleMsg(Method method, Object[] objects, Object result){ if (farmMsg.type().equals(FarmMsgTypeEnum.PROJECT)){
// String title = ""; ProjectUpdateReqVO projectDO = (ProjectUpdateReqVO) object;
// String msg = ""; title = projectDO.getName();
// }
// FarmMsg farmMsg = method.getAnnotation(FarmMsg.class); if (farmMsg.type().equals(FarmMsgTypeEnum.TASK)){
// if (method.getName().startsWith("get")){ TaskUpdateReqVO taskDO = (TaskUpdateReqVO) object;
// for (Object object : objects) { ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId());
// log.info("after用户{},{},{},{}",getLoginUserId(), farmMsg.type(), farmMsg.title(), object); title = project.getName();
// if (farmMsg.type().equals("项目")){ TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId());
// CommonResult<ProjectRespVO> projectDO = (CommonResult<ProjectRespVO>) result; msg = taskCate.getName();
// title = projectDO.getData().getName(); }
// } }
// if (farmMsg.type().equals("任务")){ }
// CommonResult<TaskRespVO> taskDO = (CommonResult<TaskRespVO>) result;
// ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getData().getProjectId()); if (method.getName().startsWith("create")){
// TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getData().getTaskCateId()); for (Object object : objects){
// title = project.getName(); if (farmMsg.type().equals(FarmMsgTypeEnum.PROJECT)){
// msg = taskCate.getName(); ProjectCreateReqVO projectDO = (ProjectCreateReqVO) object;
// } title = projectDO.getName();
// } }
// } if (farmMsg.type().equals(FarmMsgTypeEnum.TASK)){
// TaskCreateReqVO taskDO = (TaskCreateReqVO) object;
// if (method.getName().startsWith("update")){ ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId());
// for (Object object : objects) { title = project.getName();
// if (farmMsg.type().equals("项目")){ TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId());
// ProjectUpdateReqVO projectDO = (ProjectUpdateReqVO) object; msg = taskCate.getName();
// title = projectDO.getName(); }
// } }
// if (farmMsg.type().equals("任务")){ }
// TaskUpdateReqVO taskDO = (TaskUpdateReqVO) object;
// ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId()); FarmMsgDTO farmMsgDTO = FarmMsgDTO.builder()
// title = project.getName(); .type(FarmMsgTypeEnum.getDescBtType(farmMsg.type()))
// TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId()); .operation(FarmMsgTypeEnum.getDescBtType(farmMsg.operation()))
// msg = taskCate.getName(); .title(title)
// } .msg(msg).build();
// } return farmMsgDTO;
// } }
//
// if (method.getName().startsWith("create")){
// for (Object object : objects){
// if (farmMsg.type().equals("项目")){
// ProjectCreateReqVO projectDO = (ProjectCreateReqVO) object;
// title = projectDO.getName();
// }
// if (farmMsg.type().equals("任务")){
// TaskCreateReqVO taskDO = (TaskCreateReqVO) object;
// ProjectDO project = projectMapper.selectOne(ProjectDO::getId, taskDO.getProjectId());
// title = project.getName();
// TaskCateDO taskCate = taskCateMapper.selectOne(TaskCateDO::getId, taskDO.getTaskCateId());
// msg = taskCate.getName();
// }
// }
// }
//
// FarmMsgDTO farmMsgDTO = FarmMsgDTO.builder()
// .type(farmMsg.type())
// .operation(farmMsg.operation())
// .title(title)
// .msg(msg).build();
// return farmMsgDTO;
// }
} }

4
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgDTO.java

@ -10,9 +10,9 @@ import lombok.Data;
@Builder @Builder
public class FarmMsgDTO { public class FarmMsgDTO {
private String type; private FarmMsgTypeEnum type;
private String operation; private FarmMsgTypeEnum operation;
private String title; private String title;

20
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgType.java

@ -1,20 +0,0 @@
package cn.iocoder.yudao.module.farm.annotation;
import lombok.Getter;
@Getter
public enum FarmMsgType {
PROJECT,
TASK,
DISCUSS,
CREATE,
UPDATE,
SELECT,
EDIT,
DELETE,
NONE;
}

36
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/annotation/FarmMsgTypeEnum.java

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.farm.annotation;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.stream.Stream;
@Getter
@AllArgsConstructor
public enum FarmMsgTypeEnum {
PROJECT("项目"),
TASK("任务"),
DISCUSS("活动"),
CREATE("创建"),
UPDATE("更新"),
SELECT("查看"),
EDIT("编辑"),
DELETE("删除"),
NONE("无意义");
/**
* 条件
*/
private final String desc;
public static FarmMsgTypeEnum getDescBtType(FarmMsgTypeEnum msgType) {
return Stream.of(FarmMsgTypeEnum.values())
.filter(p -> p.equals(msgType))
.findAny()
.orElse(null);
}
}

2
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussBaseVO.java

@ -30,7 +30,7 @@ public class DiscussBaseVO {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
private List<String> images; private List<String> images;
private JSONArray areas; private List<Long> areas;
private Integer cropNum; private Integer cropNum;

2
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExcelVO.java

@ -33,7 +33,7 @@ public class DiscussExcelVO {
@ExcelProperty("") @ExcelProperty("")
private List<String> images; private List<String> images;
private JSONArray areas; private List<Long> areas;
private Integer cropNum; private Integer cropNum;

2
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussExportReqVO.java

@ -25,7 +25,7 @@ public class DiscussExportReqVO {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
private String images; private String images;
private JSONArray areas; private List<Long> areas;
private Integer cropNum; private Integer cropNum;

2
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/vo/DiscussPageReqVO.java

@ -27,7 +27,7 @@ public class DiscussPageReqVO extends PageParam {
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
private String images; private String images;
private JSONArray areas; private List<Long> areas;
private Integer cropNum; private Integer cropNum;

8
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/project/ProjectController.java

@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.farm.controller.admin.project;
import cn.iocoder.yudao.framework.common.page.PageVO; import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.annotation.FarmMsg; import cn.iocoder.yudao.module.farm.annotation.FarmMsg;
import cn.iocoder.yudao.module.farm.annotation.FarmMsgType; import cn.iocoder.yudao.module.farm.annotation.FarmMsgTypeEnum;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO;
import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectPageDTO;
import com.zsw.base.R; import com.zsw.base.R;
@ -40,7 +40,7 @@ public class ProjectController {
@Resource @Resource
private ProjectService projectService; private ProjectService projectService;
@FarmMsg(type = FarmMsgType.PROJECT, operation = FarmMsgType.CREATE) @FarmMsg(type = FarmMsgTypeEnum.PROJECT, operation = FarmMsgTypeEnum.CREATE)
@PostMapping("/create") @PostMapping("/create")
@ApiOperation("创建农场项目") @ApiOperation("创建农场项目")
@PreAuthorize("@ss.hasPermission('farm:project:create')") @PreAuthorize("@ss.hasPermission('farm:project:create')")
@ -48,7 +48,7 @@ public class ProjectController {
return success(projectService.createProject(createReqVO)); return success(projectService.createProject(createReqVO));
} }
@FarmMsg(type = FarmMsgType.PROJECT, operation = FarmMsgType.UPDATE) @FarmMsg(type = FarmMsgTypeEnum.PROJECT, operation = FarmMsgTypeEnum.UPDATE)
@PutMapping("/update") @PutMapping("/update")
@ApiOperation("更新农场项目") @ApiOperation("更新农场项目")
@PreAuthorize("@ss.hasPermission('farm:project:update')") @PreAuthorize("@ss.hasPermission('farm:project:update')")
@ -57,7 +57,7 @@ public class ProjectController {
return success(true); return success(true);
} }
@FarmMsg(type = FarmMsgType.PROJECT,operation = FarmMsgType.DELETE) @FarmMsg(type = FarmMsgTypeEnum.PROJECT,operation = FarmMsgTypeEnum.DELETE)
@DeleteMapping("/delete") @DeleteMapping("/delete")
@ApiOperation("删除农场项目") @ApiOperation("删除农场项目")
@ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)

1
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/TaskController.java

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.farm.controller.admin.task; package cn.iocoder.yudao.module.farm.controller.admin.task;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.page.PageVO; import cn.iocoder.yudao.framework.common.page.PageVO;
import cn.iocoder.yudao.module.farm.annotation.FarmMsg; import cn.iocoder.yudao.module.farm.annotation.FarmMsg;

5
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/discuss/DiscussDO.java

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.farm.dal.dataobject.discuss; package cn.iocoder.yudao.module.farm.dal.dataobject.discuss;
import cn.iocoder.yudao.framework.mybatis.core.handler.ListIntToListLongTypeHandler;
import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.WorkHourBaseVO; import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.WorkHourBaseVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO; import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
@ -51,8 +52,8 @@ public class DiscussDO extends BaseDO {
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = JacksonTypeHandler.class)
private List<String> images; private List<String> images;
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = ListIntToListLongTypeHandler.class)
private JSONArray areas; private List<Long> areas;
private Integer cropNum; private Integer cropNum;

7
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/task/TaskDO.java

@ -1,14 +1,19 @@
package cn.iocoder.yudao.module.farm.dal.dataobject.task; package cn.iocoder.yudao.module.farm.dal.dataobject.task;
import cn.iocoder.yudao.framework.mybatis.core.handler.ListIntToListLongTypeHandler;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import cn.iocoder.yudao.module.farm.enums.TaskStatus; import cn.iocoder.yudao.module.farm.enums.TaskStatus;
import lombok.*; import lombok.*;
import java.sql.JDBCType;
import java.sql.Types;
import java.util.*; import java.util.*;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import org.apache.ibatis.type.JdbcType;
/** /**
* 农场项目 DO * 农场项目 DO
@ -53,7 +58,7 @@ public class TaskDO extends BaseDO {
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = JacksonTypeHandler.class)
private JSONArray resources; private JSONArray resources;
@ApiModelProperty("子区域") @ApiModelProperty("子区域")
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = ListIntToListLongTypeHandler.class)
private List<Long> areas; private List<Long> areas;
@ApiModelProperty("任务图片") @ApiModelProperty("任务图片")

2
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaService.java

@ -72,6 +72,6 @@ public interface AreaService {
/** /**
* 根据区域 返回区域信息List * 根据区域 返回区域信息List
**/ **/
public List<String> findAreaName(List<AreaDO> areaList, JSONArray areaArray); List<String> findAreaName(List<AreaDO> areaList, List<Long> areaArray);
} }

25
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/area/AreaServiceImpl.java

@ -92,28 +92,23 @@ public class AreaServiceImpl implements AreaService {
/** /**
* 根据区域 返回区域信息List * 根据区域 返回区域信息List
**/ **/
public List<String> findAreaName(List<AreaDO> areaList, JSONArray areaArray){ public List<String> findAreaName(List<AreaDO> areaList, List<Long> areaArray){
List<String> areaNameList = new ArrayList<>(); List<String> areaNameList = new ArrayList<>();
JSONArray array = JSONArray.parseArray(areaArray.toString()); for (Long aLong : areaArray) {
for (Object selectArea : array) {
JSONArray array123 = JSONArray.parseArray(JSON.toJSONString( selectArea));
Long areaParent = Long.valueOf(String.valueOf(array123.get(0)));
Long areaSon = Long.valueOf(String.valueOf(array123.get(1)));
StringBuilder areaName = new StringBuilder();
for (AreaDO areaDO : areaList) { for (AreaDO areaDO : areaList) {
if (areaDO.getId().equals(areaParent)){ if (areaDO.getId().equals(aLong)){
areaName.append(areaDO.getName()); //拿到二级区域
} areaList.stream().filter(parentArea -> parentArea.getId().equals(areaDO.getParentId())).findFirst().ifPresent(
if (areaDO.getId().equals(areaSon)){ p ->{
areaName.append(areaDO.getName()); //在拿到一级区域
StringBuilder areaName = new StringBuilder().append(p.getName()).append(":").append(areaDO.getName());
areaNameList.add(areaName.toString());
} }
);
} }
if (ObjectUtil.isNotEmpty(areaName)){
areaNameList.add(areaName.toString());
} }
} }
return areaNameList; return areaNameList;
} }
} }

7
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java

@ -95,7 +95,12 @@ public class DiscussServiceImpl implements DiscussService {
//插入工时记录 //插入工时记录
workHourMapper.insertBatch(workSaveList); workHourMapper.insertBatch(workSaveList);
//更新员工工时合计 //更新员工工时合计
cpUserService.updateBatchById(userList); //todo service有问题
// cpUserService.updateBatchById(userList);
userList.stream().forEach(item ->{
cpUserMapper.updateById(item);
});
} }
// 返回 // 返回

3
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java

@ -188,11 +188,14 @@ public class TaskServiceImpl implements TaskService {
List<DiscussDO> discussDOList = discussMapper.selectList(DiscussDO::getTaskId, id); List<DiscussDO> discussDOList = discussMapper.selectList(DiscussDO::getTaskId, id);
taskMsg.setCumulativeQuantity(ObjectUtil.isEmpty(discussDOList) ? 0 : discussDOList.stream().mapToInt(DiscussDO::getCropNum).sum()); taskMsg.setCumulativeQuantity(ObjectUtil.isEmpty(discussDOList) ? 0 : discussDOList.stream().mapToInt(DiscussDO::getCropNum).sum());
//已选择的二级区域 //已选择的二级区域
if (ObjectUtil.isNotEmpty(taskDO.getAreas())){
List<AreaDO> secondAreaList = areaMapper.selectList(AreaDO::getId, taskDO.getAreas()); List<AreaDO> secondAreaList = areaMapper.selectList(AreaDO::getId, taskDO.getAreas());
taskMsg.setSecondAreaList(secondAreaList); taskMsg.setSecondAreaList(secondAreaList);
List<Long> parendIdList = secondAreaList.stream().map(AreaDO::getParentId).collect(Collectors.toList()); List<Long> parendIdList = secondAreaList.stream().map(AreaDO::getParentId).collect(Collectors.toList());
List<AreaDO> firstAreaList = areaMapper.selectList(AreaDO::getId, parendIdList); List<AreaDO> firstAreaList = areaMapper.selectList(AreaDO::getId, parendIdList);
taskMsg.setFirstAreaList(firstAreaList); taskMsg.setFirstAreaList(firstAreaList);
}
return R.success(taskMsg); return R.success(taskMsg);
} }

Loading…
Cancel
Save