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