yang_shj
11 months ago
17 changed files with 693 additions and 25 deletions
@ -0,0 +1,110 @@
|
||||
package com.hnac.hzims.operational.duty.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tenant.mp.TenantEntity; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
|
||||
/** |
||||
* 实体类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@TableName("hz_ims_duty_log") |
||||
@ApiModel(value = "ImsDutyLog对象", description = "值班日志") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class ImsDutyLogEntity extends TenantEntity implements Serializable{ |
||||
|
||||
private static final long serialVersionUID = -2877981299088576156L; |
||||
/** |
||||
* 值班ID |
||||
*/ |
||||
@ApiModelProperty(value = "值班ID") |
||||
private Long dutyId; |
||||
/** |
||||
* 日期 |
||||
*/ |
||||
@ApiModelProperty(value = "日期") |
||||
private String time; |
||||
/** |
||||
* 值班时间 |
||||
*/ |
||||
private String dutyTime; |
||||
/** |
||||
* 班类 |
||||
*/ |
||||
@ApiModelProperty(value = "班类") |
||||
private String classType; |
||||
/** |
||||
* 已执行操作票 |
||||
*/ |
||||
private String operationFinish="0"; |
||||
/** |
||||
* 未执行操作票 |
||||
*/ |
||||
private String operationUnFinish="0"; |
||||
/** |
||||
* 作废操作票 |
||||
*/ |
||||
private String operationCancel="0"; |
||||
/** |
||||
* 执行中工作票 |
||||
*/ |
||||
private String workDoing="0"; |
||||
/** |
||||
* 未执行工作票 |
||||
*/ |
||||
private String workUnFinish="0"; |
||||
/** |
||||
* 终结工作票 |
||||
*/ |
||||
private String workFinish="0"; |
||||
/** |
||||
* 作废工作票 |
||||
*/ |
||||
private String workCancel="0"; |
||||
/** |
||||
* 交班值班长 |
||||
*/ |
||||
private String handMaster; |
||||
/** |
||||
* 交班值班员 |
||||
*/ |
||||
private String handNumber; |
||||
/** |
||||
* 交班时间 |
||||
*/ |
||||
private String handTime; |
||||
/** |
||||
* 接班值班长 |
||||
*/ |
||||
private String carryMaster; |
||||
/** |
||||
* 接班值班员 |
||||
*/ |
||||
private String carryNumber; |
||||
/** |
||||
* 接班时间 |
||||
*/ |
||||
private String carryTime; |
||||
/** |
||||
* 交接班会照片 |
||||
*/ |
||||
private String dutyPic; |
||||
/** |
||||
* 值班情况 |
||||
*/ |
||||
private String dutyStatus; |
||||
/** |
||||
* 上级通知及注意事项 |
||||
*/ |
||||
private String notice; |
||||
|
||||
|
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.hnac.hzims.operational.duty.mapper; |
||||
|
||||
|
||||
import com.hnac.hzims.operational.duty.entity.ImsDutyLogEntity; |
||||
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; |
||||
|
||||
/** |
||||
* Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface ImsDutyLogMapper extends UserDataScopeBaseMapper<ImsDutyLogEntity> { |
||||
|
||||
|
||||
} |
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.operational.duty.mapper.ImsDutyLogMapper"> |
||||
</mapper> |
@ -0,0 +1,16 @@
|
||||
package com.hnac.hzims.operational.duty.service; |
||||
|
||||
import com.hnac.hzims.operational.duty.entity.ImsDutyLogEntity; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
import java.util.HashMap; |
||||
|
||||
/** |
||||
* 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface IImsDutyLogService extends BaseService<ImsDutyLogEntity> { |
||||
|
||||
void exportDutyLog(String dutyId, HashMap<String, Object> map); |
||||
|
||||
} |
@ -0,0 +1,179 @@
|
||||
package com.hnac.hzims.operational.duty.service.impl; |
||||
|
||||
import cn.afterturn.easypoi.entity.ImageEntity; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.alibaba.fastjson.TypeReference; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||
import com.hnac.hzims.operational.OperationalConstants; |
||||
import com.hnac.hzims.operational.duty.entity.*; |
||||
import com.hnac.hzims.operational.duty.mapper.ImsDutyLogMapper; |
||||
import com.hnac.hzims.operational.duty.service.*; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.commons.io.IOUtils; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springframework.stereotype.Service; |
||||
import java.io.*; |
||||
import java.net.HttpURLConnection; |
||||
import java.net.URL; |
||||
import java.util.*; |
||||
|
||||
|
||||
/** |
||||
* 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Slf4j |
||||
@Service |
||||
public class ImsDutyLogServiceImpl extends BaseServiceImpl<ImsDutyLogMapper, ImsDutyLogEntity> implements IImsDutyLogService { |
||||
|
||||
@Override |
||||
public void exportDutyLog(String dutyId, HashMap<String, Object> map) { |
||||
ImsDutyLogEntity res = this.baseMapper.selectOne(new LambdaQueryWrapper<ImsDutyLogEntity>() {{ |
||||
eq(ImsDutyLogEntity::getDutyId, dutyId) |
||||
.last(" limit 1");}}); |
||||
// ImsDutyLogEntity res=new ImsDutyLogEntity();
|
||||
if (Func.isNotEmpty(res)){ |
||||
map.put("time",res.getTime()); |
||||
map.put("dutyTime",res.getDutyTime()); |
||||
map.put("classType",res.getClassType()); |
||||
|
||||
String dutyStatus = res.getDutyStatus(); |
||||
if (StringUtils.isNotBlank(dutyStatus)){ |
||||
List<HashMap<String, String>> dutyStatusList = JSONObject.parseObject(dutyStatus, |
||||
new TypeReference< List<HashMap<String, String>>>() { |
||||
}); |
||||
|
||||
for (HashMap<String, String> stringStringHashMap : dutyStatusList) { |
||||
for (OperationalConstants.DutyLogLevel value : OperationalConstants.DutyLogLevel.values()) { |
||||
if (value.getVal().equals(stringStringHashMap.get("level"))){ |
||||
stringStringHashMap.replace("level",value.getName()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
map.put("dutyStatus",dutyStatusList); |
||||
}else { |
||||
ArrayList<HashMap<String, String>> dutyStatusList = new ArrayList<>(); |
||||
HashMap<String, String> temp = new HashMap<>(); |
||||
temp.put("name", ""); |
||||
temp.put("status",""); |
||||
temp.put("level", ""); |
||||
dutyStatusList.add(temp); |
||||
map.put("dutyStatus",dutyStatusList); |
||||
} |
||||
|
||||
|
||||
map.put("operationFinish",res.getOperationFinish()); |
||||
map.put("operationUnFinish",res.getOperationUnFinish()); |
||||
map.put("operationCancel",res.getOperationCancel()); |
||||
map.put("workDoing",res.getWorkDoing()); |
||||
map.put("workUnFinish",res.getWorkUnFinish()); |
||||
map.put("workFinish",res.getWorkFinish()); |
||||
map.put("workCancel",res.getWorkCancel()); |
||||
|
||||
String notice = res.getNotice(); |
||||
if (StringUtils.isNotBlank(notice)){ |
||||
List<HashMap<String, String>> noticeItemList = JSONObject.parseObject(notice, |
||||
new TypeReference< List<HashMap<String, String>>>() { |
||||
}); |
||||
for (HashMap<String, String> stringStringHashMap : noticeItemList) { |
||||
for (OperationalConstants.DutyLogLevel value : OperationalConstants.DutyLogLevel.values()) { |
||||
if (value.getVal().equals(stringStringHashMap.get("level"))){ |
||||
stringStringHashMap.replace("level",value.getName()); |
||||
} |
||||
} |
||||
} |
||||
map.put("notice",noticeItemList); |
||||
}else { |
||||
ArrayList<HashMap<String, String>> noticeItemList = new ArrayList<>(2); |
||||
HashMap<String, String> temp = new HashMap<>(); |
||||
temp.put("item", ""); |
||||
temp.put("level",""); |
||||
noticeItemList.add(temp); |
||||
map.put("notice",noticeItemList); |
||||
} |
||||
map.put("handMaster",res.getHandMaster()); |
||||
map.put("handNumber",res.getHandNumber()); |
||||
map.put("handTime",res.getHandTime()); |
||||
map.put("carryMaster",res.getCarryMaster()); |
||||
map.put("carryNumber",res.getCarryNumber()); |
||||
map.put("carryTime",res.getCarryTime()); |
||||
map.put("carryMaster",res.getCarryMaster()); |
||||
List<ImageEntity> imageEntityList = new ArrayList<>(); |
||||
if (StringUtils.isNotBlank(res.getDutyPic())) { |
||||
String[] dutyPicSplit = res.getDutyPic().split(","); |
||||
for (String string : dutyPicSplit) { |
||||
ImageEntity imageEntity = new ImageEntity(imgToByte("/template/img" + downloadFileByUrl(string, "/template/img")), 225, 163); |
||||
imageEntity.setUrl(string); |
||||
imageEntityList.add(imageEntity); |
||||
} |
||||
map.put("dutyPic",imageEntityList); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
private byte[] imgToByte(String tempImgPath) { |
||||
File file = new File(tempImgPath); |
||||
byte[] buffer = null; |
||||
try { |
||||
FileInputStream fis = new FileInputStream(file); |
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000); |
||||
byte[] b = new byte[1000]; |
||||
int n; |
||||
while ((n = fis.read(b)) != -1) { |
||||
bos.write(b, 0, n); |
||||
} |
||||
fis.close(); |
||||
bos.close(); |
||||
buffer = bos.toByteArray(); |
||||
} catch (IOException e) { |
||||
log.error(e.getMessage()); |
||||
} |
||||
//删除临时文件
|
||||
file.delete(); |
||||
return buffer; |
||||
} |
||||
|
||||
private String downloadFileByUrl(String fileUrl, String downloadFileDir){ |
||||
URL url = null; |
||||
String fileName = null; |
||||
try { |
||||
url = new URL(fileUrl); |
||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection(); |
||||
connection.setConnectTimeout(5000); |
||||
connection.setReadTimeout(5000); |
||||
connection.connect(); |
||||
|
||||
int responseCode = connection.getResponseCode(); |
||||
if (responseCode == 200) { |
||||
|
||||
InputStream inputStream = connection.getInputStream(); |
||||
|
||||
int lastSlashIndex = fileUrl.lastIndexOf("/"); |
||||
if (lastSlashIndex > 0){ |
||||
fileName = fileUrl.substring(lastSlashIndex+1); |
||||
String filePath = downloadFileDir + fileName; |
||||
File file = new File(filePath); |
||||
if (file.exists()){ |
||||
file.delete(); |
||||
} |
||||
OutputStream outputStream = new FileOutputStream(file); |
||||
// 将文件流拷贝到本地处理
|
||||
IOUtils.copy(inputStream, outputStream); |
||||
}else { |
||||
throw new ServiceException("下载文件路径异常:" + downloadFileDir); |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
throw new ServiceException("文件图片下载失败!"); |
||||
} |
||||
return fileName; |
||||
} |
||||
|
||||
} |
Binary file not shown.
Loading…
Reference in new issue