123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- package com.steerinfo.dil.service.impl;
- import com.steerinfo.dil.mapper.DilNoticeMapper;
- import com.steerinfo.dil.model.DilNotice;
- import com.steerinfo.dil.service.IDilNoticeService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.scheduling.annotation.Scheduled;
- import org.springframework.stereotype.Service;
- import java.util.*;
- import java.math.BigDecimal;
- /**
- * DilNotice服务实现:
- * @author generator
- * @version 1.0-SNAPSHORT 2021-12-08 02:21
- * 类描述
- * 修订历史:
- * 日期:2021-12-08
- * 作者:generator
- * 参考:
- * 描述:DilNotice服务实现
- * @see null
- * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
- */
- @Service(value = "dilNoticeService")
- public class DilNoticeServiceImpl implements IDilNoticeService {
- @Autowired
- private DilNoticeMapper dilNoticeMapper;
- /**
- * 获取通知信息
- * */
- @Override
- public List<Map<String, Object>> getNoticeList(Map<String, Object> mapVal) {
- return dilNoticeMapper.getNoticeList(mapVal);
- }
- /**
- * 承运商获取通知信息
- * */
- @Override
- public List<Map<String, Object>> getCarrierNoticeList(Map<String, Object> mapVal) {
- List<Map<String, Object>> mapList=dilNoticeMapper.getCarrierNoticeList(mapVal);
- for (Map<String, Object> map : mapList) {
- if ("1".equals(map.get("status"))){
- //有历史数据(替换)
- map.put("noticeTitle",map.get("updateTitle"));
- map.put("noticeContent",map.get("updateContent"));
- map.put("insertUsername",map.get("updateUsername"));
- map.put("insertTime",map.get("updateTime"));
- }
- }
- return mapList;
- }
- /**
- * 销售公司获取通知信息
- * */
- @Override
- public List<Map<String, Object>> getMarketingNoticeList(Map<String, Object> mapVal) {
- List<Map<String, Object>> mapList=dilNoticeMapper.getMarketingNoticeList(mapVal);
- for (Map<String, Object> map : mapList) {
- if ("1".equals(map.get("status"))){
- //有历史数据(替换)
- map.put("noticeTitle",map.get("updateTitle"));
- map.put("noticeContent",map.get("updateContent"));
- map.put("insertUsername",map.get("updateUsername"));
- map.put("insertTime",map.get("updateTime"));
- }
- }
- return mapList;
- }
- /**
- * 收货用户获取通知信息
- * */
- @Override
- public List<Map<String, Object>> getClientNoticeList(Map<String, Object> mapVal) {
- List<Map<String, Object>> mapList= dilNoticeMapper.getClientNoticeList(mapVal);
- for (Map<String, Object> map : mapList) {
- if ("1".equals(map.get("status"))){
- //有历史数据(替换)
- map.put("noticeTitle",map.get("updateTitle"));
- map.put("noticeContent",map.get("updateContent"));
- map.put("insertUsername",map.get("updateUsername"));
- map.put("insertTime",map.get("updateTime"));
- }
- }
- return mapList;
- }
- @Override
- public List<Map<String, Object>> getNewNoticeByPermission(BigDecimal permission) {
- return dilNoticeMapper.getNewNoticeByPermission(permission);
- }
- /**
- * 增加通知信息
- * */
- @Override
- /*这里是解决前端毛病所妥协的结果,前端拿不到value值,只能拿到name也就是key值,这里在后端强行将key转为value值QAQ*/
- public int insertNotice(DilNotice dilNotice) {
- int result=0;
- dilNotice.setDeleted(new BigDecimal(0));
- dilNotice.setInsertTime(dilNotice.getInsertTime());
- dilNotice.setNoticeId(dilNoticeMapper.selectNoticeId());
- dilNotice.setStatus("0");
- if(dilNotice.getPermissions()!=null){
- if(dilNotice.getPermissions().equals("承运商")){
- dilNotice.setPermission("chengyunshang");
- }
- else if(dilNotice.getPermissions().equals("销售公司")){
- dilNotice.setPermission("wuliuyunshubu");
- }
- else if(dilNotice.getPermissions().equals("收货客户")){
- dilNotice.setPermission("shouhuokehu");
- }else{
- dilNotice.setPermission("qita");
- /*dilNoticeMapper.insertSelective(dilNotice);
- result +=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
- return result;*/
- }
- }
- //需要手动设置发布人
- /*dilNotice.setInsertUsername("admin");*/
- result+=dilNoticeMapper.insertSelective(dilNotice);
- /*if (result==0){
- dilNoticeMapper.insertIntoNoticeUser(dilNotice);
- }*/
- return result;
- }
- /**
- * @author:zyf
- * @version:2.0
- * @Date:2022-10-14
- * @Description:发布通知
- */
- @Override
- public int releaseNotice(DilNotice dilNotice) {
- //发布通知
- //1.先判断permission是否有值
- //2.看notice有无历史的修改数据
- //3.发布
- int result=0;
- //发布的通知
- DilNotice dilNotice2=new DilNotice();
- if (dilNotice.getPermission()!=null){
- //查询是否有历史修改数据
- DilNotice dilNotice1 = dilNoticeMapper.gethistoryorgCode(dilNotice.getNoticeId());
- //历史数据有值与否(1为有值,0为没有值)
- if ("1".equals(dilNotice1.getStatus())){
- dilNoticeMapper.deleteNoticeUsers(dilNotice.getNoticeId());
- //1.判断时间是否需要修改(1.1)
- Date updateTime = dilNotice1.getUpdateTime();
- if (updateTime.compareTo(new Date())>0){
- //时间大于当前时间的不动
- dilNotice2.setInsertTime(updateTime);
- }else {
- //时间小于等于当前时间的,时间变为当前时间
- dilNotice2.setInsertTime(new Date());
- }
- //历史数据
- dilNotice2.setNoticeId(dilNotice.getNoticeId());
- dilNotice2.setNoticeTitle(dilNotice1.getUpdateTitle());
- dilNotice2.setNoticeContent(dilNotice1.getUpdateContent());
- dilNotice2.setInsertUsername(dilNotice1.getUpdateUsername());
- dilNoticeMapper.updatehistorydata(dilNotice2);
- if ("qita".equals(dilNotice.getPermission())){
- //全部要单独
- result+=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
- }else {
- result+=dilNoticeMapper.insertIntoNoticeUser(dilNotice);
- }
- }else {
- //判断时间是否需要修改(1.2)
- Date insertTime =dilNotice.getInsertTime();
- dilNoticeMapper.deleteNoticeUsers(dilNotice.getNoticeId());
- if (insertTime.compareTo(new Date())>0){
- //时间大于当前时间的不动
- dilNotice2.setInsertTime(dilNotice.getInsertTime());
- }else {
- //时间小于等于当前时间的,时间变为当前时间
- dilNotice2.setInsertTime(new Date());
- }
- dilNotice2.setNoticeId(dilNotice.getNoticeId());
- dilNoticeMapper.updateTime(dilNotice2);
- if ("qita".equals(dilNotice.getPermission())){
- //全部要单独
- result+=dilNoticeMapper.insertIntoNoticeUser1(dilNotice);
- }else {
- result+=dilNoticeMapper.insertIntoNoticeUser(dilNotice);
- }
- }
- }else {
- return 0;
- }
- return result;
- }
- /**
- * 修改通知信息
- * */
- @Override
- public int updateNotice(DilNotice dilNotice) {
- dilNotice.setUpdateTime(new Date());
- //存储修改过后的内容
- DilNotice dilNotice1=new DilNotice();
- dilNotice.setUpdateUsername("admin");
- if ("承运商".equals(dilNotice.getPermission())){
- dilNotice1.setPermission("chengyunshang");
- }else if ("销售公司".equals(dilNotice.getPermission())){
- dilNotice1.setPermission("wuliuyunshubu");
- }else if ("收货客户".equals(dilNotice.getPermission())){
- dilNotice1.setPermission("shouhuokehu");
- }else {
- dilNotice1.setPermission("qita");
- }
- String code = dilNoticeMapper.getorgCode(dilNotice.getNoticeId());
- dilNotice1.setUpdateTitle(dilNotice.getNoticeTitle());
- dilNotice1.setUpdateContent(dilNotice.getNoticeContent());
- dilNotice1.setUpdateTime(dilNotice.getInsertTime());
- dilNotice1.setUpdateUsername(dilNotice.getInsertUsername());
- dilNotice1.setStatus("1");
- dilNotice1.setNoticeId(dilNotice.getNoticeId());
- return dilNoticeMapper.modifyData(dilNotice1);
- }
- /**
- * @author:zyf
- * @version:1.0
- * @Date:2022-09-24
- * @Description:修改用户通知的相关信息
- */
- @Override
- public int updateNoticeStatus(String userId,int noticeId) {
- dilNoticeMapper.updatestatus(userId,noticeId);
- return dilNoticeMapper.gettaskAllNum(userId);
- }
- /**
- * 删除通知信息
- * */
- @Override
- public int deleteNotice(BigDecimal id) {
- DilNotice dilNotice = dilNoticeMapper.selectByPrimaryKey(id);
- dilNotice.setDeleted(new BigDecimal(1));
- //删除中间表信息
- dilNoticeMapper.deleteNoticeUsers(id);
- //删除通知表的数据
- return dilNoticeMapper.deleteNotice(id);
- }
- //根据用户ID获取用户名字
- @Override
- public String queryName(String userId) {
- return dilNoticeMapper.queryName(userId);
- }
- /**
- * 根据id获取运力信息
- * @param id
- * @return
- */
- @Override
- public List<Map<String, Object>> getNoticeById(BigDecimal id) {
- String status = dilNoticeMapper.getStatus(id);
- if ("1".equals(status)){
- return dilNoticeMapper.getNoticeById1(id);
- }else {
- return dilNoticeMapper.getNoticeById(id);
- }
- }
- /**
- * @author:zyf
- * @version:1.0
- * @Date:
- * @Description: 获取通知信息数据
- */
- public List<Map<String,Object>> getNoticeData(String userId){
- List<Map<String, Object>> noticeData=new ArrayList<>();
- /*if ("chengyunshang".equals(orgcode)){
- BigDecimal permission=BigDecimal.valueOf(1);
- noticeData = dilNoticeMapper.getNoticeData(permission);
- }else if ("xiaoshougongsi".equals(orgcode)){
- BigDecimal permission=BigDecimal.valueOf(2);
- noticeData = dilNoticeMapper.getNoticeData(permission);
- }else if ("shouhuokehu".equals(orgcode)){
- BigDecimal permission=BigDecimal.valueOf(3);
- noticeData = dilNoticeMapper.getNoticeData(permission);
- }else {
- noticeData = dilNoticeMapper.getNoticeData1();
- }*/
- return dilNoticeMapper.getNoticeData(userId);
- }
- /*
- * 获取下拉框
- * */
- /*
- @Override
- public List<Map<String,Object>> getCapacityTypeId() {
- return rmsCapacityMapper.getCapacityTypeId();
- }
- @Override
- public List<Map<String, Object>> getCarrierId() {
- return rmsCapacityMapper.getCarrierId();
- }
- */
- @Override
- public List<Map<String, Object>> getNoticeAll(Map<String, Object> mapValue) {
- return dilNoticeMapper.getNoticeAll(mapValue);
- }
- @Override
- public int readAll(Map<String, Object> map) {
- return dilNoticeMapper.readAll(map);
- }
- @Override
- public List<Map<String, Object>> getNoticeUser(Map<String, Object> mapValue) {
- return dilNoticeMapper.getNoticeUser(mapValue);
- }
- /**
- * 查询国内矿采购订单是否符合标准,若不符合则发送给自动化部负责人:(UserId:1012690778083954688)
- */
- @Scheduled(fixedRate = 1000*60*60)
- public void checkPurchaseOrder(){
- List<Map<String,Object>> purchaseOrders=dilNoticeMapper.findErrorOrder();
- for(Map<String,Object> item:purchaseOrders){
- //插入通知表
- DilNotice notice=new DilNotice();
- notice.setNoticeId(dilNoticeMapper.selectNoticeId());
- notice.setNoticeTitle(item.get("purchaseOrderNo")+"订单异常");
- notice.setNoticeContent("国内矿订单'"+item.get("purchaseOrderNo")+"'缺少发站!");
- notice.setInsertTime(new Date());
- notice.setInsertUsername("system");
- notice.setDeleted(new BigDecimal(0));
- notice.setInsertUpdateRemark(""+item.get("purchaseOrderNo"));
- dilNoticeMapper.insertSelective(notice);
- //插入通知子表
- item.put("noticeId",notice.getNoticeId());
- item.put("userId","1012690778083954688");
- dilNoticeMapper.insertIntoNoticeUserToOne(item);
- }
- }
- }
|