浏览代码

mapper注解

zhoutao 5 年之前
父节点
当前提交
a4f8c371c8

+ 14 - 33
pigx-inventory/pigx-inventory-biz/src/main/java/com/pig4cloud/pigx/qa/controller/InspectionApplyController.java

@@ -1,6 +1,7 @@
 package com.pig4cloud.pigx.qa.controller;
 
 import cn.hutool.core.codec.Base64;
+import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -47,7 +48,7 @@ public class InspectionApplyController {
                                 @RequestParam(required = false) String areaCode, Response response)  {
 
 		Page results = inspectionApplyService.getByParm(scCode,poCode,sId,eId,dateStart,dateEnd,null,areaCode,page) ;
-		List<InspectionApply> inspectionApplys = results.getRecords();
+/*		List<InspectionApply> inspectionApplys = results.getRecords();
 		for (InspectionApply inspectionApply :inspectionApplys ){
 			if (!StrUtil.isBlank( inspectionApply.getInspector())){
 				inspectionApply.setInspector(Base64.encode(inspectionApply.getInspector()));
@@ -69,14 +70,14 @@ public class InspectionApplyController {
 		List<String> strings=new ArrayList<>();
 		inspectionApplys.forEach(k->strings.add(JSONObject.toJSONString(k)));
 
-		results.setRecords(strings);
+		results.setRecords(strings);*/
 
 		return R.ok(results);
 	}
 
 	@PostMapping("mobile/picture" )
 	@ApiOperation(value = "陪验员上传图片")
-	public R addSampleDocumentBySdId(@RequestParam("scId" ) Integer scId,
+	public R addSampleDocumentBySdId(@RequestParam("ids" ) String ids,
 									 @RequestParam(value = "file",required = false) MultipartFile file) throws IOException {
 		List<String> urls=new ArrayList<>();
 		String filename = file.getOriginalFilename();
@@ -84,38 +85,18 @@ public class InspectionApplyController {
 		String url = FastDFSClient.upload(file.getBytes(), fileExt);
 		urls.add(url);
 
+		for (String id : StrUtil.split(ids, StrUtil.DASHED)) {
+			InspectionApply inspectionApply= inspectionApplyService.getbyScIdBetweenThisWeek(Convert.toInt(id));
 
-		//StringBuffer string=new StringBuffer();
-		//for (String file:files){
-			//if (StrUtil.startWith(file,"http://")){
-			//	string.append(file).append(",");
-		//	}else {
-			//	byte[] decode = Base64.decode(file);
-			//	String picture = FastDFSClient.upload(decode, "png");
-			//	string.append(picture).append(",");
-			//}
-		//}
-		List<InspectionApply> inspectionApplies = inspectionApplyService.getbyScIdBetweenThisWeek(scId);
-
-		if (!inspectionApplies.isEmpty()){
-			inspectionApplies.forEach(k->{
-				if (!StrUtil.isBlank(k.getPicture())){
-					List<String> oldUrls = Arrays.asList(k.getPicture().split(","));
-					urls.addAll(oldUrls);
-				}
-				k.setPicture(String.join(",",urls));
-				inspectionApplyService.updateById(k);
-			});
-		}else {
-			InspectionApply inspectionApply = new InspectionApply();
-			inspectionApply.setScId(scId);
-			inspectionApply.setPicture(String.join(",",urls));
-
-			inspectionApplyService.save(inspectionApply);
-		}
-		return R.ok();
-
+					if (!StrUtil.isBlank(inspectionApply.getPicture())){
+						List<String> oldUrls = Arrays.asList(inspectionApply.getPicture().split(","));
+						urls.addAll(oldUrls);
+					}
+				    inspectionApply.setPicture(String.join(",",urls));
+					inspectionApplyService.updateById(inspectionApply);
 
+		}
+		return R.ok(String.join(",",urls));
 
 	}
 

+ 1 - 1
pigx-inventory/pigx-inventory-biz/src/main/java/com/pig4cloud/pigx/qa/service/InspectionApplyService.java

@@ -8,7 +8,7 @@ import java.util.List;
 
 
 public interface InspectionApplyService extends IService<InspectionApply> {
-	List<InspectionApply> getbyScIdBetweenThisWeek(Integer scId);
+	InspectionApply getbyScIdBetweenThisWeek(Integer id);
 
 	Page getByParm(String scCode, String poCode, Integer sId, Integer eId, String dateStart, String dateEnd, String createTime, String areaCode, Page page);
 

+ 3 - 3
pigx-inventory/pigx-inventory-biz/src/main/java/com/pig4cloud/pigx/qa/service/impl/InspectionApplyServiceImpl.java

@@ -19,12 +19,12 @@ public class InspectionApplyServiceImpl extends ServiceImpl<InspectionApplyMappe
 
 
 	@Override
-	public List<InspectionApply> getbyScIdBetweenThisWeek(Integer scId) {
+	public InspectionApply  getbyScIdBetweenThisWeek(Integer id) {
 		QueryWrapper query=new QueryWrapper();
-		query.eq("sc_id",scId);
+		query.eq("id",id);
 		query.between("create_time", DateUtil.beginOfWeek(new Date()), DateUtil.endOfWeek(new Date()));
 
-		return  baseMapper.selectList(query);
+		return  baseMapper.selectById(id);
 	}