上传照片
This commit is contained in:
+7
@@ -3,6 +3,7 @@ package com.njzscloud.supervisory.tsp.controller;
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.supervisory.tsp.pojo.ObtainStatusParam;
|
||||
import com.njzscloud.supervisory.tsp.pojo.TspPhotoEntity;
|
||||
import com.njzscloud.supervisory.tsp.pojo.TspPhotoSaveParam;
|
||||
import com.njzscloud.supervisory.tsp.pojo.TspPhotoSearchParam;
|
||||
@@ -12,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 临时收纳点图片
|
||||
@@ -85,6 +87,11 @@ public class TspPhotoController {
|
||||
return R.success(tspPhotoService.listPhoto(tspPhotoSearchParam));
|
||||
}
|
||||
|
||||
@GetMapping("/obtain_status")
|
||||
public R<Map<String, Integer>> obtainStatus(ObtainStatusParam obtainStatusParam) {
|
||||
return R.success(tspPhotoService.obtainStatus(obtainStatusParam));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njzscloud.supervisory.tsp.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class ObtainStatusParam {
|
||||
/**
|
||||
* 临时收纳点 Id
|
||||
*/
|
||||
private Long tspId;
|
||||
|
||||
private LocalDate uploadDate;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.njzscloud.supervisory.tsp.pojo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
public class ObtainStatusResult {
|
||||
|
||||
private Integer day;
|
||||
|
||||
private List<String> photos;
|
||||
}
|
||||
@@ -43,6 +43,11 @@ public class TspPhotoEntity {
|
||||
@TableField(typeHandler = JsonTypeHandler.class)
|
||||
private List<String> photos;
|
||||
|
||||
/**
|
||||
* 图片数量
|
||||
*/
|
||||
private Integer photoCount;
|
||||
|
||||
/**
|
||||
* 创建人 Id; sys_user.id
|
||||
*/
|
||||
|
||||
+34
@@ -1,12 +1,17 @@
|
||||
package com.njzscloud.supervisory.tsp.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njzscloud.common.core.utils.GroupUtil;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.supervisory.tsp.mapper.TspPhotoMapper;
|
||||
import com.njzscloud.supervisory.tsp.pojo.ObtainStatusParam;
|
||||
import com.njzscloud.supervisory.tsp.pojo.TspPhotoEntity;
|
||||
import com.njzscloud.supervisory.tsp.pojo.TspPhotoSaveParam;
|
||||
import com.njzscloud.supervisory.tsp.pojo.TspPhotoSearchParam;
|
||||
@@ -15,7 +20,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 临时收纳点图片
|
||||
@@ -93,4 +100,31 @@ public class TspPhotoService extends ServiceImpl<TspPhotoMapper, TspPhotoEntity>
|
||||
.eq("upload_date", tspPhotoSearchParam.getUploadDate())
|
||||
);
|
||||
}
|
||||
|
||||
public Map<String, Integer> obtainStatus(ObtainStatusParam obtainStatusParam) {
|
||||
Long tspId = obtainStatusParam.getTspId();
|
||||
LocalDate uploadDate = obtainStatusParam.getUploadDate();
|
||||
int year = uploadDate.getYear();
|
||||
int month = uploadDate.getMonthValue();
|
||||
|
||||
List<TspPhotoEntity> list = this.list(Wrappers.<TspPhotoEntity>query()
|
||||
.eq("tsp_id", tspId)
|
||||
.eq("YEAR(upload_date)", year)
|
||||
.eq("MONTH(upload_date)", month)
|
||||
);
|
||||
Map<Integer, Integer> map = GroupUtil.k_o(list, it -> it.getUploadDate().getDayOfMonth(), TspPhotoEntity::getPhotoCount);
|
||||
|
||||
HashMap<String, Integer> res = new HashMap<>();
|
||||
DateTime now = DateTime.now();
|
||||
DateTime dateTime = DateUtil.date(uploadDate);
|
||||
for (int i = 0; i < uploadDate.lengthOfMonth(); i++) {
|
||||
if (dateTime.setField(DateField.DAY_OF_MONTH, i + 1).isAfter(now)) {
|
||||
res.put(String.valueOf(i + 1), null);
|
||||
} else {
|
||||
res.put(String.valueOf(i + 1), map.getOrDefault(i + 1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user