功能修改

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)){ if(CollectionUtil.isNotEmpty(deptList)){
deptIds = deptList.stream().map(Dept::getId).map(x->x+"").collect(Collectors.toList()); deptIds = deptList.stream().map(Dept::getId).map(x->x+"").collect(Collectors.toList());
} }
deptIds.add(deptId);
wrapper.in(Device::getLimsId,deptIds); wrapper.in(Device::getLimsId,deptIds);
}else{ }else{
wrapper.eq(Device::getLimsId,user.getDeptId()); 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>
<select id="selectTypeCount" resultType="org.springblade.modules.business.pojo.vo.PieStatVO"> <select id="selectTypeCount" resultType="org.springblade.modules.business.pojo.vo.PieStatVO">
SELECT SELECT
type as 'name', t2.type_name AS 'name',
COUNT( 1 ) as 'value' COUNT( 1 ) AS 'value'
FROM FROM
`lab_device` `lab_device` t1
WHERE is_deleted = 0 and type is not null 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"> <if test="deptIds != null">
and lims_id in and lims_id in
<foreach collection="deptIds" item="deptId" index="index" open="(" close=")" separator=","> <foreach collection="deptIds" item="deptId" index="index" open="(" close=")" separator=",">
@ -29,10 +32,10 @@
</foreach> </foreach>
</if> </if>
<if test="startTime != null and startTime.trim() != ''"> <if test="startTime != null and startTime.trim() != ''">
AND create_time &gt;= #{startTime} AND t1.create_time &gt;= #{startTime}
</if> </if>
<if test="endTime != null and endTime.trim() != ''"> <if test="endTime != null and endTime.trim() != ''">
AND create_time &lt;= #{endTime} AND t1.create_time &lt;= #{endTime}
</if> </if>
GROUP BY type GROUP BY type
</select> </select>

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

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

Loading…
Cancel
Save