From cbc9250b33a955bc919a6afc5d4101ef65bbfafa Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期五, 10 十一月 2023 12:53:03 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/zycrm' into zycrm --- src/main/java/com/zy/crm/manager/controller/PriOnlineController.java | 125 +++++++++++++++++++++++++++++++++++------ 1 files changed, 107 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/zy/crm/manager/controller/PriOnlineController.java b/src/main/java/com/zy/crm/manager/controller/PriOnlineController.java index 87f68a8..6e0f136 100644 --- a/src/main/java/com/zy/crm/manager/controller/PriOnlineController.java +++ b/src/main/java/com/zy/crm/manager/controller/PriOnlineController.java @@ -5,21 +5,23 @@ import com.baomidou.mybatisplus.mapper.Wrapper; import com.baomidou.mybatisplus.plugins.Page; import com.core.common.DateUtils; -import com.zy.crm.manager.entity.Item; -import com.zy.crm.manager.entity.Pri; -import com.zy.crm.manager.entity.PriOnline; -import com.zy.crm.manager.service.ItemService; -import com.zy.crm.manager.service.PriOnlineService; +import com.zy.crm.manager.entity.*; +import com.zy.crm.manager.service.*; import com.core.annotations.ManagerAuth; import com.core.common.BaseRes; import com.core.common.Cools; import com.core.common.R; import com.core.domain.KeyValueVo; import com.zy.crm.common.web.BaseController; -import com.zy.crm.manager.service.PriService; +import com.zy.crm.system.entity.Role; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ClassPathResource; +import org.springframework.util.ClassUtils; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; +import java.io.*; import java.text.SimpleDateFormat; import java.util.*; @@ -33,7 +35,7 @@ private PriService priService; @Autowired - private ItemService itemService; + private PlanService planService; @RequestMapping(value = "/priOnline/{id}/auth") @ManagerAuth @@ -60,7 +62,7 @@ @RequestParam(required = false)String condition, @RequestParam Map<String, Object> param){ EntityWrapper<PriOnline> wrapper = new EntityWrapper<>(); - wrapper.setSqlSelect("id,title,create_time as createTime,filepath,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId"); + wrapper.setSqlSelect("id,title,create_time as createTime,filepath,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,dept_id as deptId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId"); wrapper.in("member_id", getUserRoleBelongsToUserId("allopen")); excludeTrash(param); convert(param, wrapper); @@ -70,15 +72,39 @@ } private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ + boolean signUserId = false; + boolean signDeptId = false; + boolean signHostId = false; + for (Map.Entry<String, Object> entry : map.entrySet()){ + if (entry.getKey().equals("dept_id")){ + signDeptId = true; + if (String.valueOf(entry.getValue()).equals("19")){ + signHostId = true; + } + } + } for (Map.Entry<String, Object> entry : map.entrySet()){ String val = String.valueOf(entry.getValue()); if (val.contains(RANGE_TIME_LINK)){ String[] dates = val.split(RANGE_TIME_LINK); wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); + } else if (entry.getKey().equals("dept_id")){ + if (!val.equals("19")){ + wrapper.eq(entry.getKey(), val); + } + } else if (entry.getKey().equals("user_id") && !signDeptId){ + signUserId = true; + wrapper.eq(entry.getKey(), val); } else { wrapper.like(entry.getKey(), val); } + } + if (!signUserId && !signDeptId){ + wrapper.eq("user_id", getUserId()); + } + if (signHostId){ + wrapper.or().eq("host_id",1); } } @@ -101,6 +127,8 @@ priOnline.setOrderNum(format.format(new Date())); //鍒涘缓浜哄憳 priOnline.setUserId(getUserId()); + //鍒涘缓浜哄憳閮ㄩ棬 + priOnline.setDeptId(getDeptId()); //鏇存柊鏃堕棿 priOnline.setUpdateTime(new Date()); //鏇存柊浜哄憳 @@ -108,12 +136,14 @@ //鐘舵�侊紝鏈畬鎴� priOnline.setStatus(0); //涓氬姟鍛� - Item item = itemService.selectById(priOnline.getItemId()); - priOnline.setMemberId(item.getMember()); +// Item item = itemService.selectById(priOnline.getItemId()); + Plan plan = planService.selectById(priOnline.getItemId()); + priOnline.setMemberId(plan.getUserId()); + //璁剧疆椤圭洰娴佺▼ - item.setStep(2); - itemService.updateById(item); + plan.setStep(2); + planService.updateById(plan); priOnlineService.insert(priOnline); return R.ok(); @@ -141,9 +171,11 @@ priOnline.setUpdateUserId(getUserId()); //鐘舵�侊紝鏈畬鎴� priOnline.setStatus(0); + priOnline.setDeptId(getDeptId()); //涓氬姟鍛� - Item item = itemService.selectById(priOnline.getItemId()); - priOnline.setMemberId(item.getMember()); +// Item item = itemService.selectById(priOnline.getItemId()); + Plan plan = planService.selectById(priOnline.getItemId()); + priOnline.setMemberId(plan.getUserId()); priOnlineService.insert(priOnline); return R.ok(); @@ -181,14 +213,71 @@ @RequestMapping(value = "/priOnline/uploadCheck/auth") @ManagerAuth - public R uploadCheck(@RequestBody Map<String,Object> map){ - PriOnline priOnline = priOnlineService.selectById(Long.parseLong(map.get("id").toString())); + public R uploadCheck(@RequestParam("id") Integer id, + @RequestParam("checkData") String checkData, + @RequestParam("file") MultipartFile[] files){ + PriOnline priOnline = priOnlineService.selectById(id); if (priOnline.getStatus() == 1) { return R.error("鏍镐环宸插畬鎴愶紝绂佹涓婁紶"); } - priOnline.setCheckData(map.get("checkData").toString()); + priOnline.setCheckData(checkData); + + + MultipartFile file = files[0]; + SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss"); + String path = ClassUtils.getDefaultClassLoader().getResource("excel/uploadCheckData").getPath(); + //鏂囦欢鍚庣紑鍚� + String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); + //涓婁紶鏂囦欢鍚� + String filename = format.format(new Date()) + suffix; + //鏈�缁堟枃浠惰矾寰� + String filepath = path + "/" + filename; + + + //鏈嶅姟鍣ㄧ淇濆瓨鐨勬枃浠跺璞� + File serverFile = new File(filepath); + if(!serverFile.exists()) { + try { + //鍒涘缓鏂囦欢 + serverFile.createNewFile(); + //灏嗕笂浼犵殑鏂囦欢鍐欏叆鍒版湇鍔″櫒绔枃浠跺唴 + file.transferTo(serverFile); + } catch (IOException e) { + e.printStackTrace(); + } + } + + //淇濆瓨鏂囦欢鍚� + priOnline.setCheckDataFile(filename); priOnlineService.updateById(priOnline); return R.ok(); + } + + @GetMapping("/priOnline/checkDataDownload/{filename}") + public void download(@PathVariable String filename, HttpServletResponse response) { + try { + ClassPathResource pathResource = new ClassPathResource("excel/uploadCheckData/" + filename); + File file = pathResource.getFile(); + InputStream inputStream = pathResource.getInputStream(); + //杈撳嚭鏂囦欢 + InputStream fis = new BufferedInputStream(inputStream); + byte[] buffer = new byte[fis.available()]; + fis.read(buffer); + fis.close(); + response.reset(); + + //鑾峰彇鏂囦欢鐨勫悕瀛楀啀娴忚鍣ㄤ笅杞介〉闈� + String name = file.getName(); + response.addHeader("Content-Disposition", "attachment;filename=" + new String(name.getBytes(), "iso-8859-1")); + response.addHeader("Content-Length", "" + file.length()); + OutputStream out = new BufferedOutputStream(response.getOutputStream()); + response.setContentType("application/octet-stream"); + out.write(buffer); + out.flush(); + out.close(); + } catch (Exception e) { + e.printStackTrace(); + } } @RequestMapping(value = "/priOnline/delete/auth") @@ -223,7 +312,7 @@ for (PriOnline priOnline : page.getRecords()){ Map<String, Object> map = new HashMap<>(); map.put("id", priOnline.getId()); - map.put("value", priOnline.getOrderNum() + "/" + priOnline.getItemId$() + "/" + priOnline.getMemberId$()); + map.put("value", priOnline.getOrderNum() + "/" + priOnline.getPlanId$() + "/" + priOnline.getMemberId$()); result.add(map); } return R.ok(result); -- Gitblit v1.9.1