Commit 1bcd0c83 by xmh

注释

修改
1 parent 8a7417c4
......@@ -4,10 +4,9 @@ import com.github.pagehelper.PageInfo;
import com.viontech.keliu.util.JsonMessageUtil;
import com.viontech.label.platform.base.BaseExample;
import com.viontech.label.platform.controller.base.PackBaseController;
import com.viontech.label.platform.model.Pack;
import com.viontech.label.platform.model.PackExample;
import com.viontech.label.platform.model.User;
import com.viontech.label.platform.model.*;
import com.viontech.label.platform.model.entity.PackInfo;
import com.viontech.label.platform.service.adapter.SubTaskService;
import com.viontech.label.platform.service.adapter.UserService;
import com.viontech.label.platform.vo.PackVo;
import org.springframework.stereotype.Controller;
......@@ -25,6 +24,8 @@ public class PackController extends PackBaseController {
@Resource
private UserService userService;
@Resource
private SubTaskService subTaskService;
@Override
protected BaseExample getExample(PackVo packVo, int type) {
......@@ -76,19 +77,30 @@ public class PackController extends PackBaseController {
@GetMapping("/assignTo")
@ResponseBody
public JsonMessageUtil.JsonMessage assignTo(@RequestParam Long[] packIds, @RequestParam(required = false) Long taskId) {
List<Long> packIdList = Arrays.asList(packIds);
PackExample packExample = new PackExample();
packExample.createCriteria().andIdIn(Arrays.asList(packIds));
packExample.createCriteria().andIdIn(packIdList);
if (taskId == null) {
// todo 取消分配
List<Pack> packs = packService.selectByExample(packExample);
for (Pack pack : packs) {
// 将 pack 的 taskId 设为 null
pack.setTaskId(null);
packService.updateByPrimaryKey(pack);
}
} else {
// 为 pack 设置 taskId
Pack pack = new Pack();
pack.setTaskId(taskId);
packService.updateByExampleSelective(pack, packExample);
// 为 subTask 设置 taskId
SubTask subTask = new SubTask();
subTask.setTaskId(taskId);
SubTaskExample subTaskExample = new SubTaskExample();
subTaskExample.createCriteria().andPackIdIn(packIdList);
subTaskService.updateByExampleSelective(subTask, subTaskExample);
}
return JsonMessageUtil.getSuccessJsonMsg();
}
......
......@@ -252,11 +252,9 @@ public class ReidController {
}
@GetMapping("downloadLabeledPicAsZip")
public void downloadLabeledPicAsZip(@RequestParam Long packId, HttpServletResponse response) throws Exception {
public void downloadLabeledPicAsZip(@RequestParam Long packId, @RequestParam(required = false, defaultValue = "3") Integer status, HttpServletResponse response) throws Exception {
StpUtil.checkRole("super");
File file = reidService.downloadLabeledPicAsZip(packId);
File file = reidService.downloadLabeledPicAsZip(packId, status);
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition",
"attachment;filename=" + packId + ".zip");
......
......@@ -33,9 +33,9 @@ public interface LogMapper extends BaseMapper {
int updateByPrimaryKey(Log record);
@Select("<script> select \"max\"(s_user.username) as username,\"max\"(s_user.name) as name ,\"max\"(annotate_time) as finishTime ,person_unid as personUnid,count(*) as picNum, task_id as taskId " +
@Select("<script> select \"max\"(s_user.username) as username,s_user.name as name ,\"max\"(annotate_time) as finishTime ,person_unid as personUnid,count(*) as picNum, task_id as taskId " +
"from d_sub_task left join s_user on d_sub_task.annotator_id=s_user.id where pack_id in " +
" <foreach item='item' collection='packId' open='(' separator=',' close=')'> #{item ,jdbcType=NUMERIC} </foreach>" +
" and status=3 and annotate_time BETWEEN #{start} and #{end} group by task_id,person_unid </script>")
" and status=3 and annotate_time BETWEEN #{start} and #{end} group by task_id,person_unid,s_user.name </script>")
List<LogVo> exportLogByDateAndPack(List<Long> packId, Date start, Date end);
}
\ No newline at end of file
......@@ -34,6 +34,9 @@ public interface SubTaskMapper extends BaseMapper {
int updateByPrimaryKey(SubTask record);
@Update("update d_sub_task set task_id=null where pack_id=#{packId}")
void setTaskIdNullByPackId(long packId);
@Update("update d_sub_task set annotator_id = #{annotatorId} where id in (select id from d_sub_task where task_id= #{taskId} and annotator_id is null order by id OFFSET 0 limit #{count} )")
void assignAnnotators(long taskId, long annotatorId, long count);
......
......@@ -134,4 +134,13 @@ public class User extends BaseModel {
public void setAccount(Account account) {
this.account = account;
}
public boolean isInspector() {
return type != null && (type == 2 || type == 5);
}
public boolean isSuper() {
return type != null && type == 0;
}
}
\ No newline at end of file
......@@ -450,6 +450,11 @@ public class ReidService {
* 标记人为纯净的(修改人对应的所有的图片状态)
*/
public void finishLabeling(String personUnid, Long packId) {
User currentUser = userService.getCurrentUser();
if (currentUser.isInspector()) {
return;
}
SubTaskExample subTaskExample = new SubTaskExample();
subTaskExample.createCriteria().andPersonUnidEqualTo(personUnid).andPackIdEqualTo(packId);
......@@ -639,7 +644,10 @@ public class ReidService {
// 添加缓存
RMap<String, User> labelingSet = redissonClient.getMap("labeling:" + packId);
if (labelingSet.containsKey(personUnid)) {
return false;
User user = labelingSet.get(personUnid);
if (!user.getId().equals(currentUser.getId())) {
return false;
}
}
// 数据库更新状态
......@@ -685,6 +693,7 @@ public class ReidService {
String recoveryPersonUnid = null;
SubTaskExample subTaskExample = new SubTaskExample();
subTaskExample.createCriteria().andPackIdEqualTo(packId).andStatusEqualTo(SubTaskStatus.recycled.val);
subTaskExample.setOrderByClause("person_unid limit 1");
List<SubTask> subTasks = subTaskService.selectByExample(subTaskExample);
if (subTasks.size() > 0) {
recoveryPersonUnid = subTasks.get(0).getPersonUnid();
......@@ -836,12 +845,12 @@ public class ReidService {
return labelingSet.get(personUnid);
}
public File downloadLabeledPicAsZip(Long packId) throws Exception {
public File downloadLabeledPicAsZip(Long packId, Integer status) throws Exception {
File tempFile = File.createTempFile("label-" + packId, ".zip");
try (ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(tempFile))) {
SubTaskExample subTaskExample = new SubTaskExample();
subTaskExample.createCriteria().andPackIdEqualTo(packId).andStatusEqualTo(SubTaskStatus.FINISH_LABELING.val);
subTaskExample.createCriteria().andPackIdEqualTo(packId).andStatusEqualTo(status);
List<SubTask> allSubTask = subTaskService.selectByExample(subTaskExample);
Map<String, List<SubTask>> collect = allSubTask.stream().collect(Collectors.groupingBy(SubTask::getPersonUnid, Collectors.toList()));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!