Commit 55f255a1 by chenweisong

更新

parent aa03019a
package com.keymobile.rest.common.utils;
import com.keymobile.rest.model.Activity;
import com.keymobile.rest.vo.TaskForm;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Field;
@Slf4j
public class BeanUtils {
private BeanUtils() {
throw new RuntimeException("别乱搞");
}
public static <O, T> T convertTo(O o, T t) {
Class tClazz = t.getClass();
Field[] fields = tClazz.getDeclaredFields();
for (Field field : fields) {
Field accessField;
try {
Class oClazz = o.getClass();
accessField = oClazz.getDeclaredField(field.getName());
// 下面是很关键的一部,如果没有这一步,就会出错(访问权限不够)
// 修改访问权限
accessField.setAccessible(true);
Object hisValue = accessField.get(o);
field.setAccessible(true);
field.set(t, hisValue);
} catch (NoSuchFieldException | IllegalAccessException e) {
// log.info("convert error {}", e.getMessage());
}
}
return t;
}
public static void main(String[] args) throws IllegalAccessException, NoSuchFieldException, InstantiationException {
TaskForm form = new TaskForm();
Activity activity = new Activity();
form.setName("asdasdas");
form.setRemark("asdasdas");
form.setFreq(4);
convertTo(form, activity);
System.out.printf(activity.getName() + "***********************" + activity.getRemark() + "***********************" + activity.getFreq());
}
}
......@@ -4,9 +4,7 @@ import com.keymobile.rest.common.bean.ApiResponse;
import com.keymobile.rest.service.TemplateService;
import com.keymobile.rest.service.MissionService;
import com.keymobile.rest.service.UserService;
import com.keymobile.rest.vo.RecordDataForm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.*;
import org.activiti.engine.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -26,9 +24,13 @@ public class ExcelController {
private TaskService taskService;
@ApiOperation(value = "填写补录数据")
@ApiOperation(value = "当前补录任务填写补录")
@ApiImplicitParams({
@ApiImplicitParam(name = "excelId", required = true, value = "当前模板id", dataType = "long", paramType = "query"),
@ApiImplicitParam(name = "dataStr", required = true, value = "当前数据字符", dataType = "string", paramType = "query")
})
@PostMapping(value = "/excel/saveData")
public ApiResponse saveRecordData(@RequestBody RecordDataForm form) {
public ApiResponse saveRecordData(long excelId, String dataStr) {
// User curUser = userService.getNormalUser();
// Template template = excelService.get(form.getExcelId());
// ProcessInfo processInfo = jobInfoService.findByExcelIdAndUserId(form.getExcelId(), curUser.getId());
......@@ -51,8 +53,11 @@ public class ExcelController {
}
@ApiOperation(value = "传excelId过来,获取用户填写的数据")
@ApiImplicitParams(
@ApiImplicitParam(name = "excelId", required = true, value = "当前模板id", dataType = "long", paramType = "query")
)
@PostMapping(value = "/excel/getData")
public ApiResponse getRecordData(@RequestParam long excelId) {
public ApiResponse getRecordData(long excelId) {
// User curUser = userService.getNormalUser();
// ProcessInfo processInfo = processInfoService.findByExcelIdAndUserId(excelId, curUser.getId());
//
......
......@@ -17,13 +17,13 @@ import java.util.*;
@RestController
@RequestMapping(path = "/api")
public class UserController {
@Autowired
private UserService userService;
@Autowired
private GroupService groupService;
@Autowired
private RecordScopeService recordScopeService;
private Group root = new Group();
{
......@@ -59,7 +59,9 @@ public class UserController {
User user = userService.findById(userId);
TwinkleValidator.notNull(user, "所选用户不存在");
TwinkleValidator.isTrue(scope.getGroup().getId() == user.getGroup().getId(), "所选用户与所选范围不属于同一机构");
scope.setUser(user);
List<User> userList = scope.getUserList();
userList.add(user);
scope.setUserList(userList);
recordScopeService.update(scope);
return ApiResponse.ok();
}
......
......@@ -3,8 +3,11 @@ package com.keymobile.rest.dao;
import com.keymobile.rest.model.Mission;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface MissionDao extends JpaRepository<Mission, Long> {
List<Mission> findAllByTemplateIdAAndStatus(long templateId, int status);
}
......@@ -8,5 +8,7 @@ import java.util.List;
public interface UserDao extends JpaRepository<User, Long> {
List<User> findAllByIdIn(List<Long> ids);
List<User> findAllByUsername(String username);
List<User> findAllByGroupId(long groupId);
}
......@@ -26,7 +26,7 @@ public class Activity implements Serializable {
public static int TYPE_AUTO = 2;
public static int TYPE_MANUAL = 1;
// 报送频度 按年 按年 按周 按月 按日 自动推送
// 报送频度 按年 按周 按月 按日 自动推送
public static int FREQ_YEAR = 1;
public static int FREQ_WEEK = 2;
public static int FREQ_MONTH = 3;
......@@ -34,19 +34,19 @@ public class Activity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private Long id;
@Column(nullable = false, columnDefinition = ("varchar(100) comment '活动名'"))
private String name;
@Column(nullable = false, columnDefinition = ("integer(2) default 1 comment '下发方式'"))
private int type;
private Integer type;
@Column(columnDefinition = ("varchar(200) comment '备注'"))
private String remark;
@Column(columnDefinition = ("integer(2) comment '频度'"))
private int freq;
private Integer freq;
@Column(nullable = false, name = "create_at")
@CreationTimestamp
......
......@@ -22,7 +22,7 @@ public class DataInfo implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private Long id;
@Column(nullable = false, columnDefinition = ("varchar(3000) comment '填写的数据'"))
private String data;
......
......@@ -38,10 +38,6 @@ public class Group implements Serializable {
@Column(name = "parent_id", columnDefinition = ("bigint(22) default 0 comment '父机构id'"))
private long parentId;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "group")
@JsonIgnore
private List<RecordScope> recordScopeList;
@Transient
private List<Group> children;
......
package com.keymobile.rest.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSetter;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
/**
* @name 补录范围
......@@ -30,8 +33,15 @@ public class RecordScope implements Serializable {
private int role;
@ManyToOne(fetch = FetchType.EAGER)
@JsonIgnore
private Group group;
@ManyToOne
private User user;
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "t_user_record_scope", // 用来指定中间表的名称
//用于指定本表在中间表的字段名称,以及中间表依赖的是本表的哪个字段
joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
//用于指定对方表在中间表的字段名称,以及中间表依赖的是它的哪个字段
inverseJoinColumns = {@JoinColumn(name = "record_scope", referencedColumnName = "id")}
)
private List<User> userList;
}
......@@ -53,10 +53,10 @@ public class Template implements Serializable {
private int needMerge;
@Column(name = "up_stream_addr", columnDefinition = ("varchar(100) comment '上游地址'"))
private int upStreamAddr;
private String upStreamAddr;
@Column(name = "back_stream_addr", columnDefinition = ("varchar(100) comment '回流地址'"))
private int backStreamAddr;
private String backStreamAddr;
@Column(columnDefinition = ("varchar(200) comment '备注'"))
private String remark;
......
......@@ -31,11 +31,4 @@ public class User implements Serializable {
*/
@ManyToOne(fetch = FetchType.EAGER)
private Group group;
/**
* 关联的补录范围
*/
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
@JsonIgnore
private List<RecordScope> recordScopeList;
}
......@@ -3,7 +3,7 @@ package com.keymobile.rest.service;
import com.keymobile.rest.common.utils.DateUtil;
import com.keymobile.rest.dao.ActivityDao;
import com.keymobile.rest.model.Activity;
import com.keymobile.rest.vo.JobForm;
import com.keymobile.rest.vo.TaskForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
......@@ -31,20 +31,6 @@ public class ActivityService {
return activityDao.save(activity);
}
public Activity save(JobForm form) {
Activity activity = new Activity();
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
activity.setCreateAt(now);
activity.setName(form.getName());
activity.setType(form.getType());
if (form.getType() == Activity.TYPE_AUTO) {
}
activity.setUser(form.getUser());
activity = activityDao.save(activity);
return activity;
}
public Activity findByProcessId(String pid) {
return null;
}
......
......@@ -3,7 +3,6 @@ package com.keymobile.rest.service;
import com.keymobile.rest.common.utils.DateUtil;
import com.keymobile.rest.dao.*;
import com.keymobile.rest.model.DataInfo;
import com.keymobile.rest.vo.RecordDataForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -19,18 +18,18 @@ public class DataInfoService {
return dataInfoDao.getOne(id);
}
public DataInfo save(RecordDataForm form) {
DataInfo data = new DataInfo();
data.setMission(form.getMission());
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
data.setCreateAt(now);
data = dataInfoDao.save(data);
return data;
}
// public DataInfo save(RecordDataForm form) {
// DataInfo data = new DataInfo();
// data.setMission(form.getMission());
// Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
// data.setCreateAt(now);
// data = dataInfoDao.save(data);
// return data;
// }
public DataInfo update(RecordDataForm form) {
DataInfo data = this.get(form.getDataId());
data = dataInfoDao.save(data);
return data;
}
// public DataInfo update(RecordDataForm form) {
// DataInfo data = this.get(form.getDataId());
// data = dataInfoDao.save(data);
// return data;
// }
}
package com.keymobile.activiti.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.activiti.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Service;
@Service
public class GroupDataStandardServiceImpl {
public List<String> findAssigneesForProcess(DelegateExecution execution, String groupsString) {
System.out.println(groupsString);
String[] groups = groupsString.split(",");
return this.getAssignessByGroup(groups);
}
private List<String> getAssignessByGroup(String[] groups) {
List<String> assignees = new ArrayList<>();
for (String group : groups) {
if ("group1".equals(group)) {
assignees.addAll(Arrays.asList("root"));
}
if ("group2".equals(group)) {
assignees.addAll(Arrays.asList("root"));
}
if ("group3".equals(group)) {
assignees.addAll(Arrays.asList("root"));
}
if ("group4".equals(group)) {
assignees.addAll(Arrays.asList("root"));
}
if ("group5".equals(group)) {
assignees.addAll(Arrays.asList("root"));
}
if ("group6".equals(group)) {
assignees.addAll(Arrays.asList("root"));
}
if ("group7".equals(group)) {
assignees.addAll(Arrays.asList("root"));
}
if ("group8".equals(group)) {
assignees.addAll(Arrays.asList("root"));
}
}
return assignees;
}
}
\ No newline at end of file
......@@ -20,6 +20,8 @@ public class MissionService {
public Mission save(User user, Template template) {
Mission info = new Mission();
info.setTemplate(template);
// 初始的开始状态
info.setStatus(Mission.STATUS_BEGIN);
info.setUser(user);
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
info.setCreateAt(now);
......@@ -27,8 +29,8 @@ public class MissionService {
return info;
}
public List<Mission> findAllByTemplateId(long eid) {
return null;
public List<Mission> findAllByTemplateIdAndStatus(long templateId, int status) {
return missionDao.findAllByTemplateIdAAndStatus(templateId, status);
}
}
......@@ -16,25 +16,13 @@ public class TemplateService {
@Autowired
private TemplateDao templateDao;
public Template save(ExcelForm form) {
Template template = new Template();
template.setName(form.getName());
template.setDataAt(1);
template.setConfig(form.getConfig());
template.setRemark(form.getRemark());
template.setActivity(form.getActivity());
Timestamp now = Timestamp.valueOf(DateUtil.getDateTime());
template.setCreateAt(now);
template = templateDao.save(template);
return template;
}
public Template get(long id) {
return templateDao.getOne(id);
}
public void update(Template template) {
public Template save(Template template) {
templateDao.save(template);
return template;
}
public List<Template> findAllByIdIn(List<Long> ids) {
......
......@@ -13,6 +13,15 @@ public class UserService {
@Autowired
private UserDao userDao;
public List<User> findAllByUsername(String username) {
return userDao.findAllByUsername(username);
}
public List<User> findAllByGroupId(long groupId) {
return userDao.findAllByGroupId(groupId);
}
public List<User> findAllByIdIn(List<Long> ids) {
return userDao.findAllByIdIn(ids);
}
......
......@@ -12,27 +12,42 @@ import java.util.List;
@ApiModel
public class ExcelForm {
@ApiModelProperty(name = "id", value = "表格id,修改的时候需要用到")
private Long id;
@ApiModelProperty(required = true, name = "scopeId", value = "补录范围id")
private Long scopeId;
@ApiModelProperty(required = true, name = "userIds", value = "补录人员ids, 用逗号隔开")
@ApiModelProperty(required = true, name = "userIds", value = "补录人员ids, 用逗号隔开", hidden = true)
private String userIds;
@ApiModelProperty(required = true, name = "userIdList", value = "补录人员id集合", hidden = true)
private List<Long> userIdList;
@ApiModelProperty(name = "remark", value = "表格名称", required = true)
@ApiModelProperty(name = "remark", value = "模板名称", required = true)
private String name;
@ApiModelProperty(name = "config", value = "表格配置", required = true)
@ApiModelProperty(name = "config", value = "模板配置", required = true)
private String config;
@ApiModelProperty(name = "remark", value = "表格描述")
private String remark;
@ApiModelProperty(name = "dataAt", value = "数据开始", example = "1")
@ApiModelProperty(name = "dataAt", value = "数据开始行数", example = "1")
private Integer dataAt;
@ApiModelProperty(name = "needAudit", value = "需要审核", required = true, example = "1")
private Integer needAudit;
@ApiModelProperty(name = "needConfirm", value = "需要负责人确认", required = true, example = "1")
private Integer needConfirm;
@ApiModelProperty(name = "needMerge", value = "需要数据合并", example = "1")
private Integer needMerge;
@ApiModelProperty(name = "upStreamAddr", value = "上游地址 与 回流地址 同时填写")
private String upStreamAddr;
@ApiModelProperty(name = "backStreamAddr", value = "回流地址 与 上流地址 同时填写")
private String backStreamAddr;
@JsonIgnore
private Activity activity;
}
package com.keymobile.rest.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.keymobile.rest.model.Mission;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel
public class RecordDataForm {
@ApiModelProperty(name = "dataId", value = "修改数据记录时回填")
private Long dataId;
@ApiModelProperty(required = true, name = "excelId", value = "当前模板id")
private long excelId;
@ApiModelProperty(required = true, name = "dataStr", value = "当前数据字符")
private String dataStr;
@ApiModelProperty(required = true, name = "dataList", value = "当前数据数组", hidden = true)
private List<Object> dataList;
@JsonIgnore
private Mission mission;
}
......@@ -6,28 +6,24 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
@ApiModel
public class JobForm {
@ApiModelProperty(name = "id", value = "收数id,修改的时候需要用到")
private Long id;
public class TaskForm {
@ApiModelProperty(required = true, name = "name", value = "收数名称")
private String name;
@ApiModelProperty(name = "remark", value = "收数描述")
private String remark;
@ApiModelProperty(required = true, name = "type", value = "收数类型 1手动 2自动", example = "1")
private Integer type;
@ApiModelProperty(name = "startAt", value = "自动发起需要提写的时间", hidden = true)
private String startAt;
@ApiModelProperty(name = "freq", value = "频度 按年 1 按周 2 按月 3 按日 4", example = "1")
private Integer freq;
@ApiModelProperty(name = "remark", value = "收数描述")
private String remark;
@ApiModelProperty(required = true, name = "excels", value = "新建的模板配置数组")
private List<ExcelForm> excels;
......
......@@ -17,8 +17,8 @@ spring:
jpa:
show-sql: true
database-platform: org.hibernate.dialect.MySQL5Dialect
# hibernate:
# ddl-auto: update
hibernate:
ddl-auto: update
datasource:
url: jdbc:mysql://47.105.193.165:3306/dev0?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=GMT%2B8
username: root
......
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