Commit 894ead25 authored by chenzhao's avatar chenzhao

设备报废赋码

parent d9b2f803
...@@ -13,18 +13,13 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; ...@@ -13,18 +13,13 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.equipmanage.common.entity.*; import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.vo.EquipmentDetailDownloadVO; import com.yeejoin.equipmanage.common.entity.vo.EquipmentDetailDownloadVO;
import com.yeejoin.equipmanage.common.enums.EquipQrcodeColorEnum;
import com.yeejoin.equipmanage.common.enums.ExcelEnums; import com.yeejoin.equipmanage.common.enums.ExcelEnums;
import com.yeejoin.equipmanage.common.enums.SourceTypeEnum; import com.yeejoin.equipmanage.common.enums.SourceTypeEnum;
import com.yeejoin.equipmanage.common.utils.ExcelUtils; import com.yeejoin.equipmanage.common.utils.*;
import com.yeejoin.equipmanage.common.utils.NameUtils;
import com.yeejoin.equipmanage.common.utils.SpringUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.EquipmentDate; import com.yeejoin.equipmanage.common.vo.EquipmentDate;
import com.yeejoin.equipmanage.dto.ExcelDto; import com.yeejoin.equipmanage.dto.ExcelDto;
import com.yeejoin.equipmanage.mapper.EquipmentDetailMapper; import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.mapper.EquipmentSpecificMapper;
import com.yeejoin.equipmanage.mapper.ManufacturerInfoMapper;
import com.yeejoin.equipmanage.mapper.StockDetailMapper;
import com.yeejoin.equipmanage.service.*; import com.yeejoin.equipmanage.service.*;
import com.yeejoin.equipmanage.service.impl.FireFightingSystemServiceImpl; import com.yeejoin.equipmanage.service.impl.FireFightingSystemServiceImpl;
import com.yeejoin.equipmanage.service.impl.SourcesStatisticsImpl; import com.yeejoin.equipmanage.service.impl.SourcesStatisticsImpl;
...@@ -51,6 +46,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -51,6 +46,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -98,6 +94,9 @@ public class EquipmentDetailController extends AbstractBaseController { ...@@ -98,6 +94,9 @@ public class EquipmentDetailController extends AbstractBaseController {
private IExcelService excelService; private IExcelService excelService;
@Autowired @Autowired
EquipQrcodeRecordMapper equipQrcodeRecordMapper;
@Autowired
private IWarehouseStructureService warehouseStructureService; private IWarehouseStructureService warehouseStructureService;
@Autowired @Autowired
...@@ -313,8 +312,52 @@ public class EquipmentDetailController extends AbstractBaseController { ...@@ -313,8 +312,52 @@ public class EquipmentDetailController extends AbstractBaseController {
} }
} }
} }
//1.更新装备实例Detail数据 //1.更新装备实例Detail数据
EquipmentDetail equipmentDetail = equipmentDate.getEquipmentDetail(); EquipmentDetail equipmentDetail = equipmentDate.getEquipmentDetail();
if (equipmentDetail.getProductionDate() != null && equipmentDetail.getExpiryDate()!= null){
try {
//设备发生修改后 计算设备报废日期
Calendar calendar = Calendar.getInstance();
calendar.setTime(equipmentDetail.getProductionDate() );
calendar.add(Calendar.YEAR,Integer.parseInt(equipmentDetail.getExpiryDate()) );
Date now = new Date();
int day = DateUtils.dateBetween(now,calendar.getTime());
if (day > -1){
//消除设备二维码记录时间
LambdaQueryWrapper<EquipQrcodeRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipQrcodeRecord::getEquipid, vo.getId());
wrapper.eq(EquipQrcodeRecord::getSource,"scrap");
wrapper.isNull(EquipQrcodeRecord::getCleanTime);
EquipQrcodeRecord equipQrcodeRecord = equipQrcodeRecordMapper.selectOne(wrapper);
if (!ObjectUtils.isEmpty(equipQrcodeRecord)){
equipQrcodeRecord.setCleanTime(new Date());
equipQrcodeRecord.setCleanReason("设备报废日期更新后消除");
equipQrcodeRecordMapper.updateById(equipQrcodeRecord);
}
//查询二维码事件记录表中该设备的历史数据
LambdaQueryWrapper<EquipQrcodeRecord> query = new LambdaQueryWrapper<>();
query.eq(EquipQrcodeRecord::getEquipid, vo.getId());
query.isNull(EquipQrcodeRecord::getCleanTime);
List<EquipQrcodeRecord> equipQrcodeRecords = equipQrcodeRecordMapper.selectList(query);
String status = equipQrcodeRecords.stream().sorted(Comparator.comparing(EquipQrcodeRecord::getStatus)).findFirst().get().getStatus();
if (equipQrcodeRecords.size() > 0) { //如果记录表中还存在未消除的其他事件 则按照优先级赋码
equipmentSpecificSerivce.updateEquipSpecificStatus(status, String.valueOf(vo.getId()));
} else {
equipmentSpecificSerivce.updateEquipSpecificStatus(EquipQrcodeColorEnum.GREEN.getCode(), String.valueOf(vo.getId()));
}
}
} catch (ParseException e) {
e.printStackTrace();
}
}
final EquipmentDetail dateEquipmentDetail = equipmentDate.getEquipmentDetail(); final EquipmentDetail dateEquipmentDetail = equipmentDate.getEquipmentDetail();
iEquipmentDetailService.updateOneById(equipmentDate.getEquipmentSpecific().getId(), dateEquipmentDetail); iEquipmentDetailService.updateOneById(equipmentDate.getEquipmentSpecific().getId(), dateEquipmentDetail);
//2.更新装备实例主表数据 //2.更新装备实例主表数据
......
...@@ -149,6 +149,9 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -149,6 +149,9 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
@Value("${equipment.filter.code}") @Value("${equipment.filter.code}")
private String codes; private String codes;
@Autowired
EquipQrcodeRecordMapper equipQrcodeRecordMapper;
@Value("${equipment.type}") @Value("${equipment.type}")
String equipmentCategoryLeftTypeCode; String equipmentCategoryLeftTypeCode;
...@@ -1966,6 +1969,23 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1966,6 +1969,23 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
int day = DateUtils.dateBetween(now,calendar.getTime()); int day = DateUtils.dateBetween(now,calendar.getTime());
if(day < Integer.parseInt(equipmentScrapDay) && day > -1) { if(day < Integer.parseInt(equipmentScrapDay) && day > -1) {
syncSystemctlMsg(e, scrapTime, day); syncSystemctlMsg(e, scrapTime, day);
} else if (day <= -1){
LambdaQueryWrapper<EquipQrcodeRecord> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipQrcodeRecord::getEquipid, Long.valueOf(e.get("id").toString()));
wrapper.eq(EquipQrcodeRecord::getSource,"scrap");
wrapper.isNull(EquipQrcodeRecord::getCleanTime);
EquipQrcodeRecord equipQrcodeRecord = equipQrcodeRecordMapper.selectOne(wrapper);
if (ObjectUtils.isEmpty(equipQrcodeRecord)){
updateEquipSpecificStatus(EquipQrcodeColorEnum.RED.getCode(),e.get("id").toString());
EquipQrcodeRecord newEquipQrcodeRecord = new EquipQrcodeRecord();
newEquipQrcodeRecord.setEquipid(Long.valueOf(e.get("id").toString()));
newEquipQrcodeRecord.setSource("scrap");
newEquipQrcodeRecord.setAlarmTime(new Date());
newEquipQrcodeRecord.setStatus("2");
newEquipQrcodeRecord.setBizOrgCode(e.get("bizOrgCode").toString());
newEquipQrcodeRecord.setBizOrgName(e.get("bizOrgName").toString());
equipQrcodeRecordMapper.insert(newEquipQrcodeRecord);
}
} }
} }
......
...@@ -482,9 +482,10 @@ ...@@ -482,9 +482,10 @@
wes.position, wes.position,
wes.name, wes.name,
we.expiry_date as weExpiry, we.expiry_date as weExpiry,
<!-- wed.expiry_date as wesExpiry,-->
wed.area as area, wed.area as area,
wed.production_date as product wed.production_date as product,
wes.biz_org_code as bizOrgCode,
wes.biz_org_name as bizOrgName
from wl_equipment_specific wes from wl_equipment_specific wes
left join wl_equipment_detail wed on wes.equipment_detail_id = wed.id left join wl_equipment_detail wed on wes.equipment_detail_id = wed.id
left join wl_equipment we on wed.equipment_id = we.id left join wl_equipment we on wed.equipment_id = we.id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment