Merge remote-tracking branch 'origin/master'

master
mengjiao 1 year ago
commit f73b799a2a

@ -30,7 +30,7 @@ public class DevicePDAController extends BaseController {
private IEquRepairOrderService equRepairOrderService;
/**
* list
* list
*
* @param pdadto
* @return
@ -41,7 +41,7 @@ public class DevicePDAController extends BaseController {
}
/**
*
*
*
* @param pdadto
* @return

@ -37,6 +37,7 @@ public class EquCheckItemController extends BaseController {
/**
* codecode
*
* @return
*/
@RequiresPermissions("device:item:list")
@ -47,6 +48,7 @@ public class EquCheckItemController extends BaseController {
/**
* list
*
* @return
*/
@RequiresPermissions("device:item:list")

@ -16,7 +16,7 @@ import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
* Controller-使
*
* @author wws
* @date 2023-10-31

@ -67,6 +67,16 @@ public class EquPlanEquSpare extends BaseEntity {
private BigDecimal amount;
private BigDecimal storageAmount;
public BigDecimal getStorageAmount() {
return storageAmount;
}
public void setStorageAmount(BigDecimal storageAmount) {
this.storageAmount = storageAmount;
}
public BigDecimal getAmount() {
return amount;
}

@ -3,6 +3,7 @@ package com.op.device.mapper;
import java.math.BigDecimal;
import java.util.List;
import com.op.device.domain.EquPlanEquSpare;
import com.op.device.domain.EquSpareApply;
import com.op.device.domain.SparePartsLedger;
@ -62,11 +63,11 @@ public interface SparePartsLedgerMapper {
public int deleteSparePartsLedgerByStorageIds(String[] storageIds);
/**
* -
*
* @param materialCode
* @return
*/
BigDecimal selectRealAmountByMaterialCode(String materialCode);
EquPlanEquSpare selectRealAmountByMaterialCode(String materialCode);
/**
*

@ -15,14 +15,14 @@ import java.util.List;
public interface IDevicePDAService {
/**
* list
* list
*
* @return
*/
AjaxResult getTodayTask(PDADTO pdadto);
/**
*
*
*
* @param pdadto
* @return

@ -11,89 +11,94 @@ import com.op.device.domain.vo.InspectionPlanVO;
/**
* Service
*
*
* @author Open Platform
* @date 2023-10-16
*/
public interface IEquPlanService {
/**
*
*
* @param planId
* @return
*/
public EquPlan selectEquPlanByPlanId(String planId);
/**
*
*
* @param planId
* @return
*/
public EquPlan selectEquPlanByPlanId(String planId);
/**
*
*
* @param equPlan
* @return
*/
public List<EquPlan> selectEquPlanList(EquPlan equPlan);
/**
*
*
* @param equPlan
* @return
*/
public List<EquPlan> selectEquPlanList(EquPlan equPlan);
/**
*
*
* @param equPlan
* @return
*/
public AjaxResult insertEquPlan(EquPlan equPlan);
/**
*
*
* @param equPlan
* @return
*/
public AjaxResult insertEquPlan(EquPlan equPlan);
/**
*
*
* @param equPlan
* @return
*/
public AjaxResult updateEquPlan(EquPlan equPlan);
/**
*
*
* @param equPlan
* @return
*/
public AjaxResult updateEquPlan(EquPlan equPlan);
/**
*
*
* @param planIds
* @return
*/
public AjaxResult deleteEquPlanByPlanIds(String[] planIds);
/**
*
*
* @param planIds
* @return
*/
public AjaxResult deleteEquPlanByPlanIds(String[] planIds);
/**
*
*
* @param planId
* @return
*/
public int deleteEquPlanByPlanId(String planId);
/**
*
*
* @param planId
* @return
*/
public int deleteEquPlanByPlanId(String planId);
/**
* list
* @param equEquipment
* @return
*/
/**
* list
*
* @param equEquipment
* @return
*/
List<EquEquipment> getEquList(EquEquipment equEquipment);
/**
* -
* @param equPlanEquList
* @return
*/
/**
* -
*
* @param equPlanEquList
* @return
*/
AjaxResult formatEquItem(List<EquPlanEqu> equPlanEquList);
/**
* list
* @return
*/
/**
* list
*
* @return
*/
AjaxResult getPersonList();
/**
*
* @return
*/
/**
*
*
* @return
*/
AjaxResult getWorkCenter();
/**
*
* @param equPlan
* @return
*/
/**
*
*
* @param equPlan
* @return
*/
AjaxResult initUpdatePlanInfo(EquPlan equPlan);
}

@ -74,7 +74,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
/**
* list-
* list-
*
* @return
*/
@ -86,7 +86,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
}
/**
*
*
*
* @param pdadto
* @return
@ -121,51 +121,57 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
timeArray.add(order.getOrderEnd());
order.setTimeArray(timeArray);
// 查询并设置计划名称
String planName = equOrderMapper.selectPlanNameByPlanCode(order.getPlanCode());
if (planName != null) {
order.setPlanName(planName);
}
// 设备名称
// 设置设备名称
order.setEquipmentName(equipmentMapper.selectEquipmentByEquipmentCode(order.getEquipmentCode()).getEquipmentName());
// 设置工作中心名称
order.setWorkCenterName(equOrderMapper.selectCenterNameByCenterCode(order.getPlanWorkshop()));
// 通过工单编码查询检查项信息列表
List<EquOrderDetail> detailList = equOrderDetailMapper.selectEquOrderDetailByOrderCode(order.getOrderCode());
for (EquOrderDetail detail : detailList) {
// 通过检查项id查询标准信息列表
List<EquOrderStandard> standardList = equOrderStandardMapper.selectEquOrderStandardByParentCode(detail.getId());
for (EquOrderStandard standard : standardList) {
// 未达标图片
// 查询未达标图片
BaseFileData selectTemp = new BaseFileData();
selectTemp.setSourceId(standard.getId());
selectTemp.setImageType("3");
List<String> checkPictrueList = equFileMapper.selectUrlList(selectTemp);
if (checkPictrueList != null) {
standard.setCheckPictrueList(checkPictrueList);
standard.setCheckPictrueList(checkPictrueList);// 将图片地址置入
}
}
// 将处理好的标准信息列表置入检查项
detail.setStandardList(standardList);
}
// 将处理好的检查项信息列表置入工单
order.setDetailList(detailList);
// 人员信息
// 通过工单编码获取人员信息列表
List<String> users = equOrderPersonMapper.selectEquOrderPersonByOrderCode(order.getOrderCode());
// 处理人员信息
List<SysUser> personList = new ArrayList<>();
for (String id : users) {
personList.add(personMapper.selectSysUserByUserId(Long.valueOf(id)));
}
// 将人员信息置入工单
order.setPersonList(personList);
// 备件
// 通过工单编码获取备件信息列表
List<EquSpareApply> spareList = equSpareApplyMapper.selectEquSpareApplyListByWorkCode(order.getOrderCode());
if (spareList != null) {
order.setSpareList(spareList);
order.setSpareList(spareList);// 将备件信息列表置入工单
}
order.setPersonList(personList);
// 保养图片
// 获取保养图片
BaseFileData selectTemp = new BaseFileData();
selectTemp.setSourceId(order.getOrderId());
List<String> upkeepPictures = equFileMapper.selectUrlList(selectTemp);
@ -200,16 +206,23 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
}
}
// 是否含有未达标
boolean hasError = false;
// 是否为保养逻辑
boolean maintenanceFlag = false;
// 如果类型为保养
if (equOrder.getPlanType().equals("maintenance")) {
maintenanceFlag = true;
}
// 获取检查项信息列表
List<EquOrderDetail> detailList = equOrder.getDetailList();
// 处理检查项信息
for (EquOrderDetail detail : detailList) {
// 获取标准信息列表
List<EquOrderStandard> standardList = detail.getStandardList();
// 处理标准信息
for (EquOrderStandard standard : standardList) {
//上传附件
@ -225,13 +238,13 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
file.setSourceId(standard.getId());
file.setCreateBy(SecurityUtils.getUsername());
file.setCreateTime(new Date());
file.setImageType("3");
file.setImageType("3");// 设置类型为3维修前
files.add(file);
}
equFileMapper.insertEquFileBatch(files);
}
// 校验标准信息-是否申请报修
// 校验标准信息是否达标
if (standard.getStandardType().equals("quantify")) {
int up = standard.getActualValue().compareTo(standard.getDetailUpLimit());
int down = standard.getActualValue().compareTo(standard.getDetailDownLimit());
@ -256,16 +269,16 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
// 更新工单信息
equOrder.setOrderStatus("1"); // 状态为已完成
equOrder.setOrderStart(DateUtils.getNowDate());// 设置检查时间
equOrder.setUpdateTime(DateUtils.getNowDate());
equOrder.setUpdateBy(SecurityContextHolder.getUserName());
equOrder.setPlanPerson(SecurityContextHolder.getUserName());
equOrder.setPlanPerson(SecurityContextHolder.getUserName());
equOrder.setPlanPerson(SecurityContextHolder.getUserName());// 设置负责人
if (equOrder.getTimeArray().size() > 0) {
equOrder.setOrderStart(equOrder.getTimeArray().get(0));
equOrder.setOrderEnd(equOrder.getTimeArray().get(1));
equOrder.setOrderStart(equOrder.getTimeArray().get(0));// 工单开始时间
equOrder.setOrderEnd(equOrder.getTimeArray().get(1));// 工单结束时间
}
equOrder.setOrderStart(DateUtils.getNowDate());// 设置检查时间
// 是否存在报修单
boolean checkRepair = false;
if (equOrder.getRepairCode() == null) {
@ -276,7 +289,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
}
}
// 报修信息
// 报修逻辑
if (checkRepair && hasError && !maintenanceFlag) {
// 获取故障报修流水号
EquRepairOrder equRepairOrder = new EquRepairOrder();
@ -318,6 +331,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
equRepairOrderMapper.insertEquRepairOrder(equRepairOrder);
}
// 如果不存在未达标信息
if (!hasError) {
// 删除报修单
if (equOrder.getRepairCode() != null) {
@ -332,7 +346,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
if (maintenanceFlag) {
// 设置结束时间
equOrder.setOrderEnd(DateUtils.getNowDate());
// 设置保养用时
// 用时(分钟)
long diff = equOrder.getOrderEnd().getTime() - equOrder.getOrderStart().getTime();
equOrder.setOrderCostTime(String.valueOf(diff/60000));
// 创建设备对象用于更新设备状态
@ -467,6 +481,7 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
@Override
@DS("#header.poolName")
public AjaxResult startMaintenanceTask(PDADTO pdadto) {
// 通过工单编码获取工单信息
EquOrder order = equOrderMapper.selectEquOrderByOrderCode(pdadto.getOrderCode());
// 改为进行中
order.setOrderStatus("3");
@ -868,9 +883,10 @@ public class DevicePDAServiceImpl implements IDevicePDAService {
private void updateOperationRecord(String equipmentCode,String operationType,String type) {
// 设备最后一条运行记录
EquOperationRecord lastRecord = equOperationRecordMapper.selectLastOperationRecordByEquipmentCode(equipmentCode);
// 如果在维修中则不添加运行记录
if (lastRecord.getMaintenanceType() != null) {
if (!lastRecord.getMaintenanceType().isEmpty()) {
if (lastRecord.getMaintenanceType().equals("repair")) {
if (lastRecord.getMaintenanceType().equals("repair") && type.equals("upkeep")) {
return;
}
}

@ -61,6 +61,7 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
EquCheckItemVO equCheckItemVO = new EquCheckItemVO();
BeanUtils.copyProperties(equCheckItem, equCheckItemVO);
// 通过检查项编码获取标准信息列表并置入检查项
equCheckItemVO.setFormStandard(equCheckItemDetailMapper.selectEquCheckItemDetailByParentCode(equCheckItem.getItemCode()));
return equCheckItemVO;
@ -75,6 +76,7 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
@Override
@DS("#header.poolName")
public List<EquCheckItem> selectEquCheckItemList(EquCheckItem equCheckItem) {
// 创建时间列表不为空
if (equCheckItem.getCreateTimeArray() != null) {
// 设置创建日期开始和结束值
if (equCheckItem.getCreateTimeArray().size() == 2) {
@ -83,6 +85,7 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
equCheckItem.setCreateTimeEnd(formatter.format(equCheckItem.getCreateTimeArray().get(1)));
}
}
// 更新时间列表不为空
if (equCheckItem.getUpdateTimeArray() != null) {
// 设置更新日期开始和结束
if (equCheckItem.getUpdateTimeArray().size() == 2) {
@ -104,13 +107,13 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
@DS("#header.poolName")
@Transactional
public AjaxResult insertEquCheckItem(EquCheckItemDTO equCheckItemDTO) {
// 检验重复
// 校验检查项是否存在
EquCheckItem checkItem = new EquCheckItem();
checkItem.setItemType(equCheckItemDTO.getItemType());
checkItem.setItemName(equCheckItemDTO.getItemName());
List<EquCheckItem> check = equCheckItemMapper.selectEquCheckItemList(checkItem);
if (check.size() > 0) {
return error(500,"检查项已存在!新增失败!");
return error(500, "检查项已存在!新增失败!");
}
// 创建检查项对象
@ -128,64 +131,20 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
String serialNum = String.format("%03d", equCheckItemMapper.selectSerialNumber());
// 处理检查项信息
equCheckItem.setItemId(IdUtils.fastSimpleUUID());
equCheckItem.setFactoryCode(factory);
equCheckItem.setItemCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + serialNum);
equCheckItem.setItemId(IdUtils.fastSimpleUUID());// id
equCheckItem.setFactoryCode(factory);// 工厂编码
equCheckItem.setItemCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + serialNum);// 检查项编码
equCheckItem.setCreateBy(SecurityContextHolder.getUserName());
equCheckItem.setCreateTime(DateUtils.getNowDate());
equCheckItem.setUpdateBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdateTime(DateUtils.getNowDate());
if (equCheckItem.getItemType().equals("spotInspection")) {
equCheckItem.setItemTypeName("点检");
}
if (equCheckItem.getItemType().equals("inspection")) {
equCheckItem.setItemTypeName("巡检");
}
if (equCheckItem.getItemType().equals("maintenance")) {
equCheckItem.setItemTypeName("保养");
}
equCheckItem.setItemTypeName(exchangeItemType(equCheckItem.getItemType()));// 维护类型
// 插入数据库
// 检查项新增至数据库
equCheckItemMapper.insertEquCheckItem(equCheckItem);
// 处理标准信息
for (EquCheckItemDetail detail : equCheckItemDTO.getFormStandard()) {
// 获取标准流水号
String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode()));
detail.setDetailId(IdUtils.fastSimpleUUID());
detail.setParentCode(equCheckItem.getItemCode());
detail.setFactoryCode(factory);
detail.setDetailCode(equCheckItem.getItemCode() + detailSerialNum);
detail.setCreateBy(SecurityContextHolder.getUserName());
detail.setCreateTime(DateUtils.getNowDate());
detail.setUpdateBy(SecurityContextHolder.getUserName());
detail.setUpdateTime(DateUtils.getNowDate());
// 插入到数据库
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
}
// 处理关联设备信息
for (String code : equCheckItemDTO.getEquipmentCodeList()) {
EquItemEquipment equItemEquipment = new EquItemEquipment();
// 获取流水号
String cnnSerialNum = String.format("%03d", equItemEquipmentMapper.selectSerialNumber());
equItemEquipment.setId(IdUtils.fastSimpleUUID());
equItemEquipment.setConnCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+cnnSerialNum);
equItemEquipment.setItemCode(equCheckItem.getItemCode());
equItemEquipment.setEquipmentCode(code);
equItemEquipment.setFactoryCode(factory);
equItemEquipment.setCreateBy(SecurityContextHolder.getUserName());
equItemEquipment.setCreateTime(DateUtils.getNowDate());
equItemEquipment.setUpdateBy(SecurityContextHolder.getUserName());
equItemEquipment.setUpdateTime(DateUtils.getNowDate());
// 插入数据库
equItemEquipmentMapper.insertEquItemEquipment(equItemEquipment);
}
// 处理标准信息、关联设备信息
insertInfoCommon(equCheckItem,equCheckItemDTO.getFormStandard(),equCheckItemDTO.getEquipmentCodeList());
return success("新增成功");
}
@ -201,79 +160,37 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
@Transactional
public AjaxResult updateEquCheckItem(EquCheckItemDTO equCheckItemDTO) {
// 检验
// 校验检查项是否已存在
EquCheckItem checkQuery = new EquCheckItem();
checkQuery.setItemType(equCheckItemDTO.getItemType());
checkQuery.setItemName(equCheckItemDTO.getItemName());
List<EquCheckItem> check = equCheckItemMapper.selectEquCheckItemList(checkQuery);
if (check.size()>0) {
if (check.size() > 0) {
if (!check.get(0).getItemCode().equals(equCheckItemDTO.getItemCode())) {
return error(500,"检查项已存在!不可修改!");
return error(500, "检查项已存在!不可修改!");
}
}
// 创建检查项对象
EquCheckItem equCheckItem = new EquCheckItem();
BeanUtils.copyProperties(equCheckItemDTO, equCheckItem);
// 处理检查项信息
equCheckItem.setUpdateBy(SecurityContextHolder.getUserName());
equCheckItem.setUpdateTime(DateUtils.getNowDate());
if (equCheckItem.getItemType().equals("spotInspection")) {
equCheckItem.setItemTypeName("点检");
}
if (equCheckItem.getItemType().equals("inspection")) {
equCheckItem.setItemTypeName("巡检");
}
if (equCheckItem.getItemType().equals("maintenance")) {
equCheckItem.setItemTypeName("保养");
}
equCheckItem.setItemTypeName(exchangeItemType(equCheckItem.getItemType()));// 维护类型
// 更新检查项信息
equCheckItemMapper.updateEquCheckItem(equCheckItem);
// 删除所有该检查项标准
equCheckItemDetailMapper.deleteEquCheckItemDetailByItemId(equCheckItem.getItemId());
// 处理检查项详情信息
for (EquCheckItemDetail detail : equCheckItemDTO.getFormStandard()) {
// 获取标准流水号
String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode()));
detail.setDetailId(IdUtils.fastSimpleUUID());
detail.setParentCode(equCheckItem.getItemCode());
detail.setFactoryCode(equCheckItem.getFactoryCode());
detail.setDetailCode(equCheckItem.getItemCode() + detailSerialNum);
detail.setCreateBy(SecurityContextHolder.getUserName());
detail.setCreateTime(DateUtils.getNowDate());
detail.setUpdateBy(SecurityContextHolder.getUserName());
detail.setUpdateTime(DateUtils.getNowDate());
// 插入到数据库
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
}
// 删除所有该检查项关联设备
equItemEquipmentMapper.deleteEquItemEquipmentByItemCode(equCheckItemDTO.getItemCode());
// 处理关联设备信息
for (String code : equCheckItemDTO.getEquipmentCodeList()) {
EquItemEquipment equItemEquipment = new EquItemEquipment();
// 获取流水号
String cnnSerialNum = String.format("%03d", equItemEquipmentMapper.selectSerialNumber());
equItemEquipment.setId(IdUtils.fastSimpleUUID());
equItemEquipment.setConnCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+cnnSerialNum);
equItemEquipment.setItemCode(equCheckItem.getItemCode());
equItemEquipment.setEquipmentCode(code);
equItemEquipment.setFactoryCode(equCheckItemDTO.getFactoryCode());
equItemEquipment.setCreateBy(SecurityContextHolder.getUserName());
equItemEquipment.setCreateTime(DateUtils.getNowDate());
equItemEquipment.setUpdateBy(SecurityContextHolder.getUserName());
equItemEquipment.setUpdateTime(DateUtils.getNowDate());
// 处理标准信息、关联设备信息
insertInfoCommon(equCheckItem,equCheckItemDTO.getFormStandard(),equCheckItemDTO.getEquipmentCodeList());
// 插入数据库
equItemEquipmentMapper.insertEquItemEquipment(equItemEquipment);
}
return success("修改成功");
}
@ -289,11 +206,10 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
// 检验
for (String data : itemIds) {
// 检验
EquCheckItem equCheckItem = equCheckItemMapper.selectEquCheckItemByItemId(data);
List<EquPlanDetail> checkItemList = equCheckItemMapper.checkDelItem(equCheckItem.getItemCode());
if (checkItemList.size() > 0) {
return error(500,"该检查项已有计划使用,删除失败!");
return error(500, "该检查项已有计划使用,删除失败!");
}
}
@ -326,6 +242,7 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
/**
*
*
* @return
*/
@Override
@ -337,6 +254,7 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
/**
* codecode
*
* @return
*/
@Override
@ -345,4 +263,70 @@ public class EquCheckItemServiceImpl implements IEquCheckItemService {
List<String> equipmentCodeList = equItemEquipmentMapper.selectEquipmentCodeList(itemCode);
return success(equipmentCodeList);
}
/**
*
* @param itemType
* @return
*/
private String exchangeItemType(String itemType){
if (itemType.equals("spotInspection")) {
return "点检";
}
if (itemType.equals("inspection")) {
return "巡检";
}
if (itemType.equals("maintenance")) {
return "保养";
}
return null;
}
/**
*
* @param equCheckItem
* @param detailList
* @param equipmentCodes
*/
private void insertInfoCommon(EquCheckItem equCheckItem,List<EquCheckItemDetail> detailList, List<String> equipmentCodes) {
// 处理标准信息
for (EquCheckItemDetail detail : detailList) {
// 获取标准流水号
String detailSerialNum = String.format("%03d", equCheckItemDetailMapper.selectSerialNumber(equCheckItem.getItemCode()));
detail.setDetailId(IdUtils.fastSimpleUUID());// id
detail.setParentCode(equCheckItem.getItemCode());// 检查项code
detail.setFactoryCode(equCheckItem.getFactoryCode());// 工厂
detail.setDetailCode(equCheckItem.getItemCode() + detailSerialNum);// 标准code
detail.setCreateBy(SecurityContextHolder.getUserName());
detail.setCreateTime(DateUtils.getNowDate());
detail.setUpdateBy(SecurityContextHolder.getUserName());
detail.setUpdateTime(DateUtils.getNowDate());
// 插入到数据库(可优化)
equCheckItemDetailMapper.insertEquCheckItemDetail(detail);
}
// 处理关联设备信息
for (String code : equipmentCodes) {
EquItemEquipment equItemEquipment = new EquItemEquipment();
// 获取流水号
String cnnSerialNum = String.format("%03d", equItemEquipmentMapper.selectSerialNumber());
equItemEquipment.setId(IdUtils.fastSimpleUUID());// id
equItemEquipment.setConnCode(equCheckItem.getItemCode() + cnnSerialNum);// 关联设备编码
equItemEquipment.setItemCode(equCheckItem.getItemCode());// 检查项编码
equItemEquipment.setEquipmentCode(code);// 设备编码
equItemEquipment.setFactoryCode(equCheckItem.getFactoryCode());// 工厂
equItemEquipment.setCreateBy(SecurityContextHolder.getUserName());
equItemEquipment.setCreateTime(DateUtils.getNowDate());
equItemEquipment.setUpdateBy(SecurityContextHolder.getUserName());
equItemEquipment.setUpdateTime(DateUtils.getNowDate());
// 插入数据库(可优化)
equItemEquipmentMapper.insertEquItemEquipment(equItemEquipment);
}
}
}

@ -53,6 +53,7 @@ public class EquFaultTypeServiceImpl implements IEquFaultTypeService {
@Override
@DS("#header.poolName")
public List<EquFaultType> selectEquFaultTypeList(EquFaultType equFaultType) {
// 创建时间不为空
if (equFaultType.getCreateTimeArray() != null) {
// 设置创建日期开始和结束值
if (equFaultType.getCreateTimeArray().size() == 2) {
@ -61,6 +62,7 @@ public class EquFaultTypeServiceImpl implements IEquFaultTypeService {
equFaultType.setCreateTimeEnd(formatter.format(equFaultType.getCreateTimeArray().get(1)));
}
}
// 更新时间不为空
if (equFaultType.getUpdateTimeArray() != null) {
// 设置更新日期开始和结束
if (equFaultType.getUpdateTimeArray().size() == 2) {
@ -82,13 +84,13 @@ public class EquFaultTypeServiceImpl implements IEquFaultTypeService {
@DS("#header.poolName")
public AjaxResult insertEquFaultType(EquFaultType equFaultType) {
//
//
EquFaultType checkQuery = new EquFaultType();
checkQuery.setFaultType(equFaultType.getFaultType());
checkQuery.setFaultSubclass(equFaultType.getFaultSubclass());
List<EquFaultType> check = equFaultTypeMapper.selectEquFaultTypeList(checkQuery);
if (check.size() > 0) {
return error(500,"故障子类已存在!不可添加!");
return error(500, "故障子类已存在!不可添加!");
}
//获取当前所选工厂
@ -102,9 +104,9 @@ public class EquFaultTypeServiceImpl implements IEquFaultTypeService {
String serialNum = String.format("%03d", equFaultTypeMapper.selectSerialNumber());
// 处理故障信息
equFaultType.setFaultId(IdUtils.fastSimpleUUID());
equFaultType.setFaultCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + serialNum);
equFaultType.setFactoryCode(factory);
equFaultType.setFaultId(IdUtils.fastSimpleUUID());// id
equFaultType.setFaultCode(DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + serialNum);// 故障编码
equFaultType.setFactoryCode(factory);// 工厂
equFaultType.setCreateBy(SecurityContextHolder.getUserName());
equFaultType.setCreateTime(DateUtils.getNowDate());
equFaultType.setUpdateBy(SecurityContextHolder.getUserName());
@ -126,14 +128,16 @@ public class EquFaultTypeServiceImpl implements IEquFaultTypeService {
@DS("#header.poolName")
public AjaxResult updateEquFaultType(EquFaultType equFaultType) {
//
//
EquFaultType checkQuery = new EquFaultType();
checkQuery.setFaultType(equFaultType.getFaultType());
checkQuery.setFaultSubclass(equFaultType.getFaultSubclass());
List<EquFaultType> check = equFaultTypeMapper.selectEquFaultTypeList(checkQuery);
if (check.size() > 0) {
if (!check.get(0).equals(equFaultType.getFaultCode())) {
return error(500,"故障子类已存在!修改失败!");
for (EquFaultType faultType : check) {
if (!faultType.getFaultCode().equals(equFaultType.getFaultCode())){
return error(500, "故障子类已存在!修改失败!");
}
}
}
equFaultType.setUpdateBy(SecurityContextHolder.getUserName());

@ -67,7 +67,7 @@ public class EquOrderServiceImpl implements IEquOrderService {
@Override
@DS("#header.poolName")
public EquOrder selectEquOrderByOrderCode(String orderCode) {
// 查询工单信息
// 通过工单编码获取工单信息
EquOrder order = equOrderMapper.selectEquOrderByOrderCode(orderCode);
List<Date> timeArray = new ArrayList<>();
@ -122,32 +122,32 @@ public class EquOrderServiceImpl implements IEquOrderService {
@DS("#header.poolName")
public List<EquOrder> selectEquOrderList(EquOrder equOrder) {
// 循环开始时间列表不为空
if (equOrder.getLoopStartArray() != null) {
equOrder.setLoopStart(equOrder.getLoopStartArray().get(0));
equOrder.setLoopEnd(equOrder.getLoopStartArray().get(1));
}
// 循环结束时间不为空
if (equOrder.getLoopEndArray() != null) {
equOrder.setLoopEndArrayStart(equOrder.getLoopEndArray().get(0));
equOrder.setGetLoopEndArrayEnd(equOrder.getLoopEndArray().get(1));
}
// 执行开始时间不为空
if (equOrder.getOrderStartArray() != null) {
equOrder.setOrderStartArrayStart(equOrder.getOrderStartArray().get(0));
equOrder.setOrderStartArrayEnd(equOrder.getOrderStartArray().get(1));
}
// 执行结束时间不为空
if (equOrder.getOrderEndArray() != null) {
equOrder.setOrderEndArrayStart(equOrder.getOrderEndArray().get(0));
equOrder.setOrderEndArrayEnd(equOrder.getOrderEndArray().get(1));
}
// 获取工单列表
List<EquOrder> orderList = equOrderMapper.selectEquOrderList(equOrder);
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
List<WorkCenter> workCenters = equPlanMapper.selectWorkCenter(factory);
// 获取工作中心
List<WorkCenter> workCenters = getWorkCenterCommon();
// 设置工作中心
for (EquOrder order : orderList) {
@ -203,16 +203,23 @@ public class EquOrderServiceImpl implements IEquOrderService {
}
}
// 是否含有未达标
boolean hasError = false;
// 是否为保养逻辑
boolean maintenanceFlag = false;
// 如果类型为保养
if (equOrder.getPlanType().equals("maintenance")) {
maintenanceFlag = true;
}
// 获取检查项信息列表
List<EquOrderDetail> detailList = equOrder.getDetailList();
// 处理检查项信息
for (EquOrderDetail detail : detailList) {
// 获取标准列表
List<EquOrderStandard> standardList = detail.getStandardList();
// 处理标准信息
for (EquOrderStandard standard : standardList) {
//上传附件
@ -228,13 +235,13 @@ public class EquOrderServiceImpl implements IEquOrderService {
file.setSourceId(standard.getId());
file.setCreateBy(SecurityUtils.getUsername());
file.setCreateTime(new Date());
file.setImageType("3");
file.setImageType("3");// 设置类型为3维修前
files.add(file);
}
equFileMapper.insertEquFileBatch(files);
}
// 校验标准信息-是否申请报修
// 校验标准信息是否达标
if (standard.getStandardType().equals("quantify")) {
int up = standard.getActualValue().compareTo(standard.getDetailUpLimit());
int down = standard.getActualValue().compareTo(standard.getDetailDownLimit());
@ -255,19 +262,19 @@ public class EquOrderServiceImpl implements IEquOrderService {
}
}
// 更新工单信息
// 更新工单信息排除保养PCPC端手动操作状态
if (!equOrder.getPlanType().equals("maintenance")) {
equOrder.setOrderStatus("1"); // 状态为已完成
}
equOrder.setUpdateTime(DateUtils.getNowDate());
equOrder.setUpdateBy(SecurityContextHolder.getUserName());
equOrder.setPlanPerson(SecurityContextHolder.getUserName());
equOrder.setPlanPerson(SecurityContextHolder.getUserName());
equOrder.setPlanPerson(SecurityContextHolder.getUserName());// 设置负责人
if (equOrder.getTimeArray().size() > 0) {
equOrder.setOrderStart(equOrder.getTimeArray().get(0));
equOrder.setOrderEnd(equOrder.getTimeArray().get(1));
equOrder.setOrderStart(equOrder.getTimeArray().get(0));// 工单开始时间
equOrder.setOrderEnd(equOrder.getTimeArray().get(1));// 工单结束时间
}
// 是否存在报修单
boolean checkRepair = false;
if (equOrder.getRepairCode() == null) {
@ -278,7 +285,7 @@ public class EquOrderServiceImpl implements IEquOrderService {
}
}
// 报修信息
// 报修逻辑
if (checkRepair && hasError && !maintenanceFlag) {
// 获取故障报修流水号
EquRepairOrder equRepairOrder = new EquRepairOrder();
@ -322,6 +329,7 @@ public class EquOrderServiceImpl implements IEquOrderService {
equRepairOrderMapper.insertEquRepairOrder(equRepairOrder);
}
// 如果不存在未达标信息
if (!hasError) {
// 删除报修单
if (equOrder.getRepairCode() != null) {
@ -334,7 +342,7 @@ public class EquOrderServiceImpl implements IEquOrderService {
// 保养逻辑
if (maintenanceFlag) {
// 用时
// 用时(分钟)
if (equOrder.getOrderStart() != null) {
long diffSeconds = (equOrder.getOrderEnd().getTime() - equOrder.getOrderStart().getTime()) / 60000;
equOrder.setOrderCostTime(String.valueOf(diffSeconds));
@ -410,4 +418,21 @@ public class EquOrderServiceImpl implements IEquOrderService {
public int deleteEquOrderByOrderId(String orderId) {
return equOrderMapper.deleteEquOrderByOrderId(orderId);
}
/**
*
*
* @return
*/
private List<WorkCenter> getWorkCenterCommon() {
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 根据当前工厂获取该工厂下的所有工作中心
List<WorkCenter> workCenters = equPlanMapper.selectWorkCenter(factory);
return workCenters;
}
}

@ -1,6 +1,5 @@
package com.op.device.service.impl;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -54,7 +53,6 @@ public class EquPlanServiceImpl implements IEquPlanService {
private EquPlanEquMapper equPlanEquMapper;
@Autowired
private EquPlanEquSpareMapper equPlanEquSpareMapper;
// 备件mapper
@Autowired
private SparePartsLedgerMapper sparePartsLedgerMapper;
@ -79,6 +77,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
@Override
@DS("#header.poolName")
public List<EquPlan> selectEquPlanList(EquPlan equPlan) {
// 创建时间列表不为空
if (equPlan.getCreateTimeArray() != null) {
// 设置创建日期开始和结束值
if (equPlan.getCreateTimeArray().size() == 2) {
@ -87,6 +86,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
equPlan.setCreateTimeEnd(formatter.format(equPlan.getCreateTimeArray().get(1)));
}
}
// 更新时间列表不为空
if (equPlan.getUpdateTimeArray() != null) {
// 设置更新日期开始和结束
if (equPlan.getUpdateTimeArray().size() == 2) {
@ -95,30 +95,28 @@ public class EquPlanServiceImpl implements IEquPlanService {
equPlan.setUpdateTimeEnd(formatter.format(equPlan.getUpdateTimeArray().get(1)));
}
}
// 循环开始时间列表不为空
if (equPlan.getLoopStartArray() != null) {
equPlan.setLoopStart(equPlan.getLoopStartArray().get(0));
equPlan.setLoopEnd(equPlan.getLoopStartArray().get(1));
}
// 循环结束时间列表不为空
if (equPlan.getLoopEndArray() != null) {
equPlan.setLoopEndArrayStart(equPlan.getLoopEndArray().get(0));
equPlan.setGetLoopEndArrayEnd(equPlan.getLoopEndArray().get(1));
}
// 查询计划信息列表
List<EquPlan> equPlans = equPlanMapper.selectEquPlanList(equPlan);
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
List<WorkCenter> workCenters = equPlanMapper.selectWorkCenter(factory);
// 获取工作中心
List<WorkCenter> workCenters = getWorkCenterCommon();
// 处理计划信息
for (EquPlan plan : equPlans) {
for (WorkCenter center : workCenters) {
// 工作中心(车间)一致
if (plan.getPlanWorkshop().equals(center.getFactoryCode())) {
plan.setWorkCenterName(center.getFactoryName());
plan.setWorkCenterName(center.getFactoryName());// 置入工作中心名称
}
}
}
@ -135,7 +133,6 @@ public class EquPlanServiceImpl implements IEquPlanService {
@Override
@DS("#header.poolName")
public AjaxResult insertEquPlan(EquPlan equPlan) {
// 处理计划信息
// 获取计划流水号
String planSerialNum = String.format("%03d", equPlanMapper.selectSerialNumber());
@ -146,13 +143,13 @@ public class EquPlanServiceImpl implements IEquPlanService {
int index = str.indexOf("_");
String factory = str.substring(index + 1);
equPlan.setPlanId(IdUtils.fastSimpleUUID());
equPlan.setPlanCode((DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + planSerialNum));
equPlan.setPlanId(IdUtils.fastSimpleUUID());// 计划id
equPlan.setPlanCode((DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + planSerialNum));// 计划编码
if (equPlan.getPlanTimeArray().size() > 0) {
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));// 计划循环周期开始时间
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));// 计划循环周期结束时间
}
equPlan.setFactoryCode(factory);
equPlan.setFactoryCode(factory);// 工厂编码
equPlan.setCreateBy(SecurityContextHolder.getUserName());
equPlan.setCreateTime(DateUtils.getNowDate());
equPlan.setUpdateBy(SecurityContextHolder.getUserName());
@ -176,17 +173,21 @@ public class EquPlanServiceImpl implements IEquPlanService {
@Override
@DS("#header.poolName")
public AjaxResult updateEquPlan(EquPlan equPlan) {
// 更新巡检计划
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
// 设置循环范围时间
if (equPlan.getPlanTimeArray().size() != 0) {
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));// 循环开始时间
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));// 循环结束时间
}
// 更新计划
equPlanMapper.updateEquPlan(equPlan);
// 删除该计划下设备、人员、检查项、标准
equPlanPersonMapper.deleteEquPlanPersonByPlanCode(equPlan.getPlanCode());
equPlanDetailMapper.deleteEquPlanDetailByPlanCode(equPlan.getPlanCode());
equPlanEquMapper.deleteEquPlanEquByPlanCode(equPlan.getPlanCode());
equPlanStandardMapper.deleteEquPlanStandardByPlanCode(equPlan.getPlanCode());
//获取当前所选工厂
// 删除该计划下设备、人员、检查项、标准、备件
equPlanPersonMapper.deleteEquPlanPersonByPlanCode(equPlan.getPlanCode());// 人员
equPlanDetailMapper.deleteEquPlanDetailByPlanCode(equPlan.getPlanCode());// 检查项
equPlanEquMapper.deleteEquPlanEquByPlanCode(equPlan.getPlanCode());// 设备
equPlanStandardMapper.deleteEquPlanStandardByPlanCode(equPlan.getPlanCode());// 标准
equPlanEquSpareMapper.deleteEquPlanEquSpareByPlanCode(equPlan.getPlanCode());// 备件
// 获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
@ -211,13 +212,12 @@ public class EquPlanServiceImpl implements IEquPlanService {
// 逻辑删除信息
for (String id : planIds) {
EquPlan equPlan = equPlanMapper.selectEquPlanByPlanId(id);
equPlanMapper.delEquPlanByPlanCode(equPlan.getPlanCode());
equPlanPersonMapper.delEquPlanPersonByPlanCode(equPlan.getPlanCode());
equPlanDetailMapper.delEquPlanDetailByPlanCode(equPlan.getPlanCode());
equPlanEquMapper.delEquPlanEquByPlanCode(equPlan.getPlanCode());
equPlanStandardMapper.delEquPlanStandardByPlanCode(equPlan.getPlanCode());
// TODO 有问题没有删除成功
equPlanEquSpareMapper.delEquPlanEquSpareByPlanCode(equPlan.getPlanCode());
equPlanMapper.delEquPlanByPlanCode(equPlan.getPlanCode());// 计划
equPlanPersonMapper.delEquPlanPersonByPlanCode(equPlan.getPlanCode());// 人员
equPlanDetailMapper.delEquPlanDetailByPlanCode(equPlan.getPlanCode());// 检查项
equPlanEquMapper.delEquPlanEquByPlanCode(equPlan.getPlanCode());// 设备
equPlanStandardMapper.delEquPlanStandardByPlanCode(equPlan.getPlanCode());// 标准
equPlanEquSpareMapper.delEquPlanEquSpareByPlanCode(equPlan.getPlanCode());// TODO 备件(没有删除成功?)
}
return success();
}
@ -255,46 +255,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
@Override
@DS("#header.poolName")
public AjaxResult formatEquItem(List<EquPlanEqu> equPlanEquList) {
for (EquPlanEqu data : equPlanEquList) {
StringBuilder itemTempName = new StringBuilder();
// 获取检查项list
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(),"inspection");
if (equCheckItemList.size() > 0) {
List<EquPlanDetail> detailList = new ArrayList<>();
for (EquCheckItem checkItem : equCheckItemList) {
// 只需要循环周期一致的检查项
if(checkItem.getItemLoop() == data.getItemLoop() && checkItem.getItemLoopType().equals(data.getItemLoopType())) {
EquPlanDetail detail = new EquPlanDetail();
BeanUtils.copyProperties(checkItem,detail);
if (!detail.getItemCode().isEmpty()) {
itemTempName.append(detail.getItemName()).append(",");
// 获取检查项详情list
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(detail.getItemCode());
if (equCheckItemList.size() > 0) {
List<EquPlanStandard> standardList = new ArrayList<>();
for (EquCheckItemDetail standardTemp : equCheckItemDetailList) {
EquPlanStandard standard = new EquPlanStandard();
BeanUtils.copyProperties(standardTemp,standard);
standard.setShowFlag(true);
standardList.add(standard);
}
detail.setEquPlanStandardList(standardList);
}
}
detailList.add(detail);
}
}
data.setEquPlanDetailList(detailList);
data.setItemTempName(itemTempName.toString());
}else {
return error(500,"存在设备未设置巡检项!");
}
}
return success(equPlanEquList);
return formatEquItemCommon(equPlanEquList, "inspection", "存在未设置巡检项!");
}
/**
@ -317,14 +278,7 @@ public class EquPlanServiceImpl implements IEquPlanService {
@Override
@DS("#header.poolName")
public AjaxResult getWorkCenter() {
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
return success(equPlanMapper.selectWorkCenter(factory));
return success(getWorkCenterCommon());
}
/**
@ -337,9 +291,9 @@ public class EquPlanServiceImpl implements IEquPlanService {
@DS("#header.poolName")
public AjaxResult initUpdatePlanInfo(EquPlan equPlan) {
// 获取计划信息
// 通过计划编码获取计划信息
EquPlan plan = equPlanMapper.selectEquPlanByPlanCode(equPlan.getPlanCode());
// 处理计划信息
// 处理计划循环时间信息(用于前端)
List<Date> planTimeArray = new ArrayList<>();
if (plan.getPlanLoopStart() != null) {
planTimeArray.add(plan.getPlanLoopStart());
@ -348,138 +302,146 @@ public class EquPlanServiceImpl implements IEquPlanService {
}
// 获取人员信息
// 通过计划编码获取人员信息列表
List<EquPlanPerson> personList = equPlanPersonMapper.selectEquPlanPersonByPlanCode(equPlan.getPlanCode());
// 处理人员信息列表信息用于前端穿梭框信息回填
List<Long> persons = new ArrayList<>();
for (EquPlanPerson person : personList) {
persons.add(person.getUserId());
}
// 获取设备信息
// 通过计划编码获取设备信息列表
List<EquPlanEqu> equipmentList = equPlanEquMapper.selectEquPlanEquByPlanCode(equPlan.getPlanCode());
// 处理设备信息
for (EquPlanEqu equipment : equipmentList) {
// 获取检查项list
// 通过设备表id获取检查项列表
List<EquPlanDetail> detailList = equPlanDetailMapper.selectEquPlanDetailListByParentCode(equipment.getId());
for (EquPlanDetail detail : detailList) {
// 获取标准list
// 通过检查项id获取标准信息列表
List<EquPlanStandard> standardList = equPlanStandardMapper.selectEquPlanStandardListByParentCode(detail.getId());
// 处理标准信息
for (EquPlanStandard standard : standardList) {
standard.setShowFlag(true);
standard.setItemLoop(detail.getItemLoop());
standard.setItemLoopType(detail.getItemLoopType());
standard.setShowFlag(true);// 设置默认值(用于前端)
standard.setItemLoop(detail.getItemLoop());// 设置循环周期(用于前端)
standard.setItemLoopType(detail.getItemLoopType());// 设置循环周期类型(用于前端)
}
// 置入标准
// 将处理好的标准列表置入检查项
detail.setEquPlanStandardList(standardList);
}
// 置入检查项
// 将处理好的检查项列表置入设备
equipment.setEquPlanDetailList(detailList);
EquPlanEquSpare spare = new EquPlanEquSpare();
spare.setParentCode(equipment.getId());
// 备件信息
List<EquPlanEquSpare> spareList = equPlanEquSpareMapper.selectEquPlanEquSpareList(spare);
// 创建备件搜索临时对象
EquPlanEquSpare spareSelectTemp = new EquPlanEquSpare();
spareSelectTemp.setParentCode(equipment.getId());// 设置parentCode设备表id
// 通过临时搜索对象查询备件信息列表
List<EquPlanEquSpare> spareList = equPlanEquSpareMapper.selectEquPlanEquSpareList(spareSelectTemp);
if (spareList.size() > 0) {
// 处理备件信息
for (EquPlanEquSpare equSpare : spareList) {
// 通过备件编码查询备件库存信息(总量-冻结)
equSpare.setAmount(sparePartsLedgerMapper.selectRealAmountByMaterialCode(equSpare.getMaterialCode()));
// 通过备件编码查询备件库存、冻结数量信息信息
EquPlanEquSpare spareTemp = sparePartsLedgerMapper.selectRealAmountByMaterialCode(equSpare.getMaterialCode());
equSpare.setAmount(spareTemp.getAmount());// 设置库存数量信息
equSpare.setStorageAmount(spareTemp.getStorageAmount());// 设置冻结数量信息
}
// 将处理好的备件信息列表置入设备
equipment.setSpareList(spareList);
}
}
// 将处理好的设备信息列表置入计划
plan.setEquipmentItem(equipmentList);
// 将处理好的人员信息列表置入计划
plan.setPersonListVO(persons);
return success(plan);
}
/**
*
*
*
* @param equPlan
* @param factory
*/
private void insertCommonInfo(EquPlan equPlan, String factory) {
// 处理计划-巡检人员信息
// 获取人员信息列表
List<SysUser> personList = equPlan.getPersonList();
// 处理人员信息
for (SysUser user : personList) {
EquPlanPerson equPlanPerson = new EquPlanPerson();
equPlanPerson.setId(IdUtils.fastSimpleUUID());
equPlanPerson.setUserId(user.getUserId());
equPlanPerson.setPlanCode(equPlan.getPlanCode());
equPlanPerson.setFactoryCode(factory);
equPlanPerson.setId(IdUtils.fastSimpleUUID());// id
equPlanPerson.setUserId(user.getUserId());// 用户id
equPlanPerson.setPlanCode(equPlan.getPlanCode());// 计划编码
equPlanPerson.setFactoryCode(factory);// 工厂code
equPlanPerson.setCreateBy(SecurityContextHolder.getUserName());
equPlanPerson.setCreateTime(DateUtils.getNowDate());
equPlanPerson.setUpdateBy(SecurityContextHolder.getUserName());
equPlanPerson.setUpdateTime(DateUtils.getNowDate());
// 人员信息插入数据库(可优化)
equPlanPersonMapper.insertEquPlanPerson(equPlanPerson);
}
// 处理计划1-n设备信息
// 获取设备信息列表
List<EquPlanEqu> equipmentItemList = equPlan.getEquipmentItem();
// 处理设备信息
for (EquPlanEqu equipment : equipmentItemList) {
equipment.setId(IdUtils.fastSimpleUUID());
equipment.setPlanCode(equPlan.getPlanCode());
equipment.setParentCode(equPlan.getPlanId());
equipment.setFactoryCode(factory);
equipment.setId(IdUtils.fastSimpleUUID());// id
equipment.setPlanCode(equPlan.getPlanCode());// 计划编码
equipment.setParentCode(equPlan.getPlanId());// 计划id
equipment.setFactoryCode(factory);// 工厂
equipment.setCreateBy(SecurityContextHolder.getUserName());
equipment.setCreateTime(DateUtils.getNowDate());
equipment.setUpdateBy(SecurityContextHolder.getUserName());
equipment.setUpdateTime(DateUtils.getNowDate());
// 处理检查项信息
// 获取检查项信息列表
List<EquPlanDetail> detailList = equipment.getEquPlanDetailList();
// 处理检查项信息
if (detailList != null) {
for (EquPlanDetail item : detailList) {
if (item != null) {
item.setId(IdUtils.fastSimpleUUID());
item.setPlanCode(equPlan.getPlanCode());
item.setParentCode(equipment.getId());
item.setId(IdUtils.fastSimpleUUID());// id
item.setPlanCode(equPlan.getPlanCode());// 计划编码
item.setParentCode(equipment.getId());// 设备表id
item.setCreateBy(SecurityContextHolder.getUserName());
item.setCreateTime(DateUtils.getNowDate());
item.setUpdateBy(SecurityContextHolder.getUserName());
item.setUpdateTime(DateUtils.getNowDate());
// 处理标准
// 获取标准信息列表
List<EquPlanStandard> standardList = item.getEquPlanStandardList();
// 判断是否插入检查项
boolean checkInsert = false;
for (EquPlanStandard standard : standardList) {
if (standard.getShowFlag()) {
checkInsert = true;
standard.setId(IdUtils.fastSimpleUUID());
standard.setParentCode(item.getId());
standard.setPlanCode(equPlan.getPlanCode());
checkInsert = true;// 只要存在标准信息则checkInsert设置为true
standard.setId(IdUtils.fastSimpleUUID());// id
standard.setParentCode(item.getId());// 检查项id
standard.setPlanCode(equPlan.getPlanCode());// 计划编码
standard.setCreateBy(SecurityContextHolder.getUserName());
standard.setCreateTime(DateUtils.getNowDate());
standard.setUpdateBy(SecurityContextHolder.getUserName());
standard.setUpdateTime(DateUtils.getNowDate());
// 详情插入数据库
// 标准信息插入数据库(可优化)
equPlanStandardMapper.insertEquPlanStandard(standard);
}
}
// 检查项详情为空则不生成检查项信息-检查项插入数据库
// 存在标准信息则该检查项插入数据库
if (checkInsert) {
equPlanDetailMapper.insertEquPlanDetail(item);
}
@ -487,11 +449,111 @@ public class EquPlanServiceImpl implements IEquPlanService {
}
// 设备插入数据库
// 设备信息插入数据库(可优化)
equPlanEquMapper.insertEquPlanEqu(equipment);
}
// 保养逻辑-备件信息处理
if (equPlan.getPlanType().equals("maintenance")) {
// 获取备件信息列表
List<EquPlanEquSpare> spareList = equipment.getSpareList();
if (spareList != null) {
for (EquPlanEquSpare spare : spareList) {
spare.setId(IdUtils.fastSimpleUUID());// id
spare.setPlanCode(equPlan.getPlanCode());// 计划编码
spare.setParentCode(equipment.getId());// 设备id
spare.setFactoryCode(factory);// 工厂
spare.setCreateBy(SecurityContextHolder.getUserName());
spare.setCreateTime(DateUtils.getNowDate());
spare.setUpdateBy(SecurityContextHolder.getUserName());
spare.setUpdateTime(DateUtils.getNowDate());
// 备件信息插入数据库(可优化)
equPlanEquSpareMapper.insertEquPlanEquSpare(spare);
}
}
}
}
}
/**
* -
*
* @param equPlanEquList
* @param planType
* @param message
* @return
*/
private AjaxResult formatEquItemCommon(List<EquPlanEqu> equPlanEquList, String planType, String message) {
for (EquPlanEqu data : equPlanEquList) {
// 检查项名称临时对象
StringBuilder itemTempName = new StringBuilder();
// 通过设备编码、计划类型,获取检查项信息列表
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(), planType);
if (equCheckItemList.size() > 0) {
// 创建检查项列表返回对象
List<EquPlanDetail> detailList = new ArrayList<>();
// 处理检查项信息
for (EquCheckItem checkItem : equCheckItemList) {
// 获取循环周期一致的检查项
if (checkItem.getItemLoop() == data.getItemLoop() && checkItem.getItemLoopType().equals(data.getItemLoopType())) {
// 创建检查项返回对象
EquPlanDetail detail = new EquPlanDetail();
BeanUtils.copyProperties(checkItem, detail);
if (!detail.getItemCode().isEmpty()) {
// 累加检查项名称(前端信息回显)
itemTempName.append(detail.getItemName()).append(",");
// 通过检查项code获取标准信息列表
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(detail.getItemCode());
// 处理标准信息
if (equCheckItemList.size() > 0) {
// 创建标准列表返回对象
List<EquPlanStandard> standardList = new ArrayList<>();
for (EquCheckItemDetail standardTemp : equCheckItemDetailList) {
// 创建标准返回对象
EquPlanStandard standard = new EquPlanStandard();
BeanUtils.copyProperties(standardTemp, standard);
standard.setShowFlag(true);// 设置默认值(用于前端)
standardList.add(standard);// 返回对象添加到返回列表对象
}
detail.setEquPlanStandardList(standardList);// 标准列表信息置入检查项
}
}
detailList.add(detail);// 返回对象添加到返回列表对象
}
}
data.setEquPlanDetailList(detailList);// 处理好的检查项信息列表置入检查项信息列表
data.setItemTempName(itemTempName.toString());//处理好的检查项名称置入检查项名称(用于前端信息回显)
} else {
// 未查询到对应检查项信息
return error(500, message);
}
}
return success(equPlanEquList);
}
/**
*
*
* @return
*/
private List<WorkCenter> getWorkCenterCommon() {
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 根据当前工厂获取该工厂下的所有工作中心
List<WorkCenter> workCenters = equPlanMapper.selectWorkCenter(factory);
return workCenters;
}
}

@ -37,46 +37,7 @@ public class EquSpotCheckServiceImpl implements IEquSpotCheckService {
@Override
@DS("#header.poolName")
public AjaxResult formatEquItem(List<EquPlanEqu> equPlanEquList) {
for (EquPlanEqu data : equPlanEquList) {
StringBuilder itemTempName = new StringBuilder();
// 获取检查项list
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(),"spotInspection");
if (equCheckItemList.size() > 0) {
List<EquPlanDetail> detailList = new ArrayList<>();
for (EquCheckItem checkItem : equCheckItemList) {
// 只需要循环周期一致的检查项
if(checkItem.getItemLoop() == data.getItemLoop() && checkItem.getItemLoopType().equals(data.getItemLoopType())) {
EquPlanDetail detail = new EquPlanDetail();
BeanUtils.copyProperties(checkItem,detail);
if (!detail.getItemCode().isEmpty()) {
itemTempName.append(detail.getItemName()).append(",");
// 获取检查项详情list
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(detail.getItemCode());
if (equCheckItemList.size() > 0) {
List<EquPlanStandard> standardList = new ArrayList<>();
for (EquCheckItemDetail standardTemp : equCheckItemDetailList) {
EquPlanStandard standard = new EquPlanStandard();
BeanUtils.copyProperties(standardTemp,standard);
standard.setShowFlag(true);
standardList.add(standard);
}
detail.setEquPlanStandardList(standardList);
}
}
detailList.add(detail);
}
}
data.setEquPlanDetailList(detailList);
data.setItemTempName(itemTempName.toString());
}else {
return error(500,"存在设备未设置点检项!");
}
}
return success(equPlanEquList);
return formatEquItemCommon(equPlanEquList, "spotInspection", "存在设备未设置点检项!");
}
/**
@ -152,4 +113,66 @@ public class EquSpotCheckServiceImpl implements IEquSpotCheckService {
public int deleteEquPlanByPlanId(String planId) {
return equPlanMapper.deleteEquPlanByPlanId(planId);
}
/**
* -
*
* @param equPlanEquList
* @param planType
* @param message
* @return
*/
private AjaxResult formatEquItemCommon(List<EquPlanEqu> equPlanEquList, String planType, String message) {
for (EquPlanEqu data : equPlanEquList) {
// 检查项名称临时对象
StringBuilder itemTempName = new StringBuilder();
// 通过设备编码、计划类型,获取检查项信息列表
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(), planType);
if (equCheckItemList.size() > 0) {
// 创建检查项列表返回对象
List<EquPlanDetail> detailList = new ArrayList<>();
// 处理检查项信息
for (EquCheckItem checkItem : equCheckItemList) {
// 获取循环周期一致的检查项
if (checkItem.getItemLoop() == data.getItemLoop() && checkItem.getItemLoopType().equals(data.getItemLoopType())) {
// 创建检查项返回对象
EquPlanDetail detail = new EquPlanDetail();
BeanUtils.copyProperties(checkItem, detail);
if (!detail.getItemCode().isEmpty()) {
// 累加检查项名称(前端信息回显)
itemTempName.append(detail.getItemName()).append(",");
// 通过检查项code获取标准信息列表
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(detail.getItemCode());
// 处理标准信息
if (equCheckItemList.size() > 0) {
// 创建标准列表返回对象
List<EquPlanStandard> standardList = new ArrayList<>();
for (EquCheckItemDetail standardTemp : equCheckItemDetailList) {
// 创建标准返回对象
EquPlanStandard standard = new EquPlanStandard();
BeanUtils.copyProperties(standardTemp, standard);
standard.setShowFlag(true);// 设置默认值(用于前端)
standardList.add(standard);// 返回对象添加到返回列表对象
}
detail.setEquPlanStandardList(standardList);// 标准列表信息置入检查项
}
}
detailList.add(detail);// 返回对象添加到返回列表对象
}
}
data.setEquPlanDetailList(detailList);// 处理好的检查项信息列表置入检查项信息列表
data.setItemTempName(itemTempName.toString());//处理好的检查项名称置入检查项名称(用于前端信息回显)
} else {
// 未查询到对应检查项信息
return error(500, message);
}
}
return success(equPlanEquList);
}
}

@ -86,56 +86,57 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 生成主工单信息
// 创建主工单对象
EquOrder equOrder = new EquOrder();
BeanUtils.copyProperties(equPlan,equOrder);
equOrder.setOrderId(IdUtils.fastSimpleUUID());
// 流水号
equOrder.setOrderId(IdUtils.fastSimpleUUID());// id
// 获取工单流水号
String serialNum = String.format("%03d",equOrderMapper.selectSerialNumber());
equOrder.setOrderCode("F"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+serialNum);
equOrder.setOrderCode("F"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+serialNum);// 工单编码
equOrder.setPlanLoopType("");
if (equPlan.getPlanTimeArray() != null) {
equOrder.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
equOrder.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
equOrder.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));// 循环开始时间
equOrder.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));// 循环结束时间
}
// 设置工单状态
equOrder.setOrderStatus("0");
equOrder.setFactoryCode(factory);
equOrder.setOrderStatus("0");// 设置工单状态
equOrder.setFactoryCode(factory);// 工厂
equOrder.setCreateBy(SecurityContextHolder.getUserName());
equOrder.setCreateTime(DateUtils.getNowDate());
equOrder.setUpdateBy(SecurityContextHolder.getUserName());
equOrder.setUpdateTime(DateUtils.getNowDate());
equOrder.setPlanType("maintenance");
equOrder.setUpkeep("0");
equOrder.setEquipmentCode(equPlan.getEquipmentItem().get(0).getEquipmentCode());
equOrder.setPlanType("maintenance");// 计划类型
equOrder.setUpkeep("0");// 内部保养
equOrder.setEquipmentCode(equPlan.getEquipmentItem().get(0).getEquipmentCode());// 设备编码
// 工单插入数据库
equOrderMapper.insertEquOrder(equOrder);
EquPlanEqu equPlanEqu = equPlan.getEquipmentItem().get(0);
// 生成工单-备件
// 获取备件信息列表
List<EquPlanEquSpare> equSpareList = equPlanEqu.getSpareList();
if (equSpareList != null) {
// 获取流水
// 获取备件表流水号
int applySerialNum = equSpareApplyMapper.selectSerialNumber();
// 处理备件信息(申领单)
for (EquPlanEquSpare spare : equSpareList) {
EquSpareApply apply = new EquSpareApply();
apply.setApplyId(IdUtils.fastSimpleUUID());
apply.setApplyCode("A"+DateUtils.dateTimeNow(DateUtils.YYYYMMDD)+String.format("%03d",applySerialNum));
applySerialNum++;
apply.setSpareCode(spare.getMaterialCode());
apply.setSpareName(spare.getMaterialDesc());
apply.setSpareModel(spare.getSpareType());
apply.setSpareQuantity(spare.getApplyNum());
apply.setFactoryCode(factory);
apply.setApplyId(IdUtils.fastSimpleUUID());// id
apply.setApplyCode("A"+equOrder.getOrderCode()+String.format("%02d",applySerialNum));// 申领单编码
applySerialNum++;// 流水号递增
apply.setSpareCode(spare.getMaterialCode());// 备件号
apply.setSpareName(spare.getMaterialDesc());// 备件名称
apply.setSpareModel(spare.getSpareType());// 备件类型
apply.setSpareQuantity(spare.getApplyNum());// 备件数量
apply.setFactoryCode(factory);// 工厂
apply.setApplyPeople(SecurityContextHolder.getUserName());
apply.setWorkCode(equOrder.getOrderCode());
apply.setWorkCode(equOrder.getOrderCode());// 设置关联单号
apply.setCreateBy(SecurityContextHolder.getUserName());
apply.setCreateTime(DateUtils.getNowDate());
apply.setSpareUseEquipment(equOrder.getEquipmentCode());
apply.setApplyTime(DateUtils.getNowDate());
// 插入备件信息
apply.setSpareUseEquipment(equOrder.getEquipmentCode());// 设置使用设备编码
apply.setApplyTime(DateUtils.getNowDate());// 设置申领时间
// 插入备件信息(可优化)
equSpareApplyMapper.insertEquSpareApply(apply);
// 减少备件仓库中备件数量
@ -143,53 +144,53 @@ public class EquUpkeepOrderServiceImpl implements IEquUpkeepOrderService {
}
}
// 生成工单-设备-保养项
// 获取检查项信息列表
List<EquPlanDetail> detailList = equPlanEqu.getEquPlanDetailList();
// 处理检查项信息
for (EquPlanDetail detail : detailList) {
EquOrderDetail equOrderDetail = new EquOrderDetail();
List<EquOrderStandard> orderStandardList = new ArrayList<>();
List<EquPlanStandard> standardList = detail.getEquPlanStandardList();
BeanUtils.copyProperties(detail,equOrderDetail);
equOrderDetail.setId(IdUtils.fastSimpleUUID());
equOrderDetail.setOrderCode(equOrder.getOrderCode());
equOrderDetail.setFactoryCode(factory);
equOrderDetail.setStandardList(orderStandardList);
BeanUtils.copyProperties(detail,equOrderDetail);// 类型转换
equOrderDetail.setId(IdUtils.fastSimpleUUID());// id
equOrderDetail.setOrderCode(equOrder.getOrderCode());// 检查项编码
equOrderDetail.setFactoryCode(factory);// 工厂
equOrderDetail.setCreateBy(SecurityContextHolder.getUserName());
equOrderDetail.setCreateTime(DateUtils.getNowDate());
equOrderDetail.setUpdateBy(SecurityContextHolder.getUserName());
equOrderDetail.setUpdateTime(DateUtils.getNowDate());
// 插入检查项信息
// 新增检查项信息(可优化)
equOrderDetailMapper.insertEquOrderDetail(equOrderDetail);
for (EquPlanStandard standard : standardList) {
EquOrderStandard orderStandard = new EquOrderStandard();
BeanUtils.copyProperties(standard,orderStandard);
orderStandard.setId(IdUtils.fastSimpleUUID());
orderStandard.setParentCode(equOrderDetail.getId());
orderStandard.setOrderCode(equOrder.getOrderCode());
BeanUtils.copyProperties(standard,orderStandard);// 类型转换
orderStandard.setId(IdUtils.fastSimpleUUID());// id
orderStandard.setParentCode(equOrderDetail.getId());// 检查项id
orderStandard.setOrderCode(equOrder.getOrderCode());// 工单编码
orderStandard.setCreateBy(SecurityContextHolder.getUserName());
orderStandard.setCreateTime(DateUtils.getNowDate());
orderStandard.setUpdateBy(SecurityContextHolder.getUserName());
orderStandard.setUpdateTime(DateUtils.getNowDate());
// 插入标准信息
// 新增标准信息(可优化)
equOrderStandardMapper.insertEquOrderStandard(orderStandard);
}
}
// 生成工单-人员
// 获取人员信息列表
List<SysUser> personList = equPlan.getPersonList();
// 处理人员信息
for (SysUser user : personList) {
EquOrderPerson equOrderPerson = new EquOrderPerson();
equOrderPerson.setId(IdUtils.fastSimpleUUID());
equOrderPerson.setOrderCode(equOrder.getOrderCode());
equOrderPerson.setFactoryCode(factory);
equOrderPerson.setUserId(user.getUserId());
equOrderPerson.setId(IdUtils.fastSimpleUUID());// id
equOrderPerson.setOrderCode(equOrder.getOrderCode());// 工单编码
equOrderPerson.setFactoryCode(factory);// 工厂
equOrderPerson.setUserId(user.getUserId());// 用户id
equOrderPerson.setCreateBy(SecurityContextHolder.getUserName());
equOrderPerson.setCreateTime(DateUtils.getNowDate());
equOrderPerson.setUpdateBy(SecurityContextHolder.getUserName());
equOrderPerson.setUpdateTime(DateUtils.getNowDate());
// 插入人员信息
// 插入人员信息(可优化)
equOrderPersonMapper.insertEquOrderPerson(equOrderPerson);
}

@ -31,16 +31,6 @@ public class EquUpkeepServiceImpl implements IEquUpkeepService {
private EquCheckItemMapper equCheckItemMapper;
@Autowired
private EquCheckItemDetailMapper equCheckItemDetailMapper;
@Autowired
private EquPlanStandardMapper equPlanStandardMapper;
@Autowired
private EquPlanDetailMapper equPlanDetailMapper;
@Autowired
private EquPlanEquMapper equPlanEquMapper;
@Autowired
private EquPlanEquSpareMapper equPlanEquSpareMapper;
@Autowired
private EquPlanPersonMapper equPlanPersonMapper;
/**
*
@ -75,36 +65,7 @@ public class EquUpkeepServiceImpl implements IEquUpkeepService {
@Override
@DS("#header.poolName")
public AjaxResult insertEquPlan(EquPlan equPlan) {
// 获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 计划流水号
String planSerialNum = String.format("%03d", equPlanMapper.selectSerialNumber());
// 处理计划信息
equPlan.setPlanId(IdUtils.fastSimpleUUID());
equPlan.setPlanCode((DateUtils.dateTimeNow(DateUtils.YYYYMMDD) + planSerialNum));
if (equPlan.getPlanTimeArray().size() > 0) {
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
}
equPlan.setFactoryCode(factory);
equPlan.setCreateBy(SecurityContextHolder.getUserName());
equPlan.setCreateTime(DateUtils.getNowDate());
equPlan.setUpdateBy(SecurityContextHolder.getUserName());
equPlan.setUpdateTime(DateUtils.getNowDate());
// 主计划插入数据库
equPlanMapper.insertEquPlan(equPlan);
insertCommonInfo(equPlan,factory);
return success(equPlan);
return success();
}
/**
@ -116,28 +77,7 @@ public class EquUpkeepServiceImpl implements IEquUpkeepService {
@Override
@DS("#header.poolName")
public AjaxResult updateEquPlan(EquPlan equPlan) {
// 更新巡检计划
equPlan.setPlanLoopStart(equPlan.getPlanTimeArray().get(0));
equPlan.setPlanLoopEnd(equPlan.getPlanTimeArray().get(1));
equPlanMapper.updateEquPlan(equPlan);
// 删除该计划下设备、人员、检查项、标准、备件信息
equPlanPersonMapper.deleteEquPlanPersonByPlanCode(equPlan.getPlanCode());
equPlanDetailMapper.deleteEquPlanDetailByPlanCode(equPlan.getPlanCode());
equPlanEquMapper.deleteEquPlanEquByPlanCode(equPlan.getPlanCode());
equPlanStandardMapper.deleteEquPlanStandardByPlanCode(equPlan.getPlanCode());
equPlanEquSpareMapper.deleteEquPlanEquSpareByPlanCode(equPlan.getPlanCode());
//获取当前所选工厂
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
String key = "#header.poolName";
String str = request.getHeader(key.substring(8));
int index = str.indexOf("_");
String factory = str.substring(index + 1);
// 插入设备、人员、检查项、标准信息
insertCommonInfo(equPlan, factory);
return success("修改成功");
return success();
}
/**
@ -173,188 +113,68 @@ public class EquUpkeepServiceImpl implements IEquUpkeepService {
@Override
@DS("#header.poolName")
public AjaxResult formatEquItem(List<EquPlanEqu> equPlanEquList) {
return formatEquItemCommon(equPlanEquList, "maintenance", "存在设备未设置保养项!");
}
/**
* -
*
* @param equPlanEquList
* @param planType
* @param message
* @return
*/
private AjaxResult formatEquItemCommon(List<EquPlanEqu> equPlanEquList, String planType, String message) {
for (EquPlanEqu data : equPlanEquList) {
// 检查项名称临时对象
StringBuilder itemTempName = new StringBuilder();
// 获取检查项list
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(),"maintenance");
// 通过设备编码、计划类型,获取检查项信息列表
List<EquCheckItem> equCheckItemList = equCheckItemMapper.selectCheckItemByEquipmentCode(data.getEquipmentCode(), planType);
if (equCheckItemList.size() > 0) {
// 创建检查项列表返回对象
List<EquPlanDetail> detailList = new ArrayList<>();
for (EquCheckItem checkItem : equCheckItemList) {
// 只需要循环周期一致的检查项
if(checkItem.getItemLoop() == data.getItemLoop() && checkItem.getItemLoopType().equals(data.getItemLoopType())) {
EquPlanDetail detail = new EquPlanDetail();
BeanUtils.copyProperties(checkItem,detail);
if (!detail.getItemCode().isEmpty()) {
itemTempName.append(detail.getItemName()).append(",");
// 获取检查项详情list
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(detail.getItemCode());
if (equCheckItemList.size() > 0) {
List<EquPlanStandard> standardList = new ArrayList<>();
for (EquCheckItemDetail standardTemp : equCheckItemDetailList) {
EquPlanStandard standard = new EquPlanStandard();
BeanUtils.copyProperties(standardTemp,standard);
standard.setShowFlag(true);
standardList.add(standard);
}
detail.setEquPlanStandardList(standardList);
}
}
detailList.add(detail);
}
if (data.getItemLoop() == 0) {
// 处理检查项信息
for (EquCheckItem checkItem : equCheckItemList) {
// 获取循环周期一致的检查项
if (checkItem.getItemLoop() == data.getItemLoop() && checkItem.getItemLoopType().equals(data.getItemLoopType())) {
// 创建检查项返回对象
EquPlanDetail detail = new EquPlanDetail();
BeanUtils.copyProperties(checkItem,detail);
BeanUtils.copyProperties(checkItem, detail);
if (!detail.getItemCode().isEmpty()) {
// 累加检查项名称(前端信息回显)
itemTempName.append(detail.getItemName()).append(",");
// 获取检查项详情list
// 通过检查项code获取标准信息列表
List<EquCheckItemDetail> equCheckItemDetailList = equCheckItemDetailMapper.selectCheckItemDetailByItemCode(detail.getItemCode());
// 处理标准信息
if (equCheckItemList.size() > 0) {
// 创建标准列表返回对象
List<EquPlanStandard> standardList = new ArrayList<>();
for (EquCheckItemDetail standardTemp : equCheckItemDetailList) {
// 创建标准返回对象
EquPlanStandard standard = new EquPlanStandard();
BeanUtils.copyProperties(standardTemp,standard);
BeanUtils.copyProperties(standardTemp, standard);
standard.setShowFlag(true);
standardList.add(standard);
standard.setShowFlag(true);// 设置默认值(用于前端)
standardList.add(standard);// 返回对象添加到返回列表对象
}
detail.setEquPlanStandardList(standardList);
detail.setEquPlanStandardList(standardList);// 标准列表信息置入检查项
}
}
detailList.add(detail);
detailList.add(detail);// 返回对象添加到返回列表对象
}
}
data.setEquPlanDetailList(detailList);
data.setItemTempName(itemTempName.toString());
}else {
return error(500,"存在设备未设置保养项!");
data.setEquPlanDetailList(detailList);// 处理好的检查项信息列表置入检查项信息列表
data.setItemTempName(itemTempName.toString());//处理好的检查项名称置入检查项名称(用于前端信息回显)
} else {
// 未查询到对应检查项信息
return error(500, message);
}
}
return success(equPlanEquList);
}
/**
*
*
* @param equPlan
* @param factory
*/
private void insertCommonInfo(EquPlan equPlan, String factory) {
// 处理计划-巡检人员信息
List<SysUser> personList = equPlan.getPersonList();
for (SysUser user : personList) {
EquPlanPerson equPlanPerson = new EquPlanPerson();
equPlanPerson.setId(IdUtils.fastSimpleUUID());
equPlanPerson.setUserId(user.getUserId());
equPlanPerson.setPlanCode(equPlan.getPlanCode());
equPlanPerson.setFactoryCode(factory);
equPlanPerson.setCreateBy(SecurityContextHolder.getUserName());
equPlanPerson.setCreateTime(DateUtils.getNowDate());
equPlanPerson.setUpdateBy(SecurityContextHolder.getUserName());
equPlanPerson.setUpdateTime(DateUtils.getNowDate());
equPlanPersonMapper.insertEquPlanPerson(equPlanPerson);
}
// 处理计划1-n设备信息
List<EquPlanEqu> equipmentItemList = equPlan.getEquipmentItem();
// 计划-设备流水号
int equipmentCodeTemp = 0;
for (EquPlanEqu equipment : equipmentItemList) {
equipment.setId(IdUtils.fastSimpleUUID());
equipment.setPlanCode(equPlan.getPlanCode());
equipment.setCode("E" + equPlan.getPlanCode() + String.format("%02d", ++equipmentCodeTemp));
equipment.setParentCode(equPlan.getPlanId());
equipment.setFactoryCode(factory);
equipment.setCreateBy(SecurityContextHolder.getUserName());
equipment.setCreateTime(DateUtils.getNowDate());
equipment.setUpdateBy(SecurityContextHolder.getUserName());
equipment.setUpdateTime(DateUtils.getNowDate());
// 处理检查项信息
List<EquPlanDetail> detailList = equipment.getEquPlanDetailList();
if (detailList != null) {
// 计划检查项流水号
int itemCodeTemp = 0;
for (EquPlanDetail item : detailList) {
if (item != null) {
item.setId(IdUtils.fastSimpleUUID());
item.setPlanCode(equPlan.getPlanCode());
item.setCode("C" + equipment.getCode() + String.format("%02d", ++itemCodeTemp));
item.setParentCode(equipment.getId());
item.setCreateBy(SecurityContextHolder.getUserName());
item.setCreateTime(DateUtils.getNowDate());
item.setUpdateBy(SecurityContextHolder.getUserName());
item.setUpdateTime(DateUtils.getNowDate());
// 处理标准
List<EquPlanStandard> standardList = item.getEquPlanStandardList();
// 判断是否插入检查项
boolean checkInsert = false;
for (EquPlanStandard standard : standardList) {
if (standard.getShowFlag()) {
checkInsert = true;
standard.setId(IdUtils.fastSimpleUUID());
standard.setParentCode(item.getId());
standard.setPlanCode(equPlan.getPlanCode());
standard.setCreateBy(SecurityContextHolder.getUserName());
standard.setCreateTime(DateUtils.getNowDate());
standard.setUpdateBy(SecurityContextHolder.getUserName());
standard.setUpdateTime(DateUtils.getNowDate());
// 详情插入数据库
equPlanStandardMapper.insertEquPlanStandard(standard);
}
}
// 检查项详情为空则不生成检查项信息-检查项插入数据库
if (checkInsert) {
equPlanDetailMapper.insertEquPlanDetail(item);
}
}
}
// 设备插入数据库
equPlanEquMapper.insertEquPlanEqu(equipment);
}
// 处理备件信息
List<EquPlanEquSpare> spareList = equipment.getSpareList();
// 计划备件流水号
int spareCodeTemp = 0;
if (spareList != null) {
for (EquPlanEquSpare spare : spareList) {
spare.setId(IdUtils.fastSimpleUUID());
spare.setPlanCode(equPlan.getPlanCode());
spare.setParentCode(equipment.getId());
spare.setFactoryCode(factory);
spare.setCreateBy(SecurityContextHolder.getUserName());
spare.setCreateTime(DateUtils.getNowDate());
spare.setUpdateBy(SecurityContextHolder.getUserName());
spare.setUpdateTime(DateUtils.getNowDate());
equPlanEquSpareMapper.insertEquPlanEquSpare(spare);
}
}
}
}
}

@ -124,8 +124,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and storage_tpye = 'SP'
</select>
<select id="selectRealAmountByMaterialCode" resultType="java.math.BigDecimal">
select (amount-storage_amount) AS 'amount' from wms_ods_mate_storage_news where material_code = #{materialCode}
<select id="selectRealAmountByMaterialCode" resultType="com.op.device.domain.EquPlanEquSpare">
select amount AS 'amount',storage_amount AS 'storageAmount' from wms_ods_mate_storage_news where material_code = #{materialCode}
</select>
<insert id="insertSparePartsLedger" parameterType="SparePartsLedger">

@ -319,6 +319,7 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
}
//母工单报工
logger.info("==========================母工单报工开始");
pHzWork.setQuantityFeedback(sHzWorks.getQuantityFeedback());
this.reportHzToSap(pHzWork);
logger.info("==========================母工单报工结束");
//最终报工标识:关闭子母工单

@ -298,6 +298,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where
CONVERT(varchar(10),feedback_time, 120) >= #{productDateStart}
and #{productDateEnd} >= CONVERT(varchar(10),feedback_time, 120)
and parent_order = '0'
)mrw
group by mrw.nameDate,mrw.productCode,mrw.productName,mrw.feedbackTime
</select>
@ -308,6 +309,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where
CONVERT(varchar(10),mrw.feedback_time, 120) >= #{productDateStart}
and #{productDateEnd} >= CONVERT(varchar(10),mrw.feedback_time, 120)
and parent_order = '0'
</select>
<select id="getEquNames" resultType="com.op.mes.domain.MesHourReport">
select
@ -470,7 +472,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getReportWorkHzList" resultType="com.op.mes.domain.MesReportWork">
select mrw.workorderCode,mrw.productCode,mrw.productName,mrw.machineCode,mrw.machineName,
mrw.shiftCode,mrw.feedbackTime feedbackTimeStr,mrw.quantityFeedback,
mrw.workTime,mrw.useMan,mrw.uploadStatus,<!--mrw.uploadTime,mrw.unit,-->
mrw.workTime,mrw.useMan,mrw.uploadStatus,mrw.unit,<!--mrw.uploadTime,-->
pow.order_code orderCode,pow.quantity_split quantity
from (
select workorder_code workorderCode,
@ -483,10 +485,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sum(quantity_feedback) quantityFeedback,
sum(work_time) workTime,
sum(use_man) useMan,
upload_status uploadStatus
<!--,upload_time uploadTime,
,
unit-->
upload_status uploadStatus,
<!--,upload_time uploadTime,-->
unit
from mes_report_work
where del_flag = '0' and parent_order = '0'
<if test="workorderCode != null and workorderCode != ''"> and workorder_code like concat('%', #{workorderCode}, '%')</if>
@ -498,8 +499,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="feedbackTimeEnd != null "> and #{feedbackTimeEnd} >= CONVERT(varchar(19),feedback_time, 120)</if>
<if test="uploadStatus != null and uploadStatus != ''"> and upload_status = #{uploadStatus}</if>
group by workorder_code, product_code,product_name,CONVERT(varchar(10),feedback_time, 120),machine_code,machine_name,shift_code
,upload_status
<!--,upload_time,unit-->
,upload_status,unit
<!--,upload_time-->
) mrw
left join pro_order_workorder pow on mrw.workorderCode = pow.workorder_code
<where>

@ -23,7 +23,7 @@ import com.op.common.core.web.page.TableDataInfo;
/**
* Controller
*
*
* @author Open Platform
* @date 2023-10-13
*/
@ -44,6 +44,12 @@ public class QcCheckProjectController extends BaseController {
return getDataTable(list);
}
@GetMapping("/getProjectList")
public List<QcCheckProject> getProjectList(QcCheckProject qcCheckProject) {
List<QcCheckProject> list = qcCheckProjectService.selectQcCheckProjectList(qcCheckProject);
return list;
}
/**
*
*/

@ -229,4 +229,15 @@ public class QcCheckTaskIncomeController extends BaseController {
List<QcCheckTaskIncome> list = qcCheckTaskIncomeService.getLLWorkOrder(qcCheckTaskIncome);
return getDataTable(list);
}
/**获取生产工单列表**/
@GetMapping("/getWorkOrder")
public TableDataInfo getWorkOrder(QcCheckTaskIncome qcCheckTaskIncome) {
startPage();
List<QcCheckTaskIncome> list = qcCheckTaskIncomeService.getWorkOrder(qcCheckTaskIncome);
return getDataTable(list);
}
@PutMapping("/getBatchList")
public List<QcCheckTaskIncome> getBatchList(@RequestBody QcCheckTaskIncome qcCheckTaskIncome) {
return qcCheckTaskIncomeService.getBatchList(qcCheckTaskIncome);
}
}

@ -267,4 +267,18 @@ public class QuaController extends BaseController {
List<QcCheckTaskIncome> list = qcCheckTaskIncomeService.getLLWorkOrder(qcCheckTaskIncome);
return getDataTable(list);
}
/**获取生产工单列表**/
@GetMapping("/getWorkOrder")
public TableDataInfo getWorkOrder(QcCheckTaskIncome qcCheckTaskIncome) {
DynamicDataSourceContextHolder.push("ds_"+qcCheckTaskIncome.getFactoryCode());
startPage();
List<QcCheckTaskIncome> list = qcCheckTaskIncomeService.getWorkOrder(qcCheckTaskIncome);
return getDataTable(list);
}
@PutMapping("/getBatchList")
public List<QcCheckTaskIncome> getBatchList(@RequestBody QcCheckTaskIncome qcCheckTaskIncome) {
DynamicDataSourceContextHolder.push("ds_"+qcCheckTaskIncome.getFactoryCode());
return qcCheckTaskIncomeService.getBatchList(qcCheckTaskIncome);
}
}

@ -24,6 +24,8 @@ public class QcCheckTaskIncome extends BaseEntity {
@Excel(name = "检验任务编号")
private String checkNo;
private String workorderCode;
/** 来料批次号 */
@Excel(name = "批次号")
private String incomeBatchNo;
@ -123,6 +125,32 @@ public class QcCheckTaskIncome extends BaseEntity {
private String typeCode;
private String checkType;
private String qualityStatus;
private String batchCode;
private String batchId;
public String getBatchCode() {
return batchCode;
}
public void setBatchCode(String batchCode) {
this.batchCode = batchCode;
}
public String getBatchId() {
return batchId;
}
public void setBatchId(String batchId) {
this.batchId = batchId;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getQualityStatus() {
return qualityStatus;

@ -82,4 +82,6 @@ public interface QcCheckTaskIncomeMapper {
int updateQcCheckTaskDetails(@Param("list") List<QcCheckTaskDetail> details);
List<SysDictData> getQcUnitList(SysDictData sysDictData);
List<QcCheckTaskIncome> getBatchList(QcCheckTaskIncome qcCheckTaskIncome);
}

@ -76,4 +76,8 @@ public interface QcCheckUnqualifiedMapper {
public List<QcCheckTaskIncome> getLLWorkOrder(QcCheckTaskIncome qcCheckTaskIncome);
void updateQualityStatus(QcCheckTaskIncome qcCheckTaskIncome);
List<QcCheckTaskIncome> getWorkOrder(QcCheckTaskIncome qcCheckTaskIncome);
int updateWorkOrderStatus(QcCheckTaskIncome qcCheckTaskIncome);
}

@ -81,4 +81,8 @@ public interface IQcCheckTaskIncomeService {
List<QcDefectType> getDefectList(QcDefectType qcDefectType);
List<QcCheckTaskIncome> getLLWorkOrder(QcCheckTaskIncome qcCheckTaskIncome);
List<QcCheckTaskIncome> getWorkOrder(QcCheckTaskIncome qcCheckTaskIncome);
List<QcCheckTaskIncome> getBatchList(QcCheckTaskIncome qcCheckTaskIncome);
}

@ -254,6 +254,10 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
qcCheckTaskIncome.setCheckResult(result);
qcCheckTaskIncome.setCheckTime(DateUtils.getNowDate());
n = qcCheckTaskIncomeMapper.updateQcCheckTaskIncome(qcCheckTaskIncome);
/**wms_raw_order_in-->quality_status->**/
qcCheckTaskIncome.setCheckResult(result.equals("Y")?"1":"0");
qcCheckUnqualifiedMapper.updateQualityStatus(qcCheckTaskIncome);
}else if("produce".equals(qcCheckTaskIncome.getTypeCode())){
QcCheckTaskProduce qcCheckTaskProduce = new QcCheckTaskProduce();
qcCheckTaskProduce.setCheckStatus("2");
@ -261,6 +265,11 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
qcCheckTaskProduce.setCheckResult(result);
qcCheckTaskProduce.setCheckTime(DateUtils.getNowDate());
n = qcCheckTaskProduceMapper.updateQcCheckTaskProduce(qcCheckTaskProduce);
/**pro_order_workorder-->status->w5**/
qcCheckTaskIncome.setStatus("w5");
qcCheckUnqualifiedMapper.updateWorkOrderStatus(qcCheckTaskIncome);
}else if("product".equals(qcCheckTaskIncome.getTypeCode())){
QcCheckTaskWarehousing warehousing = new QcCheckTaskWarehousing();
warehousing.setCheckStatus("2");
@ -283,10 +292,6 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
qcCheckUnqualifiedMapper.insertQcCheckUnqualified(unqualified);
}
/**wms_raw_order_in-->quality_status->**/
qcCheckTaskIncome.setCheckResult(result.equals("Y")?"1":"0");
qcCheckUnqualifiedMapper.updateQualityStatus(qcCheckTaskIncome);
return n ;
}
@ -302,6 +307,18 @@ public class QcCheckTaskIncomeServiceImpl implements IQcCheckTaskIncomeService {
return qcCheckUnqualifiedMapper.getLLWorkOrder(qcCheckTaskIncome);
}
@Override
@DS("#header.poolName")
public List<QcCheckTaskIncome> getWorkOrder(QcCheckTaskIncome qcCheckTaskIncome) {
return qcCheckUnqualifiedMapper.getWorkOrder(qcCheckTaskIncome);
}
@Override
@DS("#header.poolName")
public List<QcCheckTaskIncome> getBatchList(QcCheckTaskIncome qcCheckTaskIncome) {
return qcCheckTaskIncomeMapper.getBatchList(qcCheckTaskIncome);
}
@Override
public int commitCheckResults(List<QcCheckTaskDetail> details) {
DynamicDataSourceContextHolder.push("ds_"+details.get(0).getFactoryCode());

@ -119,8 +119,9 @@ public class QcProCheckServiceImpl implements QcProCheckService {
@Override
public List<QcCheckTaskIncome> getCheckTaskList(QcCheckTaskIncome qcCheckTaskIncome) {
DynamicDataSourceContextHolder.push("ds_"+qcCheckTaskIncome.getFactoryCode());
return qcProCheckMapper.getCheckTaskList(qcCheckTaskIncome);
DynamicDataSourceContextHolder.push(qcCheckTaskIncome.getFactoryCode());
List<QcCheckTaskIncome> dtos = qcProCheckMapper.getCheckTaskList(qcCheckTaskIncome);
return dtos;
}
@Override

@ -146,6 +146,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where dict_type = 'unit'
and status = '0'
</select>
<select id="getBatchList" resultType="com.op.quality.domain.QcCheckTaskIncome">
select powb.batch_id batchId,
powb.batch_code batchCode
from pro_order_workorder_batch powb
left join pro_order_workorder pow on powb.workorder_id = pow.workorder_id
where powb.del_flag = '0' and pow.del_flag = '0'
and pow.workorder_code = #{workorderCode}
</select>
<insert id="insertQcCheckTaskIncome" parameterType="QcCheckTaskIncome">
insert into qc_check_task

@ -32,7 +32,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="typeCode != null and typeCode != ''"> and type_code = #{typeCode}</if>
<if test="typeName != null and typeName != ''"> and type_name like concat('%', #{typeName}, '%')</if>
<if test="attr1 != null and attr1 != ''"> and attr1 = #{attr1}</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
and del_flag = '0'
</where>
order by create_time

@ -103,6 +103,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where wroi.active_flag = '1' and wroi.quality_status = '0'
<if test="orderNo != null">and wroi.order_no like contact like ('%',#{orderNo})</if>
</select>
<select id="getWorkOrder" resultType="com.op.quality.domain.QcCheckTaskIncome">
select
workorder_code workorderCode,
workorder_code_sap orderNo,
product_code materialCode,
product_name materialName,
quantity_split quality,
unit,
product_date incomeTime
from pro_order_workorder
where status != 'w5' and parent_order != '0' and workorder_code_sap is not null
<if test="orderNo != null">and workorder_code_sap like contact like ('%',#{orderNo})</if>
order by product_date desc
</select>
<insert id="insertQcCheckUnqualified" parameterType="QcCheckUnqualified">
insert into qc_check_unqualified
@ -171,6 +185,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update wms_raw_order_in set quality_status = #{checkResult}
where order_no = #{orderNo}
</update>
<update id="updateWorkOrderStatus">
update pro_order_workorder set status = #{status} where workorder_code_sap = #{orderNo}
</update>
<delete id="deleteQcCheckUnqualifiedById" parameterType="String">
delete from qc_check_unqualified where id = #{id}

@ -254,7 +254,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and qct.del_flag = '0'
<if test="checkType != null and checkType != ''"> and qct.check_type = #{checkType}</if>
<if test="checkManCode != null and checkManCode != ''"> and qct.check_man_code = #{checkManCode}</if>
<if test="checkStatus != null and checkStatus != ''"> and qct.check_status in (#{checkStatus})</if>
<if test="checkStatus != null and checkStatus != ''"> and qct.check_status in (${checkStatus})</if>
</where>
order by qct.create_time desc
</select>

Loading…
Cancel
Save