Browse Source

Merge branch 'develop' of http://39.106.31.193:9211/mengff/jihe-dc into develop

develop
xiepufeng 1 year ago
parent
commit
07b4d3d1f4
  1. 11
      zc-business/pom.xml
  2. 6
      zc-business/src/main/java/com/zc/business/controller/DcOrganizationController.java
  3. 27
      zc-business/src/main/java/com/zc/business/controller/DcShiftsController.java
  4. 236
      zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java
  5. 4
      zc-business/src/main/java/com/zc/business/controller/StatusController.java
  6. 2
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  7. 46
      zc-business/src/main/java/com/zc/business/domain/DcShifts.java
  8. 120
      zc-business/src/main/java/com/zc/business/domain/DcShiftsList.java
  9. 12
      zc-business/src/main/java/com/zc/business/domain/DcShiftsRecord.java
  10. 8
      zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java
  11. 7
      zc-business/src/main/java/com/zc/business/service/IDcShiftsService.java
  12. 137
      zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java
  13. 28
      zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml

11
zc-business/pom.xml

@ -15,7 +15,18 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<!-- MQTT -->
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<version>1.1.11-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>

6
zc-business/src/main/java/com/zc/business/controller/DcOrganizationController.java

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.page.TableDataInfo;
import com.zc.business.domain.DcOrganizationExport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -47,10 +48,11 @@ public class DcOrganizationController extends BaseController
@PreAuthorize("@ss.hasPermi('business:organization:list')")
@GetMapping("/list")
public AjaxResult list(DcOrganization dcOrganization)
public TableDataInfo list(DcOrganization dcOrganization)
{
startPage();
ArrayList<HashMap> hashMaps = dcOrganizationService.selectDcOrganizationList(dcOrganization);
return AjaxResult.success(hashMaps);
return getDataTable(hashMaps);
}
/**

27
zc-business/src/main/java/com/zc/business/controller/DcShiftsController.java

@ -3,8 +3,14 @@ package com.zc.business.controller;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonElement;
import com.ruoyi.common.utils.StringUtils;
import com.zc.business.domain.DcShiftsRecord;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -12,6 +18,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
@ -28,7 +35,8 @@ import com.zc.business.service.IDcShiftsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.spring.web.json.Json;
import com.google.gson.*;
/**
* 值班Controller
*
@ -52,7 +60,7 @@ public class DcShiftsController extends BaseController
public TableDataInfo list(DcShifts dcShifts)
{
startPage();
List<HashMap> list = dcShiftsService.selectDcShiftsList(dcShifts);
List<DcShifts> list = dcShiftsService.selectDcShiftsList(dcShifts);
return getDataTable(list);
}
@ -113,6 +121,15 @@ public class DcShiftsController extends BaseController
public AjaxResult remove(@PathVariable Long[] ids) throws Exception{
return toAjax(dcShiftsService.deleteDcShiftsByIds(ids));
}
/**
* 删除值班,某个时间下驻点下的全部值班信息
*/
@PreAuthorize("@ss.hasPermi('business:shifts:remove')")
@Log(title = "值班", businessType = BusinessType.DELETE)
@PostMapping("/delete")
public AjaxResult removeDelete(@RequestBody DcShifts shifts) throws Exception{
return toAjax(dcShiftsService.deleteDcShiftsListId(shifts));
}
//导出模板
@ApiOperation("导出模板")
@ -145,11 +162,11 @@ public class DcShiftsController extends BaseController
* 查询操作记录
*/
@ApiOperation("查询操作记录")
@GetMapping("/recordList")
public TableDataInfo recordList()
@PostMapping("/recordList")
public TableDataInfo recordList(@RequestBody DcShifts dcShifts)
{
startPage();
List<DcShiftsRecord> list = dcShiftsService.selectDcShiftsRecord();
List<DcShiftsRecord> list = dcShiftsService.selectDcShiftsRecord(dcShifts);
return getDataTable(list);
}

236
zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java

@ -0,0 +1,236 @@
package com.zc.business.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.domain.DcWarning;
import com.zc.business.service.IDcWarningService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* License
*
* @author Athena-xiepufeng
*/
@Api(tags = "非机预警接口")
@RestController
@RequestMapping("/nonAutomaticWarning")
public class NonAutomaticWarningController extends BaseController {
private static final String APPKEY = "22825659";
private static final String APPSECRET = "7Qcq3fr1gaYws6QhyDqt";
private static final String URI = "/artemis/api/common/v1/event/getTopicInfo";
private static final String IP = "10.0.81.28";
@Resource
private IDcWarningService dcWarningService;
/*
* 调用功能
* */
@ApiOperation("事件订阅")
@PostMapping(value = "/eventSubscription")
public AjaxResult eventSubscription() throws Exception {
ArtemisConfig config = new ArtemisConfig();
config.setHost(IP); // 代理API网关nginx服务器ip端口
config.setAppKey(APPKEY); // 秘钥appkey
config.setAppSecret(APPSECRET);// 秘钥appSecret
final String getCamsApi = URI;
Map<String, Object> paramMap = new HashMap<String, Object>();// post请求Form表单参数
ArrayList<Long> longs = new ArrayList<>();
longs.add(6274879489L);
longs.add(6274883585L);
longs.add(7768236033L);
longs.add(7835340801L);
paramMap.put("eventTypes", longs);
String body = JSON.toJSON(paramMap).toString();
Map<String, String> path = new HashMap<String, String>(2) {
{
put("https://", getCamsApi);
}
};
String jsonString = ArtemisHttpUtil.doPostStringArtemis(config, path, body, null, null, "application/json");
JSONObject jsonObject = JSONObject.parseObject(jsonString);
String code = jsonObject.getString("code");
if (Objects.equals(code, "0")) {
JSONObject jsonResult = jsonObject.getJSONObject("data");
String host = jsonResult.getString("host");
String clientId = jsonResult.getString("clientId");
String userName = jsonResult.getString("userName");
String password = jsonResult.getString("password");
JSONObject topicName = jsonResult.getJSONObject("topicName");
try {
// host为主机名,test为clientid即连接MQTT的客户端ID,一般以客户端唯一标识符表示,MemoryPersistence设置clientid的保存形式,默认为以内存保存
MqttClient client = new MqttClient(host, clientId, new MemoryPersistence());
// MQTT的连接设置
MqttConnectOptions options = new MqttConnectOptions();
// 设置是否清空session,这里如果设置为false表示服务器会保留客户端的连接记录,这里设置为true表示每次连接到服务器都以新的身份连接
options.setCleanSession(true);
// 设置连接的用户名
options.setUserName(userName);
// 设置连接的密码
options.setPassword(password.toCharArray());
// 设置超时时间 单位为秒
options.setConnectionTimeout(10);
// 设置会话心跳时间 单位为秒 服务器会每隔1.5*20秒的时间向客户端发送个消息判断客户端是否在线,但这个方法并没有重连的机制
options.setKeepAliveInterval(20);
// 设置回调函数
client.setCallback(new MqttCallback() {
public void connectionLost(Throwable cause) {
System.out.println("connectionLost");
}
public void messageArrived(String topic, MqttMessage message) {
System.out.println("======监听到来自[" + topic + "]的消息======");
String jsonObjString = new String(message.getPayload());
JSONObject eventJsonObject = JSONObject.parseObject(jsonObjString);
JSONObject params = eventJsonObject.getJSONObject("params");
if (params == null) {
return;
}
JSONArray events = params.getJSONArray("events");
events.forEach(item -> {
JSONObject event = JSONObject.parseObject(String.valueOf(item));
JSONObject data = event.getJSONObject("data");
String crossingIndexCode = event.getString("crossingIndexCode");
Date happenTime = event.getDate("happenTime");
String srcName = event.getString("srcName").split("收费站")[1];
String illegalTrafficEvent = data.getString("illegalTrafficEvent");
String directionName = data.getString("directionName");
String crossingName = data.getString("crossingName");
String targetPicUrl = data.getString("targetPicUrl");
DcWarning dcWarning = new DcWarning();
dcWarning.setOtherConfig(jsonObjString);
switch (illegalTrafficEvent) {
case "congestion"://拥堵
dcWarning.setWarningType(1);
break;
//case "laneChange"://变道
// dcWarning.setWarningType();
// break;
//case "vehicleexist"://机占非
// dcWarning.setWarningType();
// break;
//case "roadBlock"://路障
// dcWarning.setWarningType();
// break;
//case "construction"://施工
// dcWarning.setWarningType();
// break;
case "llegalParking"://停车
dcWarning.setWarningType(4);
break;
//case "crossLane"://压线
// dcWarning.setWarningType();
// break;
//case "turnRound"://掉头
// dcWarning.setWarningType();
// break;
case "wrongDirection"://逆行
dcWarning.setWarningType(5);
break;
case "pedestrian"://行人
dcWarning.setWarningType(2);
break;
case "abandonedObject"://抛洒物
dcWarning.setWarningType(7);
break;
default://其他
dcWarning.setWarningType(99);
}
if (Objects.equals(directionName, "上行")) {
dcWarning.setDirection("1");
} else if (Objects.equals(directionName, "中")) {
dcWarning.setDirection("2");
} else if (Objects.equals(directionName, "下行")) {
dcWarning.setDirection("3");
}
dcWarning.setWarningTime(happenTime);
dcWarning.setCreateTime(new Date());
if (crossingName.startsWith("大学城")) {
dcWarning.setStakeMark("k59+289");
} else if (crossingName.startsWith("长清")) {
dcWarning.setStakeMark("k72+847");
} else if (crossingName.startsWith("孝里")) {
dcWarning.setStakeMark("k86+499");
} else if (crossingName.startsWith("平阴北")) {
dcWarning.setStakeMark("k99+750");
} else if (crossingName.startsWith("平阴南")) {
dcWarning.setStakeMark("k126+223");
} else if (crossingName.startsWith("平阴")) {
dcWarning.setStakeMark("k105+904");
} else if (crossingName.startsWith("东平")) {
dcWarning.setStakeMark("k145+933");
} else if (crossingName.startsWith("梁山东")) {
dcWarning.setStakeMark("k173+950");
} else if (crossingName.startsWith("梁山")) {
dcWarning.setStakeMark("k179+396");
} else if (crossingName.startsWith("嘉祥")) {
dcWarning.setStakeMark("k190+495");
}
dcWarning.setWarningTitle(crossingName+srcName);
//设置事件Id UUID无下划线格式32
String uuid = IdUtils.fastSimpleUUID();
dcWarning.setId(uuid);
dcWarning.setWarningSource(6);
dcWarning.setWarningState(1);
dcWarningService.insertDcWarning(dcWarning);
});
System.out.println("message content:" + jsonObjString);
System.out.println("============");
}
public void deliveryComplete(IMqttDeliveryToken token) {
System.out.println("deliveryComplete---------" + token.isComplete());
}
});
// 建立连接
System.out.println("连接到 broker: " + host);
client.connect(options);
System.out.println("连接成功.");
//订阅消息
//client.subscribe(topicName.getString("6274883585"), 1);
//System.out.println("开始监听" + topicName.getString("6274883585"));
client.subscribe(topicName.getString("6274879489"), 1);
System.out.println("开始监听" + topicName.getString("6274879489"));
client.subscribe(topicName.getString("7768236033"), 1);
System.out.println("开始监听" + topicName.getString("7768236033"));
client.subscribe(topicName.getString("7835340801"), 1);
System.out.println("开始监听" + topicName.getString("7835340801"));
} catch (Exception e) {
e.printStackTrace();
}
return AjaxResult.success();
}
return AjaxResult.error();
}
}

4
zc-business/src/main/java/com/zc/business/controller/StatusController.java

@ -4,6 +4,7 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.domain.Status;
import com.zc.business.service.impl.StatusService;
@ -125,6 +126,9 @@ public class StatusController extends BaseController {
//根据时间分组
Map<Integer, List<Status>> map = listStatus.stream()
.collect(Collectors.groupingBy(Status -> Status.getTime().getHour()));
if(StringUtils.isEmpty(map)){
return AjaxResult.success("暂无数据");
}
Map<Integer, List<Status>> ipMap = new TreeMap<>(map);
Integer lastKey = Collections.max(ipMap.keySet());
List<Status> lastEntry = ipMap.get(lastKey);

2
zc-business/src/main/java/com/zc/business/controller/VideoController.java

@ -207,7 +207,7 @@ public class VideoController extends BaseController {
.post(); // 请求方法
if (response.body() != null) {
String accessToken = JSONObject.parseObject(response.body().string()).getString("accessToken");
redisCache.setCacheObject(TOKENKEY, accessToken, 100, TimeUnit.MINUTES);
redisCache.setCacheObject(TOKENKEY, accessToken, 5, TimeUnit.MINUTES);
return accessToken;
}
return null;

46
zc-business/src/main/java/com/zc/business/domain/DcShifts.java

@ -1,6 +1,10 @@
package com.zc.business.domain;
import java.util.Date;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
@ -8,6 +12,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.HashMap;
import java.util.List;
/**
* 值班对象 dc_shifts
*
@ -23,9 +30,6 @@ public class DcShifts extends BaseEntity
private Long idBefore;
/** 所属路管驻点 */
@Excel(name = "所属路管驻点")
private Long stationId;
/** 当值人员ID */
@ApiModelProperty(value = "当值人员ID", required = true)
@ -72,16 +76,37 @@ public class DcShifts extends BaseEntity
@ApiModelProperty("驻点id")
@Excel(name = "驻点id")
private String station;
private Long station;
private JSONArray employeesJson;
public JSONArray getEmployeesJson() {
return employeesJson;
}
public void setEmployeesJson(JSONArray employeesJson) {
this.employeesJson = employeesJson;
}
private List<DcShiftsList> shiftsList;
public List<DcShiftsList> getShiftsList() {
return shiftsList;
}
public void setShiftsList(List<DcShiftsList> shiftsList) {
this.shiftsList = shiftsList;
}
public String getScheduling() {
return scheduling;
}
public String getStation() {
public Long getStation() {
return station;
}
public void setStation(String station) {
public void setStation(Long station) {
this.station = station;
}
@ -138,15 +163,7 @@ public class DcShifts extends BaseEntity
{
return id;
}
public void setStationId(Long stationId)
{
this.stationId = stationId;
}
public Long getStationId()
{
return stationId;
}
public void setEmployeesId(Long employeesId)
{
this.employeesId = employeesId;
@ -188,7 +205,6 @@ public class DcShifts extends BaseEntity
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("stationId", getStationId())
.append("employeesId", getEmployeesId())
.append("date", getDate())
.append("startTime", getStartTime())

120
zc-business/src/main/java/com/zc/business/domain/DcShiftsList.java

@ -0,0 +1,120 @@
package com.zc.business.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
import java.util.List;
/**
* @author 王思祥
* @ClassName DcShiftsList
*/
public class DcShiftsList {
private static final long serialVersionUID = 1L;
/** */
private Long id;
/** 当值人员ID */
@ApiModelProperty(value = "当值人员ID", required = true)
@Excel(name = "当值人员ID")
private Long employeesId;
@Excel(name = "姓名")
private String name;
@Excel(name = "所属路管驻点名称")
private String organizationName;
@ApiModelProperty("排班 1-白班 2-夜班")
@Excel(name = "排班 1-白班 2-夜班")
private String scheduling;
@ApiModelProperty("驻点id")
@Excel(name = "驻点id")
private String station;
@Excel(name = "手机号")
private String contactNumber;
public String getContactNumber() {
return contactNumber;
}
public void setContactNumber(String contactNumber) {
this.contactNumber = contactNumber;
}
public String getScheduling() {
return scheduling;
}
public String getStation() {
return station;
}
public void setStation(String station) {
this.station = station;
}
public void setScheduling(String scheduling) {
this.scheduling = scheduling;
}
public String getOrganizationName() {
return organizationName;
}
public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setEmployeesId(Long employeesId)
{
this.employeesId = employeesId;
}
public Long getEmployeesId()
{
return employeesId;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("employeesId", getEmployeesId())
.toString();
}
}

12
zc-business/src/main/java/com/zc/business/domain/DcShiftsRecord.java

@ -29,7 +29,7 @@ public class DcShiftsRecord extends BaseEntity
private String operationType;
/** 操作时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date operationTime;
@ -44,6 +44,8 @@ public class DcShiftsRecord extends BaseEntity
@Excel(name = "值班人员")
private String nickName;
@Excel(name = "驻点id")
private Long station;
public String getNickName() {
return nickName;
@ -108,6 +110,14 @@ public class DcShiftsRecord extends BaseEntity
return shiftsDate;
}
public Long getStation() {
return station;
}
public void setStation(Long station) {
this.station = station;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

8
zc-business/src/main/java/com/zc/business/mapper/DcShiftsMapper.java

@ -4,6 +4,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import com.zc.business.domain.DcShifts;
import com.zc.business.domain.DcShiftsList;
import com.zc.business.domain.DcShiftsRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.hssf.record.DConRefRecord;
@ -80,7 +81,12 @@ public interface DcShiftsMapper
*/
public DcShifts selectDcShiftsByEmployeesId(Long id);
//查询操作记录表
public List<DcShiftsRecord> selectDcShiftsRecord();
public List<DcShiftsRecord> selectDcShiftsRecord(DcShifts dcShifts);
//根据驻点和时间查询人员
public List<HashMap<String,Object>> selectStation(@Param("station") String station,@Param("date") Date date);
public List<DcShiftsList> selectStationDate(@Param("station") Long station, @Param("date") Date date);
//新增时查看是否存在
Long selectExist(DcShifts dcShifts);
//查看部分信息,删除使用
List<DcShifts> selectDcShiftsDeleteList(DcShifts dcShifts);
}

7
zc-business/src/main/java/com/zc/business/service/IDcShiftsService.java

@ -30,7 +30,8 @@ public interface IDcShiftsService
* @param dcShifts 值班
* @return 值班集合
*/
List<HashMap> selectDcShiftsList(DcShifts dcShifts);
List<DcShifts> selectDcShiftsList(DcShifts dcShifts);
List<DcShifts> selectDcShiftsListExcel(DcShifts dcShifts);
/**
@ -56,7 +57,7 @@ public interface IDcShiftsService
* @return 结果
*/
int deleteDcShiftsByIds(Long[] ids)throws Exception;
int deleteDcShiftsListId(DcShifts dcShifts)throws Exception;
/**
* 删除值班信息
*
@ -68,5 +69,5 @@ public interface IDcShiftsService
//导入文档数据
public AjaxResult importEquipment(MultipartFile file) throws Exception;
//查询操作记录表
public List<DcShiftsRecord> selectDcShiftsRecord();
public List<DcShiftsRecord> selectDcShiftsRecord(DcShifts dcShifts);
}

137
zc-business/src/main/java/com/zc/business/service/impl/DcShiftsServiceImpl.java

@ -1,13 +1,19 @@
package com.zc.business.service.impl;
import com.alibaba.fastjson.JSON;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanValidators;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.domain.DcEmployees;
import com.zc.business.domain.DcShifts;
import com.zc.business.domain.DcShiftsList;
import com.zc.business.domain.DcShiftsRecord;
import com.zc.business.mapper.DcEmployeesMapper;
import com.zc.business.mapper.DcShiftsMapper;
@ -19,13 +25,10 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.validation.Validator;
import java.lang.reflect.Array;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
/**
* 值班Service业务层处理
@ -62,23 +65,30 @@ public class DcShiftsServiceImpl implements IDcShiftsService
* @return 值班
*/
@Override
public List<HashMap> selectDcShiftsList(DcShifts dcShifts)
public List<DcShifts> selectDcShiftsList(DcShifts dcShifts)
{
List<HashMap> objects = new ArrayList<>();
// ArrayList<HashMap> objects = new ArrayList<>();
ArrayList<DcShifts> objects = new ArrayList<>();
List<DcShifts> list = dcShiftsMapper.selectDcShiftsList(dcShifts);
for (DcShifts shifts:list){
HashMap<String, Object> map = new HashMap<String, Object>();
for (DcShifts shifts:list ){
Date date = shifts.getDate();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = formatter.format(date);
String station = shifts.getStation();
List<HashMap<String, Object>> name = dcShiftsMapper.selectStation(station, date);
map.put("date",formattedDate);
map.put("organizationName",name);
objects.add(map);
Long station = shifts.getStation();
List<DcShiftsList> organizationName = dcShiftsMapper.selectStationDate(station, date);
shifts.setShiftsList(organizationName);
objects.add(shifts);
}
return objects;
// for (DcShifts shifts:list){
// HashMap<String, Object> map = new HashMap<String, Object>();
// Date date = shifts.getDate();
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
// String formattedDate = formatter.format(date);
// String station = shifts.getStation();
// List<HashMap<String, Object>> name = dcShiftsMapper.selectStation(station, date);
// map.put("date",formattedDate);
// map.put("organizationName",name);
// objects.add(map);
// }
return list;
}
@Override
@ -95,27 +105,45 @@ public class DcShiftsServiceImpl implements IDcShiftsService
@Override
@Transactional(rollbackFor = ServiceException.class)
public int insertDcShifts(DcShifts dcShifts) throws Exception{
dcShifts.setCreateTime(DateUtils.getNowDate());
int shifts = dcShiftsMapper.insertDcShifts(dcShifts);
String msg = "";
if (shifts==0){
msg="新增用户信息失败";
throw new ServiceException(msg);
}
DcShiftsRecord dcShiftsRecord = new DcShiftsRecord();
dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id
dcShiftsRecord.setOperationType("Add");//操作类型
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期
Long employeesId = dcShifts.getEmployeesId();//新增人员id
DcEmployees dcEmployees = dcEmployeesMapper.selectDcEmployeesById(employeesId);
String name = dcEmployees.getName();//新增人员名称
dcShiftsRecord.setModifyContent("新增值班人员"+name);
dcShifts.setCreateTime(DateUtils.getNowDate());
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord);
if (shiftsRecord==0){
msg="操作日志记录失败";
throw new ServiceException(msg);
JSON employeesJson = dcShifts.getEmployeesJson();
JsonElement jsonElement = new JsonParser().parse(String.valueOf(employeesJson));
JsonArray jsonArray = jsonElement.getAsJsonArray();
for (JsonElement element : jsonArray) {
Long employeesId = element.getAsJsonObject().get("employeesId").getAsLong();
Long station = element.getAsJsonObject().get("station").getAsLong();
String scheduling = element.getAsJsonObject().get("scheduling").getAsString();
if (employeesId!=null&&station!=null&& StringUtils.isNotEmpty(scheduling)){
dcShifts.setEmployeesId(employeesId);
dcShifts.setStation(station);
dcShifts.setScheduling(scheduling);
Long aLong = dcShiftsMapper.selectExist(dcShifts);
if (aLong!=0){
continue;
}
}
dcShifts.setCreateTime(DateUtils.getNowDate());
int shifts = dcShiftsMapper.insertDcShifts(dcShifts);
if (shifts==0){
msg="新增用户信息失败";
throw new ServiceException(msg);
}
DcShiftsRecord dcShiftsRecord = new DcShiftsRecord();
dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id
dcShiftsRecord.setOperationType("Add");//操作类型
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期
Long employeesIdS = dcShifts.getEmployeesId();//新增人员id
DcEmployees dcEmployees = dcEmployeesMapper.selectDcEmployeesById(employeesIdS);
String name = dcEmployees.getName();//新增人员名称
dcShiftsRecord.setModifyContent("新增值班人员"+name);
dcShifts.setCreateTime(DateUtils.getNowDate());
dcShiftsRecord.setStation(station);//驻点
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord);
if (shiftsRecord==0){
msg="操作日志记录失败";
throw new ServiceException(msg);
}
}
return 1;
}
@ -153,6 +181,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
dcShiftsRecord.setShiftsDate(dcShiftsById.getDate());//值班日期
dcShiftsRecord.setModifyContent("岗位" + postNameBefore + "姓名" + nameBefore + "修改为" + postName + name);
dcShiftsRecord.setStation(dcShiftsById.getStation());//驻点
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord);
if (shiftsRecord == 0) {
msg = "操作日志记录失败";
@ -186,6 +215,37 @@ public class DcShiftsServiceImpl implements IDcShiftsService
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
dcShiftsRecord.setModifyContent("删除值班人员"+name);
dcShiftsRecord.setShiftsDate(dcShifts.getDate());//值班日期
dcShiftsRecord.setStation(dcShifts.getStation());//驻点
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord);
if (shiftsRecord==0){
msg="操作日志记录失败";
throw new ServiceException(msg);
}
}
return 1;
}
@Override
@Transactional(rollbackFor = ServiceException.class)
public int deleteDcShiftsListId(DcShifts dcShifts) throws Exception {
List<DcShifts> shiftsValue = dcShiftsMapper.selectDcShiftsDeleteList(dcShifts);
for (DcShifts shifts:shiftsValue){
Long id = shifts.getId();
DcShifts dcShiftsById = dcShiftsMapper.selectDcShiftsById(id);
String name = dcShiftsById.getName();
String msg = "";
int i = dcShiftsMapper.deleteDcShiftsById(id);
if (i==0){
msg="删除用户信息失败";
throw new ServiceException(msg);
}
DcShiftsRecord dcShiftsRecord = new DcShiftsRecord();
dcShiftsRecord.setOperator(SecurityUtils.getUserId());//操作人员id
dcShiftsRecord.setOperationType("DELETE");//操作类型
dcShiftsRecord.setOperationTime(DateUtils.getNowDate());//操作时间
dcShiftsRecord.setModifyContent("删除值班人员"+name);
dcShiftsRecord.setShiftsDate(dcShiftsById.getDate());//值班日期
dcShiftsRecord.setStation(dcShiftsById.getStation());//驻点
int shiftsRecord = dcShiftsMapper.insertDcShiftsRecord(dcShiftsRecord);
if (shiftsRecord==0){
msg="操作日志记录失败";
@ -195,6 +255,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService
return 1;
}
/**
* 删除值班信息
*
@ -243,7 +304,7 @@ public class DcShiftsServiceImpl implements IDcShiftsService
//查询操作记录表
@Override
public List<DcShiftsRecord> selectDcShiftsRecord() {
return dcShiftsMapper.selectDcShiftsRecord();
public List<DcShiftsRecord> selectDcShiftsRecord(DcShifts shifts) {
return dcShiftsMapper.selectDcShiftsRecord(shifts);
}
}

28
zc-business/src/main/resources/mapper/business/DcShiftsMapper.xml

@ -30,9 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectDcShiftsList" parameterType="DcShifts" resultMap="DcShiftsResult">
select shifts.id, shifts.employees_id,shifts.station,
employees.name,employees.contact_number,post.post_name,organization.organization_name,
shifts.date, shifts.start_time, shifts.end_time,shifts.scheduling,
select shifts.id,
shifts.station,organization.organization_name,
shifts.date, shifts.start_time, shifts.end_time,
shifts.remark, shifts.create_time, shifts.update_time from dc_shifts as shifts
left join dc_employees as employees on employees.id=shifts.employees_id
left join sys_post as post on employees.post_id=post.post_id
@ -74,6 +74,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
record.operation_time,record.modify_content,
record.shifts_date from dc_shifts_record as record
left join sys_user as user on record.operator=user.user_id
<where>
<if test="date != null "> and record.shifts_date = #{date}</if>
<if test="station != null and station !='' "> and record.station = #{station}</if>
</where>
</select>
<select id="selectStation" resultType="java.util.HashMap">
@ -84,6 +88,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where shifts.date=#{date} and station=#{station}
</select>
<select id="selectStationDate" resultType="com.zc.business.domain.DcShiftsList">
select shifts.scheduling,shifts.employees_id,shifts.station,shifts.id,employees.contact_number,
organization.organization_name ,employees.name from dc_shifts as shifts
left join dc_employees as employees on shifts.employees_id=employees.id
left join dc_organization as organization on organization.id=shifts.station
where shifts.date=#{date} and station=#{station}
</select>
<select id="selectExist" resultType="java.lang.Long">
select count(1) from dc_shifts where date=#{date}
and employees_id=#{employeesId} and scheduling=#{scheduling} and station=#{station}
</select>
<select id="selectDcShiftsDeleteList" resultType="com.zc.business.domain.DcShifts">
select id from dc_shifts where date=#{date} and station=#{station}
</select>
<insert id="insertDcShifts" parameterType="DcShifts" useGeneratedKeys="true" keyProperty="id">
@ -120,7 +138,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="operationTime != null">operation_time,</if>
<if test="modifyContent != null and modifyContent != ''">modify_content,</if>
<if test="shiftsDate != null">shifts_date,</if>
<if test="station != null">station,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@ -129,7 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="operationTime != null">#{operationTime},</if>
<if test="modifyContent != null and modifyContent != ''">#{modifyContent},</if>
<if test="shiftsDate != null">#{shiftsDate},</if>
<if test="station != null">#{station},</if>
</trim>
</insert>

Loading…
Cancel
Save