From e45e3b119ee55e5a5f04116c611d5abf925986ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sat, 28 Mar 2020 19:04:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=95=E6=8D=AEinsert?= =?UTF-8?q?=E5=92=8Cupdate=E7=9A=84=E4=BB=A3=E7=A0=81=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E5=A4=A7=E6=95=B0=E6=8D=AE=E9=87=8F=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=86=99=E5=85=A5=E7=9A=84bug=EF=BC=8C=E5=8F=A6=E5=A4=96?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92=E7=9A=84?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/modules/sys/sysIndex.js | 21 +++++ erp_web/js/pages/materials/in_out.js | 6 +- .../erp/controller/DepotHeadController.java | 92 +++++++++---------- .../com/jsh/erp/controller/MsgController.java | 20 ++++ .../datasource/entities/DepotHeadVo4Body.java | 66 +++++++++++++ .../erp/datasource/mappers/MsgMapperEx.java | 4 + .../com/jsh/erp/service/msg/MsgService.java | 19 ++++ src/main/resources/mapper_xml/MsgMapperEx.xml | 11 +++ 8 files changed, 186 insertions(+), 53 deletions(-) create mode 100644 src/main/java/com/jsh/erp/datasource/entities/DepotHeadVo4Body.java diff --git a/erp_web/js/modules/sys/sysIndex.js b/erp_web/js/modules/sys/sysIndex.js index acbdddab..8349c2e0 100644 --- a/erp_web/js/modules/sys/sysIndex.js +++ b/erp_web/js/modules/sys/sysIndex.js @@ -438,4 +438,25 @@ $(function () { }, 10 * 1000); } + //更新消息条数 + function getMsgCountByStatus() { + $.ajax({ + type: "get", + url: "/msg/getMsgCountByStatus?status=1", + dataType: "json", + success: function (res) { + if (res && res.code === 200) { + if(res.data) { + var count = res.data.count; + $("#msgNum, #msgNum2").text(count); + } + } + } + }); + } + getMsgCountByStatus(); + setInterval(function() { + getMsgCountByStatus() + }, 1000*60); + }); \ No newline at end of file diff --git a/erp_web/js/pages/materials/in_out.js b/erp_web/js/pages/materials/in_out.js index 9d463eb9..57b884af 100644 --- a/erp_web/js/pages/materials/in_out.js +++ b/erp_web/js/pages/materials/in_out.js @@ -2513,9 +2513,10 @@ $.ajax({ type:"post", url: url, + contentType:"application/json", dataType: "json", async : false, - data: ({ + data: JSON.stringify({ info:infoStr, inserted: JSON.stringify(inserted), deleted: JSON.stringify(deleted), @@ -2553,9 +2554,10 @@ $.ajax({ type:"post", url: url, + contentType:"application/json", dataType: "json", async : false, - data: ({ + data: JSON.stringify({ id:url.substring(url.lastIndexOf("?id=")+4,url.length), info:infoStr, inserted: JSON.stringify(inserted), diff --git a/src/main/java/com/jsh/erp/controller/DepotHeadController.java b/src/main/java/com/jsh/erp/controller/DepotHeadController.java index 49bdd703..4f4e04e5 100644 --- a/src/main/java/com/jsh/erp/controller/DepotHeadController.java +++ b/src/main/java/com/jsh/erp/controller/DepotHeadController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.DepotHead; +import com.jsh.erp.datasource.entities.DepotHeadVo4Body; import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail; import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount; import com.jsh.erp.datasource.vo.DepotHeadVo4List; @@ -382,21 +383,19 @@ public class DepotHeadController { } /** - * create by: cjl - * description: - * 新增单据主表及单据子表信息 - * create time: 2019/1/25 14:36 - * @Param: beanJson -  * @Param: inserted -  * @Param: deleted -  * @Param: updated - * @return java.lang.String + * 新增单据主表及单据子表信息 + * @param body + * @param request + * @return + * @throws Exception */ - @RequestMapping(value = "/addDepotHeadAndDetail") - public Object addDepotHeadAndDetail(@RequestParam("info") String beanJson,@RequestParam("inserted") String inserted, - @RequestParam("deleted") String deleted, - @RequestParam("updated") String updated, HttpServletRequest request) throws Exception{ + @PostMapping(value = "/addDepotHeadAndDetail") + public Object addDepotHeadAndDetail(@RequestBody DepotHeadVo4Body body, HttpServletRequest request) throws Exception{ JSONObject result = ExceptionConstants.standardSuccess(); + String beanJson = body.getInfo(); + String inserted = body.getInserted(); + String deleted = body.getDeleted(); + String updated = body.getUpdated(); Long billsNumLimit = Long.parseLong(request.getSession().getAttribute("billsNumLimit").toString()); Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString()); Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null); @@ -408,58 +407,49 @@ public class DepotHeadController { } return result; } + /** - * create by: cjl - * description: * 更新单据主表及单据子表信息 - * create time: 2019/1/28 14:47 - * @Param: id -  * @Param: beanJson -  * @Param: inserted -  * @Param: deleted -  * @Param: updated -  * @Param: preTotalPrice - * @return java.lang.Object + * @param body + * @param request + * @return + * @throws Exception */ - @RequestMapping(value = "/updateDepotHeadAndDetail") - public Object updateDepotHeadAndDetail(@RequestParam("id") Long id, - @RequestParam("info") String beanJson, - @RequestParam("inserted") String inserted, - @RequestParam("deleted") String deleted, - @RequestParam("updated") String updated, - @RequestParam("preTotalPrice") BigDecimal preTotalPrice, - HttpServletRequest request) throws Exception{ + @PostMapping(value = "/updateDepotHeadAndDetail") + public Object updateDepotHeadAndDetail(@RequestBody DepotHeadVo4Body body, HttpServletRequest request) throws Exception{ Long tenantId = Long.parseLong(request.getSession().getAttribute("tenantId").toString()); JSONObject result = ExceptionConstants.standardSuccess(); + Long id = body.getId(); + String beanJson = body.getInfo(); + String inserted = body.getInserted(); + String deleted = body.getDeleted(); + String updated = body.getUpdated(); + BigDecimal preTotalPrice = body.getPreTotalPrice(); depotHeadService.updateDepotHeadAndDetail(id,beanJson,inserted,deleted,updated,preTotalPrice,tenantId,request); return result; } - /** - * create by: cjl - * description: - * 删除单据主表及子表信息 - * create time: 2019/1/28 17:29 - * @Param: id - * @return java.lang.Object - */ - @RequestMapping(value = "/deleteDepotHeadAndDetail") - public Object deleteDepotHeadAndDetail(@RequestParam("id") Long id) throws Exception{ + /** + * 删除单据主表及子表信息 + * @param id + * @return + * @throws Exception + */ + @PostMapping(value = "/deleteDepotHeadAndDetail") + public Object deleteDepotHeadAndDetail(@RequestParam("id") Long id) throws Exception{ JSONObject result = ExceptionConstants.standardSuccess(); depotHeadService.deleteDepotHeadAndDetail(id); return result; } - /** - * create by: cjl - * description: - * 删除单据主表及子表信息 - * create time: 2019/1/28 17:29 - * @Param: id - * @return java.lang.Object - */ - @RequestMapping(value = "/batchDeleteDepotHeadAndDetail") - public Object batchDeleteDepotHeadAndDetail(@RequestParam("ids") String ids) throws Exception{ + /** + * 批量删除单据主表及子表信息 + * @param ids + * @return + * @throws Exception + */ + @PostMapping(value = "/batchDeleteDepotHeadAndDetail") + public Object batchDeleteDepotHeadAndDetail(@RequestParam("ids") String ids) throws Exception{ JSONObject result = ExceptionConstants.standardSuccess(); depotHeadService.batchDeleteDepotHeadAndDetail(ids); return result; diff --git a/src/main/java/com/jsh/erp/controller/MsgController.java b/src/main/java/com/jsh/erp/controller/MsgController.java index a95afd75..28785db1 100644 --- a/src/main/java/com/jsh/erp/controller/MsgController.java +++ b/src/main/java/com/jsh/erp/controller/MsgController.java @@ -9,7 +9,9 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author ji sheng hua 华夏ERP @@ -54,4 +56,22 @@ public class MsgController { } return res; } + + @GetMapping("/getMsgCountByStatus") + public BaseResponseInfo getMsgCountByStatus(@RequestParam("status") String status, + HttpServletRequest request)throws Exception { + BaseResponseInfo res = new BaseResponseInfo(); + try { + Map map = new HashMap(); + Long count = msgService.getMsgCountByStatus(status); + map.put("count", count); + res.code = 200; + res.data = map; + } catch(Exception e){ + e.printStackTrace(); + res.code = 500; + res.data = "获取数据失败"; + } + return res; + } } diff --git a/src/main/java/com/jsh/erp/datasource/entities/DepotHeadVo4Body.java b/src/main/java/com/jsh/erp/datasource/entities/DepotHeadVo4Body.java new file mode 100644 index 00000000..b88ba258 --- /dev/null +++ b/src/main/java/com/jsh/erp/datasource/entities/DepotHeadVo4Body.java @@ -0,0 +1,66 @@ +package com.jsh.erp.datasource.entities; + +import java.math.BigDecimal; + +public class DepotHeadVo4Body { + + private Long id; + + private String info; + + private String inserted; + + private String deleted; + + private String updated; + + private BigDecimal preTotalPrice; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getInfo() { + return info; + } + + public void setInfo(String info) { + this.info = info; + } + + public String getInserted() { + return inserted; + } + + public void setInserted(String inserted) { + this.inserted = inserted; + } + + public String getDeleted() { + return deleted; + } + + public void setDeleted(String deleted) { + this.deleted = deleted; + } + + public String getUpdated() { + return updated; + } + + public void setUpdated(String updated) { + this.updated = updated; + } + + public BigDecimal getPreTotalPrice() { + return preTotalPrice; + } + + public void setPreTotalPrice(BigDecimal preTotalPrice) { + this.preTotalPrice = preTotalPrice; + } +} \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/datasource/mappers/MsgMapperEx.java b/src/main/java/com/jsh/erp/datasource/mappers/MsgMapperEx.java index 65704de4..ff8b0d0c 100644 --- a/src/main/java/com/jsh/erp/datasource/mappers/MsgMapperEx.java +++ b/src/main/java/com/jsh/erp/datasource/mappers/MsgMapperEx.java @@ -20,4 +20,8 @@ public interface MsgMapperEx { int insertSelectiveByTask(Msg record); int checkIsNameExistByTask(@Param("msgTitle") String msgTitle); + + Long getMsgCountByStatus( + @Param("status") String status, + @Param("userId") Long userId); } \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/service/msg/MsgService.java b/src/main/java/com/jsh/erp/service/msg/MsgService.java index f5f2a191..b88d98f6 100644 --- a/src/main/java/com/jsh/erp/service/msg/MsgService.java +++ b/src/main/java/com/jsh/erp/service/msg/MsgService.java @@ -5,11 +5,13 @@ import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.Msg; import com.jsh.erp.datasource.entities.MsgExample; +import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.mappers.MsgMapper; import com.jsh.erp.datasource.mappers.MsgMapperEx; import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.service.depotHead.DepotHeadService; import com.jsh.erp.service.log.LogService; +import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,6 +36,9 @@ public class MsgService { @Resource private DepotHeadService depotHeadService; + @Resource + private UserService userService; + @Resource private LogService logService; @@ -232,4 +237,18 @@ public class MsgService { ExceptionConstants.DATA_WRITE_FAIL_MSG); } } + + public Long getMsgCountByStatus(String status)throws Exception { + Long result=null; + try{ + User userInfo=userService.getCurrentUser(); + result=msgMapperEx.getMsgCountByStatus(status, userInfo.getId()); + }catch(Exception e){ + logger.error("异常码[{}],异常提示[{}],异常[{}]", + ExceptionConstants.DATA_READ_FAIL_CODE, ExceptionConstants.DATA_READ_FAIL_MSG,e); + throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE, + ExceptionConstants.DATA_READ_FAIL_MSG); + } + return result; + } } diff --git a/src/main/resources/mapper_xml/MsgMapperEx.xml b/src/main/resources/mapper_xml/MsgMapperEx.xml index 9ddf0c62..c31e3e9d 100644 --- a/src/main/resources/mapper_xml/MsgMapperEx.xml +++ b/src/main/resources/mapper_xml/MsgMapperEx.xml @@ -57,4 +57,15 @@ and msg_title = '${msgTitle}' + + \ No newline at end of file