|
@@ -6,12 +6,15 @@ import com.hssx.cloudmodel.mapper.MouldEquipmentMapper;
|
|
|
import com.hssx.cloudmodel.service.MouldEquipmentService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author 吴涛涛
|
|
@@ -19,20 +22,21 @@ import org.springframework.stereotype.Service;
|
|
|
*/
|
|
|
@Service
|
|
|
public class MouldEquipmentServiceImpl extends ServiceImpl<MouldEquipmentMapper, MouldEquipment> implements MouldEquipmentService {
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
MouldEquipmentMapper mouldEquipmentMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public HttpRespMsg addAndUpdateMouldEquipment(MouldEquipment mouldEquipment, User user) {
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
- if(user.getParentId() == 0){
|
|
|
- if(mouldEquipment.getId() == null){
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ if (user.getParentId() == 0) {
|
|
|
+ if (mouldEquipment.getId() == null) {
|
|
|
//添加设备
|
|
|
mouldEquipmentMapper.insert(mouldEquipment);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//修改设备
|
|
|
mouldEquipmentMapper.updateById(mouldEquipment);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
msg.setError("对不起,您不是管理员,不具备设备创建或修改的权限");
|
|
|
}
|
|
|
return msg;
|
|
@@ -42,10 +46,13 @@ public class MouldEquipmentServiceImpl extends ServiceImpl<MouldEquipmentMapper,
|
|
|
public HttpRespMsg isUse(MouldEquipment mouldEquipment, User user) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
//判断是不是超级管理员,是才可操作
|
|
|
- if(user.getParentId() == 0){
|
|
|
- //修改设备
|
|
|
- mouldEquipmentMapper.updateById(mouldEquipment);
|
|
|
- }else{
|
|
|
+ if (user.getParentId() == 0) {
|
|
|
+ //修改设备
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ mouldEquipment.setStartTime(now);
|
|
|
+ mouldEquipment.setEndTime(now.plusYears(mouldEquipment.getUseLife()));
|
|
|
+ mouldEquipmentMapper.updateById(mouldEquipment);
|
|
|
+ } else {
|
|
|
msg.setError("对不起,您不是管理员,不具备启用设备的权限");
|
|
|
}
|
|
|
return msg;
|