功能修改

master
zhouxinyu 1 year ago
parent 54b46e8d08
commit af01c6209d
  1. 6
      src/main/java/org/springblade/modules/business/contraller/DeviceController.java
  2. 15
      src/main/java/org/springblade/modules/business/mapper/DeviceMapper.xml
  3. 2
      src/main/java/org/springblade/modules/business/mapper/MaintenanceTaskDetailMapper.xml
  4. 12
      src/main/java/org/springblade/modules/business/service/impl/DeviceServiceImpl.java
  5. 134
      src/main/java/org/springblade/modules/business/service/impl/MaintenanceTaskDetailServiceImpl.java
  6. BIN
      src/main/resources/excel/MaintenanceTaskReport.xlsx
  7. BIN
      src/main/resources/excel/RepairService.xlsx

@ -116,11 +116,15 @@ public class DeviceController extends BladeController {
if(CollectionUtil.isNotEmpty(deptList)){
deptIds = deptList.stream().map(Dept::getId).map(x->x+"").collect(Collectors.toList());
}
deptIds.add(deptId);
wrapper.in(Device::getLimsId,deptIds);
}else{
wrapper.eq(Device::getLimsId,user.getDeptId());
}
if(user.getRoleName().equals("客服") || user.getRoleName().equals("维修负责人")){
wrapper.or(wq -> wq.eq(Device::getCreateDept, user.getDeptId()));
}
wrapper.or(wq -> wq.eq(Device::getCreateUser, userId));
}

@ -17,11 +17,14 @@
</select>
<select id="selectTypeCount" resultType="org.springblade.modules.business.pojo.vo.PieStatVO">
SELECT
type as 'name',
COUNT( 1 ) as 'value'
t2.type_name AS 'name',
COUNT( 1 ) AS 'value'
FROM
`lab_device`
WHERE is_deleted = 0 and type is not null
`lab_device` t1
LEFT JOIN lab_device_type t2 ON t1.type = t2.id
WHERE
t1.is_deleted = 0
AND type IS NOT NULL
<if test="deptIds != null">
and lims_id in
<foreach collection="deptIds" item="deptId" index="index" open="(" close=")" separator=",">
@ -29,10 +32,10 @@
</foreach>
</if>
<if test="startTime != null and startTime.trim() != ''">
AND create_time &gt;= #{startTime}
AND t1.create_time &gt;= #{startTime}
</if>
<if test="endTime != null and endTime.trim() != ''">
AND create_time &lt;= #{endTime}
AND t1.create_time &lt;= #{endTime}
</if>
GROUP BY type
</select>

@ -27,7 +27,7 @@
</select>
<select id="getDeptContact" resultType="map">
SELECT
a.`name` as "name",
a.real_name as "name",
a.phone as "phone"
FROM
blade_user a

@ -79,8 +79,16 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceMapper, Device> imp
public boolean add(DeviceDTO device) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String timestamp = sdf.format(new Date());
String typeName = device.getTypeName().replace("/", "-");
device.setCode(typeName + "-" + timestamp);
StringBuilder typeNameBuilder = new StringBuilder();
for (String s : device.getType().split(",")) {
DeviceType type = typeService.getById(s);
if (type != null) {
typeNameBuilder.append(type.getTypeNameSymbol()).append("-");
} else {
typeNameBuilder.append(" ");
}
}
device.setCode(typeNameBuilder + timestamp);
device.setRunStatus(CommonConstant.DEVICE_RUN_STATUS_WORKING);
boolean save = this.save(device);
// 附件保存

@ -25,7 +25,9 @@ import org.springblade.modules.business.pojo.entity.MaintenanceTaskDetailGoods;
import org.springblade.modules.business.pojo.entity.maintenance.*;
import org.springblade.modules.business.service.IMaintenanceApplyGoodsService;
import org.springblade.modules.business.service.IMaintenanceTaskDetailService;
import org.springblade.modules.system.pojo.entity.Dept;
import org.springblade.modules.system.pojo.entity.User;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -62,6 +64,9 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc
@Autowired
private IMaintenanceApplyGoodsService maintenanceApplyGoodsService;
@Autowired
private IDeptService deptService;
@Override
public List<MaintenanceTaskDetail> findListByDeviceId(Long deviceId) {
return baseMapper.findListByDeviceId(deviceId);
@ -82,14 +87,21 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc
Map<String, Object> map1 = new HashMap<>();
map1.put("taskName", task.getDeptName());
map1.put("address", task.getDeptName());
Dept dept = deptService.getById(task.getDeptId());
map1.put("address", dept.getLabAddress());
map1.put("taskContent", task.getTaskContent());
User serviceman = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, task.getServicemanId()));
map1.put("serviceManName", serviceman.getName());
map1.put("time", DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日"));
Map<String, Object> map2 = new HashMap<>();
map2.put("taskName", task.getDeptName());
map2.put("address", task.getDeptName());
// 实验室地址
map2.put("address", dept.getLabAddress());
map2.put("inspectionConclusion", task.getInspectionConclusion());
map2.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): "");
map2.put("signatureTime",task.getFinishTime() != null ? DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日"): "");
map2.put("approveRemark",task.getApproveRemark());
//获取客户联系人、联系电话
Map<String,String> cusMap = baseMapper.getDeptContact(task.getDeptId());
if(CollectionUtils.isNotEmpty(cusMap)){
@ -150,28 +162,30 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc
}
//获取签字图片
if (StringUtils.isNotBlank(task.getSignatureUrl())) {
try {
//获取图片
URL url = new URL(task.getSignatureUrl());
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setDoInput(true);
InputStream inputStream = httpURLConnection.getInputStream();
BufferedImage image = ImageIO.read(inputStream);
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
ImageIO.write(image, "png", arrayOutputStream);
byte[] bytes = arrayOutputStream.toByteArray();
Double width = Double.valueOf(image.getWidth());
Double height = Double.valueOf(image.getHeight());
WriteCellData<Void> voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9);
map2.put("image", voidWriteCellData);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
map2.put("image",null);
}
map2.put("image",task.getSignUrl());
// 目前使用signUrl字段,为字符串,后续可能会改为图片地址
// if (StringUtils.isNotBlank(task.getSignatureUrl())) {
// try {
// //获取图片
// URL url = new URL(task.getSignatureUrl());
// HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
// httpURLConnection.setRequestMethod("GET");
// httpURLConnection.setDoInput(true);
// InputStream inputStream = httpURLConnection.getInputStream();
// BufferedImage image = ImageIO.read(inputStream);
// ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
// ImageIO.write(image, "png", arrayOutputStream);
// byte[] bytes = arrayOutputStream.toByteArray();
// Double width = Double.valueOf(image.getWidth());
// Double height = Double.valueOf(image.getHeight());
// WriteCellData<Void> voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9);
// map2.put("image", voidWriteCellData);
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// } else {
// map2.put("image",null);
// }
//将数据导出到Excel
ServletOutputStream outputStream = response.getOutputStream();
@ -212,14 +226,20 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc
Map<String, Object> map1 = new HashMap<>();
map1.put("taskName", task.getDeptName());
map1.put("address", task.getDeptName());
// 实验室地址
Dept dept = deptService.getById(task.getDeptId());
map1.put("address", dept.getLabAddress());
map1.put("taskContent", task.getTaskContent());
User serviceman = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, task.getServicemanId()));
map1.put("serviceManName", serviceman.getRealName());
map1.put("time", DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日"));
Map<String, Object> map2 = new HashMap<>();
map2.put("taskName", task.getDeptName());
map2.put("address", task.getDeptName());
map2.put("address", dept.getLabAddress());
map2.put("inspectionConclusion", task.getInspectionConclusion());
map2.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): "");
map2.put("signatureTime",task.getFinishTime() != null ? DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日"): "");
map2.put("approveRemark",task.getApproveRemark());
//获取客户联系人、联系电话
Map<String,String> cusMap = baseMapper.getDeptContact(task.getDeptId());
@ -281,28 +301,30 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc
}
}
//获取签字图片
if (StringUtils.isNotBlank(task.getSignatureUrl())) {
try {
//获取图片
URL url = new URL(task.getSignatureUrl());
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setDoInput(true);
InputStream inputStream = httpURLConnection.getInputStream();
BufferedImage image = ImageIO.read(inputStream);
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
ImageIO.write(image, "png", arrayOutputStream);
byte[] bytes = arrayOutputStream.toByteArray();
Double width = Double.valueOf(image.getWidth());
Double height = Double.valueOf(image.getHeight());
WriteCellData<Void> voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9);
map2.put("image", voidWriteCellData);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
map2.put("image",null);
}
map2.put("image",task.getSignUrl());
// 目前使用signUrl字段,为字符串,后续可能会改为图片地址
// if (StringUtils.isNotBlank(task.getSignatureUrl())) {
// try {
// //获取图片
// URL url = new URL(task.getSignatureUrl());
// HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
// httpURLConnection.setRequestMethod("GET");
// httpURLConnection.setDoInput(true);
// InputStream inputStream = httpURLConnection.getInputStream();
// BufferedImage image = ImageIO.read(inputStream);
// ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
// ImageIO.write(image, "png", arrayOutputStream);
// byte[] bytes = arrayOutputStream.toByteArray();
// Double width = Double.valueOf(image.getWidth());
// Double height = Double.valueOf(image.getHeight());
// WriteCellData<Void> voidWriteCellData = TemplateExcelUtils.imageCells(bytes, width, height, 0.6, 1.9);
// map2.put("image", voidWriteCellData);
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// } else {
// map2.put("image",null);
// }
//将数据导出到Excel
String fileName = task.getTaskCode() + "巡检报告.xlsx";
zos.putNextEntry(new ZipEntry(fileName));
@ -339,18 +361,19 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
Map<String, Object> map0 = new HashMap<>();
map0.put("taskName", task.getDeptName()); //客户名称
map0.put("address", task.getDeptName()); //地址
Dept dept = deptService.getById(task.getDeptId());
map0.put("address", dept.getLabAddress()); //地址
//获取客户联系人、联系电话
Map<String,String> cusMap = baseMapper.getDeptContact(task.getDeptId());
if(CollectionUtils.isNotEmpty(cusMap)){
map0.put("contact",cusMap.get("name")); //联系人
map0.put("phone",cusMap.get("phone")); //联系方式
}
map0.put("servicemanName", task.getServicemanName()); //维修工程师
map0.put("inspectionConclusion", task.getInspectionConclusion()); //维修结论
if(task.getServicemanId() != null){
User serviceman = userService.getOne(Wrappers.lambdaQuery(User.class).eq(User::getId, task.getServicemanId()));
map0.put("servicemanPhone", serviceman.getPhone()); //维修工程师联系方式
map0.put("servicemanName", serviceman.getRealName()); //维修工程师
}
map0.put("faultDescribe",task.getFaultDescribe()); //故障现象
map0.put("faultCause",task.getFaultCause()); //故障原因
@ -360,13 +383,14 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc
Map<String, Object> map1 = new HashMap<>();
map1.put("taskName", task.getDeptName());
map1.put("address", task.getDeptName());
map1.put("address", dept.getLabAddress());
if(CollectionUtils.isNotEmpty(cusMap)){
map1.put("contact",cusMap.get("name")); //联系人
map1.put("phone",cusMap.get("phone")); //联系方式
}
map1.put("inspectionConclusion", task.getInspectionConclusion());
map1.put("signatureTime",task.getSignatureTime() != null ? DateFormatUtils.format(task.getSignatureTime(),"yyyy年MM月dd日"): ""); //客户签字时间
map1.put("evaluationRemarks", task.getEvaluationRemarks());
map1.put("signatureTime",task.getFinishTime() != null ? DateFormatUtils.format(task.getFinishTime(),"yyyy年MM月dd日"): ""); //客户签字时间
List<RepairGoodsOutputData> repairGoodsList = new ArrayList<>();
@ -417,7 +441,7 @@ public class MaintenanceTaskDetailServiceImpl extends BaseServiceImpl<Maintenanc
}
}
map0.put("total",total); //维修材料费用
map0.put("repairTotal", (task.getTravelExpense() == null ? 0.0 : task.getTravelExpense()) + total); //维修费总计
map0.put("repairTotal", task.getActualAmount());
map0.put("total1",total1); //未维修项目材料费用
//获取签字图片

Loading…
Cancel
Save